Skip to content

Commit e25ccd1

Browse files
authored
Bump hybrid-array to v0.4 (#1385)
1 parent 72fe7bc commit e25ccd1

File tree

5 files changed

+35
-36
lines changed

5 files changed

+35
-36
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ members = [
2222
opt-level = 2
2323

2424
[patch.crates-io]
25+
block-buffer = { git = "https://github.com/RustCrypto/utils" }
2526
crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint" }
26-
27+
crypto-common = { git = "https://github.com/RustCrypto/traits" }
28+
digest = { git = "https://github.com/RustCrypto/traits" }
2729
elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" }
28-
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
30+
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
31+
sec1 = { git = "https://github.com/RustCrypto/formats", branch = "sec1/hybrid-array-v0.4" }
2932

3033
ed448-goldilocks = { path = "ed448-goldilocks" }
3134
hash2curve = { path = "hash2curve" }

p256/benches/field.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
use criterion::{
44
BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement,
55
};
6+
use elliptic_curve::array::Array;
67
use hex_literal::hex;
78
use p256::FieldElement;
89

910
fn test_field_element_x() -> FieldElement {
10-
FieldElement::from_bytes(
11-
hex!("1ccbe91c075fc7f4f033bfa248db8fccd3565de94bbfb12f3c59ff46c271bf83").as_ref(),
12-
)
11+
FieldElement::from_bytes(&Array(hex!(
12+
"1ccbe91c075fc7f4f033bfa248db8fccd3565de94bbfb12f3c59ff46c271bf83"
13+
)))
1314
.unwrap()
1415
}
1516

1617
fn test_field_element_y() -> FieldElement {
17-
FieldElement::from_bytes(
18-
hex!("ce4014c68811f9a21a1fdb2c0e6113e06db7ca93b7404e78dc7ccd5ca89a4ca9").as_ref(),
19-
)
18+
FieldElement::from_bytes(&Array(hex!(
19+
"ce4014c68811f9a21a1fdb2c0e6113e06db7ca93b7404e78dc7ccd5ca89a4ca9"
20+
)))
2021
.unwrap()
2122
}
2223

p256/src/arithmetic/field.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ impl PrimeField for FieldElement {
196196
mod tests {
197197
use super::FieldElement;
198198
use crate::{FieldBytes, U256, test_vectors::field::DBL_TEST_VECTORS};
199+
use elliptic_curve::array::Array;
199200

200201
#[cfg(target_pointer_width = "64")]
201202
use proptest::{num::u64::ANY, prelude::*};
@@ -209,18 +210,15 @@ mod tests {
209210
FieldElement::ZERO
210211
);
211212
assert_eq!(
212-
FieldElement::from_bytes(
213-
[
214-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
215-
0, 0, 0, 0, 0, 1
216-
]
217-
.as_ref()
218-
)
213+
FieldElement::from_bytes(&Array([
214+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
215+
0, 0, 0, 1
216+
]))
219217
.unwrap(),
220218
FieldElement::ONE
221219
);
222220
assert!(bool::from(
223-
FieldElement::from_bytes([0xff; 32].as_ref()).is_none()
221+
FieldElement::from_bytes(&Array([0xff; 32])).is_none()
224222
));
225223
}
226224

p521/benches/field.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
use criterion::{
44
BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement,
55
};
6+
use elliptic_curve::array::Array;
67
use hex_literal::hex;
78
use p521::FieldElement;
89
use std::hint::black_box;
910

1011
fn test_field_element_x() -> FieldElement {
1112
black_box(FieldElement::from_bytes(
12-
hex!("01a7596d38aac7868327ddc1ef5e8178cf052b7ebc512828e8a45955d85bef49494d15278198bbcc5454358c12a2af9a3874e7002e1a2f02fcb36ff3e3b4bc0c69e7").as_ref()
13+
&Array(hex!("01a7596d38aac7868327ddc1ef5e8178cf052b7ebc512828e8a45955d85bef49494d15278198bbcc5454358c12a2af9a3874e7002e1a2f02fcb36ff3e3b4bc0c69e7"))
1314
)
1415
.unwrap())
1516
}
1617

1718
fn test_field_element_y() -> FieldElement {
1819
black_box(FieldElement::from_bytes(
19-
hex!("0184902e515982bb225b8c84f245e61b327c08e94d41c07d0b4101a963e02fe52f6a9f33e8b1de2394e0cb74c40790b4e489b5500e6804cabed0fe8c192443d4027b").as_ref()
20+
&Array(hex!("0184902e515982bb225b8c84f245e61b327c08e94d41c07d0b4101a963e02fe52f6a9f33e8b1de2394e0cb74c40790b4e489b5500e6804cabed0fe8c192443d4027b"))
2021
)
2122
.unwrap())
2223
}

0 commit comments

Comments
 (0)