File tree Expand file tree Collapse file tree 5 files changed +11
-12
lines changed Expand file tree Collapse file tree 5 files changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ members = [
16
16
17
17
[patch .crates-io ]
18
18
digest = { path = " digest" }
19
+ ff = { git = " https://github.com/zkcrypto/ff.git" , rev = " 8e139e2fb25ab61a5d362394af0a34b10c03d59b" }
19
20
hkdf = { git = " https://github.com/RustCrypto/KDFs.git" }
20
21
hmac = { git = " https://github.com/RustCrypto/MACs.git" }
21
22
sha2 = { git = " https://github.com/RustCrypto/hashes.git" }
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ impl Field for Scalar {
104
104
105
105
loop {
106
106
rng. try_fill_bytes ( & mut bytes) ?;
107
- if let Some ( scalar) = Self :: from_repr ( bytes) . into ( ) {
107
+ if let Some ( scalar) = Self :: from_repr ( & bytes) . into ( ) {
108
108
return Ok ( scalar) ;
109
109
}
110
110
}
@@ -149,8 +149,8 @@ impl PrimeField for Scalar {
149
149
const ROOT_OF_UNITY_INV : Self = Self :: ZERO ; // BOGUS!
150
150
const DELTA : Self = Self :: ZERO ; // BOGUS!
151
151
152
- fn from_repr ( bytes : FieldBytes ) -> CtOption < Self > {
153
- ScalarPrimitive :: from_bytes ( & bytes) . map ( Self )
152
+ fn from_repr ( bytes : & FieldBytes ) -> CtOption < Self > {
153
+ ScalarPrimitive :: from_bytes ( bytes) . map ( Self )
154
154
}
155
155
156
156
fn to_repr ( & self ) -> FieldBytes {
@@ -898,7 +898,7 @@ mod tests {
898
898
#[ test]
899
899
fn round_trip ( ) {
900
900
let bytes = hex ! ( "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721" ) ;
901
- let scalar = Scalar :: from_repr ( bytes. into ( ) ) . unwrap ( ) ;
901
+ let scalar = Scalar :: from_repr ( & bytes. into ( ) ) . unwrap ( ) ;
902
902
assert_eq ! ( & bytes, scalar. to_repr( ) . as_slice( ) ) ;
903
903
}
904
904
}
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ mod tests {
293
293
#[ test]
294
294
fn mul_by_generator ( ) {
295
295
let scalar = NonZeroScalar :: from_repr (
296
- hex ! ( "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721" ) . into ( ) ,
296
+ & hex ! ( "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721" ) . into ( ) ,
297
297
)
298
298
. unwrap ( ) ;
299
299
let point = NonIdentity :: < ProjectivePoint > :: mul_by_generator ( & scalar) ;
Original file line number Diff line number Diff line change 77
77
}
78
78
79
79
/// Decode a [`NonZeroScalar`] from a big endian-serialized field element.
80
- pub fn from_repr ( repr : FieldBytes < C > ) -> CtOption < Self > {
80
+ pub fn from_repr ( repr : & FieldBytes < C > ) -> CtOption < Self > {
81
81
Scalar :: < C > :: from_repr ( repr) . and_then ( Self :: new)
82
82
}
83
83
@@ -419,7 +419,7 @@ where
419
419
let mut bytes = FieldBytes :: < C > :: default ( ) ;
420
420
421
421
if base16ct:: mixed:: decode ( hex, & mut bytes) ?. len ( ) == bytes. len ( ) {
422
- Self :: from_repr ( bytes) . into_option ( ) . ok_or ( Error )
422
+ Self :: from_repr ( & bytes) . into_option ( ) . ok_or ( Error )
423
423
} else {
424
424
Err ( Error )
425
425
}
@@ -465,7 +465,7 @@ mod tests {
465
465
#[ test]
466
466
fn round_trip ( ) {
467
467
let bytes = hex ! ( "c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721" ) ;
468
- let scalar = NonZeroScalar :: from_repr ( bytes. into ( ) ) . unwrap ( ) ;
468
+ let scalar = NonZeroScalar :: from_repr ( & bytes. into ( ) ) . unwrap ( ) ;
469
469
assert_eq ! ( & bytes, scalar. to_repr( ) . as_slice( ) ) ;
470
470
}
471
471
You can’t perform that action at this time.
0 commit comments