From 112ce402ff0b3b038edb60de01faed74d61be74c Mon Sep 17 00:00:00 2001 From: Kevin Griffin Date: Thu, 2 Feb 2023 16:32:34 -0500 Subject: [PATCH] wip --- src/core/indexer/mod.rs | 41 +++-- src/core/indexer/tables.rs | 317 +++++++++++++++++++------------------ 2 files changed, 177 insertions(+), 181 deletions(-) diff --git a/src/core/indexer/mod.rs b/src/core/indexer/mod.rs index a078f4e..43240e2 100644 --- a/src/core/indexer/mod.rs +++ b/src/core/indexer/mod.rs @@ -27,7 +27,7 @@ impl Default for Indexer { fn default() -> Self { Indexer { raw: vec![], - code: tables::Codex::Ed25519_Sig.code().to_string(), + code: tables::Codex::Ed25519.code().to_string(), index: 0, ondex: Some(u32::MAX), } @@ -65,7 +65,7 @@ impl Indexer { } if let Some(o) = ondex { - if szg.os > 0 && !(o <= SIXTY_FOUR.pow(szg.os - 1)) { + if szg.os > 0 && o > SIXTY_FOUR.pow(szg.os - 1) { return Err(Box::new(Error::InvalidVarIndex(format!( "Invalid ondex '{o}' for code '{code}'" )))); @@ -84,19 +84,16 @@ impl Indexer { // when not provided make ondex match index ondex = Some(index); } - } else { - if let Some(o) = ondex { - if o != index && szg.os == 0 { - return Err(Box::new(Error::InvalidVarIndex(format!( - "Non matching ondex '{o}' and index '{index}' for code = '{code}'." - )))); - } + } else if let Some(o) = ondex { + if o != index && szg.os == 0 { + return Err(Box::new(Error::InvalidVarIndex(format!( + "Non matching ondex '{o}' and index '{index}' for code = '{code}'." + )))); } } // compute fs from index - let fs; - if szg.fs == u32::MAX { + let fs = if szg.fs == u32::MAX { if cs % 4 != 0 { return Err(Box::new(Error::InvalidCodeSize(format!( "Whole code size not multiple of 4 for variable length material. cs = '{cs}'." @@ -110,9 +107,9 @@ impl Indexer { )))); } - fs = (index * 4) + cs + (index * 4) + cs } else { - fs = szg.fs; + szg.fs }; let raw_size = (fs - cs) * 3 / 4; @@ -127,8 +124,8 @@ impl Indexer { Ok(Indexer { code, raw: raw.to_vec(), - index: index, - ondex: ondex, + index, + ondex, }) } @@ -147,7 +144,7 @@ impl Indexer { } pub fn new_with_qb2(qb2: &[u8]) -> Result { - let mut i: Indexer = Default::default(); + let i: Indexer = Default::default(); i.bexfil(qb2)?; Ok(i) } @@ -195,12 +192,10 @@ impl Indexer { o = ondex.unwrap() )))); } + } else if szg.os != 0 { + ondex = Some(util::b64_to_u32(odx)?); } else { - if szg.os != 0 { - ondex = Some(util::b64_to_u32(odx)?); - } else { - ondex = Some(index); - } + ondex = Some(index); } // index is index for some codes and variable length for others @@ -283,14 +278,14 @@ impl Indexer { Ok(()) } - fn bexfil(&self, qb2: &[u8]) -> Result<()> { + fn bexfil(&self, _qb2: &[u8]) -> Result<()> { todo!() } } #[cfg(test)] mod indexer_tests { - use crate::core::indexer::Indexer; + #[test] fn test_indexer_new() { diff --git a/src/core/indexer/tables.rs b/src/core/indexer/tables.rs index 6dbcdcb..8707d6e 100644 --- a/src/core/indexer/tables.rs +++ b/src/core/indexer/tables.rs @@ -3,32 +3,32 @@ use crate::error::{Error, Result}; /// /// Codes indicate which list of keys, current and/or prior next, index is for: /// -/// _Sig: Indices in code may appear in both current signing and -/// prior next key lists when event has both current and prior -/// next key lists. Two character code table has only one index -/// so must be the same for both lists. Other index if for -/// prior next. -/// The indices may be different in those code tables which -/// have two sets of indices. +/// Indices in code may appear in both current signing and +/// prior next key lists when event has both current and prior +/// next key lists. Two character code table has only one index +/// so must be the same for both lists. Other index if for +/// prior next. +/// The indices may be different in those code tables which +/// have two sets of indices. /// -/// _Crt_Sig: Index in code for current signing key list only. +/// _Crt: Index in code for current signing key list only. /// -/// _Big_: Big index values +/// _Big: Big index values #[allow(non_camel_case_types)] #[derive(Debug, Eq, PartialEq, Clone)] pub(crate) enum Codex { - Ed25519_Sig, - Ed25519_Crt_Sig, - ECDSA_256k1_Sig, - ECDSA_256k1_Crt_Sig, - Ed448_Sig, - Ed448_Crt_Sig, - Ed25519_Big_Sig, - Ed25519_Big_Crt_Sig, - ECDSA_256k1_Big_Sig, - ECDSA_256k1_Big_Crt_Sig, - Ed448_Big_Sig, - Ed448_Big_Crt_Sig, + Ed25519, + Ed25519_Crt, + ECDSA_256k1, + ECDSA_256k1_Crt, + Ed448, + Ed448_Crt, + Ed25519_Big, + Ed25519_Big_Crt, + ECDSA_256k1_Big, + ECDSA_256k1_Big_Crt, + Ed448_Big, + Ed448_Big_Crt, TBD0, TBD1, TBD4, @@ -37,18 +37,18 @@ pub(crate) enum Codex { impl Codex { pub(crate) fn code(&self) -> &'static str { match self { - Codex::Ed25519_Sig => "A", // Ed25519 sig appears same in both lists if any. - Codex::Ed25519_Crt_Sig => "B", // Ed25519 sig appears in current list only. - Codex::ECDSA_256k1_Sig => "C", // ECDSA secp256k1 sig appears same in both lists if any. - Codex::ECDSA_256k1_Crt_Sig => "D", // ECDSA secp256k1 sig appears in current list. - Codex::Ed448_Sig => "0A", // Ed448 signature appears in both lists. - Codex::Ed448_Crt_Sig => "0B", // Ed448 signature appears in current list only. - Codex::Ed25519_Big_Sig => "2A", // Ed25519 sig appears in both lists. - Codex::Ed25519_Big_Crt_Sig => "2B", // Ed25519 sig appears in current list only. - Codex::ECDSA_256k1_Big_Sig => "2C", // ECDSA secp256k1 sig appears in both lists. - Codex::ECDSA_256k1_Big_Crt_Sig => "2D", // ECDSA secp256k1 sig appears in current list only. - Codex::Ed448_Big_Sig => "3A", // Ed448 signature appears in both lists. - Codex::Ed448_Big_Crt_Sig => "3B", // Ed448 signature appears in current list only. + Codex::Ed25519 => "A", // Ed25519 sig appears same in both lists if any. + Codex::Ed25519_Crt => "B", // Ed25519 sig appears in current list only. + Codex::ECDSA_256k1 => "C", // ECDSA secp256k1 sig appears same in both lists if any. + Codex::ECDSA_256k1_Crt => "D", // ECDSA secp256k1 sig appears in current list. + Codex::Ed448 => "0A", // Ed448 signature appears in both lists. + Codex::Ed448_Crt => "0B", // Ed448 signature appears in current list only. + Codex::Ed25519_Big => "2A", // Ed25519 sig appears in both lists. + Codex::Ed25519_Big_Crt => "2B", // Ed25519 sig appears in current list only. + Codex::ECDSA_256k1_Big => "2C", // ECDSA secp256k1 sig appears in both lists. + Codex::ECDSA_256k1_Big_Crt => "2D", // ECDSA secp256k1 sig appears in current list only. + Codex::Ed448_Big => "3A", // Ed448 signature appears in both lists. + Codex::Ed448_Big_Crt => "3B", // Ed448 signature appears in current list only. Codex::TBD0 => "0z", // Test of Var len label L=N*4 <= 4095 char quadlets includes code Codex::TBD1 => "1z", // Test of index sig lead 1 Codex::TBD4 => "4z", // Test of index sig lead 1 big @@ -57,85 +57,85 @@ impl Codex { } /// SigCodex is all indexed signature derivation codes -#[allow(non_camel_case_types)] +#[allow(non_camel_case_types, clippy::enum_variant_names)] #[derive(Debug, Eq, PartialEq, Clone)] pub(crate) enum SigCodex { - Ed25519_Sig, - Ed25519_Crt_Sig, - ECDSA_256k1_Sig, - ECDSA_256k1_Crt_Sig, - Ed448_Sig, - Ed448_Crt_Sig, - Ed25519_Big_Sig, - Ed25519_Big_Crt_Sig, - ECDSA_256k1_Big_Sig, - ECDSA_256k1_Big_Crt_Sig, - Ed448_Big_Sig, - Ed448_Big_Crt_Sig, + Ed25519, + Ed25519_Crt, + ECDSA_256k1, + ECDSA_256k1_Crt, + Ed448, + Ed448_Crt, + Ed25519_Big, + Ed25519_Big_Crt, + ECDSA_256k1_Big, + ECDSA_256k1_Big_Crt, + Ed448_Big, + Ed448_Big_Crt, } impl SigCodex { pub(crate) fn code(&self) -> &'static str { match self { - SigCodex::Ed25519_Sig => "A", // Ed25519 sig appears same in both lists if any. - SigCodex::Ed25519_Crt_Sig => "B", // Ed25519 sig appears in current list only. - SigCodex::ECDSA_256k1_Sig => "C", // ECDSA secp256k1 sig appears same in both lists if any. - SigCodex::ECDSA_256k1_Crt_Sig => "D", // ECDSA secp256k1 sig appears in current list. - SigCodex::Ed448_Sig => "0A", // Ed448 signature appears in both lists. - SigCodex::Ed448_Crt_Sig => "0B", // Ed448 signature appears in current list only. - SigCodex::Ed25519_Big_Sig => "2A", // Ed25519 sig appears in both lists. - SigCodex::Ed25519_Big_Crt_Sig => "2B", // Ed25519 sig appears in current list only. - SigCodex::ECDSA_256k1_Big_Sig => "2C", // ECDSA secp256k1 sig appears in both lists. - SigCodex::ECDSA_256k1_Big_Crt_Sig => "2D", // ECDSA secp256k1 sig appears in current list only. - SigCodex::Ed448_Big_Sig => "3A", // Ed448 signature appears in both lists. - SigCodex::Ed448_Big_Crt_Sig => "3B", // Ed448 signature appears in current list only. + SigCodex::Ed25519 => "A", // Ed25519 sig appears same in both lists if any. + SigCodex::Ed25519_Crt => "B", // Ed25519 sig appears in current list only. + SigCodex::ECDSA_256k1 => "C", // ECDSA secp256k1 sig appears same in both lists if any. + SigCodex::ECDSA_256k1_Crt => "D", // ECDSA secp256k1 sig appears in current list. + SigCodex::Ed448 => "0A", // Ed448 signature appears in both lists. + SigCodex::Ed448_Crt => "0B", // Ed448 signature appears in current list only. + SigCodex::Ed25519_Big => "2A", // Ed25519 sig appears in both lists. + SigCodex::Ed25519_Big_Crt => "2B", // Ed25519 sig appears in current list only. + SigCodex::ECDSA_256k1_Big => "2C", // ECDSA secp256k1 sig appears in both lists. + SigCodex::ECDSA_256k1_Big_Crt => "2D", // ECDSA secp256k1 sig appears in current list only. + SigCodex::Ed448_Big => "3A", // Ed448 signature appears in both lists. + SigCodex::Ed448_Big_Crt => "3B", // Ed448 signature appears in current list only. } } } /// CurrentSigCodex is codex indexed signature codes for current list. -#[allow(non_camel_case_types)] +#[allow(non_camel_case_types, clippy::enum_variant_names)] pub(crate) enum CurrentSigCodex { - Ed25519_Crt_Sig, - ECDSA_256k1_Crt_Sig, - Ed448_Crt_Sig, - Ed25519_Big_Crt_Sig, - ECDSA_256k1_Big_Crt_Sig, - Ed448_Big_Crt_Sig, + Ed25519_Crt, + ECDSA_256k1_Crt, + Ed448_Crt, + Ed25519_Big_Crt, + ECDSA_256k1_Big_Crt, + Ed448_Big_Crt, } impl CurrentSigCodex { pub(crate) fn code(&self) -> &'static str { match self { - CurrentSigCodex::Ed25519_Crt_Sig => "B", // Ed25519 sig appears in current list only. - CurrentSigCodex::ECDSA_256k1_Crt_Sig => "D", // ECDSA secp256k1 sig appears in current list only. - CurrentSigCodex::Ed448_Crt_Sig => "0B", // Ed448 signature appears in current list only. - CurrentSigCodex::Ed25519_Big_Crt_Sig => "2B", // Ed25519 sig appears in current list only. - CurrentSigCodex::ECDSA_256k1_Big_Crt_Sig => "2D", // ECDSA secp256k1 sig appears in current list only. - CurrentSigCodex::Ed448_Big_Crt_Sig => "3B", // Ed448 signature appears in current list only. + CurrentSigCodex::Ed25519_Crt => "B", // Ed25519 sig appears in current list only. + CurrentSigCodex::ECDSA_256k1_Crt => "D", // ECDSA secp256k1 sig appears in current list only. + CurrentSigCodex::Ed448_Crt => "0B", // Ed448 signature appears in current list only. + CurrentSigCodex::Ed25519_Big_Crt => "2B", // Ed25519 sig appears in current list only. + CurrentSigCodex::ECDSA_256k1_Big_Crt => "2D", // ECDSA secp256k1 sig appears in current list only. + CurrentSigCodex::Ed448_Big_Crt => "3B", // Ed448 signature appears in current list only. } } pub(crate) fn from_code(code: &str) -> Result { Ok(match code { - "B" => CurrentSigCodex::Ed25519_Crt_Sig, - "D" => CurrentSigCodex::ECDSA_256k1_Crt_Sig, - "0B" => CurrentSigCodex::Ed448_Crt_Sig, - "2B" => CurrentSigCodex::Ed25519_Big_Crt_Sig, - "2D" => CurrentSigCodex::ECDSA_256k1_Big_Crt_Sig, - "3B" => CurrentSigCodex::Ed448_Big_Crt_Sig, + "B" => CurrentSigCodex::Ed25519_Crt, + "D" => CurrentSigCodex::ECDSA_256k1_Crt, + "0B" => CurrentSigCodex::Ed448_Crt, + "2B" => CurrentSigCodex::Ed25519_Big_Crt, + "2D" => CurrentSigCodex::ECDSA_256k1_Big_Crt, + "3B" => CurrentSigCodex::Ed448_Big_Crt, _ => return Err(Box::new(Error::UnexpectedCode(code.to_string()))), }) } pub(crate) fn has_code(code: &str) -> bool { vec![ - CurrentSigCodex::Ed25519_Crt_Sig.code(), - CurrentSigCodex::ECDSA_256k1_Crt_Sig.code(), - CurrentSigCodex::Ed448_Crt_Sig.code(), - CurrentSigCodex::Ed25519_Big_Crt_Sig.code(), - CurrentSigCodex::ECDSA_256k1_Big_Crt_Sig.code(), - CurrentSigCodex::Ed448_Big_Crt_Sig.code(), + CurrentSigCodex::Ed25519_Crt.code(), + CurrentSigCodex::ECDSA_256k1_Crt.code(), + CurrentSigCodex::Ed448_Crt.code(), + CurrentSigCodex::Ed25519_Big_Crt.code(), + CurrentSigCodex::ECDSA_256k1_Big_Crt.code(), + CurrentSigCodex::Ed448_Big_Crt.code(), ] .contains(&code) } @@ -143,47 +143,48 @@ impl CurrentSigCodex { /// BothSigCodex is codex indexed signature codes for both lists. #[allow(non_camel_case_types)] +#[allow(clippy::enum_variant_names)] pub(crate) enum BothSigCodex { - Ed25519_Sig, - ECDSA_256k1_Sig, - Ed448_Sig, - Ed25519_Big_Sig, - ECDSA_256k1_Big_Sig, - Ed448_Big_Sig, + Ed25519, + ECDSA_256k1, + Ed448, + Ed25519_Big, + ECDSA_256k1_Big, + Ed448_Big, } impl BothSigCodex { pub(crate) fn code(&self) -> &'static str { match self { - BothSigCodex::Ed25519_Sig => "A", // Ed25519 sig appears same in both lists if any. - BothSigCodex::ECDSA_256k1_Sig => "C", // ECDSA secp256k1 sig appears same in both lists if any. - BothSigCodex::Ed448_Sig => "0A", // Ed448 signature appears in both lists. - BothSigCodex::Ed25519_Big_Sig => "2A", // Ed25519 sig appears in both listsy. - BothSigCodex::ECDSA_256k1_Big_Sig => "2C", // ECDSA secp256k1 sig appears in both lists. - BothSigCodex::Ed448_Big_Sig => "3A", // Ed448 signature appears in both lists. + BothSigCodex::Ed25519 => "A", // Ed25519 sig appears same in both lists if any. + BothSigCodex::ECDSA_256k1 => "C", // ECDSA secp256k1 sig appears same in both lists if any. + BothSigCodex::Ed448 => "0A", // Ed448 signature appears in both lists. + BothSigCodex::Ed25519_Big => "2A", // Ed25519 sig appears in both listsy. + BothSigCodex::ECDSA_256k1_Big => "2C", // ECDSA secp256k1 sig appears in both lists. + BothSigCodex::Ed448_Big => "3A", // Ed448 signature appears in both lists. } } pub(crate) fn from_code(code: &str) -> Result { Ok(match code { - "A" => BothSigCodex::Ed25519_Sig, - "C" => BothSigCodex::ECDSA_256k1_Sig, - "0A" => BothSigCodex::Ed448_Sig, - "2A" => BothSigCodex::Ed25519_Big_Sig, - "2C" => BothSigCodex::ECDSA_256k1_Big_Sig, - "3A" => BothSigCodex::Ed448_Big_Sig, + "A" => BothSigCodex::Ed25519, + "C" => BothSigCodex::ECDSA_256k1, + "0A" => BothSigCodex::Ed448, + "2A" => BothSigCodex::Ed25519_Big, + "2C" => BothSigCodex::ECDSA_256k1_Big, + "3A" => BothSigCodex::Ed448_Big, _ => return Err(Box::new(Error::UnexpectedCode(code.to_string()))), }) } pub(crate) fn has_code(code: &str) -> bool { vec![ - BothSigCodex::Ed25519_Sig.code(), - BothSigCodex::ECDSA_256k1_Sig.code(), - BothSigCodex::Ed448_Sig.code(), - BothSigCodex::Ed25519_Big_Sig.code(), - BothSigCodex::ECDSA_256k1_Big_Sig.code(), - BothSigCodex::Ed448_Big_Sig.code(), + BothSigCodex::Ed25519.code(), + BothSigCodex::ECDSA_256k1.code(), + BothSigCodex::Ed448.code(), + BothSigCodex::Ed25519_Big.code(), + BothSigCodex::ECDSA_256k1_Big.code(), + BothSigCodex::Ed448_Big.code(), ] .contains(&code) } @@ -242,141 +243,141 @@ mod index_tables_tests { #[test] fn test_codex() { - assert_eq!(Codex::Ed25519_Sig.code(), "A"); - assert_eq!(Codex::Ed25519_Crt_Sig.code(), "B"); - assert_eq!(Codex::ECDSA_256k1_Sig.code(), "C"); - assert_eq!(Codex::ECDSA_256k1_Crt_Sig.code(), "D"); - assert_eq!(Codex::Ed448_Sig.code(), "0A"); - assert_eq!(Codex::Ed448_Crt_Sig.code(), "0B"); - assert_eq!(Codex::Ed25519_Big_Sig.code(), "2A"); - assert_eq!(Codex::Ed25519_Big_Crt_Sig.code(), "2B"); - assert_eq!(Codex::ECDSA_256k1_Big_Sig.code(), "2C"); - assert_eq!(Codex::ECDSA_256k1_Big_Crt_Sig.code(), "2D"); - assert_eq!(Codex::Ed448_Big_Sig.code(), "3A"); - assert_eq!(Codex::Ed448_Big_Crt_Sig.code(), "3B"); + assert_eq!(Codex::Ed25519.code(), "A"); + assert_eq!(Codex::Ed25519_Crt.code(), "B"); + assert_eq!(Codex::ECDSA_256k1.code(), "C"); + assert_eq!(Codex::ECDSA_256k1_Crt.code(), "D"); + assert_eq!(Codex::Ed448.code(), "0A"); + assert_eq!(Codex::Ed448_Crt.code(), "0B"); + assert_eq!(Codex::Ed25519_Big.code(), "2A"); + assert_eq!(Codex::Ed25519_Big_Crt.code(), "2B"); + assert_eq!(Codex::ECDSA_256k1_Big.code(), "2C"); + assert_eq!(Codex::ECDSA_256k1_Big_Crt.code(), "2D"); + assert_eq!(Codex::Ed448_Big.code(), "3A"); + assert_eq!(Codex::Ed448_Big_Crt.code(), "3B"); assert_eq!(Codex::TBD0.code(), "0z"); assert_eq!(Codex::TBD1.code(), "1z"); assert_eq!(Codex::TBD4.code(), "4z"); } #[test] - fn test_sig_code() { - assert_eq!(SigCodex::Ed25519_Sig.code(), "A"); - assert_eq!(SigCodex::Ed25519_Crt_Sig.code(), "B"); - assert_eq!(SigCodex::ECDSA_256k1_Sig.code(), "C"); - assert_eq!(SigCodex::ECDSA_256k1_Crt_Sig.code(), "D"); - assert_eq!(SigCodex::Ed448_Sig.code(), "0A"); - assert_eq!(SigCodex::Ed448_Crt_Sig.code(), "0B"); - assert_eq!(SigCodex::Ed25519_Big_Sig.code(), "2A"); - assert_eq!(SigCodex::Ed25519_Big_Crt_Sig.code(), "2B"); - assert_eq!(SigCodex::ECDSA_256k1_Big_Sig.code(), "2C"); - assert_eq!(SigCodex::ECDSA_256k1_Big_Crt_Sig.code(), "2D"); - assert_eq!(SigCodex::Ed448_Big_Sig.code(), "3A"); - assert_eq!(SigCodex::Ed448_Big_Crt_Sig.code(), "3B"); + fn test_code() { + assert_eq!(SigCodex::Ed25519.code(), "A"); + assert_eq!(SigCodex::Ed25519_Crt.code(), "B"); + assert_eq!(SigCodex::ECDSA_256k1.code(), "C"); + assert_eq!(SigCodex::ECDSA_256k1_Crt.code(), "D"); + assert_eq!(SigCodex::Ed448.code(), "0A"); + assert_eq!(SigCodex::Ed448_Crt.code(), "0B"); + assert_eq!(SigCodex::Ed25519_Big.code(), "2A"); + assert_eq!(SigCodex::Ed25519_Big_Crt.code(), "2B"); + assert_eq!(SigCodex::ECDSA_256k1_Big.code(), "2C"); + assert_eq!(SigCodex::ECDSA_256k1_Big_Crt.code(), "2D"); + assert_eq!(SigCodex::Ed448_Big.code(), "3A"); + assert_eq!(SigCodex::Ed448_Big_Crt.code(), "3B"); } #[test] - fn test_current_sig_code() { - assert_eq!(CurrentSigCodex::Ed25519_Crt_Sig.code(), "B"); - assert_eq!(CurrentSigCodex::ECDSA_256k1_Crt_Sig.code(), "D"); - assert_eq!(CurrentSigCodex::Ed448_Crt_Sig.code(), "0B"); - assert_eq!(CurrentSigCodex::Ed25519_Big_Crt_Sig.code(), "2B"); - assert_eq!(CurrentSigCodex::ECDSA_256k1_Big_Crt_Sig.code(), "2D"); - assert_eq!(CurrentSigCodex::Ed448_Big_Crt_Sig.code(), "3B"); + fn test_current_code() { + assert_eq!(CurrentSigCodex::Ed25519_Crt.code(), "B"); + assert_eq!(CurrentSigCodex::ECDSA_256k1_Crt.code(), "D"); + assert_eq!(CurrentSigCodex::Ed448_Crt.code(), "0B"); + assert_eq!(CurrentSigCodex::Ed25519_Big_Crt.code(), "2B"); + assert_eq!(CurrentSigCodex::ECDSA_256k1_Big_Crt.code(), "2D"); + assert_eq!(CurrentSigCodex::Ed448_Big_Crt.code(), "3B"); } #[test] - fn test_both_sig_code() { - assert_eq!(BothSigCodex::Ed25519_Sig.code(), "A"); - assert_eq!(BothSigCodex::ECDSA_256k1_Sig.code(), "C"); - assert_eq!(BothSigCodex::Ed448_Sig.code(), "0A"); - assert_eq!(BothSigCodex::Ed25519_Big_Sig.code(), "2A"); - assert_eq!(BothSigCodex::ECDSA_256k1_Big_Sig.code(), "2C"); - assert_eq!(BothSigCodex::Ed448_Big_Sig.code(), "3A"); + fn test_both_code() { + assert_eq!(BothSigCodex::Ed25519.code(), "A"); + assert_eq!(BothSigCodex::ECDSA_256k1.code(), "C"); + assert_eq!(BothSigCodex::Ed448.code(), "0A"); + assert_eq!(BothSigCodex::Ed25519_Big.code(), "2A"); + assert_eq!(BothSigCodex::ECDSA_256k1_Big.code(), "2C"); + assert_eq!(BothSigCodex::Ed448_Big.code(), "3A"); } #[test] fn test_sizage() { let mut s: Sizage; - s = sizage(Codex::Ed25519_Sig.code()).unwrap(); + s = sizage(Codex::Ed25519.code()).unwrap(); assert_eq!(s.hs, 1); assert_eq!(s.ss, 1); assert_eq!(s.os, 0); assert_eq!(s.fs, 88); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed25519_Crt_Sig.code()).unwrap(); + s = sizage(Codex::Ed25519_Crt.code()).unwrap(); assert_eq!(s.hs, 1); assert_eq!(s.ss, 1); assert_eq!(s.os, 0); assert_eq!(s.fs, 88); assert_eq!(s.ls, 0); - s = sizage(Codex::ECDSA_256k1_Sig.code()).unwrap(); + s = sizage(Codex::ECDSA_256k1.code()).unwrap(); assert_eq!(s.hs, 1); assert_eq!(s.ss, 1); assert_eq!(s.os, 0); assert_eq!(s.fs, 88); assert_eq!(s.ls, 0); - s = sizage(Codex::ECDSA_256k1_Crt_Sig.code()).unwrap(); + s = sizage(Codex::ECDSA_256k1_Crt.code()).unwrap(); assert_eq!(s.hs, 1); assert_eq!(s.ss, 1); assert_eq!(s.os, 0); assert_eq!(s.fs, 88); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed448_Sig.code()).unwrap(); + s = sizage(Codex::Ed448.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 2); assert_eq!(s.os, 1); assert_eq!(s.fs, 156); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed448_Crt_Sig.code()).unwrap(); + s = sizage(Codex::Ed448_Crt.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 2); assert_eq!(s.os, 1); assert_eq!(s.fs, 156); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed25519_Big_Sig.code()).unwrap(); + s = sizage(Codex::Ed25519_Big.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 4); assert_eq!(s.os, 2); assert_eq!(s.fs, 92); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed25519_Big_Crt_Sig.code()).unwrap(); + s = sizage(Codex::Ed25519_Big_Crt.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 4); assert_eq!(s.os, 2); assert_eq!(s.fs, 92); assert_eq!(s.ls, 0); - s = sizage(Codex::ECDSA_256k1_Big_Sig.code()).unwrap(); + s = sizage(Codex::ECDSA_256k1_Big.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 4); assert_eq!(s.os, 2); assert_eq!(s.fs, 92); assert_eq!(s.ls, 0); - s = sizage(Codex::ECDSA_256k1_Big_Crt_Sig.code()).unwrap(); + s = sizage(Codex::ECDSA_256k1_Big_Crt.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 4); assert_eq!(s.os, 2); assert_eq!(s.fs, 92); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed448_Big_Sig.code()).unwrap(); + s = sizage(Codex::Ed448_Big.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 6); assert_eq!(s.os, 3); assert_eq!(s.fs, 160); assert_eq!(s.ls, 0); - s = sizage(Codex::Ed448_Big_Crt_Sig.code()).unwrap(); + s = sizage(Codex::Ed448_Big_Crt.code()).unwrap(); assert_eq!(s.hs, 2); assert_eq!(s.ss, 6); assert_eq!(s.os, 3);