File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -189,7 +189,6 @@ pub struct KeyPair<P: MlDsaParams> {
189189 verifying_key : VerifyingKey < P > ,
190190
191191 /// The seed this signing key was derived from
192- #[ cfg( all( feature = "alloc" , feature = "pkcs8" ) ) ]
193192 seed : B32 ,
194193}
195194
@@ -203,6 +202,17 @@ impl<P: MlDsaParams> KeyPair<P> {
203202 pub fn verifying_key ( & self ) -> & VerifyingKey < P > {
204203 & self . verifying_key
205204 }
205+
206+ /// Serialize the [`Seed`] value: 32-bytes which can be used to reconstruct the
207+ /// [`KeyPair`].
208+ ///
209+ /// # ⚠️ Warning!
210+ ///
211+ /// This value is key material. Please treat it with care.
212+ #[ inline]
213+ pub fn to_seed ( & self ) -> Seed {
214+ self . seed
215+ }
206216}
207217
208218impl < P : MlDsaParams > AsRef < VerifyingKey < P > > for KeyPair < P > {
@@ -906,7 +916,6 @@ where
906916 KeyPair {
907917 signing_key,
908918 verifying_key,
909- #[ cfg( all( feature = "alloc" , feature = "pkcs8" ) ) ]
910919 seed : xi. clone ( ) ,
911920 }
912921 }
@@ -941,7 +950,10 @@ mod test {
941950 where
942951 P : MlDsaParams + PartialEq ,
943952 {
944- let kp = P :: from_seed ( & Array :: default ( ) ) ;
953+ let seed = Array :: default ( ) ;
954+ let kp = P :: from_seed ( & seed) ;
955+ assert_eq ! ( kp. to_seed( ) , seed) ;
956+
945957 let sk = kp. signing_key ;
946958 let vk = kp. verifying_key ;
947959
You can’t perform that action at this time.
0 commit comments