@@ -10,7 +10,7 @@ use secrecy::{ExposeSecret, Secret, SecretVec};
1010use serde:: { de, Deserialize , Deserializer , Serialize , Serializer } ;
1111
1212use crate :: rng:: Crng ;
13- use crate :: { ed25519, hex} ;
13+ use crate :: { ed25519, hex, sha256 } ;
1414
1515/// The user's root seed from which we derive all child secrets.
1616pub struct RootSeed ( Secret < [ u8 ; Self :: LENGTH ] > ) ;
@@ -22,15 +22,9 @@ impl RootSeed {
2222 /// single secret.
2323 const HKDF_MAX_OUT_LEN : usize = 8160 /* 255*32 */ ;
2424
25- /// The HKDF domain separation value as a human-readable byte string.
26- #[ cfg( test) ]
27- const HKDF_SALT_STR : & ' static [ u8 ] = b"LEXE-HASH-REALM::RootSeed" ;
28-
29- /// We salt the HKDF for domain separation purposes. The raw bytes here are
30- /// equal to the hash value: `SHA-256(b"LEXE-HASH-REALM::RootSeed")`.
31- const HKDF_SALT : [ u8 ; 32 ] = hex:: decode_const (
32- b"363b116be1690fcd481f2d4014812aaecff2411b861198eec42c6e31d80a28a4" ,
33- ) ;
25+ /// We salt the HKDF for domain separation purposes.
26+ const HKDF_SALT : [ u8 ; 32 ] =
27+ sha256:: digest_const ( b"LEXE-HASH-REALM::RootSeed" ) . into_inner ( ) ;
3428
3529 pub fn new ( bytes : Secret < [ u8 ; Self :: LENGTH ] > ) -> Self {
3630 Self ( bytes)
@@ -350,24 +344,6 @@ mod test {
350344 assert_eq ! ( foo2. y, "asdf" ) ;
351345 }
352346
353- #[ test]
354- fn test_root_seed_hkdf_salt ( ) {
355- let actual = RootSeed :: HKDF_SALT . as_slice ( ) ;
356- let expected = sha256:: digest ( RootSeed :: HKDF_SALT_STR ) ;
357-
358- // // print out salt
359- // let hex = hex::encode(expected.as_ref());
360- // let (chunks, _) = hex.as_bytes().as_chunks::<2>();
361- // for &[hi, lo] in chunks {
362- // let hi = hi as char;
363- // let lo = lo as char;
364- // println!("0x{hi}{lo},");
365- // }
366-
367- // compare hex encode for easier debugging
368- assert_eq ! ( hex:: encode( actual) , hex:: encode( expected. as_ref( ) ) ) ;
369- }
370-
371347 #[ test]
372348 fn test_root_seed_derive ( ) {
373349 let seed = RootSeed :: new ( Secret :: new ( [ 0x42 ; 32 ] ) ) ;
0 commit comments