Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 90 additions & 19 deletions src/signature/generalized_xmss/instantiations_aborting.rs
Original file line number Diff line number Diff line change
@@ -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<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;
type IE = TargetSumEncoding<MH, TARGET_SUM>;

pub type SIGAbortingTargetSumLifetime32Dim64Base8 =
GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>;
pub type PubKeyAbortingTargetSumLifetime32Dim64Base8 = GeneralizedXMSSPublicKey<TH>;
pub type SigAbortingTargetSumLifetime32Dim64Base8 = GeneralizedXMSSSignature<IE, TH>;

#[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::<SIGAbortingTargetSumLifetime32Dim64Base8>(
213,
0,
SIGAbortingTargetSumLifetime32Dim64Base8::LIFETIME as usize,
);
test_signature_scheme_correctness::<SIGAbortingTargetSumLifetime32Dim64Base8>(
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,
Expand All @@ -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,
Expand All @@ -44,13 +117,11 @@ pub mod lifetime_2_to_the_6 {
MSG_LEN_FE,
>;

const TARGET_SUM: usize = 230; // TODO

type TH = PoseidonTweakHash<PARAMETER_LEN, TH_HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<TH_HASH_LEN_FE, RAND_LEN_FE>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;
type IE = TargetSumEncoding<MH, TARGET_SUM>;

pub type SIGAbortingLifetime6Dim64Base8 =
pub type SIGAbortingTargetSumLifetime6Dim46Base8 =
GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>;

#[cfg(test)]
Expand All @@ -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::<SIGAbortingLifetime6Dim64Base8>(
test_signature_scheme_correctness::<SIGAbortingTargetSumLifetime6Dim46Base8>(
2,
0,
SIGAbortingLifetime6Dim64Base8::LIFETIME as usize,
SIGAbortingTargetSumLifetime6Dim46Base8::LIFETIME as usize,
);
test_signature_scheme_correctness::<SIGAbortingLifetime6Dim64Base8>(
test_signature_scheme_correctness::<SIGAbortingTargetSumLifetime6Dim46Base8>(
11,
0,
SIGAbortingLifetime6Dim64Base8::LIFETIME as usize,
SIGAbortingTargetSumLifetime6Dim46Base8::LIFETIME as usize,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down
Loading