Skip to content

Commit d692ce9

Browse files
committed
Remove SHA instantiations
1 parent 3fec7a6 commit d692ce9

File tree

12 files changed

+14
-1618
lines changed

12 files changed

+14
-1618
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It was originally developed in [this repository](https://github.com/b-wagn/hash-
1010

1111
The code has *not been audited and is not meant to be used in production*. It is a playground to explore and benchmark these signatures. Use it at your own risk.
1212

13-
The implementation takes a generic RNG as input (e.g., `key_gen`, see below). Users must make sure that the RNG is *cryptographically secure*.
13+
The implementation takes a generic RNG as input (e.g., `key_gen`, see below). Users must make sure that the RNG is *cryptographically secure*.
1414
The examples below, tests, and benchmarks just use a default (potentially insecure) RNG for illustration.
1515

1616
## Signature Interface
@@ -56,12 +56,11 @@ See also function `test_signature_scheme_correctness` in [this file](https://git
5656

5757
## Schemes
5858
The code implements a generic framework from [this paper](https://eprint.iacr.org/2025/055.pdf), which builds XMSS-like hash-based signatures from a primitive called incomparable encodings.
59-
Hardcoded instantiations of this generic framework (using SHA3 or Poseidon2) are defined in `hashsig::signature::generalized_xmss`.
59+
Hardcoded instantiations of this generic framework (using Poseidon2) are defined in `hashsig::signature::generalized_xmss`.
6060
The parameters have been chosen based on the analysis in the paper using Python scripts. Details are as follows:
6161

6262
| Submodule | Paper / Documentation | Parameters Set With |
6363
|---------------|-----------------------------------------------------------|--------------------------|
64-
| `instantiations_sha::*` | [original paper](https://eprint.iacr.org/2025/055.pdf) | [this repository](https://github.com/b-wagn/hashsig-parameters) |
6564
| `instantiations_poseidon::*` | [original paper](https://eprint.iacr.org/2025/055.pdf) | [this repository](https://github.com/b-wagn/hashsig-parameters) |
6665
| `instantiations_poseidon_top_level::*` | [this document](https://eprint.iacr.org/2025/1332), inspired by [this](https://eprint.iacr.org/2025/889.pdf) | [this repository](https://github.com/b-wagn/hypercube-hashsig-parameters) |
6766

@@ -97,7 +96,7 @@ cargo bench
9796
The schemes that are benchmarked are hardcoded instantiations of the generic framework, which are defined in `hashsig::signature::generalized_xmss`.
9897
The parameters of these instantiations have been chosen carefully with the aim to achieve a desired security level.
9998
By default, key generation is not benchmarked. There are two options to benchmark it:
100-
1. add the option `--features with-gen-benches-sha` or `--features with-gen-benches-poseidon` or `--features with-gen-benches-poseidon-top-level` to `cargo bench`. Note that this will make benchmarks very slow, as key generation will be repeated within the benchmarks. Especially for Poseidon, this is not recommended.
99+
1. add the option `--features with-gen-benches-poseidon` or `--features with-gen-benches-poseidon-top-level` to `cargo bench`. Note that this will make benchmarks very slow, as key generation will be repeated within the benchmarks. Especially for Poseidon, this is not recommended.
101100
2. use code similar to the one provided in `src/bin/main.rs` and run it with `cargo run --release`.
102101

103102
If criterion only generates json files, one way to extract all means for all benchmarks easily (without re-running criterion) is to run

benches/benchmark.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ use criterion::{criterion_group, criterion_main};
22

33
mod benchmark_poseidon;
44
mod benchmark_poseidon_top_level;
5-
mod benchmark_sha;
65

76
use benchmark_poseidon::bench_function_poseidon;
87
use benchmark_poseidon_top_level::bench_function_poseidon_top_level;
9-
use benchmark_sha::bench_function_sha;
108

119
criterion_group!(
1210
benches,
1311
bench_function_poseidon_top_level,
14-
bench_function_sha,
1512
bench_function_poseidon
1613
);
1714
criterion_main!(benches);

benches/benchmark_sha.rs

Lines changed: 0 additions & 217 deletions
This file was deleted.

src/signature/generalized_xmss.rs

Lines changed: 6 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -553,96 +553,21 @@ pub mod instantiations_poseidon;
553553
/// Instantiations of the generalized XMSS signature scheme based on the
554554
/// top level target sum encoding using Poseidon2
555555
pub mod instantiations_poseidon_top_level;
556-
/// Instantiations of the generalized XMSS signature scheme based on SHA
557-
pub mod instantiations_sha;
558556

559557
#[cfg(test)]
560558
mod tests {
561559
use crate::{
562-
inc_encoding::{basic_winternitz::WinternitzEncoding, target_sum::TargetSumEncoding},
560+
inc_encoding::target_sum::TargetSumEncoding,
563561
signature::test_templates::test_signature_scheme_correctness,
564562
symmetric::{
565-
message_hash::{
566-
MessageHash,
567-
poseidon::PoseidonMessageHashW1,
568-
sha::{ShaMessageHash, ShaMessageHash192x3},
569-
},
570-
prf::{sha::ShaPRF, shake_to_field::ShakePRFtoF},
571-
tweak_hash::{poseidon::PoseidonTweakW1L5, sha::ShaTweak192192},
563+
message_hash::{MessageHash, poseidon::PoseidonMessageHashW1},
564+
prf::shake_to_field::ShakePRFtoF,
565+
tweak_hash::poseidon::PoseidonTweakW1L5,
572566
},
573567
};
574568

575569
use super::*;
576570

577-
#[test]
578-
pub fn test_winternitz() {
579-
// Note: do not use these parameters, they are just for testing
580-
type PRF = ShaPRF<24, 24>;
581-
type TH = ShaTweak192192;
582-
type MH = ShaMessageHash192x3;
583-
const CHUNK_SIZE: usize = 4;
584-
const NUM_CHUNKS_CHECKSUM: usize = 3;
585-
type IE = WinternitzEncoding<MH, CHUNK_SIZE, NUM_CHUNKS_CHECKSUM>;
586-
const LOG_LIFETIME: usize = 10;
587-
type Sig = GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>;
588-
589-
Sig::internal_consistency_check();
590-
test_signature_scheme_correctness::<Sig>(289, 0, Sig::LIFETIME as usize);
591-
test_signature_scheme_correctness::<Sig>(2, 0, Sig::LIFETIME as usize);
592-
test_signature_scheme_correctness::<Sig>(19, 0, Sig::LIFETIME as usize);
593-
test_signature_scheme_correctness::<Sig>(0, 0, Sig::LIFETIME as usize);
594-
test_signature_scheme_correctness::<Sig>(11, 0, Sig::LIFETIME as usize);
595-
}
596-
597-
#[test]
598-
pub fn test_winternitz_poseidon() {
599-
// Note: do not use these parameters, they are just for testing
600-
type PRF = ShakePRFtoF<7, 5>;
601-
type TH = PoseidonTweakW1L5;
602-
type MH = PoseidonMessageHashW1;
603-
const CHUNK_SIZE: usize = 1;
604-
const _BASE: usize = 2;
605-
const NUM_CHUNKS_CHECKSUM: usize = 8;
606-
type IE = WinternitzEncoding<MH, CHUNK_SIZE, NUM_CHUNKS_CHECKSUM>;
607-
const LOG_LIFETIME: usize = 6;
608-
type Sig = GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>;
609-
610-
Sig::internal_consistency_check();
611-
612-
test_signature_scheme_correctness::<Sig>(2, 0, Sig::LIFETIME as usize);
613-
test_signature_scheme_correctness::<Sig>(19, 0, Sig::LIFETIME as usize);
614-
test_signature_scheme_correctness::<Sig>(0, 0, Sig::LIFETIME as usize);
615-
test_signature_scheme_correctness::<Sig>(11, 0, Sig::LIFETIME as usize);
616-
617-
test_signature_scheme_correctness::<Sig>(12, 10, (1 << 5) - 10);
618-
test_signature_scheme_correctness::<Sig>(19, 4, 20);
619-
test_signature_scheme_correctness::<Sig>(16, 16, 4);
620-
test_signature_scheme_correctness::<Sig>(11, 1, 29);
621-
}
622-
623-
#[test]
624-
pub fn test_target_sum() {
625-
// Note: do not use these parameters, they are just for testing
626-
type PRF = ShaPRF<24, 24>;
627-
type TH = ShaTweak192192;
628-
type MH = ShaMessageHash192x3;
629-
const BASE: usize = MH::BASE;
630-
const NUM_CHUNKS: usize = MH::DIMENSION;
631-
const MAX_CHUNK_VALUE: usize = BASE - 1;
632-
const EXPECTED_SUM: usize = NUM_CHUNKS * MAX_CHUNK_VALUE / 2;
633-
type IE = TargetSumEncoding<MH, EXPECTED_SUM>;
634-
const LOG_LIFETIME: usize = 8;
635-
type Sig = GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>;
636-
637-
Sig::internal_consistency_check();
638-
639-
test_signature_scheme_correctness::<Sig>(13, 0, Sig::LIFETIME as usize);
640-
test_signature_scheme_correctness::<Sig>(9, 0, Sig::LIFETIME as usize);
641-
test_signature_scheme_correctness::<Sig>(21, 0, Sig::LIFETIME as usize);
642-
test_signature_scheme_correctness::<Sig>(0, 0, Sig::LIFETIME as usize);
643-
test_signature_scheme_correctness::<Sig>(31, 0, Sig::LIFETIME as usize);
644-
}
645-
646571
#[test]
647572
pub fn test_target_sum_poseidon() {
648573
// Note: do not use these parameters, they are just for testing
@@ -707,7 +632,7 @@ mod tests {
707632
assert_eq!(rho1, rho2);
708633
}
709634

710-
#[test]
635+
/*#[test]
711636
pub fn test_large_base_sha() {
712637
// Note: do not use these parameters, they are just for testing
713638
type PRF = ShaPRF<24, 8>;
@@ -743,7 +668,7 @@ mod tests {
743668
744669
test_signature_scheme_correctness::<Sig>(2, 0, Sig::LIFETIME as usize);
745670
test_signature_scheme_correctness::<Sig>(19, 0, Sig::LIFETIME as usize);
746-
}
671+
}*/
747672

748673
#[test]
749674
pub fn test_expand_activation_time() {

0 commit comments

Comments
 (0)