Skip to content
Closed
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
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) mod inc_encoding;
pub mod serialization;
pub mod signature;
pub(crate) mod simd_utils;
pub(crate) mod symmetric;
pub mod symmetric;

// Cached Poseidon2 permutations.
//
Expand Down
16 changes: 8 additions & 8 deletions src/signature/generalized_xmss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ pub struct GeneralizedXMSSSignatureScheme<
#[derive(Serialize, Deserialize)]
#[serde(bound = "")]
pub struct GeneralizedXMSSSignature<IE: IncomparableEncoding, TH: TweakableHash> {
path: HashTreeOpening<TH>,
rho: IE::Randomness,
hashes: Vec<TH::Domain>,
pub path: HashTreeOpening<TH>,
pub rho: IE::Randomness,
pub hashes: Vec<TH::Domain>,
}

impl<IE: IncomparableEncoding, TH: TweakableHash> Encode for GeneralizedXMSSSignature<IE, TH> {
Expand Down Expand Up @@ -176,8 +176,8 @@ impl<IE: IncomparableEncoding, TH: TweakableHash> Decode for GeneralizedXMSSSign
/// It contains a Merkle root and a parameter for the tweakable hash
#[derive(Serialize, Deserialize)]
pub struct GeneralizedXMSSPublicKey<TH: TweakableHash> {
root: TH::Domain,
parameter: TH::Parameter,
pub root: TH::Domain,
pub parameter: TH::Parameter,
}

/// Secret key for GeneralizedXMSSSignatureScheme
Expand Down Expand Up @@ -1003,7 +1003,7 @@ mod tests {
use rand::rng;
use ssz::{Decode, Encode};

type TestTH = PoseidonTweakHash<5, 7, 2, 9, 155>;
type TestTH = PoseidonTweakHash<5, 7, 9, 155>;

#[test]
pub fn test_target_sum_poseidon() {
Expand Down Expand Up @@ -1073,7 +1073,7 @@ mod tests {
pub fn test_large_base_poseidon() {
// Note: do not use these parameters, they are just for testing
type PRF = ShakePRFtoF<4, 8>;
type TH = PoseidonTweakHash<4, 4, 2, 8, 32>;
type TH = PoseidonTweakHash<4, 4, 8, 32>;
type MH = PoseidonMessageHash<4, 8, 8, 32, 256, 2, 9>;
const TARGET_SUM: usize = 1 << 12;
type IE = TargetSumEncoding<MH, TARGET_SUM>;
Expand All @@ -1090,7 +1090,7 @@ mod tests {
pub fn test_large_dimension_poseidon() {
// Note: do not use these parameters, they are just for testing
type PRF = ShakePRFtoF<8, 8>;
type TH = PoseidonTweakHash<4, 8, 2, 8, 256>;
type TH = PoseidonTweakHash<4, 8, 8, 256>;
type MH = PoseidonMessageHash<4, 8, 8, 256, 2, 2, 9>;
const TARGET_SUM: usize = 128;
type IE = TargetSumEncoding<MH, TARGET_SUM>;
Expand Down
24 changes: 8 additions & 16 deletions src/signature/generalized_xmss/instantiations_poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ pub mod lifetime_2_to_the_18 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw1 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W1>;
type THw1 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W1>;
type PRFw1 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw1<const TARGET_SUM: usize> = TargetSumEncoding<MHw1, TARGET_SUM>;
/// Instantiation with Lifetime 2^18, Target sum encoding, chunk size w = 1,
Expand All @@ -59,8 +58,7 @@ pub mod lifetime_2_to_the_18 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw2 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W2>;
type THw2 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W2>;
type PRFw2 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw2<const TARGET_SUM: usize> = TargetSumEncoding<MHw2, TARGET_SUM>;
/// Instantiation with Lifetime 2^18, Target sum encoding, chunk size w = 2,
Expand All @@ -85,8 +83,7 @@ pub mod lifetime_2_to_the_18 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw4 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W4>;
type THw4 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W4>;
type PRFw4 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw4<const TARGET_SUM: usize> = TargetSumEncoding<MHw4, TARGET_SUM>;
/// Instantiation with Lifetime 2^18, Target sum encoding, chunk size w = 4,
Expand All @@ -111,8 +108,7 @@ pub mod lifetime_2_to_the_18 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw8 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W8>;
type THw8 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W8>;
type PRFw8 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw8<const TARGET_SUM: usize> = TargetSumEncoding<MHw8, TARGET_SUM>;
/// Instantiation with Lifetime 2^18, Target sum encoding, chunk size w = 8,
Expand Down Expand Up @@ -260,8 +256,7 @@ pub mod lifetime_2_to_the_20 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw1 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W1>;
type THw1 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W1>;
type PRFw1 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw1<const TARGET_SUM: usize> = TargetSumEncoding<MHw1, TARGET_SUM>;
/// Instantiation with Lifetime 2^20, Target sum encoding, chunk size w = 1,
Expand All @@ -286,8 +281,7 @@ pub mod lifetime_2_to_the_20 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw2 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W2>;
type THw2 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W2>;
type PRFw2 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw2<const TARGET_SUM: usize> = TargetSumEncoding<MHw2, TARGET_SUM>;
/// Instantiation with Lifetime 2^20, Target sum encoding, chunk size w = 2,
Expand All @@ -312,8 +306,7 @@ pub mod lifetime_2_to_the_20 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw4 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W4>;
type THw4 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, NUM_CHUNKS_W4>;
type PRFw4 = ShakePRFtoF<HASH_LEN_FE, RAND_LEN>;
type IEw4<const TARGET_SUM: usize> = TargetSumEncoding<MHw4, TARGET_SUM>;
/// Instantiation with Lifetime 2^20, Target sum encoding, chunk size w = 4,
Expand All @@ -339,8 +332,7 @@ pub mod lifetime_2_to_the_20 {
TWEAK_LEN_FE,
MSG_LEN_FE,
>;
type THw8 =
PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE_W8, TWEAK_LEN_FE, CAPACITY, NUM_CHUNKS_W8>;
type THw8 = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE_W8, CAPACITY, NUM_CHUNKS_W8>;
type PRFw8 = ShakePRFtoF<HASH_LEN_FE_W8, RAND_LEN>;
type IEw8<const TARGET_SUM: usize> = TargetSumEncoding<MHw8, TARGET_SUM>;
/// Instantiation with Lifetime 2^20, Target sum encoding, chunk size w = 8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub mod lifetime_2_to_the_18 {
PARAMETER_LEN,
RAND_LEN_FE,
>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;
type IE = TargetSumEncoding<MH, TARGET_SUM>;

Expand Down Expand Up @@ -86,7 +86,9 @@ pub mod lifetime_2_to_the_32 {

use crate::{
inc_encoding::target_sum::TargetSumEncoding,
signature::generalized_xmss::GeneralizedXMSSSignatureScheme,
signature::generalized_xmss::{
GeneralizedXMSSPublicKey, GeneralizedXMSSSignature, GeneralizedXMSSSignatureScheme,
},
symmetric::{
message_hash::top_level_poseidon::TopLevelPoseidonMessageHash,
prf::shake_to_field::ShakePRFtoF, tweak_hash::poseidon::PoseidonTweakHash,
Expand All @@ -103,7 +105,7 @@ pub mod lifetime_2_to_the_32 {
const PARAMETER_LEN: usize = 5;
const TWEAK_LEN_FE: usize = 2;
const MSG_LEN_FE: usize = 9;
const RAND_LEN_FE: usize = 7;
pub const RAND_LEN_FE: usize = 7;
const HASH_LEN_FE: usize = 8;

const CAPACITY: usize = 9;
Expand All @@ -112,7 +114,7 @@ pub mod lifetime_2_to_the_32 {
const POS_INVOCATIONS: usize = 1;
const POS_OUTPUT_LEN_FE: usize = POS_OUTPUT_LEN_PER_INV_FE * POS_INVOCATIONS;

type MH = TopLevelPoseidonMessageHash<
pub type MH = TopLevelPoseidonMessageHash<
POS_OUTPUT_LEN_PER_INV_FE,
POS_INVOCATIONS,
POS_OUTPUT_LEN_FE,
Expand All @@ -124,12 +126,14 @@ pub mod lifetime_2_to_the_32 {
PARAMETER_LEN,
RAND_LEN_FE,
>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;
type IE = TargetSumEncoding<MH, TARGET_SUM>;

pub type SIGTopLevelTargetSumLifetime32Dim64Base8 =
GeneralizedXMSSSignatureScheme<PRF, IE, TH, LOG_LIFETIME>;
pub type PubKeyTopLevelTargetSumLifetime32Dim64Base8 = GeneralizedXMSSPublicKey<TH>;
pub type SigTopLevelTargetSumLifetime32Dim64Base8 = GeneralizedXMSSSignature<IE, TH>;

#[cfg(test)]
mod test {
Expand Down Expand Up @@ -205,7 +209,7 @@ pub mod lifetime_2_to_the_32 {
PARAMETER_LEN,
RAND_LEN_FE,
>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;
type IE = TargetSumEncoding<MH, TARGET_SUM>;

Expand Down Expand Up @@ -285,7 +289,7 @@ pub mod lifetime_2_to_the_32 {
PARAMETER_LEN,
RAND_LEN_FE,
>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, DIMENSION>;
type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;
type IE = TargetSumEncoding<MH, TARGET_SUM>;

Expand Down Expand Up @@ -368,7 +372,7 @@ pub mod lifetime_2_to_the_8 {
PARAMETER_LEN,
RAND_LEN_FE,
>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, CAPACITY, DIMENSION>;

type PRF = ShakePRFtoF<HASH_LEN_FE, RAND_LEN_FE>;

Expand Down
Loading
Loading