1
+ //! Redpallas verification keys for Zebra.
2
+
1
3
use std:: marker:: PhantomData ;
2
4
3
5
use group:: { cofactor:: CofactorGroup , ff:: PrimeField , GroupEncoding } ;
4
6
use halo2:: pasta:: pallas;
5
7
8
+ use crate :: fmt:: HexDebug ;
9
+
6
10
use super :: * ;
7
11
8
12
/// A refinement type for `[u8; 32]` indicating that the bytes represent
@@ -13,22 +17,22 @@ use super::*;
13
17
/// used in signature verification.
14
18
#[ derive( Copy , Clone , Debug , Deserialize , Eq , PartialEq , Serialize ) ]
15
19
pub struct VerificationKeyBytes < T : SigType > {
16
- pub ( crate ) bytes : [ u8 ; 32 ] ,
20
+ pub ( crate ) bytes : HexDebug < [ u8 ; 32 ] > ,
17
21
pub ( crate ) _marker : PhantomData < T > ,
18
22
}
19
23
20
24
impl < T : SigType > From < [ u8 ; 32 ] > for VerificationKeyBytes < T > {
21
25
fn from ( bytes : [ u8 ; 32 ] ) -> VerificationKeyBytes < T > {
22
26
VerificationKeyBytes {
23
- bytes,
27
+ bytes : bytes . into ( ) ,
24
28
_marker : PhantomData ,
25
29
}
26
30
}
27
31
}
28
32
29
33
impl < T : SigType > From < VerificationKeyBytes < T > > for [ u8 ; 32 ] {
30
34
fn from ( refined : VerificationKeyBytes < T > ) -> [ u8 ; 32 ] {
31
- refined. bytes
35
+ * refined. bytes
32
36
}
33
37
}
34
38
@@ -65,7 +69,7 @@ impl<T: SigType> From<VerificationKey<T>> for VerificationKeyBytes<T> {
65
69
66
70
impl < T : SigType > From < VerificationKey < T > > for [ u8 ; 32 ] {
67
71
fn from ( pk : VerificationKey < T > ) -> [ u8 ; 32 ] {
68
- pk. bytes . bytes
72
+ * pk. bytes . bytes
69
73
}
70
74
}
71
75
@@ -107,7 +111,7 @@ impl VerificationKey<SpendAuth> {
107
111
use super :: private:: Sealed ;
108
112
let point = self . point + ( SpendAuth :: basepoint ( ) * randomizer) ;
109
113
let bytes = VerificationKeyBytes {
110
- bytes : point. to_bytes ( ) ,
114
+ bytes : point. to_bytes ( ) . into ( ) ,
111
115
_marker : PhantomData ,
112
116
} ;
113
117
VerificationKey { point, bytes }
@@ -118,7 +122,7 @@ impl<T: SigType> VerificationKey<T> {
118
122
pub ( crate ) fn from_scalar ( s : & pallas:: Scalar ) -> VerificationKey < T > {
119
123
let point = T :: basepoint ( ) * s;
120
124
let bytes = VerificationKeyBytes {
121
- bytes : point. to_bytes ( ) ,
125
+ bytes : point. to_bytes ( ) . into ( ) ,
122
126
_marker : PhantomData ,
123
127
} ;
124
128
VerificationKey { point, bytes }
@@ -154,7 +158,7 @@ impl<T: SigType> VerificationKey<T> {
154
158
155
159
let s = {
156
160
// XXX-pasta_curves: should not use CtOption here
157
- let maybe_scalar = pallas:: Scalar :: from_repr ( signature. s_bytes ) ;
161
+ let maybe_scalar = pallas:: Scalar :: from_repr ( * signature. s_bytes ) ;
158
162
if maybe_scalar. is_some ( ) . into ( ) {
159
163
maybe_scalar. unwrap ( )
160
164
} else {
0 commit comments