Skip to content

Commit

Permalink
use 5 series for codes
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncolburne committed Aug 14, 2023
1 parent cac5384 commit b1186c0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/core/indexer/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ 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_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.
pub const CRYSTALS_Dilithium5: &str = "1AAC"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium5_Crt: &str = "1AAD"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium3: &str = "5AAA"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium3_Crt: &str = "5AAB"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium5: &str = "5AAC"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium5_Crt: &str = "5AAD"; // CRYSTALS Dilithium sig appears in current list.
}

/// SigCodex is all indexed signature derivation codes
Expand All @@ -75,10 +75,10 @@ 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_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.
pub const CRYSTALS_Dilithium5: &str = "1AAC"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium5_Crt: &str = "1AAD"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium3: &str = "5AAA"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium3_Crt: &str = "5AAB"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium5: &str = "5AAC"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium5_Crt: &str = "5AAD"; // CRYSTALS Dilithium sig appears in current list.
}

/// CurrentSigCodex is codex indexed signature codes for current list.
Expand All @@ -95,8 +95,8 @@ pub mod CurrentSigCodex {
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_Dilithium3_Crt: &str = "1AAB"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium5_Crt: &str = "1AAD"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium3_Crt: &str = "5AAB"; // CRYSTALS Dilithium sig appears in current list.
pub const CRYSTALS_Dilithium5_Crt: &str = "5AAD"; // CRYSTALS Dilithium sig appears in current list.

pub(crate) fn has_code(code: &str) -> bool {
const CODES: &[&str] = &[
Expand Down Expand Up @@ -131,8 +131,8 @@ pub mod BothSigCodex {
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_Dilithium3: &str = "1AAA"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium5: &str = "1AAC"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium3: &str = "5AAA"; // CRYSTALS Dilithium sig appears same in both lists if any.
pub const CRYSTALS_Dilithium5: &str = "5AAC"; // CRYSTALS Dilithium sig appears same in both lists if any.

pub(crate) fn has_code(code: &str) -> bool {
const CODES: &[&str] = &[
Expand Down Expand Up @@ -193,10 +193,10 @@ pub(crate) fn sizage(s: &str) -> Result<Sizage> {
"0z" => Sizage { hs: 2, ss: 2, os: 0, fs: u32::MAX, ls: 0 },
"1z" => Sizage { hs: 2, ss: 2, os: 1, fs: 76, ls: 1 },
"4z" => Sizage { hs: 2, ss: 6, os: 3, fs: 80, ls: 1 },
"1AAA" => Sizage { hs: 4, ss: 1, os: 0, fs: 4396, ls: 0 },
"1AAB" => Sizage { hs: 4, ss: 1, os: 0, fs: 4396, ls: 0 },
"1AAC" => Sizage { hs: 4, ss: 1, os: 0, fs: 6132, ls: 0 },
"1AAD" => Sizage { hs: 4, ss: 1, os: 0, fs: 6132, ls: 0 },
"5AAA" => Sizage { hs: 4, ss: 1, os: 0, fs: 4396, ls: 0 },
"5AAB" => Sizage { hs: 4, ss: 1, os: 0, fs: 4396, ls: 0 },
"5AAC" => Sizage { hs: 4, ss: 1, os: 0, fs: 6132, ls: 0 },
"5AAD" => Sizage { hs: 4, ss: 1, os: 0, fs: 6132, ls: 0 },
_ => return err!(Error::UnknownSizage(s.to_string())),
})
}
Expand All @@ -205,6 +205,7 @@ pub(crate) fn hardage(c: char) -> Result<u32> {
match c {
'A'..='Z' | 'a'..='z' => Ok(1),
'0'..='4' => Ok(2),
'5' => Ok(4),
'-' => err!(Error::UnexpectedCode("count code start".to_owned())),
'_' => err!(Error::UnexpectedCode("op code start".to_owned())),
_ => err!(Error::UnknownHardage(c.to_string())),
Expand All @@ -215,6 +216,7 @@ pub(crate) fn bardage(b: u8) -> Result<u32> {
match b {
b'\x00'..=b'\x33' => Ok(1),
b'\x34'..=b'\x38' => Ok(2),
b'\x39' => Ok(4),
b'\x3e' => err!(Error::UnexpectedCode("count code start".to_owned())),
b'\x3f' => err!(Error::UnexpectedCode("op code start".to_owned())),
_ => err!(Error::UnknownBardage(b.to_string())),
Expand Down Expand Up @@ -427,6 +429,7 @@ mod test {
#[case(0x36, 2)]
#[case(0x37, 2)]
#[case(0x38, 2)]
#[case(0x39, 4)]
fn bardage(#[case] code: u8, #[case] bdg: u32) {
assert_eq!(indexer::bardage(code).unwrap(), bdg);
}
Expand All @@ -443,6 +446,6 @@ mod test {

#[test]
fn unknown_bardage() {
assert!(indexer::bardage(0x39).is_err());
assert!(indexer::bardage(0x40).is_err());
}
}
8 changes: 8 additions & 0 deletions src/core/siger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ mod test {
.is_ok());
}

#[test]
fn new_with_qb64() {
let qsig64 = "5AAAAKEWfy8izZF5MNOHRA5jj0WdWR4LnasWt97UTwEgku7o5xd_L7Oftt8oHAS4qO4gUpbj7rZntpI4wB-vHSvTXDBXSsEc3NOJ4Vb1MWfxiYHsJSSHSh5g-_S-6LmBeC5v66eMh8RUsAuP-SqfXwH3O2Vim3e44wTY7tf5XCxuGHdXLpvksZ3ut5W-TtT_yz5zCzO88M4SwNKg6VACGXwXyASLzlsHSaxx3Y4FQa8o3AImkfoIJmMQYHYo--EhIJkWl5zLOmljGenQUC7mie2wqe0_JtA0PS-2lsFRFhHT4xvoHDNH-T9t72mZY_fHqeuQx2sqf6f-tjqAzSly1DHxPc_q6evDLSev_90GGWmaY2ZcionQZZr8pM741vy7u_pdSRc_rvrEcSf9ofE_4eXFezNHfHBVlsLaX3BsztwXvAxT_FmCRrrTGzR_uYffYnAdvaLCDdnuflaEC8stAsuOEnZbpgHIeeYWJK8xkwq-pwDQ-khGFVM0aJnMUIyNJpHzwBQS-OcTjU3HLObOOy5L3tuTkoRdvlxv0nNUre9ZY5S7rDW8vSQgCEXJOw0RkKr5uOjwQwM-yARGu-Ta44RddAKDvijDI0OAyT5Lv2U2U1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-ksxnJjLTAur4UpyWncYUeegj7PmSSv2MPe1B-6IKhlqr3vzo8S3K8xteGXR6LMhsh_mU0Bbo_HLlIll_xNcCh-HgGkLb-sqKcC09HwBEGBB1A3xO_rNkIjMcgwClA-l-3klQCohmkk2fd39m_ZYq5MabS9ge2jV8jg_9jBJVwO3kd9KhCRBoYjnGucN2eiheo2BsFFrFo7lexE7z90Pf4zhLBu-RKqV4X0Y7SVUWZgJBNK_GAmyAWmqYMmviO0fP5UZ29KoDdIpgnCqWme6FNTyew7wFvL7pbeEr7OcGzH6zDMHQdNFPns3MNCw6OMUIq2CDSHpccaj2vZkA0gM8z8Tg1MdreU12UkyzVjFFFkdCROSX32hBndzQa14977XP1JBom_vlzFdDxOeZ03-cVTpzH_Y8ha5D9J_gKA9locHSdbvUA7hAzjfrVVpBAAHpc9prqqO3bLgt08dCLa9Hf08l9wzyBQCW3_2ETRq0114g6Ws2uouS1S77_MNb8AOD1NVWGBoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgPFRgf";

Siger::new(None, None, None, None, None, None, Some(qsig64), None).unwrap();
assert!(Siger::new(None, None, None, None, None, None, Some(qsig64), None).is_ok());
}

#[test]
fn new_with_qb64b() {
let verfer_raw = hex!("0123456789abcdef00001111222233334444555566667777888899990000aaaa");
Expand Down

0 comments on commit b1186c0

Please sign in to comment.