diff --git a/src/signature/generalized_xmss/instantiations_aborting.rs b/src/signature/generalized_xmss/instantiations_aborting.rs index 2ca521b..ddd5942 100644 --- a/src/signature/generalized_xmss/instantiations_aborting.rs +++ b/src/signature/generalized_xmss/instantiations_aborting.rs @@ -1,8 +1,84 @@ +/// Instantiations with Lifetime 2^32 +pub mod lifetime_2_to_the_32 { + + use crate::{ + inc_encoding::target_sum::TargetSumEncoding, + signature::generalized_xmss::{ + GeneralizedXMSSPublicKey, GeneralizedXMSSSignature, GeneralizedXMSSSignatureScheme, + }, + symmetric::{ + message_hash::aborting::AbortingHypercubeMessageHash, prf::shake_to_field::ShakePRFtoF, + tweak_hash::poseidon::PoseidonTweakHash, + }, + }; + + const LOG_LIFETIME: usize = 32; + + const DIMENSION: usize = 46; + const BASE: usize = 8; + const TARGET_SUM: usize = 200; + const Z: usize = 8; + const Q: usize = 127; + + const PARAMETER_LEN: usize = 5; + const TWEAK_LEN_FE: usize = 2; + const MSG_LEN_FE: usize = 9; + const RAND_LEN_FE: usize = 7; + const HASH_LEN_FE: usize = 8; + + const CAPACITY: usize = 9; + + type MH = AbortingHypercubeMessageHash< + PARAMETER_LEN, + RAND_LEN_FE, + HASH_LEN_FE, + DIMENSION, + BASE, + Z, + Q, + TWEAK_LEN_FE, + MSG_LEN_FE, + >; + type TH = PoseidonTweakHash; + type PRF = ShakePRFtoF; + type IE = TargetSumEncoding; + + pub type SIGAbortingTargetSumLifetime32Dim64Base8 = + GeneralizedXMSSSignatureScheme; + pub type PubKeyAbortingTargetSumLifetime32Dim64Base8 = GeneralizedXMSSPublicKey; + pub type SigAbortingTargetSumLifetime32Dim64Base8 = GeneralizedXMSSSignature; + + #[cfg(test)] + mod test { + + #[cfg(feature = "slow-tests")] + use super::*; + #[cfg(feature = "slow-tests")] + use crate::signature::SignatureScheme; + + #[cfg(feature = "slow-tests")] + use crate::signature::test_templates::test_signature_scheme_correctness; + + #[test] + #[cfg(feature = "slow-tests")] + pub fn test_correctness() { + test_signature_scheme_correctness::( + 213, + 0, + SIGAbortingTargetSumLifetime32Dim64Base8::LIFETIME as usize, + ); + test_signature_scheme_correctness::( + 4, + 0, + SIGAbortingTargetSumLifetime32Dim64Base8::LIFETIME as usize, + ); + } + } +} + /// Instantiations with Lifetime 2^6. This is for testing purposes only. /// /// Warning: Should not be used in production environments. -/// -/// !!! TODO: compute properly each parameter. !!! pub mod lifetime_2_to_the_6 { use crate::{ inc_encoding::target_sum::TargetSumEncoding, @@ -15,27 +91,24 @@ pub mod lifetime_2_to_the_6 { const LOG_LIFETIME: usize = 6; - // KoalaBear: p = 2^31 - 2^24 + 1 = 127 * 8^8 + 1 - // w=8, z=8, Q=127, alpha=1 - const DIMENSION: usize = 64; + const DIMENSION: usize = 46; const BASE: usize = 8; + const TARGET_SUM: usize = 200; const Z: usize = 8; const Q: usize = 127; - // TODO const PARAMETER_LEN: usize = 5; const TWEAK_LEN_FE: usize = 2; const MSG_LEN_FE: usize = 9; const RAND_LEN_FE: usize = 7; - const MH_HASH_LEN_FE: usize = 8; + const HASH_LEN_FE: usize = 8; - const TH_HASH_LEN_FE: usize = 8; const CAPACITY: usize = 9; type MH = AbortingHypercubeMessageHash< PARAMETER_LEN, RAND_LEN_FE, - MH_HASH_LEN_FE, + HASH_LEN_FE, DIMENSION, BASE, Z, @@ -44,13 +117,11 @@ pub mod lifetime_2_to_the_6 { MSG_LEN_FE, >; - const TARGET_SUM: usize = 230; // TODO - - type TH = PoseidonTweakHash; - type PRF = ShakePRFtoF; + type TH = PoseidonTweakHash; + type PRF = ShakePRFtoF; type IE = TargetSumEncoding; - pub type SIGAbortingLifetime6Dim64Base8 = + pub type SIGAbortingTargetSumLifetime6Dim46Base8 = GeneralizedXMSSSignatureScheme; #[cfg(test)] @@ -59,19 +130,19 @@ pub mod lifetime_2_to_the_6 { SignatureScheme, test_templates::test_signature_scheme_correctness, }; - use super::SIGAbortingLifetime6Dim64Base8; + use super::SIGAbortingTargetSumLifetime6Dim46Base8; #[test] pub fn test_correctness() { - test_signature_scheme_correctness::( + test_signature_scheme_correctness::( 2, 0, - SIGAbortingLifetime6Dim64Base8::LIFETIME as usize, + SIGAbortingTargetSumLifetime6Dim46Base8::LIFETIME as usize, ); - test_signature_scheme_correctness::( + test_signature_scheme_correctness::( 11, 0, - SIGAbortingLifetime6Dim64Base8::LIFETIME as usize, + SIGAbortingTargetSumLifetime6Dim46Base8::LIFETIME as usize, ); } } diff --git a/src/signature/generalized_xmss/instantiations_poseidon_top_level.rs b/src/signature/generalized_xmss/instantiations_poseidon_top_level.rs index 55e420e..cf7ff26 100644 --- a/src/signature/generalized_xmss/instantiations_poseidon_top_level.rs +++ b/src/signature/generalized_xmss/instantiations_poseidon_top_level.rs @@ -49,6 +49,7 @@ pub mod lifetime_2_to_the_18 { #[cfg(all(test, feature = "slow-tests"))] mod test { + #[cfg(feature = "slow-tests")] use crate::signature::{ SignatureScheme, generalized_xmss::instantiations_poseidon_top_level::lifetime_2_to_the_18::SIGTopLevelTargetSumLifetime18Dim64Base8, @@ -130,6 +131,7 @@ pub mod lifetime_2_to_the_32 { #[cfg(all(test, feature = "slow-tests"))] mod test { + #[cfg(feature = "slow-tests")] use super::*; use crate::signature::{ SignatureScheme, test_templates::test_signature_scheme_correctness, @@ -204,6 +206,7 @@ pub mod lifetime_2_to_the_32 { #[cfg(all(test, feature = "slow-tests"))] mod test { + #[cfg(feature = "slow-tests")] use super::*; use crate::signature::{ SignatureScheme, test_templates::test_signature_scheme_correctness, @@ -277,6 +280,7 @@ pub mod lifetime_2_to_the_32 { #[cfg(all(test, feature = "slow-tests"))] mod test { + #[cfg(feature = "slow-tests")] use super::*; use crate::signature::{ SignatureScheme, test_templates::test_signature_scheme_correctness, @@ -359,6 +363,7 @@ pub mod lifetime_2_to_the_8 { SignatureScheme, test_templates::test_signature_scheme_correctness, }; + #[cfg(feature = "slow-tests")] use super::SIGTopLevelTargetSumLifetime8Dim64Base8; #[test]