From ad020be5dbceab96299dab26e9caf2f071cd1fcc Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 10 Jan 2024 18:03:16 -0700 Subject: [PATCH] k256: fix benchmarks --- k256/benches/ecdsa.rs | 40 ++++++++++++++++++++++------------------ k256/benches/scalar.rs | 30 +++++++++++++++++------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/k256/benches/ecdsa.rs b/k256/benches/ecdsa.rs index da32db12..572d42b8 100644 --- a/k256/benches/ecdsa.rs +++ b/k256/benches/ecdsa.rs @@ -5,35 +5,39 @@ use ecdsa_core::{ elliptic_curve::group::prime::PrimeCurveAffine, hazmat::{SignPrimitive, VerifyPrimitive}, }; -use k256::{ - elliptic_curve::{array::arr, group::ff::PrimeField}, - AffinePoint, FieldBytes, Scalar, -}; +use k256::{elliptic_curve::group::ff::PrimeField, AffinePoint, FieldBytes, Scalar}; fn test_scalar_d() -> Scalar { - Scalar::from_repr(arr![u8; - 0xbb, 0x48, 0x8a, 0xef, 0x41, 0x6a, 0x41, 0xd7, 0x68, 0x0d, 0x1c, 0xf0, 0x1d, 0x70, - 0xf5, 0x9b, 0x60, 0xd7, 0xf5, 0xf7, 0x7e, 0x30, 0xe7, 0x8b, 0x8b, 0xf9, 0xd2, 0xd8, - 0x82, 0xf1, 0x56, 0xa6, - ]) + Scalar::from_repr( + [ + 0xbb, 0x48, 0x8a, 0xef, 0x41, 0x6a, 0x41, 0xd7, 0x68, 0x0d, 0x1c, 0xf0, 0x1d, 0x70, + 0xf5, 0x9b, 0x60, 0xd7, 0xf5, 0xf7, 0x7e, 0x30, 0xe7, 0x8b, 0x8b, 0xf9, 0xd2, 0xd8, + 0x82, 0xf1, 0x56, 0xa6, + ] + .into(), + ) .unwrap() } fn test_scalar_k() -> Scalar { - Scalar::from_repr(arr![u8; - 0x67, 0xe2, 0xf6, 0x80, 0x71, 0xed, 0x82, 0x81, 0xe8, 0xae, 0xd6, 0xbc, 0xf1, 0xc5, - 0x20, 0x7c, 0x5e, 0x63, 0x37, 0x22, 0xd9, 0x20, 0xaf, 0xd6, 0xae, 0x22, 0xd0, 0x6e, - 0xeb, 0x80, 0x35, 0xe3, - ]) + Scalar::from_repr( + [ + 0x67, 0xe2, 0xf6, 0x80, 0x71, 0xed, 0x82, 0x81, 0xe8, 0xae, 0xd6, 0xbc, 0xf1, 0xc5, + 0x20, 0x7c, 0x5e, 0x63, 0x37, 0x22, 0xd9, 0x20, 0xaf, 0xd6, 0xae, 0x22, 0xd0, 0x6e, + 0xeb, 0x80, 0x35, 0xe3, + ] + .into(), + ) .unwrap() } fn test_scalar_z() -> FieldBytes { - arr![u8; - 0xe3, 0x35, 0x80, 0xeb, 0x6e, 0xd0, 0x22, 0xae, 0xd6, 0xaf, 0x20, 0xd9, 0x22, 0x37, - 0x63, 0x5e, 0x7c, 0x20, 0xc5, 0xf1, 0xbc, 0xd6, 0xae, 0xe8, 0x81, 0x82, 0xed, 0x71, - 0x80, 0xf6, 0xe2, 0x67 + [ + 0xe3, 0x35, 0x80, 0xeb, 0x6e, 0xd0, 0x22, 0xae, 0xd6, 0xaf, 0x20, 0xd9, 0x22, 0x37, 0x63, + 0x5e, 0x7c, 0x20, 0xc5, 0xf1, 0xbc, 0xd6, 0xae, 0xe8, 0x81, 0x82, 0xed, 0x71, 0x80, 0xf6, + 0xe2, 0x67, ] + .into() } fn bench_ecdsa(c: &mut Criterion) { diff --git a/k256/benches/scalar.rs b/k256/benches/scalar.rs index ea88a8dd..d7bc7f9e 100644 --- a/k256/benches/scalar.rs +++ b/k256/benches/scalar.rs @@ -5,27 +5,31 @@ use criterion::{ }; use hex_literal::hex; use k256::{ - elliptic_curve::{ - array::arr, group::ff::PrimeField, ops::LinearCombination, ops::MulByGenerator, - }, + elliptic_curve::{group::ff::PrimeField, ops::LinearCombination, ops::MulByGenerator}, ProjectivePoint, Scalar, }; fn test_scalar_x() -> Scalar { - Scalar::from_repr(arr![u8; - 0xbb, 0x48, 0x8a, 0xef, 0x41, 0x6a, 0x41, 0xd7, 0x68, 0x0d, 0x1c, 0xf0, 0x1d, 0x70, - 0xf5, 0x9b, 0x60, 0xd7, 0xf5, 0xf7, 0x7e, 0x30, 0xe7, 0x8b, 0x8b, 0xf9, 0xd2, 0xd8, - 0x82, 0xf1, 0x56, 0xa6, - ]) + Scalar::from_repr( + [ + 0xbb, 0x48, 0x8a, 0xef, 0x41, 0x6a, 0x41, 0xd7, 0x68, 0x0d, 0x1c, 0xf0, 0x1d, 0x70, + 0xf5, 0x9b, 0x60, 0xd7, 0xf5, 0xf7, 0x7e, 0x30, 0xe7, 0x8b, 0x8b, 0xf9, 0xd2, 0xd8, + 0x82, 0xf1, 0x56, 0xa6, + ] + .into(), + ) .unwrap() } fn test_scalar_y() -> Scalar { - Scalar::from_repr(arr![u8; - 0x67, 0xe2, 0xf6, 0x80, 0x71, 0xed, 0x82, 0x81, 0xe8, 0xae, 0xd6, 0xbc, 0xf1, 0xc5, - 0x20, 0x7c, 0x5e, 0x63, 0x37, 0x22, 0xd9, 0x20, 0xaf, 0xd6, 0xae, 0x22, 0xd0, 0x6e, - 0xeb, 0x80, 0x35, 0xe3, - ]) + Scalar::from_repr( + [ + 0x67, 0xe2, 0xf6, 0x80, 0x71, 0xed, 0x82, 0x81, 0xe8, 0xae, 0xd6, 0xbc, 0xf1, 0xc5, + 0x20, 0x7c, 0x5e, 0x63, 0x37, 0x22, 0xd9, 0x20, 0xaf, 0xd6, 0xae, 0x22, 0xd0, 0x6e, + 0xeb, 0x80, 0x35, 0xe3, + ] + .into(), + ) .unwrap() }