@@ -6,9 +6,12 @@ use crate::crypto_helper::ProtocolPartyId;
66
77use bech32:: { self , ToBase32 , Variant } ;
88use blake2:: { digest:: consts:: U28 , Blake2b , Digest } ;
9- use ed25519_dalek:: { Keypair as EdKeypair , Signer } ;
10- use ed25519_dalek:: { PublicKey as EdPublicKey , Signature as EdSignature , Verifier } ;
9+ use ed25519_dalek:: {
10+ Signature as EdSignature , Signer , SigningKey as EdSecretKey , Verifier ,
11+ VerifyingKey as EdVerificationKey ,
12+ } ;
1113use kes_summed_ed25519:: PublicKey as KesPublicKey ;
14+ use nom:: AsBytes ;
1215use serde:: de:: Error ;
1316use serde:: { Deserialize , Deserializer , Serialize , Serializer } ;
1417use sha2:: Sha256 ;
@@ -22,7 +25,7 @@ pub enum OpCertError {
2225 PoolAddressEncoding ,
2326}
2427
25- /// Raw Fields of the operational certificates (without incluiding the cold VK)
28+ /// Raw Fields of the operational certificates (without including the cold VK)
2629#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
2730struct RawFields (
2831 #[ serde( with = "serde_bytes" ) ] Vec < u8 > ,
@@ -33,7 +36,7 @@ struct RawFields(
3336
3437/// Raw Operational Certificate
3538#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
36- struct RawOpCert ( RawFields , EdPublicKey ) ;
39+ struct RawOpCert ( RawFields , EdVerificationKey ) ;
3740
3841/// Parsed Operational Certificate
3942#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -43,7 +46,7 @@ pub struct OpCert {
4346 /// KES period at which KES key is initalized
4447 pub start_kes_period : u64 ,
4548 pub ( crate ) cert_sig : EdSignature ,
46- pub ( crate ) cold_vk : EdPublicKey ,
49+ pub ( crate ) cold_vk : EdVerificationKey ,
4750}
4851
4952impl SerDeShelleyFileFormat for OpCert {
@@ -57,14 +60,15 @@ impl OpCert {
5760 kes_vk : KesPublicKey ,
5861 issue_number : u64 ,
5962 start_kes_period : u64 ,
60- cold_keypair : EdKeypair ,
63+ cold_secret_key : EdSecretKey ,
6164 ) -> Self {
62- let cold_vk: EdPublicKey = cold_keypair . public ;
63- let cert_sig = cold_keypair . sign ( & Self :: compute_message_to_sign (
65+ let cold_vk: EdVerificationKey = cold_secret_key . verifying_key ( ) ;
66+ let cert_sig = cold_secret_key . sign ( & Self :: compute_message_to_sign (
6467 & kes_vk,
6568 issue_number,
6669 start_kes_period,
6770 ) ) ;
71+
6872 Self {
6973 kes_vk,
7074 issue_number,
@@ -112,7 +116,7 @@ impl OpCert {
112116 let mut hasher = Blake2b :: < U28 > :: new ( ) ;
113117 hasher. update ( self . cold_vk . as_bytes ( ) ) ;
114118 let mut pool_id = [ 0u8 ; 28 ] ;
115- pool_id. copy_from_slice ( hasher. finalize ( ) . as_slice ( ) ) ;
119+ pool_id. copy_from_slice ( hasher. finalize ( ) . as_bytes ( ) ) ;
116120 bech32:: encode ( "pool" , pool_id. to_base32 ( ) , Variant :: Bech32 )
117121 . map_err ( |_| OpCertError :: PoolAddressEncoding )
118122 }
@@ -166,7 +170,7 @@ impl<'de> Deserialize<'de> for OpCert {
166170 . map_err ( |_| Error :: custom ( "KES vk serialisation error" ) ) ?,
167171 issue_number : raw_cert. 0 . 1 ,
168172 start_kes_period : raw_cert. 0 . 2 ,
169- cert_sig : EdSignature :: from_bytes ( & raw_cert. 0 . 3 )
173+ cert_sig : EdSignature :: from_slice ( & raw_cert. 0 . 3 )
170174 . map_err ( |_| Error :: custom ( "ed25519 signature serialisation error" ) ) ?,
171175 cold_vk : raw_cert. 1 ,
172176 } )
0 commit comments