From 0fc4e02e763aa315af0fdb597a79e1063d4b8083 Mon Sep 17 00:00:00 2001 From: Jason Colburne Date: Sun, 13 Aug 2023 17:34:13 -0300 Subject: [PATCH] clarify Dilithium3 --- src/core/cigar.rs | 2 +- src/core/indexer/tables.rs | 32 +++++++++++++------------- src/core/matter/mod.rs | 6 ++--- src/core/matter/tables.rs | 8 +++---- src/core/siger.rs | 8 +++---- src/core/signer.rs | 46 +++++++++++++++++++------------------- src/core/verfer.rs | 4 ++-- src/crypto/sign.rs | 36 ++++++++++++++--------------- 8 files changed, 71 insertions(+), 71 deletions(-) diff --git a/src/core/cigar.rs b/src/core/cigar.rs index 59ff63b..3887334 100644 --- a/src/core/cigar.rs +++ b/src/core/cigar.rs @@ -26,7 +26,7 @@ fn validate_code(code: &str) -> Result<()> { matter::Codex::Ed25519_Sig, matter::Codex::ECDSA_256k1_Sig, matter::Codex::ECDSA_256r1_Sig, - matter::Codex::CRYSTALS_Dilithium_Sig, + matter::Codex::CRYSTALS_Dilithium3_Sig, // matter::Codex::Ed448_Sig, ]; diff --git a/src/core/indexer/tables.rs b/src/core/indexer/tables.rs index 77f63f4..d888a18 100644 --- a/src/core/indexer/tables.rs +++ b/src/core/indexer/tables.rs @@ -28,8 +28,8 @@ pub mod Codex { pub const ECDSA_256k1_Crt: &str = "D"; // ECDSA secp256k1 sig appears in current list. pub const ECDSA_256r1: &str = "E"; // ECDSA secp256r1 sig appears same in both lists if any. pub const ECDSA_256r1_Crt: &str = "F"; // ECDSA secp256r1 sig appears in current list. - pub const CRYSTALS_Dilithium_Big: &str = "G"; // CRYSTALS Dilithium sig appears in both lists. - pub const CRYSTALS_Dilithium_Big_Crt: &str = "H"; // CRYSTALS Dilithium sig appears in current list only. + pub const CRYSTALS_Dilithium3_Big: &str = "G"; // CRYSTALS Dilithium sig appears in both lists. + pub const CRYSTALS_Dilithium3_Big_Crt: &str = "H"; // CRYSTALS Dilithium sig appears in current list only. pub const Ed448: &str = "0A"; // Ed448 signature appears in both lists. pub const Ed448_Crt: &str = "0B"; // Ed448 signature appears in current list only. pub const Ed25519_Big: &str = "2A"; // Ed25519 sig appears in both lists. @@ -43,8 +43,8 @@ pub mod Codex { pub const TBD0: &str = "0z"; // Test of Var len label L=N*4 <= 4095 char quadlets includes code pub const TBD1: &str = "1z"; // Test of index sig lead 1 pub const TBD4: &str = "4z"; // Test of index sig lead 1 big - pub const CRYSTALS_Dilithium: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any. - pub const CRYSTALS_Dilithium_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list. + pub const CRYSTALS_Dilithium3: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any. + pub const CRYSTALS_Dilithium3_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list. } /// SigCodex is all indexed signature derivation codes @@ -57,8 +57,8 @@ pub mod SigCodex { pub const ECDSA_256k1_Crt: &str = "D"; // ECDSA secp256k1 sig appears in current list. pub const ECDSA_256r1: &str = "E"; // ECDSA secp256r1 sig appears same in both lists if any. pub const ECDSA_256r1_Crt: &str = "F"; // ECDSA secp256r1 sig appears in current list. - pub const CRYSTALS_Dilithium_Big: &str = "G"; // CRYSTALS Dilithium sig appears in both lists. - pub const CRYSTALS_Dilithium_Big_Crt: &str = "H"; // CRYSTALS Dilithium sig appears in current list only. + pub const CRYSTALS_Dilithium3_Big: &str = "G"; // CRYSTALS Dilithium sig appears in both lists. + pub const CRYSTALS_Dilithium3_Big_Crt: &str = "H"; // CRYSTALS Dilithium sig appears in current list only. pub const Ed448: &str = "0A"; // Ed448 signature appears in both lists. pub const Ed448_Crt: &str = "0B"; // Ed448 signature appears in current list only. pub const Ed25519_Big: &str = "2A"; // Ed25519 sig appears in both lists. @@ -69,8 +69,8 @@ pub mod SigCodex { pub const ECDSA_256r1_Big_Crt: &str = "2F"; // ECDSA secp256r1 sig appears in current list only. pub const Ed448_Big: &str = "3A"; // Ed448 signature appears in both lists. pub const Ed448_Big_Crt: &str = "3B"; // Ed448 signature appears in current list only. - pub const CRYSTALS_Dilithium: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any. - pub const CRYSTALS_Dilithium_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list. + pub const CRYSTALS_Dilithium3: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any. + pub const CRYSTALS_Dilithium3_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list. } /// CurrentSigCodex is codex indexed signature codes for current list. @@ -80,26 +80,26 @@ pub mod CurrentSigCodex { pub const Ed25519_Crt: &str = "B"; // Ed25519 sig appears in current list only. pub const ECDSA_256k1_Crt: &str = "D"; // ECDSA secp256k1 sig appears in current list only. pub const ECDSA_256r1_Crt: &str = "F"; // ECDSA secp256r1 sig appears in current list. - pub const CRYSTALS_Dilithium_Big_Crt: &str = "H"; // CRYSTALS Dilithium sig appears in current list only. + pub const CRYSTALS_Dilithium3_Big_Crt: &str = "H"; // CRYSTALS Dilithium sig appears in current list only. pub const Ed448_Crt: &str = "0B"; // Ed448 signature appears in current list only. pub const Ed25519_Big_Crt: &str = "2B"; // Ed25519 sig appears in current list only. pub const ECDSA_256k1_Big_Crt: &str = "2D"; // ECDSA secp256k1 sig appears in current list only. pub const ECDSA_256r1_Big_Crt: &str = "2F"; // ECDSA secp256r1 sig appears in current list only. pub const Ed448_Big_Crt: &str = "3B"; // Ed448 signature appears in current list only. - pub const CRYSTALS_Dilithium_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list. + pub const CRYSTALS_Dilithium3_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list. pub(crate) fn has_code(code: &str) -> bool { const CODES: &[&str] = &[ Ed25519_Crt, ECDSA_256k1_Crt, ECDSA_256r1_Crt, - CRYSTALS_Dilithium_Crt, + CRYSTALS_Dilithium3_Crt, Ed448_Crt, Ed25519_Big_Crt, ECDSA_256k1_Big_Crt, ECDSA_256r1_Big_Crt, Ed448_Big_Crt, - CRYSTALS_Dilithium_Big_Crt, + CRYSTALS_Dilithium3_Big_Crt, ]; CODES.contains(&code) @@ -112,25 +112,25 @@ pub mod BothSigCodex { pub const Ed25519: &str = "A"; // Ed25519 sig appears same in both lists if any. pub const ECDSA_256k1: &str = "C"; // ECDSA secp256k1 sig appears same in both lists if any. pub const ECDSA_256r1: &str = "E"; // ECDSA secp256r1 sig appears same in both lists if any. - pub const CRYSTALS_Dilithium_Big: &str = "G"; // CRYSTALS Dilithium sig appears in both lists. + pub const CRYSTALS_Dilithium3_Big: &str = "G"; // CRYSTALS Dilithium sig appears in both lists. pub const Ed448: &str = "0A"; // Ed448 signature appears in both lists. pub const Ed25519_Big: &str = "2A"; // Ed25519 sig appears in both lists. pub const ECDSA_256k1_Big: &str = "2C"; // ECDSA secp256k1 sig appears in both lists. pub const ECDSA_256r1_Big: &str = "2E"; // ECDSA secp256r1 sig appears in both lists. pub const Ed448_Big: &str = "3A"; // Ed448 signature appears in both lists. - pub const CRYSTALS_Dilithium: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any. + pub const CRYSTALS_Dilithium3: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any. pub(crate) fn has_code(code: &str) -> bool { const CODES: &[&str] = &[ Ed25519, ECDSA_256k1, ECDSA_256r1, - CRYSTALS_Dilithium, + CRYSTALS_Dilithium3, Ed448, Ed25519_Big, ECDSA_256k1_Big, ECDSA_256r1_Big, - CRYSTALS_Dilithium_Big, + CRYSTALS_Dilithium3_Big, Ed448_Big, ]; diff --git a/src/core/matter/mod.rs b/src/core/matter/mod.rs index f51ece7..13259d2 100644 --- a/src/core/matter/mod.rs +++ b/src/core/matter/mod.rs @@ -176,7 +176,7 @@ pub trait Matter: Default { tables::Codex::ECDSA_256k1N, tables::Codex::Ed448N, tables::Codex::ECDSA_256r1N, - tables::Codex::CRYSTALS_DilithiumN, + tables::Codex::CRYSTALS_Dilithium3N, ]; !CODES.contains(&self.code().as_str()) @@ -824,12 +824,12 @@ mod test { #[case(TestMatter::new_with_code_and_raw(matter::Codex::ECDSA_256k1, b"000000000000000000000000000000000").unwrap(), true)] #[case(TestMatter::new_with_code_and_raw(matter::Codex::ECDSA_256r1, b"000000000000000000000000000000000").unwrap(), true)] #[case(TestMatter::new_with_code_and_raw(matter::Codex::Ed448, &[0u8; 57]).unwrap(), true)] - #[case(TestMatter::new_with_code_and_raw(matter::Codex::CRYSTALS_Dilithium, &[0u8; 4000]).unwrap(), true)] + #[case(TestMatter::new_with_code_and_raw(matter::Codex::CRYSTALS_Dilithium3, &[0u8; 4000]).unwrap(), true)] #[case(TestMatter::new_with_code_and_raw(matter::Codex::Ed25519N, b"00000000000000000000000000000000").unwrap(), false)] #[case(TestMatter::new_with_code_and_raw(matter::Codex::ECDSA_256k1N, b"000000000000000000000000000000000").unwrap(), false)] #[case(TestMatter::new_with_code_and_raw(matter::Codex::ECDSA_256r1N, b"000000000000000000000000000000000").unwrap(), false)] #[case(TestMatter::new_with_code_and_raw(matter::Codex::Ed448N, &[0u8; 57]).unwrap(), false)] - #[case(TestMatter::new_with_code_and_raw(matter::Codex::CRYSTALS_DilithiumN, &[0u8; 4000]).unwrap(), false)] + #[case(TestMatter::new_with_code_and_raw(matter::Codex::CRYSTALS_Dilithium3N, &[0u8; 4000]).unwrap(), false)] fn transferable(#[case] matter: TestMatter, #[case] result: bool) { assert_eq!(matter.transferable(), result); } diff --git a/src/core/matter/tables.rs b/src/core/matter/tables.rs index 4d55748..526afb8 100644 --- a/src/core/matter/tables.rs +++ b/src/core/matter/tables.rs @@ -125,10 +125,10 @@ pub mod Codex { pub const X25519_Private: &str = "O"; // X25519 private decryption key converted from Ed25519 pub const X25519_Cipher_Seed: &str = "P"; // X25519 124 char b64 Cipher of 44 char qb64 Seed pub const ECDSA_256r1_Seed: &str = "Q"; // ECDSA secp256r1 256 bit random Seed for private key - pub const CRYSTALS_DilithiumN: &str = "R"; // CRYSTALS Dilithium verficiation key, non-transferable. - pub const CRYSTALS_Dilithium: &str = "S"; // CRYSTALS Dilithium verficiation key. - pub const CRYSTALS_Dilithium_Seed: &str = "T"; // CRYSTALS Dilithium private key seed. This one is actually a seed. - pub const CRYSTALS_Dilithium_Sig: &str = "U"; // CRYSTALS Dilithium signature. + pub const CRYSTALS_Dilithium3N: &str = "R"; // CRYSTALS Dilithium verficiation key, non-transferable. + pub const CRYSTALS_Dilithium3: &str = "S"; // CRYSTALS Dilithium verficiation key. + pub const CRYSTALS_Dilithium3_Seed: &str = "T"; // CRYSTALS Dilithium private key seed. This one is actually a seed. + pub const CRYSTALS_Dilithium3_Sig: &str = "U"; // CRYSTALS Dilithium signature. pub const Salt_128: &str = "0A"; // 128 bit random salt or 128 bit number (see Huge) pub const Ed25519_Sig: &str = "0B"; // Ed25519 signature. pub const ECDSA_256k1_Sig: &str = "0C"; // ECDSA secp256k1 signature. diff --git a/src/core/siger.rs b/src/core/siger.rs index 8fedf65..1735d54 100644 --- a/src/core/siger.rs +++ b/src/core/siger.rs @@ -31,8 +31,8 @@ fn validate_code(code: &str) -> Result<()> { indexer::Codex::ECDSA_256k1_Crt, indexer::Codex::ECDSA_256r1, indexer::Codex::ECDSA_256r1_Crt, - indexer::Codex::CRYSTALS_Dilithium, - indexer::Codex::CRYSTALS_Dilithium_Crt, + indexer::Codex::CRYSTALS_Dilithium3, + indexer::Codex::CRYSTALS_Dilithium3_Crt, // indexer::Codex::Ed448, // indexer::Codex::Ed448_Crt, indexer::Codex::Ed25519_Big, @@ -41,8 +41,8 @@ fn validate_code(code: &str) -> Result<()> { indexer::Codex::ECDSA_256k1_Big_Crt, indexer::Codex::ECDSA_256r1_Big, indexer::Codex::ECDSA_256r1_Big_Crt, - indexer::Codex::CRYSTALS_Dilithium_Big, - indexer::Codex::CRYSTALS_Dilithium_Big_Crt, + indexer::Codex::CRYSTALS_Dilithium3_Big, + indexer::Codex::CRYSTALS_Dilithium3_Big_Crt, // indexer::Codex::Ed448_Big, // indexer::Codex::Ed448_Big_Crt, ]; diff --git a/src/core/signer.rs b/src/core/signer.rs index 15a7bdd..645183a 100644 --- a/src/core/signer.rs +++ b/src/core/signer.rs @@ -61,7 +61,7 @@ fn validate_code(code: &str) -> Result<()> { matter::Codex::Ed25519_Seed, matter::Codex::ECDSA_256k1_Seed, matter::Codex::ECDSA_256r1_Seed, - matter::Codex::CRYSTALS_Dilithium_Seed, + matter::Codex::CRYSTALS_Dilithium3_Seed, // matter::Codex::Ed448_Seed, ]; @@ -78,14 +78,14 @@ fn derive_verfer(code: &str, private_key: &[u8], transferable: bool) -> Result matter::Codex::Ed25519, matter::Codex::ECDSA_256k1_Seed => matter::Codex::ECDSA_256k1, matter::Codex::ECDSA_256r1_Seed => matter::Codex::ECDSA_256r1, - matter::Codex::CRYSTALS_Dilithium_Seed => matter::Codex::CRYSTALS_Dilithium, + matter::Codex::CRYSTALS_Dilithium3_Seed => matter::Codex::CRYSTALS_Dilithium3, _ => return err!(Error::UnexpectedCode(code.to_string())), }, false => match code { matter::Codex::Ed25519_Seed => matter::Codex::Ed25519N, matter::Codex::ECDSA_256k1_Seed => matter::Codex::ECDSA_256k1N, matter::Codex::ECDSA_256r1_Seed => matter::Codex::ECDSA_256r1N, - matter::Codex::CRYSTALS_Dilithium_Seed => matter::Codex::CRYSTALS_DilithiumN, + matter::Codex::CRYSTALS_Dilithium3_Seed => matter::Codex::CRYSTALS_Dilithium3N, _ => return err!(Error::UnexpectedCode(code.to_string())), }, }; @@ -151,7 +151,7 @@ impl Signer { matter::Codex::Ed25519_Seed => matter::Codex::Ed25519_Sig, matter::Codex::ECDSA_256k1_Seed => matter::Codex::ECDSA_256k1_Sig, matter::Codex::ECDSA_256r1_Seed => matter::Codex::ECDSA_256r1_Sig, - matter::Codex::CRYSTALS_Dilithium_Seed => matter::Codex::CRYSTALS_Dilithium_Sig, + matter::Codex::CRYSTALS_Dilithium3_Seed => matter::Codex::CRYSTALS_Dilithium3_Sig, _ => return err!(Error::UnexpectedCode(self.code())), }; @@ -173,7 +173,7 @@ impl Signer { matter::Codex::Ed25519_Seed => indexer::Codex::Ed25519_Crt, matter::Codex::ECDSA_256k1_Seed => indexer::Codex::ECDSA_256k1_Crt, matter::Codex::ECDSA_256r1_Seed => indexer::Codex::ECDSA_256r1_Crt, - matter::Codex::CRYSTALS_Dilithium_Seed => indexer::Codex::CRYSTALS_Dilithium_Crt, + matter::Codex::CRYSTALS_Dilithium3_Seed => indexer::Codex::CRYSTALS_Dilithium3_Crt, _ => return err!(Error::UnexpectedCode(self.code())), } } else { @@ -181,7 +181,7 @@ impl Signer { matter::Codex::Ed25519_Seed => indexer::Codex::Ed25519_Big_Crt, matter::Codex::ECDSA_256k1_Seed => indexer::Codex::ECDSA_256k1_Big_Crt, matter::Codex::ECDSA_256r1_Seed => indexer::Codex::ECDSA_256r1_Big_Crt, - matter::Codex::CRYSTALS_Dilithium_Seed => indexer::Codex::CRYSTALS_Dilithium_Big_Crt, + matter::Codex::CRYSTALS_Dilithium3_Seed => indexer::Codex::CRYSTALS_Dilithium3_Big_Crt, _ => return err!(Error::UnexpectedCode(self.code())), } }; @@ -195,7 +195,7 @@ impl Signer { matter::Codex::Ed25519_Seed => indexer::Codex::Ed25519, matter::Codex::ECDSA_256k1_Seed => indexer::Codex::ECDSA_256k1, matter::Codex::ECDSA_256r1_Seed => indexer::Codex::ECDSA_256r1, - matter::Codex::CRYSTALS_Dilithium_Seed => indexer::Codex::CRYSTALS_Dilithium, + matter::Codex::CRYSTALS_Dilithium3_Seed => indexer::Codex::CRYSTALS_Dilithium3, _ => return err!(Error::UnexpectedCode(self.code())), } } else { @@ -203,7 +203,7 @@ impl Signer { matter::Codex::Ed25519_Seed => indexer::Codex::Ed25519_Big, matter::Codex::ECDSA_256k1_Seed => indexer::Codex::ECDSA_256k1_Big, matter::Codex::ECDSA_256r1_Seed => indexer::Codex::ECDSA_256r1_Big, - matter::Codex::CRYSTALS_Dilithium_Seed => indexer::Codex::CRYSTALS_Dilithium_Big, + matter::Codex::CRYSTALS_Dilithium3_Seed => indexer::Codex::CRYSTALS_Dilithium3_Big, _ => return err!(Error::UnexpectedCode(self.code())), } }; @@ -318,8 +318,8 @@ mod test { "1AAJA3cK_P2CDlh-_EMFPvyqTPI1POkw-dr14DANx5JEXDCZ" )] #[case( - matter::Codex::CRYSTALS_Dilithium_Seed, - matter::Codex::CRYSTALS_Dilithium, + matter::Codex::CRYSTALS_Dilithium3_Seed, + matter::Codex::CRYSTALS_Dilithium3, "TJ97qKeoQzmWJvqxmeuqIMQbRxHErlNBUsm9BJ2FKX6T", "SFXIJIfr7VJTb6AV6A-zZfinSBo7NlZkeffGOL2a4jbeuLU4SIqchhoT6PuAL1SP-Izi84lJDEP7wmU3L6iess2gvI6nGWn0QYGWoOh2fXC4ZXRqqbQcVlqfUL_VH0vGLpYxPQEljaHPtxtZO1vVUHyburUjmZ6d3YzGxJ2G3L1sGjveFiwGO_vV7tC12Fs4F_2Qtq2oybIn5FrCPPns-MrRXSKM3VgXSHzrUYbmAwmufLlW3IfQPsIWPMzfA0sFk5wuD6tBVIw5nGme2D0SjjY8kg5McYxScZX_Oe6tS6dXXAJ4ibk3xv0VeQRGOfTgViM_GANIJ5OTcWS-Rwe60_i95hYJG9F-fQ2jt8Y2bYqI-ELTQeozF5PnkcMm1Z3PCnRxdfgrVuAmxVxWR8to1yPMHVKw9Uzn-nK5P7y1Z_VYn1jdfdHq4YnrVNmZn_F9g4CyTNqEYY3j8HUXFP9Dax3-XhHYqMnL4tJ6pUMaDLmqQ7LVCr8V-VQN9WTRIIHuhF5ixnVI94LV8FeSinFv-UEPqnVQ3aTvCpRdQV4uhvXu7DA_hata6R_TYJB2iGJyij9PhZDBTs2gDR0EQ5qFGFXqtp_FE-YYVT8dx3PpINTvTSGoPBpj6KraGaFKuuamJHZN2PlRR9zV8eSGwzA0I-8TlAtC5YePGMWJEPsc3dOzGcktfuPQn3tMka3LuYxZ9NaoHc3iRWZnXN-KnhRf31JSuVQWxmhB4pCd5L46AdwXapL5SFiJhkvV9LKiqzsbOLThCocuRLdGOrLFDnrBkxnit6_sbpV7fRVJYshu2sZ2u4TDjAj4XgM4tR7tkgD9pNqhtdMaqeS9E3aKcTNldDe11vRlT5tEOlcD6w9VrAzRO2V0sqZdKopzeS_QWohUxZYlF3QKuJ6Vd30GuvOa2za9EQdwLhWVoJHYl5vU6yerDEloTnX_AZFGxzqQEK0Pc31R5rU9s9OjZrcRPn19XI0BmfphrCMxv_eTThHPtlLS5AE7wzQEfk1mhjPzXh1lbDA0L7l846fI8EvWfpyTsniOubBZLHGFzOheZoOlJsyjPcs-9eFEgRGdGvwELkA_qlqb16V7aBJ27MZ22aYl2dMGcBGqObnwdJS055ZYS_gG4Skl6Valse9w95npfNmfu5TgoqUqdC8FV86vV4wR-mwagHKsrahKMIpjpmH7pobNQm8G9hU_ZpTd_VhIwObaMfmNMwTEWufzgYB7ouUF_Z6gkm0xJkVZ0LXfmL2cpF4zljej2vcNcbNNlKqM4GgYvDpV67niDooXqycGOrF_VH_OQUnew0r1An8TvOPKH_HiiD6YJtHUTEa-5mdouVlN9SHBGPkwm3JSqHW_Cmtir1qrV_lNyYOPwaYzgME-alkizNrzY7mA1iTzl0sdUHcLXq92ej9Dy0RY7C4bmlNzO0LYlpFk8szpx5h3kAKjq-E7qg8pwyMs6Bg_G6qrbJyFMo4mzVq8OvdTYJToMi626S1SH5LQPMzUP9wF3sSlsulpFXXFFcOtlMgSSYv-g1JuqV6euFyqW7tNL5IboLtOrZkBQBCzJj4w1pkl5IUVfHpGXauv-WkrHsUbpMeZAPHNUJbRbki8U7Lh9mrXriiglFelQO89KO5CICLfve6sydk20szrNh7RQZWL1X9eE1VIhaiOIUkoKn9mPmcpZfNFXlj67f1Dhc9OLRGOmcEaWZNJ1rCMJET3_MZnintbsWycKVcrGRidqly8KmxN8DB27_N73Ei1ejSmE2LNJCtcAoD-LWtpu0UTrZ9exH3U_dsJwUZAcywqzJLvBDTZE53GRq-taP1pfGBB_1gaSkO_CAHz0xZtuJyZzS3T8C_ZXgGEL1wuSiYZJXMf7Vw2W-6drRXt63sdrz5nk2THiS9kmn9gQkIO7319fIXOToNpCO6cROOT_rQkv4ZClIdoAER-eWS-aP0wHvDcgSlroeZjRk_qApD34yWtNNBexWE6wyoL6HEI7kxHJbcQ_Zsxjnb8bOTdHJ-weZLMPAGHVzyTJSrDqYvxsBJuCGnjTE44Tw8FjKGM_rJaqOygJjTpHwTOjYQdo-bDjbDaNxwcQCpOUeic_QwxXbB2MP7PJahRU-NhGLYWCS3yh8aVslNcgmMto7juVCSKtrp3GCOwK-gB0Ay4_A0bly33LbadQTuw10QrkD_pIWigYAeD_FYcjixcmn382vRe6yWJBUtPaiwFjQ9fJ0icYZcrHCfZsDMa-lkyld3rRKZv7UFiTJdtUgRg-UCo7inQoK6lW-wFCwVD5lwjWpda1HHn-8uFje9or533XRlEezKEofEAGy6WTd9pttaVyxyq1buagnUGSEf7fxf6AObpFzzQt01WVl5bQCf1SdoUfw5yqKe7xKmsfqUmsIoX1AfMdM9Iyy4TGuz5y-uWWxv0hbrsVIzrPpnxc_h_IRksfxeuGCXFx-sSIb0lj7cqdPCs2PbJxp0opbw6qKCbafOXzKrqhnCTUbjfaYuwN4PNOnWYIhelI327jTNiDk3GoRn0lBjx75ACBGeGbE1qiI55bMCJjDhRwmfsDtpd83cN7isFJo6djOlN_WjytOVAm8b2m-QXp2kUlNDcwZcw" )] @@ -425,7 +425,7 @@ mod test { matter::Codex::Ed25519_Seed, matter::Codex::ECDSA_256k1_Seed, matter::Codex::ECDSA_256r1_Seed, - matter::Codex::CRYSTALS_Dilithium_Seed, + matter::Codex::CRYSTALS_Dilithium3_Seed, )] code: &str, ) { @@ -506,11 +506,11 @@ mod test { let bad_ser = b"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG"; let signer = - Signer::new(Some(true), Some(matter::Codex::CRYSTALS_Dilithium_Seed), None, None, None, None) + Signer::new(Some(true), Some(matter::Codex::CRYSTALS_Dilithium3_Seed), None, None, None, None) .unwrap(); let cigar = signer.sign_unindexed(ser).unwrap(); - assert_eq!(cigar.code(), matter::Codex::CRYSTALS_Dilithium_Sig); + assert_eq!(cigar.code(), matter::Codex::CRYSTALS_Dilithium3_Sig); assert!(signer.verfer().verify(&cigar.raw(), ser).unwrap()); assert!(!signer.verfer().verify(&cigar.raw(), bad_ser).unwrap()); } @@ -624,15 +624,15 @@ mod test { } #[rstest] - #[case(false, 0, None, 0, indexer::Codex::CRYSTALS_Dilithium)] - #[case(false, 1, None, 1, indexer::Codex::CRYSTALS_Dilithium)] - #[case(false, 1, Some(3), 3, indexer::Codex::CRYSTALS_Dilithium_Big)] - #[case(false, 67, Some(3), 3, indexer::Codex::CRYSTALS_Dilithium_Big)] - #[case(false, 67, Some(67), 67, indexer::Codex::CRYSTALS_Dilithium_Big)] - #[case(true, 4, None, 0, indexer::Codex::CRYSTALS_Dilithium_Crt)] - #[case(true, 4, Some(6), 0, indexer::Codex::CRYSTALS_Dilithium_Crt)] - #[case(true, 65, None, 0, indexer::Codex::CRYSTALS_Dilithium_Big_Crt)] - #[case(true, 65, Some(67), 0, indexer::Codex::CRYSTALS_Dilithium_Big_Crt)] + #[case(false, 0, None, 0, indexer::Codex::CRYSTALS_Dilithium3)] + #[case(false, 1, None, 1, indexer::Codex::CRYSTALS_Dilithium3)] + #[case(false, 1, Some(3), 3, indexer::Codex::CRYSTALS_Dilithium3_Big)] + #[case(false, 67, Some(3), 3, indexer::Codex::CRYSTALS_Dilithium3_Big)] + #[case(false, 67, Some(67), 67, indexer::Codex::CRYSTALS_Dilithium3_Big)] + #[case(true, 4, None, 0, indexer::Codex::CRYSTALS_Dilithium3_Crt)] + #[case(true, 4, Some(6), 0, indexer::Codex::CRYSTALS_Dilithium3_Crt)] + #[case(true, 65, None, 0, indexer::Codex::CRYSTALS_Dilithium3_Big_Crt)] + #[case(true, 65, Some(67), 0, indexer::Codex::CRYSTALS_Dilithium3_Big_Crt)] fn sign_crystals_dilithium_indexed( #[case] only: bool, #[case] index: u32, @@ -644,7 +644,7 @@ mod test { let bad_ser = b"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG"; let signer = - Signer::new(Some(true), Some(matter::Codex::CRYSTALS_Dilithium_Seed), None, None, None, None) + Signer::new(Some(true), Some(matter::Codex::CRYSTALS_Dilithium3_Seed), None, None, None, None) .unwrap(); let siger = signer.sign_indexed(ser, only, index, input_ondex).unwrap(); diff --git a/src/core/verfer.rs b/src/core/verfer.rs index 2fc5de8..10dbf1c 100644 --- a/src/core/verfer.rs +++ b/src/core/verfer.rs @@ -23,8 +23,8 @@ fn validate_code(code: &str) -> Result<()> { matter::Codex::ECDSA_256k1, matter::Codex::ECDSA_256r1N, matter::Codex::ECDSA_256r1, - matter::Codex::CRYSTALS_DilithiumN, - matter::Codex::CRYSTALS_Dilithium, + matter::Codex::CRYSTALS_Dilithium3N, + matter::Codex::CRYSTALS_Dilithium3, // matter::Codex::Ed448N, // matter::Codex::Ed448, ]; diff --git a/src/crypto/sign.rs b/src/crypto/sign.rs index 3f2ca26..36dbf28 100644 --- a/src/crypto/sign.rs +++ b/src/crypto/sign.rs @@ -15,10 +15,10 @@ pub(crate) fn generate(code: &str) -> Result> { | matter::Codex::ECDSA_256r1N | matter::Codex::ECDSA_256r1_Seed | matter::Codex::ECDSA_256r1_Sig => ecdsa_256r1::generate(), - matter::Codex::CRYSTALS_Dilithium - | matter::Codex::CRYSTALS_DilithiumN - | matter::Codex::CRYSTALS_Dilithium_Seed - | matter::Codex::CRYSTALS_Dilithium_Sig => crystals_dilithium_mod::generate(), + matter::Codex::CRYSTALS_Dilithium3 + | matter::Codex::CRYSTALS_Dilithium3N + | matter::Codex::CRYSTALS_Dilithium3_Seed + | matter::Codex::CRYSTALS_Dilithium3_Sig => crystals_dilithium3::generate(), _ => err!(Error::UnexpectedCode(code.to_string())), } } @@ -37,10 +37,10 @@ pub(crate) fn public_key(code: &str, private_key: &[u8]) -> Result> { | matter::Codex::ECDSA_256r1N | matter::Codex::ECDSA_256r1_Seed | matter::Codex::ECDSA_256r1_Sig => ecdsa_256r1::public_key(private_key), - matter::Codex::CRYSTALS_Dilithium - | matter::Codex::CRYSTALS_DilithiumN - | matter::Codex::CRYSTALS_Dilithium_Seed - | matter::Codex::CRYSTALS_Dilithium_Sig => crystals_dilithium_mod::public_key(private_key), + matter::Codex::CRYSTALS_Dilithium3 + | matter::Codex::CRYSTALS_Dilithium3N + | matter::Codex::CRYSTALS_Dilithium3_Seed + | matter::Codex::CRYSTALS_Dilithium3_Sig => crystals_dilithium3::public_key(private_key), _ => err!(Error::UnexpectedCode(code.to_string())), } } @@ -59,10 +59,10 @@ pub(crate) fn sign(code: &str, private_key: &[u8], ser: &[u8]) -> Result | matter::Codex::ECDSA_256r1N | matter::Codex::ECDSA_256r1_Seed | matter::Codex::ECDSA_256r1_Sig => ecdsa_256r1::sign(private_key, ser), - matter::Codex::CRYSTALS_Dilithium - | matter::Codex::CRYSTALS_DilithiumN - | matter::Codex::CRYSTALS_Dilithium_Seed - | matter::Codex::CRYSTALS_Dilithium_Sig => crystals_dilithium_mod::sign(private_key, ser), + matter::Codex::CRYSTALS_Dilithium3 + | matter::Codex::CRYSTALS_Dilithium3N + | matter::Codex::CRYSTALS_Dilithium3_Seed + | matter::Codex::CRYSTALS_Dilithium3_Sig => crystals_dilithium3::sign(private_key, ser), _ => err!(Error::UnexpectedCode(code.to_string())), } } @@ -81,10 +81,10 @@ pub(crate) fn verify(code: &str, public_key: &[u8], sig: &[u8], ser: &[u8]) -> R | matter::Codex::ECDSA_256r1N | matter::Codex::ECDSA_256r1_Seed | matter::Codex::ECDSA_256r1_Sig => ecdsa_256r1::verify(public_key, sig, ser), - matter::Codex::CRYSTALS_Dilithium - | matter::Codex::CRYSTALS_DilithiumN - | matter::Codex::CRYSTALS_Dilithium_Seed - | matter::Codex::CRYSTALS_Dilithium_Sig => crystals_dilithium_mod::verify(public_key, sig, ser), + matter::Codex::CRYSTALS_Dilithium3 + | matter::Codex::CRYSTALS_Dilithium3N + | matter::Codex::CRYSTALS_Dilithium3_Seed + | matter::Codex::CRYSTALS_Dilithium3_Sig => crystals_dilithium3::verify(public_key, sig, ser), _ => err!(Error::UnexpectedCode(code.to_string())), } } @@ -208,7 +208,7 @@ mod ecdsa_256r1 { } } -mod crystals_dilithium_mod { +mod crystals_dilithium3 { use crystals_dilithium::dilithium3::{Keypair, PublicKey}; use zeroize::Zeroize; @@ -252,7 +252,7 @@ mod test { #[rstest] fn end_to_end( - #[values(matter::Codex::Ed25519, matter::Codex::ECDSA_256k1, matter::Codex::ECDSA_256r1, matter::Codex::CRYSTALS_Dilithium)] + #[values(matter::Codex::Ed25519, matter::Codex::ECDSA_256k1, matter::Codex::ECDSA_256r1, matter::Codex::CRYSTALS_Dilithium3)] code: &str, ) { let ser = b"abcdefghijklmnopqrstuvwxyz";