File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed
ed448-goldilocks/src/field Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -698,11 +698,6 @@ impl Scalar {
698
698
bits
699
699
}
700
700
701
- /// Construct a `Scalar` from a little-endian byte representation.
702
- pub fn from_bytes ( bytes : & [ u8 ; 56 ] ) -> Scalar {
703
- Self ( U448 :: from_le_slice ( bytes) )
704
- }
705
-
706
701
/// Convert this `Scalar` to a little-endian byte array.
707
702
pub fn to_bytes ( & self ) -> [ u8 ; 56 ] {
708
703
let bytes = self . 0 . to_le_bytes ( ) ;
@@ -780,7 +775,7 @@ impl Scalar {
780
775
// Check that the 10 high bits are not set
781
776
let is_valid = is_zero ( bytes[ 56 ] ) | is_zero ( bytes[ 55 ] >> 6 ) ;
782
777
let bytes: [ u8 ; 56 ] = core:: array:: from_fn ( |i| bytes[ i] ) ;
783
- let candidate = Scalar :: from_bytes ( & bytes) ;
778
+ let candidate = Scalar ( U448 :: from_le_slice ( & bytes) ) ;
784
779
785
780
// underflow means candidate < ORDER, thus canonical
786
781
let ( _, underflow) = candidate. 0 . borrowing_sub ( & ORDER , Limb :: ZERO ) ;
@@ -971,7 +966,7 @@ mod test {
971
966
let scalar = Scalar ( U448 :: from_be_hex (
972
967
"0d79f6e375d3395ed9a6c4c3c49a1433fd7c58aa38363f74e9ab2c22a22347d79988f8e01e8a309f862a9f1052fcd042b9b1ed7115598f62" ,
973
968
) ) ;
974
- let got = Scalar :: from_bytes ( & scalar. to_bytes ( ) ) ;
969
+ let got = Scalar :: from_canonical_bytes ( & scalar. into ( ) ) . unwrap ( ) ;
975
970
assert_eq ! ( scalar, got)
976
971
}
977
972
#[ test]
You can’t perform that action at this time.
0 commit comments