Skip to content

Commit fbfc568

Browse files
authored
Bump elliptic-curve crate dependency (#1164)
1 parent 29556dd commit fbfc568

File tree

5 files changed

+82
-61
lines changed

5 files changed

+82
-61
lines changed

Cargo.lock

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

k256/src/arithmetic/hash2curve.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use elliptic_curve::Field;
22
use elliptic_curve::array::Array;
33
use elliptic_curve::bigint::{ArrayEncoding, U256};
4-
use elliptic_curve::consts::{U4, U48};
4+
use elliptic_curve::consts::{U4, U16, U48};
55
use elliptic_curve::group::cofactor::CofactorGroup;
66
use elliptic_curve::hash2curve::{
77
FromOkm, GroupDigest, Isogeny, IsogenyCoefficients, MapToCurve, OsswuMap, OsswuMapParams, Sgn0,
@@ -14,6 +14,8 @@ use super::FieldElement;
1414

1515
impl GroupDigest for Secp256k1 {
1616
type FieldElement = FieldElement;
17+
18+
type K = U16;
1719
}
1820

1921
impl FromOkm for FieldElement {
@@ -367,11 +369,10 @@ mod tests {
367369
for test_vector in TEST_VECTORS {
368370
// in parts
369371
let mut u = [FieldElement::default(), FieldElement::default()];
370-
hash2curve::hash_to_field::<ExpandMsgXmd<Sha256>, FieldElement>(
371-
&[test_vector.msg],
372-
&[DST],
373-
&mut u,
374-
)
372+
hash2curve::hash_to_field::<
373+
ExpandMsgXmd<Sha256, <Secp256k1 as GroupDigest>::K>,
374+
FieldElement,
375+
>(&[test_vector.msg], &[DST], &mut u)
375376
.unwrap();
376377
assert_eq!(u[0].to_bytes().as_slice(), test_vector.u_0);
377378
assert_eq!(u[1].to_bytes().as_slice(), test_vector.u_1);
@@ -392,8 +393,10 @@ mod tests {
392393
assert_eq!(ap.y.to_bytes().as_slice(), test_vector.p_y);
393394

394395
// complete run
395-
let pt = Secp256k1::hash_from_bytes::<ExpandMsgXmd<Sha256>>(&[test_vector.msg], &[DST])
396-
.unwrap();
396+
let pt = Secp256k1::hash_from_bytes::<
397+
ExpandMsgXmd<Sha256, <Secp256k1 as GroupDigest>::K>,
398+
>(&[test_vector.msg], &[DST])
399+
.unwrap();
397400
let apt = pt.to_affine();
398401
assert_eq!(apt.x.to_bytes().as_slice(), test_vector.p_x);
399402
assert_eq!(apt.y.to_bytes().as_slice(), test_vector.p_y);

p256/src/arithmetic/hash2curve.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ use crate::{AffinePoint, FieldBytes, NistP256, ProjectivePoint, Scalar};
33
use elliptic_curve::{
44
array::Array,
55
bigint::{ArrayEncoding, U256},
6-
consts::U48,
6+
consts::{U16, U48},
77
hash2curve::{FromOkm, GroupDigest, MapToCurve, OsswuMap, OsswuMapParams, Sgn0},
88
point::DecompressPoint,
99
subtle::Choice,
1010
};
1111

1212
impl GroupDigest for NistP256 {
1313
type FieldElement = FieldElement;
14+
15+
type K = U16;
1416
}
1517

1618
impl FromOkm for FieldElement {
@@ -201,11 +203,10 @@ mod tests {
201203
for test_vector in TEST_VECTORS {
202204
// in parts
203205
let mut u = [FieldElement::default(), FieldElement::default()];
204-
hash2curve::hash_to_field::<ExpandMsgXmd<Sha256>, FieldElement>(
205-
&[test_vector.msg],
206-
&[DST],
207-
&mut u,
208-
)
206+
hash2curve::hash_to_field::<
207+
ExpandMsgXmd<Sha256, <NistP256 as GroupDigest>::K>,
208+
FieldElement,
209+
>(&[test_vector.msg], &[DST], &mut u)
209210
.unwrap();
210211

211212
/// Assert that the provided projective point matches the given test vector.
@@ -236,7 +237,11 @@ mod tests {
236237
assert_point_eq!(p, test_vector.p_x, test_vector.p_y);
237238

238239
// complete run
239-
let pt = NistP256::hash_from_bytes::<ExpandMsgXmd<Sha256>>(&[test_vector.msg], &[DST])
240+
let pt =
241+
NistP256::hash_from_bytes::<ExpandMsgXmd<Sha256, <NistP256 as GroupDigest>::K>>(
242+
&[test_vector.msg],
243+
&[DST],
244+
)
240245
.unwrap();
241246
assert_point_eq!(pt, test_vector.p_x, test_vector.p_y);
242247
}
@@ -279,16 +284,17 @@ mod tests {
279284
.to_be_bytes();
280285

281286
for counter in 0_u8..=u8::MAX {
282-
let scalar = NistP256::hash_to_scalar::<ExpandMsgXmd<Sha256>>(
283-
&[
284-
test_vector.seed,
285-
&key_info_len,
286-
test_vector.key_info,
287-
&counter.to_be_bytes(),
288-
],
289-
&[test_vector.dst],
290-
)
291-
.unwrap();
287+
let scalar =
288+
NistP256::hash_to_scalar::<ExpandMsgXmd<Sha256, <NistP256 as GroupDigest>::K>>(
289+
&[
290+
test_vector.seed,
291+
&key_info_len,
292+
test_vector.key_info,
293+
&counter.to_be_bytes(),
294+
],
295+
&[test_vector.dst],
296+
)
297+
.unwrap();
292298

293299
if !bool::from(scalar.is_zero()) {
294300
assert_eq!(scalar.to_bytes().as_slice(), test_vector.sk_sm);

p384/src/arithmetic/hash2curve.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{AffinePoint, FieldBytes, NistP384, ProjectivePoint, Scalar};
33
use elliptic_curve::{
44
array::Array,
55
bigint::{ArrayEncoding, U384},
6-
consts::U72,
6+
consts::{U24, U72},
77
hash2curve::{FromOkm, GroupDigest, MapToCurve, OsswuMap, OsswuMapParams, Sgn0},
88
ops::Reduce,
99
point::DecompressPoint,
@@ -12,6 +12,8 @@ use elliptic_curve::{
1212

1313
impl GroupDigest for NistP384 {
1414
type FieldElement = FieldElement;
15+
16+
type K = U24;
1517
}
1618

1719
impl FromOkm for FieldElement {
@@ -203,11 +205,10 @@ mod tests {
203205
for test_vector in TEST_VECTORS {
204206
// in parts
205207
let mut u = [FieldElement::default(), FieldElement::default()];
206-
hash2curve::hash_to_field::<ExpandMsgXmd<Sha384>, FieldElement>(
207-
&[test_vector.msg],
208-
&[DST],
209-
&mut u,
210-
)
208+
hash2curve::hash_to_field::<
209+
ExpandMsgXmd<Sha384, <NistP384 as GroupDigest>::K>,
210+
FieldElement,
211+
>(&[test_vector.msg], &[DST], &mut u)
211212
.unwrap();
212213

213214
/// Assert that the provided projective point matches the given test vector.
@@ -238,7 +239,11 @@ mod tests {
238239
assert_point_eq!(p, test_vector.p_x, test_vector.p_y);
239240

240241
// complete run
241-
let pt = NistP384::hash_from_bytes::<ExpandMsgXmd<Sha384>>(&[test_vector.msg], &[DST])
242+
let pt =
243+
NistP384::hash_from_bytes::<ExpandMsgXmd<Sha384, <NistP384 as GroupDigest>::K>>(
244+
&[test_vector.msg],
245+
&[DST],
246+
)
242247
.unwrap();
243248
assert_point_eq!(pt, test_vector.p_x, test_vector.p_y);
244249
}
@@ -287,16 +292,17 @@ mod tests {
287292
.to_be_bytes();
288293

289294
for counter in 0_u8..=u8::MAX {
290-
let scalar = NistP384::hash_to_scalar::<ExpandMsgXmd<Sha384>>(
291-
&[
292-
test_vector.seed,
293-
&key_info_len,
294-
test_vector.key_info,
295-
&counter.to_be_bytes(),
296-
],
297-
&[test_vector.dst],
298-
)
299-
.unwrap();
295+
let scalar =
296+
NistP384::hash_to_scalar::<ExpandMsgXmd<Sha384, <NistP384 as GroupDigest>::K>>(
297+
&[
298+
test_vector.seed,
299+
&key_info_len,
300+
test_vector.key_info,
301+
&counter.to_be_bytes(),
302+
],
303+
&[test_vector.dst],
304+
)
305+
.unwrap();
300306

301307
if !bool::from(scalar.is_zero()) {
302308
assert_eq!(scalar.to_bytes().as_slice(), test_vector.sk_sm);

p521/src/arithmetic/hash2curve.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{AffinePoint, NistP521, ProjectivePoint, Scalar};
33
use elliptic_curve::{
44
array::Array,
55
bigint::{ArrayEncoding, U576},
6-
consts::U98,
6+
consts::{U32, U98},
77
hash2curve::{FromOkm, GroupDigest, MapToCurve, OsswuMap, OsswuMapParams, Sgn0},
88
ops::Reduce,
99
point::DecompressPoint,
@@ -12,6 +12,8 @@ use elliptic_curve::{
1212

1313
impl GroupDigest for NistP521 {
1414
type FieldElement = FieldElement;
15+
16+
type K = U32;
1517
}
1618

1719
impl FromOkm for FieldElement {
@@ -209,11 +211,10 @@ mod tests {
209211
for test_vector in TEST_VECTORS {
210212
// in parts
211213
let mut u = [FieldElement::default(), FieldElement::default()];
212-
hash2curve::hash_to_field::<ExpandMsgXmd<Sha512>, FieldElement>(
213-
&[test_vector.msg],
214-
&[DST],
215-
&mut u,
216-
)
214+
hash2curve::hash_to_field::<
215+
ExpandMsgXmd<Sha512, <NistP521 as GroupDigest>::K>,
216+
FieldElement,
217+
>(&[test_vector.msg], &[DST], &mut u)
217218
.unwrap();
218219

219220
/// Assert that the provided projective point matches the given test vector.
@@ -244,7 +245,11 @@ mod tests {
244245
assert_point_eq!(p, test_vector.p_x, test_vector.p_y);
245246

246247
// complete run
247-
let pt = NistP521::hash_from_bytes::<ExpandMsgXmd<Sha512>>(&[test_vector.msg], &[DST])
248+
let pt =
249+
NistP521::hash_from_bytes::<ExpandMsgXmd<Sha512, <NistP521 as GroupDigest>::K>>(
250+
&[test_vector.msg],
251+
&[DST],
252+
)
248253
.unwrap();
249254
assert_point_eq!(pt, test_vector.p_x, test_vector.p_y);
250255
}
@@ -293,16 +298,17 @@ mod tests {
293298
.to_be_bytes();
294299

295300
for counter in 0_u8..=u8::MAX {
296-
let scalar = NistP521::hash_to_scalar::<ExpandMsgXmd<Sha512>>(
297-
&[
298-
test_vector.seed,
299-
&key_info_len,
300-
test_vector.key_info,
301-
&counter.to_be_bytes(),
302-
],
303-
&[test_vector.dst],
304-
)
305-
.unwrap();
301+
let scalar =
302+
NistP521::hash_to_scalar::<ExpandMsgXmd<Sha512, <NistP521 as GroupDigest>::K>>(
303+
&[
304+
test_vector.seed,
305+
&key_info_len,
306+
test_vector.key_info,
307+
&counter.to_be_bytes(),
308+
],
309+
&[test_vector.dst],
310+
)
311+
.unwrap();
306312

307313
if !bool::from(scalar.is_zero()) {
308314
assert_eq!(scalar.to_bytes().as_slice(), test_vector.sk_sm);

0 commit comments

Comments
 (0)