Skip to content

Commit 238fa08

Browse files
committed
Update to PrimeField::from_repr() changes
1 parent 9e54c34 commit 238fa08

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ members = [
1616

1717
[patch.crates-io]
1818
digest = { path = "digest" }
19+
ff = { git = "https://github.com/zkcrypto/ff.git", rev = "8e139e2fb25ab61a5d362394af0a34b10c03d59b" }
1920
hkdf = { git = "https://github.com/RustCrypto/KDFs.git" }
2021
hmac = { git = "https://github.com/RustCrypto/MACs.git" }
2122
sha2 = { git = "https://github.com/RustCrypto/hashes.git" }

elliptic-curve/src/dev.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Field for Scalar {
104104

105105
loop {
106106
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() {
108108
return Ok(scalar);
109109
}
110110
}
@@ -149,8 +149,8 @@ impl PrimeField for Scalar {
149149
const ROOT_OF_UNITY_INV: Self = Self::ZERO; // BOGUS!
150150
const DELTA: Self = Self::ZERO; // BOGUS!
151151

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)
154154
}
155155

156156
fn to_repr(&self) -> FieldBytes {
@@ -898,7 +898,7 @@ mod tests {
898898
#[test]
899899
fn round_trip() {
900900
let bytes = hex!("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721");
901-
let scalar = Scalar::from_repr(bytes.into()).unwrap();
901+
let scalar = Scalar::from_repr(&bytes.into()).unwrap();
902902
assert_eq!(&bytes, scalar.to_repr().as_slice());
903903
}
904904
}

elliptic-curve/src/point/non_identity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ mod tests {
293293
#[test]
294294
fn mul_by_generator() {
295295
let scalar = NonZeroScalar::from_repr(
296-
hex!("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721").into(),
296+
&hex!("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721").into(),
297297
)
298298
.unwrap();
299299
let point = NonIdentity::<ProjectivePoint>::mul_by_generator(&scalar);

elliptic-curve/src/scalar/nonzero.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ where
7777
}
7878

7979
/// 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> {
8181
Scalar::<C>::from_repr(repr).and_then(Self::new)
8282
}
8383

@@ -419,7 +419,7 @@ where
419419
let mut bytes = FieldBytes::<C>::default();
420420

421421
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)
423423
} else {
424424
Err(Error)
425425
}
@@ -465,7 +465,7 @@ mod tests {
465465
#[test]
466466
fn round_trip() {
467467
let bytes = hex!("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721");
468-
let scalar = NonZeroScalar::from_repr(bytes.into()).unwrap();
468+
let scalar = NonZeroScalar::from_repr(&bytes.into()).unwrap();
469469
assert_eq!(&bytes, scalar.to_repr().as_slice());
470470
}
471471

0 commit comments

Comments
 (0)