@@ -6,9 +6,12 @@ use crate::crypto_helper::ProtocolPartyId;
6
6
7
7
use bech32:: { self , ToBase32 , Variant } ;
8
8
use 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
+ } ;
11
13
use kes_summed_ed25519:: PublicKey as KesPublicKey ;
14
+ use nom:: AsBytes ;
12
15
use serde:: de:: Error ;
13
16
use serde:: { Deserialize , Deserializer , Serialize , Serializer } ;
14
17
use sha2:: Sha256 ;
@@ -22,7 +25,7 @@ pub enum OpCertError {
22
25
PoolAddressEncoding ,
23
26
}
24
27
25
- /// Raw Fields of the operational certificates (without incluiding the cold VK)
28
+ /// Raw Fields of the operational certificates (without including the cold VK)
26
29
#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
27
30
struct RawFields (
28
31
#[ serde( with = "serde_bytes" ) ] Vec < u8 > ,
@@ -33,7 +36,7 @@ struct RawFields(
33
36
34
37
/// Raw Operational Certificate
35
38
#[ derive( Clone , Debug , Deserialize , PartialEq , Eq , Serialize ) ]
36
- struct RawOpCert ( RawFields , EdPublicKey ) ;
39
+ struct RawOpCert ( RawFields , EdVerificationKey ) ;
37
40
38
41
/// Parsed Operational Certificate
39
42
#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -43,7 +46,7 @@ pub struct OpCert {
43
46
/// KES period at which KES key is initalized
44
47
pub start_kes_period : u64 ,
45
48
pub ( crate ) cert_sig : EdSignature ,
46
- pub ( crate ) cold_vk : EdPublicKey ,
49
+ pub ( crate ) cold_vk : EdVerificationKey ,
47
50
}
48
51
49
52
impl SerDeShelleyFileFormat for OpCert {
@@ -57,14 +60,15 @@ impl OpCert {
57
60
kes_vk : KesPublicKey ,
58
61
issue_number : u64 ,
59
62
start_kes_period : u64 ,
60
- cold_keypair : EdKeypair ,
63
+ cold_secret_key : EdSecretKey ,
61
64
) -> 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 (
64
67
& kes_vk,
65
68
issue_number,
66
69
start_kes_period,
67
70
) ) ;
71
+
68
72
Self {
69
73
kes_vk,
70
74
issue_number,
@@ -112,7 +116,7 @@ impl OpCert {
112
116
let mut hasher = Blake2b :: < U28 > :: new ( ) ;
113
117
hasher. update ( self . cold_vk . as_bytes ( ) ) ;
114
118
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 ( ) ) ;
116
120
bech32:: encode ( "pool" , pool_id. to_base32 ( ) , Variant :: Bech32 )
117
121
. map_err ( |_| OpCertError :: PoolAddressEncoding )
118
122
}
@@ -166,7 +170,7 @@ impl<'de> Deserialize<'de> for OpCert {
166
170
. map_err ( |_| Error :: custom ( "KES vk serialisation error" ) ) ?,
167
171
issue_number : raw_cert. 0 . 1 ,
168
172
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 )
170
174
. map_err ( |_| Error :: custom ( "ed25519 signature serialisation error" ) ) ?,
171
175
cold_vk : raw_cert. 1 ,
172
176
} )
0 commit comments