Skip to content

Commit 62b9eaf

Browse files
committed
Update to PrimeField::from_repr() changes
1 parent 9074ef9 commit 62b9eaf

File tree

33 files changed

+78
-78
lines changed

33 files changed

+78
-78
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ hmac = { git = "https://github.com/RustCrypto/MACs.git" }
3131
# https://github.com/RustCrypto/signatures/pull/913
3232
# https://github.com/RustCrypto/signatures/pull/940
3333
# https://github.com/RustCrypto/signatures/pull/955
34-
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
34+
ecdsa = { git = "https://github.com/RustCrypto/signatures.git", rev = "8aff077a4789c70da2930bf7f19206a4940f2da9" }
3535
rfc6979 = { git = "https://github.com/RustCrypto/signatures.git" }
3636

3737
# https://github.com/RustCrypto/traits/pull/1777
3838
# https://github.com/RustCrypto/traits/pull/1845
39+
# https://github.com/zkcrypto/ff/pull/137
3940
digest = { git = "https://github.com/RustCrypto/traits.git" }
40-
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
41+
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git", rev = "238fa0841040acb8a8b0a7c50a66adcaa847d28a" }
42+
ff = { git = "https://github.com/zkcrypto/ff.git", rev = "8e139e2fb25ab61a5d362394af0a34b10c03d59b" }
4143
signature = { git = "https://github.com/RustCrypto/traits.git" }
4244

bign256/benches/scalar.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ use hex_literal::hex;
88

99
fn test_scalar_x() -> Scalar {
1010
Scalar::from_repr(
11-
hex!("519b423d715f8b581f4fa8ee59f4771a5b44c8130b4e3eacca54a56dda72b464").into(),
11+
&hex!("519b423d715f8b581f4fa8ee59f4771a5b44c8130b4e3eacca54a56dda72b464").into(),
1212
)
1313
.unwrap()
1414
}
1515

1616
fn test_scalar_y() -> Scalar {
1717
Scalar::from_repr(
18-
hex!("0f56db78ca460b055c500064824bed999a25aaf48ebb519ac201537b85479813").into(),
18+
&hex!("0f56db78ca460b055c500064824bed999a25aaf48ebb519ac201537b85479813").into(),
1919
)
2020
.unwrap()
2121
}
2222

2323
fn bench_point_mul<M: Measurement>(group: &mut BenchmarkGroup<M>) {
2424
let p = ProjectivePoint::GENERATOR;
2525
let m = test_scalar_x();
26-
let s = Scalar::from_repr(m.into()).unwrap();
26+
let s = Scalar::from_repr(&m.into()).unwrap();
2727
group.bench_function("point-scalar mul", |b| b.iter(|| p * s));
2828
}
2929

bign256/src/arithmetic/field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ impl PrimeField for FieldElement {
9494
type Repr = FieldBytes;
9595

9696
#[inline]
97-
fn from_repr(bytes: FieldBytes) -> CtOption<Self> {
98-
Self::from_bytes(&bytes)
97+
fn from_repr(bytes: &FieldBytes) -> CtOption<Self> {
98+
Self::from_bytes(bytes)
9999
}
100100

101101
#[inline]

bign256/src/arithmetic/scalar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ impl IsHigh for Scalar {
130130
impl PrimeField for Scalar {
131131
type Repr = FieldBytes;
132132

133-
fn from_repr(repr: Self::Repr) -> CtOption<Self> {
134-
Self::from_bytes(&repr)
133+
fn from_repr(repr: &Self::Repr) -> CtOption<Self> {
134+
Self::from_bytes(repr)
135135
}
136136

137137
fn to_repr(&self) -> Self::Repr {

bign256/src/ecdsa/signing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl PrehashSigner<Signature> for SigningKey {
112112
let h = Scalar::reduce_bytes(&h_word);
113113

114114
//2. Generate 𝑘 ← rand(1,..,𝑞-1)
115-
let k = Scalar::from_repr(rfc6979::generate_k::<BeltHash, _>(
115+
let k = Scalar::from_repr(&rfc6979::generate_k::<BeltHash, _>(
116116
&self.secret_scalar.to_repr(),
117117
&FieldBytesEncoding::<BignP256>::encode_field_bytes(&BignP256::ORDER),
118118
&h.to_bytes(),

bp256/src/arithmetic/field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ impl PrimeField for FieldElement {
9090
const DELTA: Self = Self::from_u64(121);
9191

9292
#[inline]
93-
fn from_repr(bytes: FieldBytes) -> CtOption<Self> {
94-
Self::from_bytes(&bytes)
93+
fn from_repr(bytes: &FieldBytes) -> CtOption<Self> {
94+
Self::from_bytes(bytes)
9595
}
9696

9797
#[inline]

bp256/src/arithmetic/scalar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ impl PrimeField for Scalar {
116116
const DELTA: Self = Self::from_u64(9);
117117

118118
#[inline]
119-
fn from_repr(bytes: FieldBytes) -> CtOption<Self> {
120-
Self::from_bytes(&bytes)
119+
fn from_repr(bytes: &FieldBytes) -> CtOption<Self> {
120+
Self::from_bytes(bytes)
121121
}
122122

123123
#[inline]

bp384/src/arithmetic/field.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ impl PrimeField for FieldElement {
9393
const DELTA: Self = Self::from_u64(9);
9494

9595
#[inline]
96-
fn from_repr(bytes: FieldBytes) -> CtOption<Self> {
97-
Self::from_bytes(&bytes)
96+
fn from_repr(bytes: &FieldBytes) -> CtOption<Self> {
97+
Self::from_bytes(bytes)
9898
}
9999

100100
#[inline]

bp384/src/arithmetic/scalar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ impl PrimeField for Scalar {
124124
const DELTA: Self = Self::from_u64(16);
125125

126126
#[inline]
127-
fn from_repr(bytes: FieldBytes) -> CtOption<Self> {
128-
Self::from_bytes(&bytes)
127+
fn from_repr(bytes: &FieldBytes) -> CtOption<Self> {
128+
Self::from_bytes(bytes)
129129
}
130130

131131
#[inline]

0 commit comments

Comments
 (0)