Skip to content

Commit

Permalink
clarify Dilithium3
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncolburne committed Aug 13, 2023
1 parent 7ba4349 commit 0fc4e02
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/core/cigar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];

Expand Down
32 changes: 16 additions & 16 deletions src/core/indexer/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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,
];

Expand Down
6 changes: 3 additions & 3 deletions src/core/matter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/matter/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/core/siger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
];
Expand Down
Loading

0 comments on commit 0fc4e02

Please sign in to comment.