From e2211337338a735e4b983bc1a5198e6a2c71b7ed Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:40:39 -0800 Subject: [PATCH 01/20] bring elliptic-curve pre --- Cargo.lock | 69 +++++++++++++++++++++++++++++++++++++----------------- Cargo.toml | 13 ++++++++++ 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4830856c..abb0c0700 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,7 +73,7 @@ dependencies = [ "pkcs8", "primeorder", "proptest", - "rand_core", + "rand_core 0.6.4", "rfc6979", "sec1", "signature", @@ -319,7 +319,7 @@ checksum = "d748d1f5b807ee6d0df5a548d0130417295c3aaed1dcbbb3d6a2e7106e11fcca" dependencies = [ "hybrid-array", "num-traits", - "rand_core", + "rand_core 0.6.4", "subtle", "zeroize", ] @@ -394,7 +394,7 @@ dependencies = [ "hybrid-array", "pem-rfc7468", "pkcs8", - "rand_core", + "rand_core 0.6.4", "sec1", "serde_json", "serdect", @@ -422,11 +422,10 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "ff" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +source = "git+https://github.com/pinkforest/ff.git?branch=bump-rand-core#c734f7f21d6639bc6494dde538209d0770207c49" dependencies = [ "bitvec", - "rand_core", + "rand_core 0.9.2", "subtle", ] @@ -456,11 +455,10 @@ dependencies = [ [[package]] name = "group" version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +source = "git+https://github.com/pinkforest/group.git?branch=bump-rand-0.9#06ac6fb11ced26fbf980ee65e74fced4da66ec3e" dependencies = [ "ff", - "rand_core", + "rand_core 0.9.2", "subtle", ] @@ -570,7 +568,7 @@ dependencies = [ "num-traits", "once_cell", "proptest", - "rand_core", + "rand_core 0.6.4", "serdect", "sha2", "sha3", @@ -688,7 +686,7 @@ dependencies = [ "elliptic-curve", "hex-literal", "primeorder", - "rand_core", + "rand_core 0.6.4", "serdect", "sha2", ] @@ -704,7 +702,7 @@ dependencies = [ "hex-literal", "primeorder", "proptest", - "rand_core", + "rand_core 0.6.4", "serdect", "sha2", ] @@ -720,7 +718,7 @@ dependencies = [ "hex-literal", "primeorder", "proptest", - "rand_core", + "rand_core 0.6.4", "serdect", "sha2", ] @@ -738,7 +736,7 @@ dependencies = [ "primefield", "primeorder", "proptest", - "rand_core", + "rand_core 0.6.4", "serdect", "sha2", ] @@ -802,7 +800,7 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ - "zerocopy", + "zerocopy 0.7.35", ] [[package]] @@ -875,7 +873,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -885,7 +883,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -897,13 +895,22 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_core" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c" +dependencies = [ + "zerocopy 0.8.20", +] + [[package]] name = "rand_xorshift" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" dependencies = [ - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -1090,7 +1097,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "054d71959c7051b9042c26af337f05cc930575ed2604d7d3ced3158383e59734" dependencies = [ "digest", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -1101,7 +1108,7 @@ dependencies = [ "hex-literal", "primeorder", "proptest", - "rand_core", + "rand_core 0.6.4", "rfc6979", "serdect", "signature", @@ -1388,7 +1395,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", - "zerocopy-derive", + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dde3bb8c68a8f3f1ed4ac9221aad6b10cece3e60a8e2ea54a6a2dec806d0084c" +dependencies = [ + "zerocopy-derive 0.8.20", ] [[package]] @@ -1402,6 +1418,17 @@ dependencies = [ "syn", ] +[[package]] +name = "zerocopy-derive" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eea57037071898bf96a6da35fd626f4f27e9cee3ead2a6c703cf09d472b2e700" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "zeroize" version = "1.8.1" diff --git a/Cargo.toml b/Cargo.toml index 126bda128..f4ae75a06 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,16 @@ members = [ [profile.dev] opt-level = 2 + +[patch.crates-io] +# https://github.com/zkcrypto/ff/pull/122 +ff = { git = "https://github.com/pinkforest/ff.git", branch = "bump-rand-core" } + +# https://github.com/zkcrypto/group/pull/56 +group = { git = "https://github.com/pinkforest/group.git", branch = "bump-rand-0.9" } + +# https://github.com/RustCrypto/signatures/pull/913 +ecdsa = { git = "https://github.com/RustCrypto/signatures.git" } + +elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" } +signature = { git = "https://github.com/RustCrypto/traits.git" } From e104ff3b7bfc4aed778ddb22fe03f4cdc0ae3b9c Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:41:46 -0800 Subject: [PATCH 02/20] bign256: bump to edition 2024; msrv 1.85 --- .github/workflows/bign256.yml | 12 ++++++------ Cargo.lock | 2 +- bign256/Cargo.toml | 12 ++++++------ bign256/README.md | 14 +------------- bign256/benches/field.rs | 2 +- bign256/benches/scalar.rs | 4 ++-- bign256/src/arithmetic.rs | 2 +- bign256/src/arithmetic/scalar.rs | 4 ++-- bign256/src/ecdh.rs | 4 ++-- bign256/src/ecdsa.rs | 4 ++-- bign256/src/ecdsa/signing.rs | 8 ++++---- bign256/src/ecdsa/verifying.rs | 10 +++++----- bign256/src/lib.rs | 6 +++--- bign256/src/public_key.rs | 6 +++--- bign256/src/secret_key.rs | 12 ++++++------ bign256/tests/dsa.rs | 4 ++-- bign256/tests/ecdh.rs | 8 ++++---- bign256/tests/pkcs8.rs | 6 ++++-- bign256/tests/projective.rs | 6 +++--- 19 files changed, 58 insertions(+), 68 deletions(-) diff --git a/.github/workflows/bign256.yml b/.github/workflows/bign256.yml index 2d2ad7dc2..d1a974f93 100644 --- a/.github/workflows/bign256.yml +++ b/.github/workflows/bign256.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -46,7 +46,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -54,7 +54,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable @@ -76,19 +76,19 @@ jobs: include: # ARM32 - target: armv7-unknown-linux-gnueabihf - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: armv7-unknown-linux-gnueabihf rust: stable # ARM64 - target: aarch64-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: aarch64-unknown-linux-gnu rust: stable # PPC32 - target: powerpc-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: powerpc-unknown-linux-gnu rust: stable diff --git a/Cargo.lock b/Cargo.lock index abb0c0700..023c104f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,7 +73,7 @@ dependencies = [ "pkcs8", "primeorder", "proptest", - "rand_core 0.6.4", + "rand_core 0.9.2", "rfc6979", "sec1", "signature", diff --git a/bign256/Cargo.toml b/bign256/Cargo.toml index 2705d6841..27747e316 100644 --- a/bign256/Cargo.toml +++ b/bign256/Cargo.toml @@ -14,8 +14,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "stb", "bign-curve256v1", "bignp256"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", features = ["sec1"] } @@ -23,23 +23,23 @@ elliptic-curve = { version = "0.14.0-rc.0", features = ["sec1"] } # optional dependencies belt-hash = { version = "=0.2.0-pre.4", optional = true, default-features = false } der = { version = "0.8.0-rc.0" } -digest = { version = "=0.11.0-pre.9", optional = true } +digest = { version = "=0.11.0-pre.10", optional = true } hex-literal = { version = "0.4", optional = true } hkdf = { version = "=0.13.0-pre.4", optional = true } hmac = { version = "=0.13.0-pre.4", optional = true } -rand_core = "0.6.4" +rand_core = "0.9" rfc6979 = { version = "=0.5.0-pre.4", optional = true } pkcs8 = { version = "0.11.0-rc.1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } sec1 = { version = "0.8.0-rc.1", optional = true } -signature = { version = "=2.3.0-pre.4", optional = true } +signature = { version = "=2.3.0-pre.6", optional = true } [dev-dependencies] criterion = "0.5" hex-literal = "0.4" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } hex = { version = "0.4" } [features] diff --git a/bign256/README.md b/bign256/README.md index 1406df596..c27058751 100644 --- a/bign256/README.md +++ b/bign256/README.md @@ -33,18 +33,6 @@ USE AT YOUR OWN RISK! BIGN P-256 is a Weierstrass curve specified in [STB 34.101.45-2013]. Also known as bign-curve256v1. -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -69,7 +57,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/bign256.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/bign256.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/bign256/benches/field.rs b/bign256/benches/field.rs index 33efd8dfc..a462bea86 100644 --- a/bign256/benches/field.rs +++ b/bign256/benches/field.rs @@ -2,7 +2,7 @@ use bign256::arithmetic::FieldElement; use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; diff --git a/bign256/benches/scalar.rs b/bign256/benches/scalar.rs index 35d1f3f34..4667a1e90 100644 --- a/bign256/benches/scalar.rs +++ b/bign256/benches/scalar.rs @@ -1,8 +1,8 @@ //! bign-curve256v1 scalar arithmetic benchmarks -use bign256::{elliptic_curve::group::ff::PrimeField, ProjectivePoint, Scalar}; +use bign256::{ProjectivePoint, Scalar, elliptic_curve::group::ff::PrimeField}; use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; diff --git a/bign256/src/arithmetic.rs b/bign256/src/arithmetic.rs index 915c55162..9d6550765 100644 --- a/bign256/src/arithmetic.rs +++ b/bign256/src/arithmetic.rs @@ -13,7 +13,7 @@ pub use self::scalar::Scalar; pub use self::field::FieldElement; use crate::BignP256; pub use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -pub use primeorder::{point_arithmetic, PrimeCurveParams}; +pub use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; diff --git a/bign256/src/arithmetic/scalar.rs b/bign256/src/arithmetic/scalar.rs index 3d2d91228..44c79cc5b 100644 --- a/bign256/src/arithmetic/scalar.rs +++ b/bign256/src/arithmetic/scalar.rs @@ -15,18 +15,18 @@ mod scalar_impl; use self::scalar_impl::*; -use crate::{BignP256, FieldBytes, FieldBytesEncoding, SecretKey, ORDER_HEX, U256}; +use crate::{BignP256, FieldBytes, FieldBytesEncoding, ORDER_HEX, SecretKey, U256}; use core::{ iter::{Product, Sum}, ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Curve as _, Error, Result, ScalarPrimitive, bigint::Limb, ff::PrimeField, ops::{Invert, Reduce}, scalar::{FromUintUnchecked, IsHigh}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, CtOption}, - Curve as _, Error, Result, ScalarPrimitive, }; use primeorder::impl_bernstein_yang_invert; diff --git a/bign256/src/ecdh.rs b/bign256/src/ecdh.rs index 34b491e13..b4e47fecb 100644 --- a/bign256/src/ecdh.rs +++ b/bign256/src/ecdh.rs @@ -40,7 +40,7 @@ use elliptic_curve::point::AffineCoordinates; use elliptic_curve::zeroize::{Zeroize, ZeroizeOnDrop}; use hkdf::Hkdf; use hmac::SimpleHmac; -use rand_core::CryptoRngCore; +use rand_core::CryptoRng; /// Low-level Elliptic Curve Diffie-Hellman (ECDH) function. /// @@ -99,7 +99,7 @@ pub struct EphemeralSecret { impl EphemeralSecret { /// Generate a cryptographically random [`EphemeralSecret`]. - pub fn random(rng: &mut impl CryptoRngCore) -> Self { + pub fn random(rng: &mut R) -> Self { Self { scalar: NonZeroScalar::random(rng), } diff --git a/bign256/src/ecdsa.rs b/bign256/src/ecdsa.rs index 5197eaf0b..6dea30c97 100644 --- a/bign256/src/ecdsa.rs +++ b/bign256/src/ecdsa.rs @@ -7,14 +7,14 @@ #![cfg_attr(feature = "std", doc = "```")] #![cfg_attr(not(feature = "std"), doc = "```ignore")] //! # fn example() -> Result<(), Box> { -//! use rand_core::OsRng; // requires 'getrandom` feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'getrandom` feature //! use bign256::{ //! ecdsa::{Signature, SigningKey, signature::Signer}, //! SecretKey //! }; //! //! // Signing -//! let secret_key = SecretKey::random(&mut OsRng); // serialize with `::to_bytes()` +//! let secret_key = SecretKey::random(&mut OsRng.unwrap_mut()); // serialize with `::to_bytes()` //! let signing_key = SigningKey::new(&secret_key)?; //! let verifying_key_bytes = signing_key.verifying_key().to_bytes(); //! let message = b"test message"; diff --git a/bign256/src/ecdsa/signing.rs b/bign256/src/ecdsa/signing.rs index 66f46395f..b055f8ab7 100644 --- a/bign256/src/ecdsa/signing.rs +++ b/bign256/src/ecdsa/signing.rs @@ -14,18 +14,18 @@ #![allow(non_snake_case)] -use super::{Signature, VerifyingKey, BELT_OID}; +use super::{BELT_OID, Signature, VerifyingKey}; use crate::{BignP256, FieldBytes, NonZeroScalar, ProjectivePoint, PublicKey, Scalar, SecretKey}; use belt_hash::{BeltHash, Digest}; use core::fmt::{self, Debug}; use elliptic_curve::{ - array::{sizes::U32, typenum::Unsigned, Array}, + Curve, Field, FieldBytesEncoding, PrimeField, + array::{Array, sizes::U32, typenum::Unsigned}, ops::{MulByGenerator, Reduce}, point::AffineCoordinates, subtle::{Choice, ConstantTimeEq}, - Curve, Field, FieldBytesEncoding, PrimeField, }; -use signature::{hazmat::PrehashSigner, Error, KeypairRef, Result, Signer}; +use signature::{Error, KeypairRef, Result, Signer, hazmat::PrehashSigner}; /// BignP256 secret key used for signing messages and producing signatures. /// diff --git a/bign256/src/ecdsa/verifying.rs b/bign256/src/ecdsa/verifying.rs index 7f04a1c7a..ed94d3fad 100644 --- a/bign256/src/ecdsa/verifying.rs +++ b/bign256/src/ecdsa/verifying.rs @@ -17,21 +17,21 @@ #[cfg(feature = "alloc")] use alloc::boxed::Box; -use super::{Signature, BELT_OID}; +use super::{BELT_OID, Signature}; use crate::{ AffinePoint, BignP256, EncodedPoint, FieldBytes, Hash, ProjectivePoint, PublicKey, Scalar, }; use belt_hash::{ - digest::{Digest, FixedOutput}, BeltHash, + digest::{Digest, FixedOutput}, }; use elliptic_curve::{ - array::{sizes::U32, typenum::Unsigned, Array}, + Curve, Field, Group, + array::{Array, sizes::U32, typenum::Unsigned}, group::GroupEncoding, ops::{LinearCombination, Reduce}, - Curve, Field, Group, }; -use signature::{hazmat::PrehashVerifier, Error, Result, Verifier}; +use signature::{Error, Result, Verifier, hazmat::PrehashVerifier}; use elliptic_curve::sec1::ToEncodedPoint; diff --git a/bign256/src/lib.rs b/bign256/src/lib.rs index f57cd6d8d..356d0ae79 100644 --- a/bign256/src/lib.rs +++ b/bign256/src/lib.rs @@ -30,10 +30,10 @@ extern crate alloc; pub use elliptic_curve::{self, bigint::U256}; -use elliptic_curve::{bigint::ArrayEncoding, consts::U32, Error, FieldBytesEncoding}; +use elliptic_curve::{Error, FieldBytesEncoding, bigint::ArrayEncoding, consts::U32}; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; /// Bign256 result type pub type Result = core::result::Result; @@ -132,7 +132,7 @@ impl FieldBytesEncoding for U256 { #[cfg(feature = "arithmetic")] pub type NonZeroScalar = elliptic_curve::NonZeroScalar; -/// BIGN P-256 public key. +// /// BIGN P-256 public key. // #[cfg(feature = "arithmetic")] // pub type PublicKey = elliptic_curve::PublicKey; diff --git a/bign256/src/public_key.rs b/bign256/src/public_key.rs index 399f00db8..7557e45b3 100644 --- a/bign256/src/public_key.rs +++ b/bign256/src/public_key.rs @@ -5,17 +5,17 @@ use alloc::{boxed::Box, fmt}; use core::{fmt::Display, str::FromStr}; use elliptic_curve::{ + AffinePoint, CurveArithmetic, Error, Group, array::Array, point::NonIdentity, sec1::{FromEncodedPoint, ToEncodedPoint}, - AffinePoint, CurveArithmetic, Error, Group, }; use pkcs8::{ - spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier}, AssociatedOid, DecodePublicKey, EncodePublicKey, ObjectIdentifier, + spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier}, }; -use crate::{BignP256, EncodedPoint, NonZeroScalar, ProjectivePoint, PublicKey, ALGORITHM_OID}; +use crate::{ALGORITHM_OID, BignP256, EncodedPoint, NonZeroScalar, ProjectivePoint, PublicKey}; impl PublicKey { /// Convert an [`AffinePoint`] into a [`PublicKey`] diff --git a/bign256/src/secret_key.rs b/bign256/src/secret_key.rs index c1b4ce462..5a3ffdc05 100644 --- a/bign256/src/secret_key.rs +++ b/bign256/src/secret_key.rs @@ -1,26 +1,26 @@ //! Bign256 secret key. use core::str::FromStr; -use der::{asn1::OctetStringRef, SecretDocument}; +use der::{SecretDocument, asn1::OctetStringRef}; -use elliptic_curve::{array::typenum::Unsigned, zeroize::Zeroizing, Error}; +use elliptic_curve::{Error, array::typenum::Unsigned, zeroize::Zeroizing}; use pkcs8::{ - spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier}, AssociatedOid, DecodePrivateKey, EncodePrivateKey, ObjectIdentifier, + spki::{AlgorithmIdentifier, AssociatedAlgorithmIdentifier}, }; #[cfg(feature = "arithmetic")] use crate::FieldBytes; +use crate::{ALGORITHM_OID, PublicKey, ScalarPrimitive, SecretKey}; #[cfg(feature = "arithmetic")] -use crate::{elliptic_curve::rand_core::CryptoRngCore, BignP256, NonZeroScalar, Result}; -use crate::{PublicKey, ScalarPrimitive, SecretKey, ALGORITHM_OID}; +use crate::{BignP256, NonZeroScalar, Result, elliptic_curve::rand_core::CryptoRng}; impl SecretKey { const MIN_SIZE: usize = 24; /// Generate a random [`SecretKey`]. #[cfg(feature = "arithmetic")] - pub fn random(rng: &mut impl CryptoRngCore) -> Self { + pub fn random(rng: &mut R) -> Self { Self { inner: NonZeroScalar::random(rng).into(), } diff --git a/bign256/tests/dsa.rs b/bign256/tests/dsa.rs index 96c88604a..fd7d4cfe9 100644 --- a/bign256/tests/dsa.rs +++ b/bign256/tests/dsa.rs @@ -7,11 +7,11 @@ use hex_literal::hex; use proptest::prelude::*; use bign256::{ + NonZeroScalar, Scalar, U256, ecdsa::{ - signature::{Signer, Verifier}, Signature, SigningKey, VerifyingKey, + signature::{Signer, Verifier}, }, - NonZeroScalar, Scalar, U256, }; const PUBLIC_KEY: [u8; 64] = hex!( diff --git a/bign256/tests/ecdh.rs b/bign256/tests/ecdh.rs index 7b070d8f3..077ce4f93 100644 --- a/bign256/tests/ecdh.rs +++ b/bign256/tests/ecdh.rs @@ -1,15 +1,15 @@ #![cfg(feature = "ecdh")] #[test] fn ecdh() { - use bign256::{ecdh::EphemeralSecret, EncodedPoint, PublicKey}; - use rand_core::OsRng; // requires 'getrandom' feature + use bign256::{EncodedPoint, PublicKey, ecdh::EphemeralSecret}; + use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature // Alice - let alice_secret = EphemeralSecret::random(&mut OsRng); + let alice_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); let alice_pk_bytes = EncodedPoint::from(alice_secret.public_key()); // Bob - let bob_secret = EphemeralSecret::random(&mut OsRng); + let bob_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); let bob_pk_bytes = EncodedPoint::from(bob_secret.public_key()); // Alice decodes Bob's serialized public key and computes a shared secret from it diff --git a/bign256/tests/pkcs8.rs b/bign256/tests/pkcs8.rs index 7d434a6f6..14d17614b 100644 --- a/bign256/tests/pkcs8.rs +++ b/bign256/tests/pkcs8.rs @@ -22,10 +22,12 @@ fn decode_pkcs8_private_key_from_der() { #[test] fn decode_pkcs8_public_key_from_der() { let public_key = PublicKey::from_public_key_der(&PKCS8_PUBLIC_KEY_DER[..]).unwrap(); - let expected_point = hex!("\ + let expected_point = hex!( + "\ B2 D8 99 74 6C EB 2D 38 90 1C EF 42 46 39 EA 30 FD A2 72 0B E7 C1 BA 3F 04 BC 31 5D F2 41 2B A9 \ 38 0E A8 EC E0 F7 A7 BA 7E A9 65 2D BA C5 3B 82 7B D2 C2 FB 59 84 86 98 DE 2E A6 75 96 05 EB 96\ - "); + " + ); assert_eq!(public_key.to_bytes().as_ref(), &expected_point[..]); } diff --git a/bign256/tests/projective.rs b/bign256/tests/projective.rs index dc88b3193..d0ed4e4d1 100644 --- a/bign256/tests/projective.rs +++ b/bign256/tests/projective.rs @@ -3,14 +3,14 @@ #![cfg(all(feature = "arithmetic", feature = "test-vectors"))] use bign256::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, AffinePoint, ProjectivePoint, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; use elliptic_curve::{ - group::{ff::PrimeField, GroupEncoding}, + group::{GroupEncoding, ff::PrimeField}, sec1::{self, ToEncodedPoint}, }; -use primeorder::{impl_projective_arithmetic_tests, Double}; +use primeorder::{Double, impl_projective_arithmetic_tests}; impl_projective_arithmetic_tests!( AffinePoint, From d549079172ac76008caea5b151e832b1ea4bc64c Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:43:35 -0800 Subject: [PATCH 03/20] bp256: bump to edition 2024; msrv 1.85 --- .github/workflows/bp256.yml | 4 ++-- bp256/Cargo.toml | 4 ++-- bp256/README.md | 14 +------------- bp256/src/arithmetic/field.rs | 2 +- bp256/src/arithmetic/scalar.rs | 2 +- bp256/src/lib.rs | 2 +- bp256/src/r1.rs | 2 +- bp256/src/r1/arithmetic.rs | 2 +- bp256/src/t1.rs | 2 +- bp256/src/t1/arithmetic.rs | 2 +- 10 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.github/workflows/bp256.yml b/.github/workflows/bp256.yml index 1c6387168..e562d786f 100644 --- a/.github/workflows/bp256.yml +++ b/.github/workflows/bp256.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -49,7 +49,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/bp256/Cargo.toml b/bp256/Cargo.toml index c6f309c77..ed110b020 100644 --- a/bp256/Cargo.toml +++ b/bp256/Cargo.toml @@ -10,8 +10,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["brainpool", "crypto", "ecc"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } diff --git a/bp256/README.md b/bp256/README.md index 3d37df8ca..916be9351 100644 --- a/bp256/README.md +++ b/bp256/README.md @@ -12,18 +12,6 @@ implemented in terms of traits from the [`elliptic-curve`] crate. [Documentation][docs-link] -## Minimum Supported Rust Version - -Rust **1.81* or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -46,7 +34,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/bp256/badge.svg [docs-link]: https://docs.rs/bp256/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves [build-image]: https://github.com/RustCrypto/elliptic-curves/workflows/bp256/badge.svg?branch=master&event=push diff --git a/bp256/src/arithmetic/field.rs b/bp256/src/arithmetic/field.rs index df5759b4e..240d8908a 100644 --- a/bp256/src/arithmetic/field.rs +++ b/bp256/src/arithmetic/field.rs @@ -23,10 +23,10 @@ use core::{ }; use elliptic_curve::ops::Invert; use elliptic_curve::{ + Error, Result, bigint::{ArrayEncoding, Integer, Limb}, ff::PrimeField, subtle::{Choice, ConstantTimeEq, ConstantTimeLess, CtOption}, - Error, Result, }; /// Constant representing the modulus serialized as hex. diff --git a/bp256/src/arithmetic/scalar.rs b/bp256/src/arithmetic/scalar.rs index 450171d3b..f6ee0e898 100644 --- a/bp256/src/arithmetic/scalar.rs +++ b/bp256/src/arithmetic/scalar.rs @@ -22,6 +22,7 @@ use core::{ ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Error, Result, bigint::{ArrayEncoding, Integer, Limb}, ff::PrimeField, ops::{Invert, Reduce}, @@ -30,7 +31,6 @@ use elliptic_curve::{ Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, ConstantTimeLess, CtOption, }, - Error, Result, }; #[cfg(doc)] diff --git a/bp256/src/lib.rs b/bp256/src/lib.rs index 55c130616..92752bfa7 100644 --- a/bp256/src/lib.rs +++ b/bp256/src/lib.rs @@ -30,7 +30,7 @@ pub use crate::arithmetic::scalar::Scalar; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; -use elliptic_curve::array::{typenum::U32, Array}; +use elliptic_curve::array::{Array, typenum::U32}; #[cfg(feature = "wip-arithmetic-do-not-use")] pub(crate) use crate::arithmetic::field::FieldElement; diff --git a/bp256/src/r1.rs b/bp256/src/r1.rs index 1a98517d6..8b3ed1a01 100644 --- a/bp256/src/r1.rs +++ b/bp256/src/r1.rs @@ -14,9 +14,9 @@ pub use { use crate::ORDER; use elliptic_curve::{ + FieldBytesEncoding, bigint::{ArrayEncoding, U256}, consts::U32, - FieldBytesEncoding, }; #[cfg(feature = "pkcs8")] diff --git a/bp256/src/r1/arithmetic.rs b/bp256/src/r1/arithmetic.rs index 794c88b17..4c3cc6d2a 100644 --- a/bp256/src/r1/arithmetic.rs +++ b/bp256/src/r1/arithmetic.rs @@ -3,7 +3,7 @@ use super::BrainpoolP256r1; use crate::{FieldElement, Scalar}; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; diff --git a/bp256/src/t1.rs b/bp256/src/t1.rs index 8fc3cf08c..45add20a5 100644 --- a/bp256/src/t1.rs +++ b/bp256/src/t1.rs @@ -14,9 +14,9 @@ pub use { use crate::ORDER; use elliptic_curve::{ + FieldBytesEncoding, bigint::{ArrayEncoding, U256}, consts::U32, - FieldBytesEncoding, }; #[cfg(feature = "pkcs8")] diff --git a/bp256/src/t1/arithmetic.rs b/bp256/src/t1/arithmetic.rs index 3329a9bc9..66e69fed9 100644 --- a/bp256/src/t1/arithmetic.rs +++ b/bp256/src/t1/arithmetic.rs @@ -3,7 +3,7 @@ use super::BrainpoolP256t1; use crate::{FieldElement, Scalar}; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; From a093c9090bd728ca76f6aa9233c9a2b386fc8f09 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:44:39 -0800 Subject: [PATCH 04/20] k256: bump to edition 2024; msrv 1.85 --- .github/workflows/k256.yml | 14 +++++----- Cargo.lock | 2 +- k256/Cargo.toml | 8 +++--- k256/README.md | 14 +--------- k256/benches/ecdsa.rs | 6 ++-- k256/benches/field.rs | 2 +- k256/benches/scalar.rs | 32 ++++++++++----------- k256/src/arithmetic.rs | 4 +-- k256/src/arithmetic/affine.rs | 10 +++---- k256/src/arithmetic/field.rs | 18 ++++++------ k256/src/arithmetic/hash2curve.rs | 4 +-- k256/src/arithmetic/mul.rs | 38 ++++++++++++++----------- k256/src/arithmetic/projective.rs | 27 +++++++++--------- k256/src/arithmetic/scalar.rs | 42 ++++++++++++++-------------- k256/src/arithmetic/scalar/wide32.rs | 2 +- k256/src/arithmetic/scalar/wide64.rs | 2 +- k256/src/ecdh.rs | 6 ++-- k256/src/ecdsa.rs | 14 ++++++---- k256/src/lib.rs | 2 +- k256/src/schnorr.rs | 26 ++++++++++------- k256/src/schnorr/signing.rs | 32 ++++++++++++--------- k256/src/schnorr/verifying.rs | 8 +++--- 22 files changed, 160 insertions(+), 153 deletions(-) diff --git a/.github/workflows/k256.yml b/.github/workflows/k256.yml index 66bad01b6..74e2f4222 100644 --- a/.github/workflows/k256.yml +++ b/.github/workflows/k256.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -59,7 +59,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable steps: - uses: actions/checkout@v4 @@ -75,7 +75,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -83,7 +83,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable @@ -105,19 +105,19 @@ jobs: include: # ARM32 - target: armv7-unknown-linux-gnueabihf - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: armv7-unknown-linux-gnueabihf rust: stable # ARM64 - target: aarch64-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: aarch64-unknown-linux-gnu rust: stable # PPC32 - target: powerpc-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: powerpc-unknown-linux-gnu rust: stable diff --git a/Cargo.lock b/Cargo.lock index 023c104f8..25aca4136 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -568,7 +568,7 @@ dependencies = [ "num-traits", "once_cell", "proptest", - "rand_core 0.6.4", + "rand_core 0.9.2", "serdect", "sha2", "sha3", diff --git a/k256/Cargo.toml b/k256/Cargo.toml index d0ebc81f8..ba362d3d9 100644 --- a/k256/Cargo.toml +++ b/k256/Cargo.toml @@ -15,8 +15,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "cryptography::cryptocurrencies", "no-std"] keywords = ["bitcoin", "crypto", "ecc", "ethereum", "secp256k1"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] cfg-if = "1.0" @@ -28,7 +28,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, de hex-literal = { version = "0.4", optional = true } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } -signature = { version = "=2.3.0-pre.4", optional = true } +signature = { version = "=2.3.0-pre.6", optional = true } [dev-dependencies] blobby = "0.3" @@ -39,7 +39,7 @@ hex-literal = "0.4" num-bigint = "0.4" num-traits = "0.2" proptest = "1.5" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } sha3 = { version = "=0.11.0-pre.4", default-features = false } [features] diff --git a/k256/README.md b/k256/README.md index 1b5c4396f..985a3d197 100644 --- a/k256/README.md +++ b/k256/README.md @@ -69,18 +69,6 @@ particularly in conjunction with the Owing to its wide deployment in these applications, secp256k1 is one of the most popular and commonly used elliptic curves. -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -105,7 +93,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/workflows/k256/badge.svg?branch=master&event=push [build-link]: https://github.com/RustCrypto/elliptic-curves/actions?query=workflow%3Ak256 [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/k256/benches/ecdsa.rs b/k256/benches/ecdsa.rs index 8a0982674..8e39c047d 100644 --- a/k256/benches/ecdsa.rs +++ b/k256/benches/ecdsa.rs @@ -1,13 +1,13 @@ //! secp256k1 scalar arithmetic benchmarks -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, black_box, criterion_group, criterion_main}; use k256::{ + FieldBytes, NonZeroScalar, Scalar, ecdsa::{ - signature::hazmat::{PrehashSigner, PrehashVerifier}, Signature, SigningKey, + signature::hazmat::{PrehashSigner, PrehashVerifier}, }, elliptic_curve::group::ff::PrimeField, - FieldBytes, NonZeroScalar, Scalar, }; fn test_scalar_d() -> NonZeroScalar { diff --git a/k256/benches/field.rs b/k256/benches/field.rs index 2c0bdd02a..ae64c1751 100644 --- a/k256/benches/field.rs +++ b/k256/benches/field.rs @@ -1,7 +1,7 @@ //! secp256k1 field element benchmarks use criterion::{ - black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main, measurement::Measurement, }; use k256::FieldElement; diff --git a/k256/benches/scalar.rs b/k256/benches/scalar.rs index b700f39e3..2a15f5b6b 100644 --- a/k256/benches/scalar.rs +++ b/k256/benches/scalar.rs @@ -1,12 +1,12 @@ //! secp256k1 scalar arithmetic benchmarks use criterion::{ - black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; use k256::{ - elliptic_curve::{group::ff::PrimeField, ops::LinearCombination, ops::MulByGenerator}, ProjectivePoint, Scalar, + elliptic_curve::{group::ff::PrimeField, ops::LinearCombination, ops::MulByGenerator}, }; fn test_scalar_x() -> Scalar { @@ -33,21 +33,21 @@ fn test_scalar_y() -> Scalar { .unwrap() } -fn bench_point_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_point_mul(group: &mut BenchmarkGroup<'_, M>) { let p = ProjectivePoint::GENERATOR; let m = hex!("AA5E28D6A97A2479A65527F7290311A3624D4CC0FA1578598EE3C2613BF99522"); let s = Scalar::from_repr(m.into()).unwrap(); group.bench_function("point-scalar mul", |b| { - b.iter(|| &black_box(p) * &black_box(s)) + b.iter(|| black_box(p) * black_box(s)) }); } -fn bench_point_lincomb<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_point_lincomb(group: &mut BenchmarkGroup<'_, M>) { let p = ProjectivePoint::GENERATOR; let m = hex!("AA5E28D6A97A2479A65527F7290311A3624D4CC0FA1578598EE3C2613BF99522"); let s = Scalar::from_repr(m.into()).unwrap(); group.bench_function("lincomb via mul+add", |b| { - b.iter(|| &black_box(p) * &black_box(s) + &black_box(p) * &black_box(s)) + b.iter(|| black_box(p) * black_box(s) + black_box(p) * black_box(s)) }); group.bench_function("lincomb()", |b| { b.iter(|| { @@ -56,12 +56,12 @@ fn bench_point_lincomb<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { }); } -fn bench_point_mul_by_generator<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_point_mul_by_generator(group: &mut BenchmarkGroup<'_, M>) { let p = ProjectivePoint::GENERATOR; let x = test_scalar_x(); group.bench_function("mul_by_generator naive", |b| { - b.iter(|| &black_box(p) * &black_box(x)) + b.iter(|| black_box(p) * black_box(x)) }); group.bench_function("mul_by_generator precomputed", |b| { @@ -77,30 +77,30 @@ fn bench_high_level(c: &mut Criterion) { group.finish(); } -fn bench_scalar_sub<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_sub(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("sub", |b| b.iter(|| &black_box(x) - &black_box(y))); + group.bench_function("sub", |b| b.iter(|| black_box(x) - black_box(y))); } -fn bench_scalar_add<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_add(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("add", |b| b.iter(|| &black_box(x) + &black_box(y))); + group.bench_function("add", |b| b.iter(|| black_box(x) + black_box(y))); } -fn bench_scalar_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_mul(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("mul", |b| b.iter(|| &black_box(x) * &black_box(y))); + group.bench_function("mul", |b| b.iter(|| black_box(x) * black_box(y))); } -fn bench_scalar_negate<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_negate(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("negate", |b| b.iter(|| -black_box(x))); } -fn bench_scalar_invert<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_invert(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("invert", |b| b.iter(|| black_box(x).invert())); } diff --git a/k256/src/arithmetic.rs b/k256/src/arithmetic.rs index 1b83dc065..6b454dfb3 100644 --- a/k256/src/arithmetic.rs +++ b/k256/src/arithmetic.rs @@ -49,8 +49,8 @@ mod tests { #[test] fn generate_secret_key() { use crate::SecretKey; - use elliptic_curve::rand_core::OsRng; - let key = SecretKey::random(&mut OsRng); + use elliptic_curve::rand_core::{OsRng, TryRngCore}; + let key = SecretKey::random(&mut OsRng.unwrap_mut()); // Sanity check assert!(!key.to_bytes().iter().all(|b| *b == 0)) diff --git a/k256/src/arithmetic/affine.rs b/k256/src/arithmetic/affine.rs index 2fb1e8880..d9446b2f4 100644 --- a/k256/src/arithmetic/affine.rs +++ b/k256/src/arithmetic/affine.rs @@ -2,20 +2,20 @@ #![allow(clippy::op_ref)] -use super::{FieldElement, ProjectivePoint, CURVE_EQUATION_B}; +use super::{CURVE_EQUATION_B, FieldElement, ProjectivePoint}; use crate::{CompressedPoint, EncodedPoint, FieldBytes, PublicKey, Scalar, Secp256k1}; use core::ops::{Mul, Neg}; use elliptic_curve::{ - group::{prime::PrimeCurveAffine, GroupEncoding}, + Error, Result, + group::{GroupEncoding, prime::PrimeCurveAffine}, point::{AffineCoordinates, DecompactPoint, DecompressPoint}, sec1::{self, FromEncodedPoint, ToEncodedPoint}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}, zeroize::DefaultIsZeroes, - Error, Result, }; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; /// secp256k1 curve point expressed in affine coordinates. /// @@ -366,7 +366,7 @@ mod tests { use super::AffinePoint; use crate::EncodedPoint; use elliptic_curve::{ - group::{prime::PrimeCurveAffine, GroupEncoding}, + group::{GroupEncoding, prime::PrimeCurveAffine}, sec1::{FromEncodedPoint, ToEncodedPoint}, }; use hex_literal::hex; diff --git a/k256/src/arithmetic/field.rs b/k256/src/arithmetic/field.rs index 9cbe924f8..ecb9c3864 100644 --- a/k256/src/arithmetic/field.rs +++ b/k256/src/arithmetic/field.rs @@ -515,13 +515,13 @@ mod tests { use elliptic_curve::ops::BatchInvert; use num_bigint::{BigUint, ToBigUint}; use proptest::prelude::*; - use rand_core::OsRng; + use rand_core::{OsRng, TryRngCore}; use super::FieldElement; use crate::{ + FieldBytes, arithmetic::dev::{biguint_to_bytes, bytes_to_biguint}, test_vectors::field::DBL_TEST_VECTORS, - FieldBytes, }; #[cfg(feature = "alloc")] @@ -561,7 +561,7 @@ mod tests { // ROOT_OF_UNITY^{2^s} mod m == 1 assert_eq!( FieldElement::ROOT_OF_UNITY - .pow_vartime(&[1u64 << FieldElement::S, 0, 0, 0]) + .pow_vartime([1u64 << FieldElement::S, 0, 0, 0]) .normalize(), FieldElement::ONE ); @@ -569,7 +569,7 @@ mod tests { // MULTIPLICATIVE_GENERATOR^{t} mod m == ROOT_OF_UNITY assert_eq!( FieldElement::MULTIPLICATIVE_GENERATOR - .pow_vartime(&T) + .pow_vartime(T) .normalize(), FieldElement::ROOT_OF_UNITY ) @@ -587,7 +587,7 @@ mod tests { fn delta_constant() { // DELTA^{t} mod m == 1 assert_eq!( - FieldElement::DELTA.pow_vartime(&T).normalize(), + FieldElement::DELTA.pow_vartime(T).normalize(), FieldElement::ONE ); } @@ -690,8 +690,8 @@ mod tests { #[test] fn batch_invert_array() { - let k: FieldElement = FieldElement::random(&mut OsRng); - let l: FieldElement = FieldElement::random(&mut OsRng); + let k: FieldElement = FieldElement::random(&mut OsRng.unwrap_mut()); + let l: FieldElement = FieldElement::random(&mut OsRng.unwrap_mut()); let expected = [k.invert().unwrap(), l.invert().unwrap()]; assert_eq!( @@ -703,8 +703,8 @@ mod tests { #[test] #[cfg(feature = "alloc")] fn batch_invert() { - let k: FieldElement = FieldElement::random(&mut OsRng); - let l: FieldElement = FieldElement::random(&mut OsRng); + let k: FieldElement = FieldElement::random(&mut OsRng.unwrap_mut()); + let l: FieldElement = FieldElement::random(&mut OsRng.unwrap_mut()); let expected = vec![k.invert().unwrap(), l.invert().unwrap()]; let field_elements = vec![k, l]; diff --git a/k256/src/arithmetic/hash2curve.rs b/k256/src/arithmetic/hash2curve.rs index 598748b82..2552515b3 100644 --- a/k256/src/arithmetic/hash2curve.rs +++ b/k256/src/arithmetic/hash2curve.rs @@ -1,3 +1,4 @@ +use elliptic_curve::Field; use elliptic_curve::array::Array; use elliptic_curve::bigint::{ArrayEncoding, U256}; use elliptic_curve::consts::{U4, U48}; @@ -6,7 +7,6 @@ use elliptic_curve::hash2curve::{ FromOkm, GroupDigest, Isogeny, IsogenyCoefficients, MapToCurve, OsswuMap, OsswuMapParams, Sgn0, }; use elliptic_curve::subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}; -use elliptic_curve::Field; use crate::{AffinePoint, ProjectivePoint, Scalar, Secp256k1}; @@ -276,12 +276,12 @@ impl CofactorGroup for ProjectivePoint { mod tests { use crate::{FieldElement, Scalar, Secp256k1, U256}; use elliptic_curve::{ + Curve, array::Array, bigint::{ArrayEncoding, NonZero, U384}, consts::U48, group::cofactor::CofactorGroup, hash2curve::{FromOkm, GroupDigest, MapToCurve}, - Curve, }; use hex_literal::hex; use proptest::{num::u64::ANY, prelude::ProptestConfig, proptest}; diff --git a/k256/src/arithmetic/mul.rs b/k256/src/arithmetic/mul.rs index 162229f74..fec77d3e0 100644 --- a/k256/src/arithmetic/mul.rs +++ b/k256/src/arithmetic/mul.rs @@ -41,8 +41,8 @@ compile_error!("`precomputed-tables` feature requires either `critical-section` or `std`"); use crate::arithmetic::{ - scalar::{Scalar, WideScalar}, ProjectivePoint, + scalar::{Scalar, WideScalar}, }; use core::ops::{Mul, MulAssign}; @@ -367,15 +367,15 @@ static GEN_LOOKUP_TABLE: Lazy<[LookupTable; 33]> = Lazy::new(precompute_gen_look #[cfg(feature = "precomputed-tables")] fn precompute_gen_lookup_table() -> [LookupTable; 33] { - let mut gen = ProjectivePoint::GENERATOR; + let mut generator = ProjectivePoint::GENERATOR; let mut res = [LookupTable::default(); 33]; for i in 0..33 { - res[i] = LookupTable::from(&gen); + res[i] = LookupTable::from(&generator); // We are storing tables spaced by two radix steps, // to decrease the size of the precomputed data. for _ in 0..8 { - gen = gen.double(); + generator = generator.double(); } } res @@ -453,24 +453,28 @@ impl MulAssign<&Scalar> for ProjectivePoint { mod tests { use super::*; use crate::arithmetic::{ProjectivePoint, Scalar}; - use elliptic_curve::{ops::MulByGenerator, rand_core::OsRng, Field, Group}; + use elliptic_curve::{ + Field, Group, + ops::MulByGenerator, + rand_core::{OsRng, TryRngCore}, + }; #[test] fn test_lincomb() { - let x = ProjectivePoint::random(&mut OsRng); - let y = ProjectivePoint::random(&mut OsRng); - let k = Scalar::random(&mut OsRng); - let l = Scalar::random(&mut OsRng); + let x = ProjectivePoint::random(&mut OsRng.unwrap_mut()); + let y = ProjectivePoint::random(&mut OsRng.unwrap_mut()); + let k = Scalar::random(&mut OsRng.unwrap_mut()); + let l = Scalar::random(&mut OsRng.unwrap_mut()); - let reference = &x * &k + &y * &l; + let reference = x * k + y * l; let test = ProjectivePoint::lincomb(&[(x, k), (y, l)]); assert_eq!(reference, test); } #[test] fn test_mul_by_generator() { - let k = Scalar::random(&mut OsRng); - let reference = &ProjectivePoint::GENERATOR * &k; + let k = Scalar::random(&mut OsRng.unwrap_mut()); + let reference = ProjectivePoint::GENERATOR * k; let test = ProjectivePoint::mul_by_generator(&k); assert_eq!(reference, test); } @@ -478,12 +482,12 @@ mod tests { #[cfg(feature = "alloc")] #[test] fn test_lincomb_slice() { - let x = ProjectivePoint::random(&mut OsRng); - let y = ProjectivePoint::random(&mut OsRng); - let k = Scalar::random(&mut OsRng); - let l = Scalar::random(&mut OsRng); + let x = ProjectivePoint::random(&mut OsRng.unwrap_mut()); + let y = ProjectivePoint::random(&mut OsRng.unwrap_mut()); + let k = Scalar::random(&mut OsRng.unwrap_mut()); + let l = Scalar::random(&mut OsRng.unwrap_mut()); - let reference = &x * &k + &y * &l; + let reference = x * k + y * l; let points_and_scalars = vec![(x, k), (y, l)]; let test = ProjectivePoint::lincomb(points_and_scalars.as_slice()); diff --git a/k256/src/arithmetic/projective.rs b/k256/src/arithmetic/projective.rs index cf05fa16d..84eae3626 100644 --- a/k256/src/arithmetic/projective.rs +++ b/k256/src/arithmetic/projective.rs @@ -2,7 +2,7 @@ #![allow(clippy::op_ref)] -use super::{AffinePoint, FieldElement, Scalar, CURVE_EQUATION_B_SINGLE}; +use super::{AffinePoint, CURVE_EQUATION_B_SINGLE, FieldElement, Scalar}; use crate::{CompressedPoint, EncodedPoint, PublicKey, Secp256k1}; use core::{ iter::Sum, @@ -10,16 +10,16 @@ use core::{ }; use elliptic_curve::ops::BatchInvert; use elliptic_curve::{ + BatchNormalize, Error, Result, group::{ + Curve, Group, GroupEncoding, ff::Field, prime::{PrimeCurve, PrimeCurveAffine, PrimeGroup}, - Curve, Group, GroupEncoding, }, rand_core::RngCore, sec1::{FromEncodedPoint, ToEncodedPoint}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}, zeroize::DefaultIsZeroes, - BatchNormalize, Error, Result, }; #[cfg(feature = "alloc")] @@ -635,7 +635,7 @@ impl Neg for ProjectivePoint { } } -impl<'a> Neg for &'a ProjectivePoint { +impl Neg for &ProjectivePoint { type Output = ProjectivePoint; fn neg(self) -> ProjectivePoint { @@ -675,14 +675,14 @@ impl TryFrom<&ProjectivePoint> for PublicKey { mod tests { use super::{AffinePoint, ProjectivePoint}; use crate::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; + use elliptic_curve::Field; use elliptic_curve::group::{ff::PrimeField, prime::PrimeCurveAffine}; use elliptic_curve::ops::MulByGenerator; - use elliptic_curve::Field; - use elliptic_curve::{group, BatchNormalize}; - use rand_core::OsRng; + use elliptic_curve::{BatchNormalize, group}; + use rand_core::{OsRng, TryRngCore}; #[cfg(feature = "alloc")] use alloc::vec::Vec; @@ -706,8 +706,8 @@ mod tests { #[test] fn batch_normalize_array() { - let k: Scalar = Scalar::random(&mut OsRng); - let l: Scalar = Scalar::random(&mut OsRng); + let k: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); + let l: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); let g = ProjectivePoint::mul_by_generator(&k); let h = ProjectivePoint::mul_by_generator(&l); @@ -722,7 +722,8 @@ mod tests { assert_eq!(res, expected); let mut res = [AffinePoint::IDENTITY; 3]; - let non_normalized_identity = ProjectivePoint::IDENTITY * Scalar::random(&mut OsRng); + let non_normalized_identity = + ProjectivePoint::IDENTITY * Scalar::random(&mut OsRng.unwrap_mut()); let expected = [g.to_affine(), AffinePoint::IDENTITY, AffinePoint::IDENTITY]; assert_eq!( >::batch_normalize(&[ @@ -743,8 +744,8 @@ mod tests { #[test] #[cfg(feature = "alloc")] fn batch_normalize_slice() { - let k: Scalar = Scalar::random(&mut OsRng); - let l: Scalar = Scalar::random(&mut OsRng); + let k: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); + let l: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); let g = ProjectivePoint::mul_by_generator(&k); let h = ProjectivePoint::mul_by_generator(&l); diff --git a/k256/src/arithmetic/scalar.rs b/k256/src/arithmetic/scalar.rs index dad9288e5..43fc7ed54 100644 --- a/k256/src/arithmetic/scalar.rs +++ b/k256/src/arithmetic/scalar.rs @@ -6,30 +6,30 @@ mod wide; pub(crate) use self::wide::WideScalar; -use crate::{FieldBytes, Secp256k1, WideBytes, ORDER, ORDER_HEX}; +use crate::{FieldBytes, ORDER, ORDER_HEX, Secp256k1, WideBytes}; use core::{ iter::{Product, Sum}, ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, Sub, SubAssign}, }; use elliptic_curve::{ - bigint::{prelude::*, Limb, Word, U256, U512}, + Curve, ScalarPrimitive, + bigint::{Limb, U256, U512, Word, prelude::*}, ff::{self, Field, PrimeField}, ops::{Invert, Reduce, ReduceNonZero}, - rand_core::{CryptoRngCore, RngCore}, + rand_core::{CryptoRng, RngCore}, scalar::{FromUintUnchecked, IsHigh}, subtle::{ Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, ConstantTimeLess, CtOption, }, zeroize::DefaultIsZeroes, - Curve, ScalarPrimitive, }; #[cfg(feature = "bits")] use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(test)] use num_bigint::{BigUint, ToBigUint}; @@ -182,7 +182,7 @@ impl Scalar { } /// Returns a (nearly) uniformly-random scalar, generated in constant time. - pub fn generate_biased(rng: &mut impl CryptoRngCore) -> Self { + pub fn generate_biased(rng: &mut R) -> Self { // We reduce a random 512-bit value into a 256-bit field, which results in a // negligible bias from the uniform distribution, but the process is constant-time. let mut buf = [0u8; 64]; @@ -192,7 +192,7 @@ impl Scalar { /// Returns a uniformly-random scalar, generated using rejection sampling. // TODO(tarcieri): make this a `CryptoRng` when `ff` allows it - pub fn generate_vartime(rng: &mut impl RngCore) -> Self { + pub fn generate_vartime(rng: &mut R) -> Self { let mut bytes = FieldBytes::default(); // TODO: pre-generate several scalars to bring the probability of non-constant-timeness down? @@ -790,8 +790,8 @@ impl<'de> Deserialize<'de> for Scalar { mod tests { use super::Scalar; use crate::{ + FieldBytes, NonZeroScalar, ORDER, WideBytes, arithmetic::dev::{biguint_to_bytes, bytes_to_biguint}, - FieldBytes, NonZeroScalar, WideBytes, ORDER, }; use elliptic_curve::{ array::Array, @@ -803,7 +803,7 @@ mod tests { use num_bigint::{BigUint, ToBigUint}; use num_traits::Zero; use proptest::prelude::*; - use rand_core::OsRng; + use rand_core::{OsRng, TryRngCore}; #[cfg(feature = "alloc")] use alloc::vec::Vec; @@ -846,13 +846,13 @@ mod tests { fn root_of_unity_constant() { // ROOT_OF_UNITY^{2^s} mod m == 1 assert_eq!( - Scalar::ROOT_OF_UNITY.pow_vartime(&[1u64 << Scalar::S, 0, 0, 0]), + Scalar::ROOT_OF_UNITY.pow_vartime([1u64 << Scalar::S, 0, 0, 0]), Scalar::ONE ); // MULTIPLICATIVE_GENERATOR^{t} mod m == ROOT_OF_UNITY assert_eq!( - Scalar::MULTIPLICATIVE_GENERATOR.pow_vartime(&T), + Scalar::MULTIPLICATIVE_GENERATOR.pow_vartime(T), Scalar::ROOT_OF_UNITY ) } @@ -868,7 +868,7 @@ mod tests { #[test] fn delta_constant() { // DELTA^{t} mod m == 1 - assert_eq!(Scalar::DELTA.pow_vartime(&T), Scalar::ONE); + assert_eq!(Scalar::DELTA.pow_vartime(T), Scalar::ONE); } #[test] @@ -957,8 +957,8 @@ mod tests { #[test] fn batch_invert_array() { - let k: Scalar = Scalar::random(&mut OsRng); - let l: Scalar = Scalar::random(&mut OsRng); + let k: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); + let l: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); let expected = [k.invert().unwrap(), l.invert().unwrap()]; assert_eq!( @@ -970,8 +970,8 @@ mod tests { #[test] #[cfg(feature = "alloc")] fn batch_invert() { - let k: Scalar = Scalar::random(&mut OsRng); - let l: Scalar = Scalar::random(&mut OsRng); + let k: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); + let l: Scalar = Scalar::random(&mut OsRng.unwrap_mut()); let expected = vec![k.invert().unwrap(), l.invert().unwrap()]; let scalars = vec![k, l]; @@ -1009,7 +1009,7 @@ mod tests { let a = Scalar::from(&t - &one); let b = Scalar::from(&t); - let res = &a + &b; + let res = a + b; let m = Scalar::modulus_as_biguint(); let res_ref = Scalar::from((&t + &t - &one) % &m); @@ -1017,18 +1017,18 @@ mod tests { assert_eq!(res, res_ref); } + #[allow(clippy::op_ref)] #[test] fn generate_biased() { - use elliptic_curve::rand_core::OsRng; - let a = Scalar::generate_biased(&mut OsRng); + let a = Scalar::generate_biased(&mut OsRng.unwrap_mut()); // just to make sure `a` is not optimized out by the compiler assert_eq!((a - &a).is_zero().unwrap_u8(), 1); } + #[allow(clippy::op_ref)] #[test] fn generate_vartime() { - use elliptic_curve::rand_core::OsRng; - let a = Scalar::generate_vartime(&mut OsRng); + let a = Scalar::generate_vartime(&mut OsRng.unwrap_mut()); // just to make sure `a` is not optimized out by the compiler assert_eq!((a - &a).is_zero().unwrap_u8(), 1); } diff --git a/k256/src/arithmetic/scalar/wide32.rs b/k256/src/arithmetic/scalar/wide32.rs index 1f5b31f41..7f6a64722 100644 --- a/k256/src/arithmetic/scalar/wide32.rs +++ b/k256/src/arithmetic/scalar/wide32.rs @@ -1,6 +1,6 @@ //! Wide scalar (32-bit limbs) -use super::{Scalar, MODULUS}; +use super::{MODULUS, Scalar}; use crate::ORDER; use elliptic_curve::{ bigint::{Limb, U256, U512}, diff --git a/k256/src/arithmetic/scalar/wide64.rs b/k256/src/arithmetic/scalar/wide64.rs index 64d1212ef..ac7b79561 100644 --- a/k256/src/arithmetic/scalar/wide64.rs +++ b/k256/src/arithmetic/scalar/wide64.rs @@ -1,6 +1,6 @@ //! Wide scalar (64-bit limbs) -use super::{Scalar, MODULUS}; +use super::{MODULUS, Scalar}; use crate::ORDER; use elliptic_curve::{ bigint::{Limb, U256, U512}, diff --git a/k256/src/ecdh.rs b/k256/src/ecdh.rs index ffaf138df..406830057 100644 --- a/k256/src/ecdh.rs +++ b/k256/src/ecdh.rs @@ -10,14 +10,14 @@ //! //! ``` //! use k256::{EncodedPoint, PublicKey, ecdh::EphemeralSecret}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Alice -//! let alice_secret = EphemeralSecret::random(&mut OsRng); +//! let alice_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let alice_pk_bytes = EncodedPoint::from(alice_secret.public_key()); //! //! // Bob -//! let bob_secret = EphemeralSecret::random(&mut OsRng); +//! let bob_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let bob_pk_bytes = EncodedPoint::from(bob_secret.public_key()); //! //! // Alice decodes Bob's serialized public key and computes a shared secret from it diff --git a/k256/src/ecdsa.rs b/k256/src/ecdsa.rs index 246c5505c..f932e3187 100644 --- a/k256/src/ecdsa.rs +++ b/k256/src/ecdsa.rs @@ -28,10 +28,10 @@ //! ecdsa::{SigningKey, Signature, signature::Signer}, //! SecretKey, //! }; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Signing -//! let signing_key = SigningKey::random(&mut OsRng); // Serialize with `::to_bytes()` +//! let signing_key = SigningKey::random(&mut OsRng.unwrap_mut()); // Serialize with `::to_bytes()` //! let message = b"ECDSA proves knowledge of a secret number in the context of a single message"; //! //! // Note: The signature type must be annotated or otherwise inferable as @@ -93,8 +93,8 @@ //! ``` pub use ecdsa_core::{ - signature::{self, Error}, EcdsaCurve, RecoveryId, + signature::{self, Error}, }; #[cfg(any(feature = "ecdsa", feature = "sha256"))] @@ -177,8 +177,8 @@ mod tests { #[cfg(feature = "sha256")] mod recovery { use crate::{ - ecdsa::{signature::DigestVerifier, RecoveryId, Signature, SigningKey, VerifyingKey}, EncodedPoint, + ecdsa::{RecoveryId, Signature, SigningKey, VerifyingKey, signature::DigestVerifier}, }; use hex_literal::hex; use sha2::{Digest, Sha256}; @@ -247,7 +247,9 @@ mod tests { let (sig, recid) = signing_key.sign_digest_recoverable(digest.clone()).unwrap(); assert_eq!( sig.to_bytes().as_slice(), - &hex!("c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68") + &hex!( + "c9cf86333bcb065d140032ecaab5d9281bde80f21b9687b3e94161de42d51895727a108a0b8d101465414033c3f705a9c7b826e596766046ee1183dbc8aeaa68" + ) ); assert_eq!(recid, RecoveryId::from_byte(0).unwrap()); @@ -261,7 +263,7 @@ mod tests { mod wycheproof { use crate::{EncodedPoint, Secp256k1}; - use ecdsa_core::{signature::Verifier, Signature}; + use ecdsa_core::{Signature, signature::Verifier}; use elliptic_curve::array::typenum::Unsigned; #[test] diff --git a/k256/src/lib.rs b/k256/src/lib.rs index 435045630..7db4610a1 100644 --- a/k256/src/lib.rs +++ b/k256/src/lib.rs @@ -62,10 +62,10 @@ pub use elliptic_curve::pkcs8; pub use sha2; use elliptic_curve::{ + FieldBytesEncoding, array::Array, bigint::ArrayEncoding, consts::{U32, U33, U64}, - FieldBytesEncoding, }; /// Order of the secp256k1 elliptic curve in hexadecimal. diff --git a/k256/src/schnorr.rs b/k256/src/schnorr.rs index f509b4ed7..b7ae581b8 100644 --- a/k256/src/schnorr.rs +++ b/k256/src/schnorr.rs @@ -35,12 +35,12 @@ //! signature::{Signer, Verifier}, //! SigningKey, VerifyingKey //! }; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // //! // Signing //! // -//! let signing_key = SigningKey::random(&mut OsRng); // serialize with `.to_bytes()` +//! let signing_key = SigningKey::random(&mut OsRng.unwrap_mut()); // serialize with `.to_bytes()` //! let verifying_key_bytes = signing_key.verifying_key().to_bytes(); // 32-bytes //! //! let message = b"Schnorr signatures prove knowledge of a secret in the random oracle model"; @@ -66,9 +66,9 @@ mod signing; mod verifying; pub use self::{signing::SigningKey, verifying::VerifyingKey}; -pub use signature::{self, rand_core::CryptoRngCore, Error}; +pub use signature::{self, Error, rand_core::CryptoRng}; -use crate::{arithmetic::FieldElement, FieldBytes, NonZeroScalar}; +use crate::{FieldBytes, NonZeroScalar, arithmetic::FieldElement}; use core::fmt; use elliptic_curve::subtle::ConstantTimeEq; use sha2::{Digest, Sha256}; @@ -341,24 +341,30 @@ mod tests { index: 15, msg: vec![], signature: hex!( - "71535DB165ECD9FBBC046E5FFAEA61186BB6AD436732FCCC25291A55895464CF + "71535DB165ECD9FBBC046E5FFAEA61186BB6AD436732FCCC25291A55895464CF 6069CE26BF03466228F19A3A62DB8A649F2D560FAC652827D1AF0574E427AB63" - ) + ), }, Bip340ExtTest { index: 16, msg: hex!("11").to_vec(), - signature: hex!("08A20A0AFEF64124649232E0693C583AB1B9934AE63B4C3511F3AE1134C6A303EA3173BFEA6683BD101FA5AA5DBC1996FE7CACFC5A577D33EC14564CEC2BACBF") + signature: hex!( + "08A20A0AFEF64124649232E0693C583AB1B9934AE63B4C3511F3AE1134C6A303EA3173BFEA6683BD101FA5AA5DBC1996FE7CACFC5A577D33EC14564CEC2BACBF" + ), }, Bip340ExtTest { index: 17, msg: hex!("0102030405060708090A0B0C0D0E0F1011").to_vec(), - signature: hex!("5130F39A4059B43BC7CAC09A19ECE52B5D8699D1A71E3C52DA9AFDB6B50AC370C4A482B77BF960F8681540E25B6771ECE1E5A37FD80E5A51897C5566A97EA5A5"), + signature: hex!( + "5130F39A4059B43BC7CAC09A19ECE52B5D8699D1A71E3C52DA9AFDB6B50AC370C4A482B77BF960F8681540E25B6771ECE1E5A37FD80E5A51897C5566A97EA5A5" + ), }, Bip340ExtTest { index: 18, msg: vec![0x99; 100], - signature: hex!("403B12B0D8555A344175EA7EC746566303321E5DBFA8BE6F091635163ECA79A8585ED3E3170807E7C03B720FC54C7B23897FCBA0E9D0B4A06894CFD249F22367"), + signature: hex!( + "403B12B0D8555A344175EA7EC746566303321E5DBFA8BE6F091635163ECA79A8585ED3E3170807E7C03B720FC54C7B23897FCBA0E9D0B4A06894CFD249F22367" + ), }, ]; @@ -545,6 +551,6 @@ mod tests { // Pass an invalid signature (shorter than Self::BYTES / 2) and make sure // it does not panic, but return Err let invalid_signature = [111; 24]; - assert_eq!(Signature::try_from(&invalid_signature[..]).is_err(), true); + assert!(Signature::try_from(&invalid_signature[..]).is_err()); } } diff --git a/k256/src/schnorr/signing.rs b/k256/src/schnorr/signing.rs index c280d70c3..647faf473 100644 --- a/k256/src/schnorr/signing.rs +++ b/k256/src/schnorr/signing.rs @@ -1,25 +1,25 @@ //! Taproot Schnorr signing key. -use super::{tagged_hash, Signature, VerifyingKey, AUX_TAG, CHALLENGE_TAG, NONCE_TAG}; +use super::{AUX_TAG, CHALLENGE_TAG, NONCE_TAG, Signature, VerifyingKey, tagged_hash}; use crate::{ AffinePoint, FieldBytes, NonZeroScalar, ProjectivePoint, PublicKey, Scalar, SecretKey, }; use elliptic_curve::{ bigint::U256, ops::Reduce, - rand_core::CryptoRngCore, + rand_core::{CryptoRng, TryCryptoRng}, subtle::ConditionallySelectable, zeroize::{Zeroize, ZeroizeOnDrop}, }; use sha2::{Digest, Sha256}; use signature::{ - digest::{consts::U32, FixedOutput}, - hazmat::{PrehashSigner, RandomizedPrehashSigner}, DigestSigner, Error, KeypairRef, RandomizedDigestSigner, RandomizedSigner, Result, Signer, + digest::{FixedOutput, consts::U32}, + hazmat::{PrehashSigner, RandomizedPrehashSigner}, }; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(debug_assertions)] use signature::hazmat::PrehashVerifier; @@ -36,7 +36,7 @@ pub struct SigningKey { impl SigningKey { /// Generate a cryptographically random [`SigningKey`]. - pub fn random(rng: &mut impl CryptoRngCore) -> Self { + pub fn random(rng: &mut R) -> Self { NonZeroScalar::random(rng).into() } @@ -176,31 +176,37 @@ impl RandomizedDigestSigner for SigningKey where D: Digest + FixedOutput, { - fn try_sign_digest_with_rng( + fn try_sign_digest_with_rng( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, digest: D, ) -> Result { let mut aux_rand = [0u8; 32]; - rng.fill_bytes(&mut aux_rand); + rng.try_fill_bytes(&mut aux_rand) + .map_err(|_| Error::new())?; self.sign_raw(&digest.finalize_fixed(), &aux_rand) } } impl RandomizedSigner for SigningKey { - fn try_sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> Result { + fn try_sign_with_rng( + &self, + rng: &mut R, + msg: &[u8], + ) -> Result { self.try_sign_digest_with_rng(rng, Sha256::new_with_prefix(msg)) } } impl RandomizedPrehashSigner for SigningKey { - fn sign_prehash_with_rng( + fn sign_prehash_with_rng( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, prehash: &[u8], ) -> Result { let mut aux_rand = [0u8; 32]; - rng.fill_bytes(&mut aux_rand); + rng.try_fill_bytes(&mut aux_rand) + .map_err(|_| Error::new())?; self.sign_raw(prehash, &aux_rand) } diff --git a/k256/src/schnorr/verifying.rs b/k256/src/schnorr/verifying.rs index ccebe6f3f..ea9a63af3 100644 --- a/k256/src/schnorr/verifying.rs +++ b/k256/src/schnorr/verifying.rs @@ -1,6 +1,6 @@ //! Taproot Schnorr verifying key. -use super::{tagged_hash, Signature, CHALLENGE_TAG}; +use super::{CHALLENGE_TAG, Signature, tagged_hash}; use crate::{AffinePoint, FieldBytes, ProjectivePoint, PublicKey, Scalar}; use elliptic_curve::{ bigint::U256, @@ -9,13 +9,13 @@ use elliptic_curve::{ point::DecompactPoint, }; use sha2::{ - digest::{consts::U32, FixedOutput}, Digest, Sha256, + digest::{FixedOutput, consts::U32}, }; -use signature::{hazmat::PrehashVerifier, DigestVerifier, Error, Result, Verifier}; +use signature::{DigestVerifier, Error, Result, Verifier, hazmat::PrehashVerifier}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; /// Taproot Schnorr verifying key. #[derive(Copy, Clone, Debug, Eq, PartialEq)] From 6e6e03abb5c135c05433a6dea090108e644bc168 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:46:04 -0800 Subject: [PATCH 05/20] p192: bump to edition 2024; msrv 1.85 --- .github/workflows/p192.yml | 6 +++--- p192/Cargo.toml | 4 ++-- p192/README.md | 14 +------------- p192/src/arithmetic.rs | 2 +- p192/src/arithmetic/scalar.rs | 4 ++-- p192/src/ecdsa.rs | 2 +- p192/src/lib.rs | 4 ++-- p192/src/test_vectors/ecdsa.rs | 1 - p192/tests/projective.rs | 4 ++-- 9 files changed, 14 insertions(+), 27 deletions(-) diff --git a/.github/workflows/p192.yml b/.github/workflows/p192.yml index 671f7cc80..13c069a13 100644 --- a/.github/workflows/p192.yml +++ b/.github/workflows/p192.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -49,7 +49,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -57,7 +57,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable diff --git a/p192/Cargo.toml b/p192/Cargo.toml index 5f5b6419b..c64ad38e8 100644 --- a/p192/Cargo.toml +++ b/p192/Cargo.toml @@ -13,8 +13,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "nist", "secp192r1"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } diff --git a/p192/README.md b/p192/README.md index 12b4d456f..922d78707 100644 --- a/p192/README.md +++ b/p192/README.md @@ -51,18 +51,6 @@ NIST P-192 is a Weierstrass curve specified in [FIPS 186-4]. Also known as secp192r1 (SECG). -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -87,7 +75,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p192.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p192.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/p192/src/arithmetic.rs b/p192/src/arithmetic.rs index 3b2dd696b..ce75e70a0 100644 --- a/p192/src/arithmetic.rs +++ b/p192/src/arithmetic.rs @@ -10,7 +10,7 @@ pub(crate) mod scalar; use self::{field::FieldElement, scalar::Scalar}; use crate::NistP192; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; diff --git a/p192/src/arithmetic/scalar.rs b/p192/src/arithmetic/scalar.rs index f5c5c44c5..443ffb289 100644 --- a/p192/src/arithmetic/scalar.rs +++ b/p192/src/arithmetic/scalar.rs @@ -29,19 +29,19 @@ use core::{ ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Curve as _, Error, Result, ScalarPrimitive, bigint::Limb, ff::PrimeField, ops::{Invert, Reduce}, scalar::{FromUintUnchecked, IsHigh}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, CtOption}, - Curve as _, Error, Result, ScalarPrimitive, }; #[cfg(feature = "bits")] use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(doc)] use core::ops::{Add, Mul, Sub}; diff --git a/p192/src/ecdsa.rs b/p192/src/ecdsa.rs index 666022fde..c1a7feefa 100644 --- a/p192/src/ecdsa.rs +++ b/p192/src/ecdsa.rs @@ -53,7 +53,7 @@ pub type VerifyingKey = ecdsa_core::VerifyingKey; #[cfg(all(test, feature = "ecdsa"))] mod tests { mod verify { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP192}; + use crate::{NistP192, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_verification_test!(NistP192, ECDSA_TEST_VECTORS); } } diff --git a/p192/src/lib.rs b/p192/src/lib.rs index 158a0d195..5c669b80c 100644 --- a/p192/src/lib.rs +++ b/p192/src/lib.rs @@ -27,16 +27,16 @@ pub mod test_vectors; pub use elliptic_curve; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; use elliptic_curve::{ + FieldBytesEncoding, array::Array, bigint::{ArrayEncoding, U192}, consts::{U24, U25}, - FieldBytesEncoding, }; const ORDER_HEX: &str = "ffffffffffffffffffffffff99def836146bc9b1b4d22831"; diff --git a/p192/src/test_vectors/ecdsa.rs b/p192/src/test_vectors/ecdsa.rs index 9d2323310..209f95472 100644 --- a/p192/src/test_vectors/ecdsa.rs +++ b/p192/src/test_vectors/ecdsa.rs @@ -11,7 +11,6 @@ use hex_literal::hex; /// /// The `m` field contains a SHA-1 prehash of the `Msg` field in the /// original `SigTen.txt`. - pub const ECDSA_TEST_VECTORS: &[TestVector; 15] = &[ TestVector { m: &hex!("000000005c8190e87adb631bb5537f3f5f478888bd002ff5"), diff --git a/p192/tests/projective.rs b/p192/tests/projective.rs index bb06a7c26..0ce26a864 100644 --- a/p192/tests/projective.rs +++ b/p192/tests/projective.rs @@ -7,10 +7,10 @@ use elliptic_curve::{ sec1::{self, ToEncodedPoint}, }; use p192::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, AffinePoint, ProjectivePoint, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; -use primeorder::{impl_projective_arithmetic_tests, Double}; +use primeorder::{Double, impl_projective_arithmetic_tests}; impl_projective_arithmetic_tests!( AffinePoint, From 8fe1d9805ebfe1948ff16a1cbe4ec424b2beba21 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:47:09 -0800 Subject: [PATCH 06/20] p256: bump to edition 2024; msrv 1.85 --- .github/workflows/p256.yml | 12 ++++++------ p256/Cargo.toml | 6 +++--- p256/README.md | 14 +------------- p256/benches/field.rs | 2 +- p256/benches/scalar.rs | 24 ++++++++++++------------ p256/src/arithmetic.rs | 2 +- p256/src/arithmetic/field.rs | 14 +++++++------- p256/src/arithmetic/hash2curve.rs | 4 ++-- p256/src/arithmetic/scalar.rs | 22 +++++++++++----------- p256/src/ecdh.rs | 6 +++--- p256/src/ecdsa.rs | 14 +++++++------- p256/src/lib.rs | 4 ++-- p256/tests/affine.rs | 6 +++--- p256/tests/ecdsa.rs | 2 +- p256/tests/pkcs8.rs | 4 +++- p256/tests/projective.rs | 6 +++--- 16 files changed, 66 insertions(+), 76 deletions(-) diff --git a/.github/workflows/p256.yml b/.github/workflows/p256.yml index 92f070b22..46ce1578b 100644 --- a/.github/workflows/p256.yml +++ b/.github/workflows/p256.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -58,7 +58,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -66,7 +66,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable @@ -89,19 +89,19 @@ jobs: include: # ARM32 - target: armv7-unknown-linux-gnueabihf - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: armv7-unknown-linux-gnueabihf rust: stable # ARM64 - target: aarch64-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: aarch64-unknown-linux-gnu rust: stable # PPC32 - target: powerpc-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: powerpc-unknown-linux-gnu rust: stable diff --git a/p256/Cargo.toml b/p256/Cargo.toml index e2f298cba..1f06d8b31 100644 --- a/p256/Cargo.toml +++ b/p256/Cargo.toml @@ -14,8 +14,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "nist", "prime256v1", "secp256r1"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } @@ -34,7 +34,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = hex-literal = "0.4" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } [features] default = ["arithmetic", "ecdsa", "pem", "std"] diff --git a/p256/README.md b/p256/README.md index 6cbfa8329..f65022bdb 100644 --- a/p256/README.md +++ b/p256/README.md @@ -42,18 +42,6 @@ Also known as prime256v1 (ANSI X9.62) and secp256r1 (SECG), it's included in the US National Security Agency's "Suite B" and is widely used in protocols like TLS and the associated X.509 PKI. -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -78,7 +66,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p256.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p256.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/p256/benches/field.rs b/p256/benches/field.rs index 43ece839f..b73165ba6 100644 --- a/p256/benches/field.rs +++ b/p256/benches/field.rs @@ -1,7 +1,7 @@ //! secp256r1 field element benchmarks use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; use p256::FieldElement; diff --git a/p256/benches/scalar.rs b/p256/benches/scalar.rs index a8db8d5da..2de4d74ef 100644 --- a/p256/benches/scalar.rs +++ b/p256/benches/scalar.rs @@ -1,10 +1,10 @@ //! secp256r1 scalar arithmetic benchmarks use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; -use p256::{elliptic_curve::group::ff::PrimeField, ProjectivePoint, Scalar}; +use p256::{ProjectivePoint, Scalar, elliptic_curve::group::ff::PrimeField}; fn test_scalar_x() -> Scalar { Scalar::from_repr( @@ -20,37 +20,37 @@ fn test_scalar_y() -> Scalar { .unwrap() } -fn bench_point_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_point_mul(group: &mut BenchmarkGroup<'_, M>) { let p = ProjectivePoint::GENERATOR; let m = test_scalar_x(); let s = Scalar::from_repr(m.into()).unwrap(); - group.bench_function("point-scalar mul", |b| b.iter(|| &p * &s)); + group.bench_function("point-scalar mul", |b| b.iter(|| p * s)); } -fn bench_scalar_sub<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_sub(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("sub", |b| b.iter(|| &x - &y)); + group.bench_function("sub", |b| b.iter(|| x - y)); } -fn bench_scalar_add<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_add(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("add", |b| b.iter(|| &x + &y)); + group.bench_function("add", |b| b.iter(|| x + y)); } -fn bench_scalar_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_mul(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("mul", |b| b.iter(|| &x * &y)); + group.bench_function("mul", |b| b.iter(|| x * y)); } -fn bench_scalar_negate<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_negate(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("negate", |b| b.iter(|| -x)); } -fn bench_scalar_invert<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_invert(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("invert", |b| b.iter(|| x.invert())); } diff --git a/p256/src/arithmetic.rs b/p256/src/arithmetic.rs index 9cdd94f1d..1579a1106 100644 --- a/p256/src/arithmetic.rs +++ b/p256/src/arithmetic.rs @@ -12,7 +12,7 @@ pub(crate) mod scalar; use self::{field::FieldElement, scalar::Scalar}; use crate::NistP256; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; diff --git a/p256/src/arithmetic/field.rs b/p256/src/arithmetic/field.rs index 61f3e89f0..dea3c5f42 100644 --- a/p256/src/arithmetic/field.rs +++ b/p256/src/arithmetic/field.rs @@ -503,7 +503,7 @@ impl<'a> Product<&'a FieldElement> for FieldElement { #[cfg(test)] mod tests { use super::FieldElement; - use crate::{test_vectors::field::DBL_TEST_VECTORS, FieldBytes}; + use crate::{FieldBytes, test_vectors::field::DBL_TEST_VECTORS}; use core::ops::Mul; #[cfg(target_pointer_width = "64")] @@ -562,8 +562,8 @@ mod tests { #[test] fn repeated_add() { let mut r = FieldElement::ONE; - for i in 0..DBL_TEST_VECTORS.len() { - assert_eq!(r.to_bytes(), DBL_TEST_VECTORS[i]); + for item in DBL_TEST_VECTORS { + assert_eq!(r.to_bytes().as_slice(), item); r = r + &r; } } @@ -571,8 +571,8 @@ mod tests { #[test] fn repeated_double() { let mut r = FieldElement::ONE; - for i in 0..DBL_TEST_VECTORS.len() { - assert_eq!(r.to_bytes(), DBL_TEST_VECTORS[i]); + for item in DBL_TEST_VECTORS { + assert_eq!(r.to_bytes().as_slice(), item); r = r.double(); } } @@ -581,8 +581,8 @@ mod tests { fn repeated_mul() { let mut r = FieldElement::ONE; let two = r + &r; - for i in 0..DBL_TEST_VECTORS.len() { - assert_eq!(r.to_bytes(), DBL_TEST_VECTORS[i]); + for item in DBL_TEST_VECTORS { + assert_eq!(r.to_bytes().as_slice(), item); r = r * &two; } } diff --git a/p256/src/arithmetic/hash2curve.rs b/p256/src/arithmetic/hash2curve.rs index c6da89b95..bed1ca2ae 100644 --- a/p256/src/arithmetic/hash2curve.rs +++ b/p256/src/arithmetic/hash2curve.rs @@ -94,15 +94,15 @@ impl FromOkm for Scalar { #[cfg(test)] mod tests { use super::FieldElement; - use crate::{arithmetic::field::MODULUS, NistP256, Scalar, U256}; + use crate::{NistP256, Scalar, U256, arithmetic::field::MODULUS}; use elliptic_curve::{ + Curve, Field, array::Array, bigint::{ArrayEncoding, CheckedSub, NonZero, U384}, consts::U48, group::cofactor::CofactorGroup, hash2curve::{self, ExpandMsgXmd, FromOkm, GroupDigest, MapToCurve, OsswuMap}, sec1::{self, ToEncodedPoint}, - Curve, Field, }; use hex_literal::hex; use proptest::{num::u64::ANY, prelude::ProptestConfig, proptest}; diff --git a/p256/src/arithmetic/scalar.rs b/p256/src/arithmetic/scalar.rs index 9642cd704..24cdd1b93 100644 --- a/p256/src/arithmetic/scalar.rs +++ b/p256/src/arithmetic/scalar.rs @@ -5,14 +5,15 @@ mod scalar_impl; use self::scalar_impl::barrett_reduce; -use crate::{FieldBytes, NistP256, SecretKey, ORDER_HEX}; +use crate::{FieldBytes, NistP256, ORDER_HEX, SecretKey}; use core::{ fmt::{self, Debug}, iter::{Product, Sum}, ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, Sub, SubAssign}, }; use elliptic_curve::{ - bigint::{prelude::*, Limb, U256}, + Curve, ScalarPrimitive, + bigint::{Limb, U256, prelude::*}, group::ff::{self, Field, PrimeField}, ops::{Invert, Reduce, ReduceNonZero}, rand_core::RngCore, @@ -22,14 +23,13 @@ use elliptic_curve::{ CtOption, }, zeroize::DefaultIsZeroes, - Curve, ScalarPrimitive, }; #[cfg(feature = "bits")] use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; /// Constant representing the modulus /// n = FFFFFFFF 00000000 FFFFFFFF FFFFFFFF BCE6FAAD A7179E84 F3B9CAC2 FC632551 @@ -639,7 +639,7 @@ impl Neg for Scalar { } } -impl<'a> Neg for &'a Scalar { +impl Neg for &Scalar { type Output = Scalar; fn neg(self) -> Scalar { @@ -773,17 +773,17 @@ mod tests { #[test] fn multiply() { let one = Scalar::ONE; - let two = one + &one; - let three = two + &one; - let six = three + &three; - assert_eq!(six, two * &three); + let two = one + one; + let three = two + one; + let six = three + three; + assert_eq!(six, two * three); let minus_two = -two; let minus_three = -three; assert_eq!(two, -minus_two); - assert_eq!(minus_three * &minus_two, minus_two * &minus_three); - assert_eq!(six, minus_two * &minus_three); + assert_eq!(minus_three * minus_two, minus_two * minus_three); + assert_eq!(six, minus_two * minus_three); } /// Tests that a Scalar can be safely converted to a SecretKey and back diff --git a/p256/src/ecdh.rs b/p256/src/ecdh.rs index ab408dd8e..34423f5e7 100644 --- a/p256/src/ecdh.rs +++ b/p256/src/ecdh.rs @@ -10,14 +10,14 @@ //! //! ``` //! use p256::{EncodedPoint, PublicKey, ecdh::EphemeralSecret}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Alice -//! let alice_secret = EphemeralSecret::random(&mut OsRng); +//! let alice_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let alice_pk_bytes = EncodedPoint::from(alice_secret.public_key()); //! //! // Bob -//! let bob_secret = EphemeralSecret::random(&mut OsRng); +//! let bob_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let bob_pk_bytes = EncodedPoint::from(bob_secret.public_key()); //! //! // Alice decodes Bob's serialized public key and computes a shared secret from it diff --git a/p256/src/ecdsa.rs b/p256/src/ecdsa.rs index 0a612baba..acf6e88c2 100644 --- a/p256/src/ecdsa.rs +++ b/p256/src/ecdsa.rs @@ -24,10 +24,10 @@ //! use p256::{ //! ecdsa::{SigningKey, Signature, signature::Signer}, //! }; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Signing -//! let signing_key = SigningKey::random(&mut OsRng); // Serialize with `::to_bytes()` +//! let signing_key = SigningKey::random(&mut OsRng.unwrap_mut()); // Serialize with `::to_bytes()` //! let message = b"ECDSA proves knowledge of a secret number in the context of a single message"; //! let signature: Signature = signing_key.sign(message); //! @@ -69,12 +69,12 @@ impl ecdsa_core::hazmat::DigestPrimitive for NistP256 { #[cfg(all(test, feature = "ecdsa"))] mod tests { use crate::{ + AffinePoint, EncodedPoint, ecdsa::{ - signature::hazmat::{PrehashSigner, PrehashVerifier}, - signature::Signer, Signature, SigningKey, VerifyingKey, + signature::Signer, + signature::hazmat::{PrehashSigner, PrehashVerifier}, }, - AffinePoint, EncodedPoint, }; use elliptic_curve::sec1::FromEncodedPoint; use hex_literal::hex; @@ -148,12 +148,12 @@ mod tests { } mod sign { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP256}; + use crate::{NistP256, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_signing_test!(NistP256, ECDSA_TEST_VECTORS); } mod verify { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP256}; + use crate::{NistP256, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_verification_test!(NistP256, ECDSA_TEST_VECTORS); } diff --git a/p256/src/lib.rs b/p256/src/lib.rs index 5ba447e5d..2ce7d2e01 100644 --- a/p256/src/lib.rs +++ b/p256/src/lib.rs @@ -41,7 +41,7 @@ pub mod test_vectors; pub use elliptic_curve::{self, bigint::U256, consts::U32}; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; #[cfg(feature = "expose-field")] pub use arithmetic::field::FieldElement; @@ -49,7 +49,7 @@ pub use arithmetic::field::FieldElement; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; -use elliptic_curve::{array::Array, bigint::ArrayEncoding, consts::U33, FieldBytesEncoding}; +use elliptic_curve::{FieldBytesEncoding, array::Array, bigint::ArrayEncoding, consts::U33}; /// Order of NIST P-256's elliptic curve group (i.e. scalar modulus) serialized /// as hexadecimal. diff --git a/p256/tests/affine.rs b/p256/tests/affine.rs index a339811b3..614fef317 100644 --- a/p256/tests/affine.rs +++ b/p256/tests/affine.rs @@ -1,9 +1,9 @@ //! Affine arithmetic tests. -#![cfg(all(feature = "arithmetic"))] +#![cfg(feature = "arithmetic")] use elliptic_curve::{ - group::{prime::PrimeCurveAffine, GroupEncoding}, + group::{GroupEncoding, prime::PrimeCurveAffine}, sec1::{FromEncodedPoint, ToCompactEncodedPoint, ToEncodedPoint}, }; use hex_literal::hex; @@ -88,7 +88,7 @@ fn compact_round_trip() { #[test] fn uncompact_to_compact() { let pubkey = EncodedPoint::from_bytes(UNCOMPACT_BASEPOINT).unwrap(); - assert_eq!(false, pubkey.is_compact()); + assert!(!pubkey.is_compact()); let point = AffinePoint::from_encoded_point(&pubkey).unwrap(); let res = point.to_compact_encoded_point().unwrap(); diff --git a/p256/tests/ecdsa.rs b/p256/tests/ecdsa.rs index dfc80ae5b..6d209f5cd 100644 --- a/p256/tests/ecdsa.rs +++ b/p256/tests/ecdsa.rs @@ -4,8 +4,8 @@ use elliptic_curve::ops::Reduce; use p256::{ - ecdsa::{SigningKey, VerifyingKey}, NonZeroScalar, U256, + ecdsa::{SigningKey, VerifyingKey}, }; use proptest::prelude::*; diff --git a/p256/tests/pkcs8.rs b/p256/tests/pkcs8.rs index e9468ef77..4ff420d50 100644 --- a/p256/tests/pkcs8.rs +++ b/p256/tests/pkcs8.rs @@ -35,7 +35,9 @@ fn decode_pkcs8_private_key_from_der() { #[test] fn decode_pkcs8_public_key_from_der() { let public_key = p256::PublicKey::from_public_key_der(&PKCS8_PUBLIC_KEY_DER[..]).unwrap(); - let expected_sec1_point = hex!("041CACFFB55F2F2CEFD89D89EB374B2681152452802DEEA09916068137D839CF7FC481A44492304D7EF66AC117BEFE83A8D08F155F2B52F9F618DD447029048E0F"); + let expected_sec1_point = hex!( + "041CACFFB55F2F2CEFD89D89EB374B2681152452802DEEA09916068137D839CF7FC481A44492304D7EF66AC117BEFE83A8D08F155F2B52F9F618DD447029048E0F" + ); assert_eq!( public_key.to_encoded_point(false).as_bytes(), &expected_sec1_point[..] diff --git a/p256/tests/projective.rs b/p256/tests/projective.rs index 6845f423e..3c414be62 100644 --- a/p256/tests/projective.rs +++ b/p256/tests/projective.rs @@ -3,14 +3,14 @@ #![cfg(all(feature = "arithmetic", feature = "test-vectors"))] use elliptic_curve::{ - group::{ff::PrimeField, GroupEncoding}, + group::{GroupEncoding, ff::PrimeField}, sec1::{self, ToEncodedPoint}, }; use p256::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, AffinePoint, ProjectivePoint, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; -use primeorder::{impl_projective_arithmetic_tests, Double}; +use primeorder::{Double, impl_projective_arithmetic_tests}; impl_projective_arithmetic_tests!( AffinePoint, From ebd307aa31d5529d883d51d654fc6044144baf3b Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:48:05 -0800 Subject: [PATCH 07/20] p384: bump to edition 2024; msrv 1.85 --- .github/workflows/p384.yml | 12 +- p384/Cargo.toml | 6 +- p384/README.md | 14 +- p384/benches/field.rs | 2 +- p384/benches/scalar.rs | 24 +- p384/src/arithmetic.rs | 14 +- p384/src/arithmetic/field.rs | 4 +- p384/src/arithmetic/hash2curve.rs | 16 +- p384/src/arithmetic/scalar.rs | 10 +- p384/src/ecdh.rs | 6 +- p384/src/ecdsa.rs | 22 +- p384/src/lib.rs | 4 +- p384/src/test_vectors/ecdsa.rs | 420 +++++++++++++----- p384/src/test_vectors/group.rs | 684 +++++++++++++++++++++--------- p384/tests/affine.rs | 2 +- p384/tests/projective.rs | 6 +- 16 files changed, 868 insertions(+), 378 deletions(-) diff --git a/.github/workflows/p384.yml b/.github/workflows/p384.yml index e83b3af8a..5cf32236b 100644 --- a/.github/workflows/p384.yml +++ b/.github/workflows/p384.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -55,7 +55,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -63,7 +63,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable @@ -85,19 +85,19 @@ jobs: include: # ARM32 - target: armv7-unknown-linux-gnueabihf - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: armv7-unknown-linux-gnueabihf rust: stable # ARM64 - target: aarch64-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: aarch64-unknown-linux-gnu rust: stable # PPC32 - target: powerpc-unknown-linux-gnu - rust: 1.81.0 # MSRV (cross) + rust: 1.85.0 # MSRV (cross) - target: powerpc-unknown-linux-gnu rust: stable diff --git a/p384/Cargo.toml b/p384/Cargo.toml index ecda70e68..34758b24f 100644 --- a/p384/Cargo.toml +++ b/p384/Cargo.toml @@ -14,8 +14,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "nist", "secp384r1"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } @@ -34,7 +34,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = hex-literal = "0.4" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1.5" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } [features] default = ["arithmetic", "ecdsa", "pem", "std"] diff --git a/p384/README.md b/p384/README.md index 79f04ff92..f80043104 100644 --- a/p384/README.md +++ b/p384/README.md @@ -42,18 +42,6 @@ Also known as secp384r1 (SECG), it's included in the US National Security Agency's "Suite B" and is widely used in protocols like TLS and the associated X.509 PKI. -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -78,7 +66,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p384.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p384.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/p384/benches/field.rs b/p384/benches/field.rs index f1b1d4529..13723e1ce 100644 --- a/p384/benches/field.rs +++ b/p384/benches/field.rs @@ -1,7 +1,7 @@ //! secp384r1 field element benchmarks use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; use p384::FieldElement; diff --git a/p384/benches/scalar.rs b/p384/benches/scalar.rs index 3589d79d1..c53d1b1ab 100644 --- a/p384/benches/scalar.rs +++ b/p384/benches/scalar.rs @@ -1,10 +1,10 @@ //! secp384r1 scalar arithmetic benchmarks use criterion::{ - criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; -use p384::{elliptic_curve::group::ff::PrimeField, ProjectivePoint, Scalar}; +use p384::{ProjectivePoint, Scalar, elliptic_curve::group::ff::PrimeField}; fn test_scalar_x() -> Scalar { Scalar::from_repr( @@ -18,37 +18,37 @@ fn test_scalar_y() -> Scalar { ).unwrap() } -fn bench_point_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_point_mul(group: &mut BenchmarkGroup<'_, M>) { let p = ProjectivePoint::GENERATOR; let m = test_scalar_x(); let s = Scalar::from_repr(m.into()).unwrap(); - group.bench_function("point-scalar mul", |b| b.iter(|| &p * &s)); + group.bench_function("point-scalar mul", |b| b.iter(|| p * s)); } -fn bench_scalar_sub<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_sub(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("sub", |b| b.iter(|| &x - &y)); + group.bench_function("sub", |b| b.iter(|| x - y)); } -fn bench_scalar_add<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_add(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("add", |b| b.iter(|| &x + &y)); + group.bench_function("add", |b| b.iter(|| x + y)); } -fn bench_scalar_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_mul(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("mul", |b| b.iter(|| &x * &y)); + group.bench_function("mul", |b| b.iter(|| x * y)); } -fn bench_scalar_negate<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_negate(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("negate", |b| b.iter(|| -x)); } -fn bench_scalar_invert<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_invert(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("invert", |b| b.iter(|| x.invert())); } diff --git a/p384/src/arithmetic.rs b/p384/src/arithmetic.rs index 2073191d4..b750ab430 100644 --- a/p384/src/arithmetic.rs +++ b/p384/src/arithmetic.rs @@ -12,7 +12,7 @@ pub(crate) mod scalar; use self::{field::FieldElement, scalar::Scalar}; use crate::NistP384; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; @@ -42,7 +42,9 @@ impl PrimeCurveParams for NistP384 { /// b = b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 /// 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef - const EQUATION_B: FieldElement = FieldElement::from_hex("b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"); + const EQUATION_B: FieldElement = FieldElement::from_hex( + "b3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef", + ); /// Base point of P-384. /// @@ -55,7 +57,11 @@ impl PrimeCurveParams for NistP384 { /// e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f /// ``` const GENERATOR: (FieldElement, FieldElement) = ( - FieldElement::from_hex("aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"), - FieldElement::from_hex("3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"), + FieldElement::from_hex( + "aa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7", + ), + FieldElement::from_hex( + "3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f", + ), ); } diff --git a/p384/src/arithmetic/field.rs b/p384/src/arithmetic/field.rs index cd677d928..7abd1581c 100644 --- a/p384/src/arithmetic/field.rs +++ b/p384/src/arithmetic/field.rs @@ -135,7 +135,9 @@ impl PrimeField for FieldElement { const TWO_INV: Self = Self::from_u64(2).invert_unchecked(); const MULTIPLICATIVE_GENERATOR: Self = Self::from_u64(19); const S: u32 = 1; - const ROOT_OF_UNITY: Self = Self::from_hex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffe"); + const ROOT_OF_UNITY: Self = Self::from_hex( + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffe", + ); const ROOT_OF_UNITY_INV: Self = Self::ROOT_OF_UNITY.invert_unchecked(); const DELTA: Self = Self::from_u64(49); diff --git a/p384/src/arithmetic/hash2curve.rs b/p384/src/arithmetic/hash2curve.rs index 1e103aa81..16f819b46 100644 --- a/p384/src/arithmetic/hash2curve.rs +++ b/p384/src/arithmetic/hash2curve.rs @@ -96,8 +96,9 @@ impl FromOkm for Scalar { #[cfg(test)] mod tests { - use crate::{arithmetic::field::MODULUS, FieldElement, NistP384, Scalar}; + use crate::{FieldElement, NistP384, Scalar, arithmetic::field::MODULUS}; use elliptic_curve::{ + Curve, array::Array, bigint::{ArrayEncoding, CheckedSub, NonZero, U384, U576}, consts::U72, @@ -105,7 +106,6 @@ mod tests { hash2curve::{self, ExpandMsgXmd, FromOkm, GroupDigest, MapToCurve, OsswuMap}, ops::Reduce, sec1::{self, ToEncodedPoint}, - Curve, }; use hex_literal::hex; use proptest::{num::u64::ANY, prelude::ProptestConfig, proptest}; @@ -259,19 +259,25 @@ mod tests { dst: b"DeriveKeyPairOPRFV1-\x00-P384-SHA384", key_info: b"test key", seed: &hex!("a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3"), - sk_sm: &hex!("dfe7ddc41a4646901184f2b432616c8ba6d452f9bcd0c4f75a5150ef2b2ed02ef40b8b92f60ae591bcabd72a6518f188"), + sk_sm: &hex!( + "dfe7ddc41a4646901184f2b432616c8ba6d452f9bcd0c4f75a5150ef2b2ed02ef40b8b92f60ae591bcabd72a6518f188" + ), }, TestVector { dst: b"DeriveKeyPairOPRFV1-\x01-P384-SHA384", key_info: b"test key", seed: &hex!("a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3"), - sk_sm: &hex!("051646b9e6e7a71ae27c1e1d0b87b4381db6d3595eeeb1adb41579adbf992f4278f9016eafc944edaa2b43183581779d"), + sk_sm: &hex!( + "051646b9e6e7a71ae27c1e1d0b87b4381db6d3595eeeb1adb41579adbf992f4278f9016eafc944edaa2b43183581779d" + ), }, TestVector { dst: b"DeriveKeyPairOPRFV1-\x02-P384-SHA384", key_info: b"test key", seed: &hex!("a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3"), - sk_sm: &hex!("5b2690d6954b8fbb159f19935d64133f12770c00b68422559c65431942d721ff79d47d7a75906c30b7818ec0f38b7fb2"), + sk_sm: &hex!( + "5b2690d6954b8fbb159f19935d64133f12770c00b68422559c65431942d721ff79d47d7a75906c30b7818ec0f38b7fb2" + ), }, ]; diff --git a/p384/src/arithmetic/scalar.rs b/p384/src/arithmetic/scalar.rs index 336640dc2..0eb8067a7 100644 --- a/p384/src/arithmetic/scalar.rs +++ b/p384/src/arithmetic/scalar.rs @@ -22,19 +22,19 @@ mod scalar_impl; use self::scalar_impl::*; -use crate::{FieldBytes, NistP384, SecretKey, ORDER_HEX, U384}; +use crate::{FieldBytes, NistP384, ORDER_HEX, SecretKey, U384}; use core::{ fmt::{self, Debug}, iter::{Product, Sum}, ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Curve as _, Error, Result, ScalarPrimitive, bigint::{ArrayEncoding, Limb}, ff::PrimeField, ops::{Invert, Reduce}, scalar::{FromUintUnchecked, IsHigh}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, CtOption}, - Curve as _, Error, Result, ScalarPrimitive, }; use primeorder::impl_bernstein_yang_invert; @@ -42,7 +42,7 @@ use primeorder::impl_bernstein_yang_invert; use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(doc)] use core::ops::{Add, Mul, Sub}; @@ -242,7 +242,9 @@ impl PrimeField for Scalar { const TWO_INV: Self = Self::from_u64(2).invert_unchecked(); const MULTIPLICATIVE_GENERATOR: Self = Self::from_u64(2); const S: u32 = 1; - const ROOT_OF_UNITY: Self = Self::from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52972"); + const ROOT_OF_UNITY: Self = Self::from_hex( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52972", + ); const ROOT_OF_UNITY_INV: Self = Self::ROOT_OF_UNITY.invert_unchecked(); const DELTA: Self = Self::from_u64(4); diff --git a/p384/src/ecdh.rs b/p384/src/ecdh.rs index 2e12c3da6..84cd6b344 100644 --- a/p384/src/ecdh.rs +++ b/p384/src/ecdh.rs @@ -10,14 +10,14 @@ //! //! ``` //! use p384::{EncodedPoint, PublicKey, ecdh::EphemeralSecret}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Alice -//! let alice_secret = EphemeralSecret::random(&mut OsRng); +//! let alice_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let alice_pk_bytes = EncodedPoint::from(alice_secret.public_key()); //! //! // Bob -//! let bob_secret = EphemeralSecret::random(&mut OsRng); +//! let bob_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let bob_pk_bytes = EncodedPoint::from(bob_secret.public_key()); //! //! // Alice decodes Bob's serialized public key and computes a shared secret from it diff --git a/p384/src/ecdsa.rs b/p384/src/ecdsa.rs index 67aaf7093..931417381 100644 --- a/p384/src/ecdsa.rs +++ b/p384/src/ecdsa.rs @@ -22,10 +22,10 @@ //! # #[cfg(feature = "ecdsa")] //! # { //! use p384::ecdsa::{signature::Signer, Signature, SigningKey}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Signing -//! let signing_key = SigningKey::random(&mut OsRng); // Serialize with `::to_bytes()` +//! let signing_key = SigningKey::random(&mut OsRng.unwrap_mut()); // Serialize with `::to_bytes()` //! let message = b"ECDSA proves knowledge of a secret number in the context of a single message"; //! let signature: Signature = signing_key.sign(message); //! @@ -68,12 +68,12 @@ impl ecdsa_core::hazmat::DigestPrimitive for NistP384 { #[cfg(all(test, feature = "ecdsa"))] mod tests { use crate::{ + AffinePoint, EncodedPoint, SecretKey, ecdsa::{ - signature::hazmat::{PrehashSigner, PrehashVerifier}, - signature::Signer, Signature, SigningKey, VerifyingKey, + signature::Signer, + signature::hazmat::{PrehashSigner, PrehashVerifier}, }, - AffinePoint, EncodedPoint, SecretKey, }; use elliptic_curve::sec1::FromEncodedPoint; @@ -84,7 +84,9 @@ mod tests { // #[test] fn rfc6979() { - let x = hex!("6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5"); + let x = hex!( + "6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5" + ); let signer = SigningKey::from_bytes(&x.into()).unwrap(); let signature: Signature = signer.sign(b"sample"); assert_eq!( @@ -108,7 +110,9 @@ mod tests { // Test signing with PrehashSigner using SHA-256 whose output is smaller than P-384 field size. #[test] fn prehash_signer_signing_with_sha256() { - let x = hex!("6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5"); + let x = hex!( + "6b9d3dad2e1b8c1c05b19875b6659f4de23c3b667bf297ba9aa47740787137d896d5724e4c70a825f872c9ea60d2edf5" + ); let signer = SigningKey::from_bytes(&x.into()).unwrap(); let digest = sha2::Sha256::digest(b"test"); let signature: Signature = signer.sign_prehash(&digest).unwrap(); @@ -163,12 +167,12 @@ mod tests { } mod sign { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP384}; + use crate::{NistP384, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_signing_test!(NistP384, ECDSA_TEST_VECTORS); } mod verify { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP384}; + use crate::{NistP384, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_verification_test!(NistP384, ECDSA_TEST_VECTORS); } diff --git a/p384/src/lib.rs b/p384/src/lib.rs index a0bd2bc17..1fb2e624b 100644 --- a/p384/src/lib.rs +++ b/p384/src/lib.rs @@ -34,7 +34,7 @@ pub mod test_vectors; pub use elliptic_curve::{self, bigint::U384, consts::U48}; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; #[cfg(feature = "expose-field")] pub use arithmetic::field::FieldElement; @@ -42,7 +42,7 @@ pub use arithmetic::field::FieldElement; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; -use elliptic_curve::{array::Array, bigint::ArrayEncoding, consts::U49, FieldBytesEncoding}; +use elliptic_curve::{FieldBytesEncoding, array::Array, bigint::ArrayEncoding, consts::U49}; /// Order of NIST P-384's elliptic curve group (i.e. scalar modulus) in hexadecimal. const ORDER_HEX: &str = "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"; diff --git a/p384/src/test_vectors/ecdsa.rs b/p384/src/test_vectors/ecdsa.rs index 2532a8dcb..9cf3e64d3 100644 --- a/p384/src/test_vectors/ecdsa.rs +++ b/p384/src/test_vectors/ecdsa.rs @@ -13,138 +13,348 @@ use hex_literal::hex; /// original `SigTen.txt`. pub const ECDSA_TEST_VECTORS: &[TestVector; 15] = &[ TestVector { - d: &hex!("201b432d8df14324182d6261db3e4b3f46a8284482d52e370da41e6cbdf45ec2952f5db7ccbce3bc29449f4fb080ac97"), - q_x: &hex!("c2b47944fb5de342d03285880177ca5f7d0f2fcad7678cce4229d6e1932fcac11bfc3c3e97d942a3c56bf34123013dbf"), - q_y: &hex!("37257906a8223866eda0743c519616a76a758ae58aee81c5fd35fbf3a855b7754a36d4a0672df95d6c44a81cf7620c2d"), - k: &hex!("dcedabf85978e090f733c6e16646fa34df9ded6e5ce28c6676a00f58a25283db8885e16ce5bf97f917c81e1f25c9c771"), - m: &hex!("31a452d6164d904bb5724c878280231eae705c29ce9d4bc7d58e020e1085f17eebcc1a38f0ed0bf2b344d81fbd896825"), - r: &hex!("50835a9251bad008106177ef004b091a1e4235cd0da84fff54542b0ed755c1d6f251609d14ecf18f9e1ddfe69b946e32"), - s: &hex!("0475f3d30c6463b646e8d3bf2455830314611cbde404be518b14464fdb195fdcc92eb222e61f426a4a592c00a6a89721"), + d: &hex!( + "201b432d8df14324182d6261db3e4b3f46a8284482d52e370da41e6cbdf45ec2952f5db7ccbce3bc29449f4fb080ac97" + ), + q_x: &hex!( + "c2b47944fb5de342d03285880177ca5f7d0f2fcad7678cce4229d6e1932fcac11bfc3c3e97d942a3c56bf34123013dbf" + ), + q_y: &hex!( + "37257906a8223866eda0743c519616a76a758ae58aee81c5fd35fbf3a855b7754a36d4a0672df95d6c44a81cf7620c2d" + ), + k: &hex!( + "dcedabf85978e090f733c6e16646fa34df9ded6e5ce28c6676a00f58a25283db8885e16ce5bf97f917c81e1f25c9c771" + ), + m: &hex!( + "31a452d6164d904bb5724c878280231eae705c29ce9d4bc7d58e020e1085f17eebcc1a38f0ed0bf2b344d81fbd896825" + ), + r: &hex!( + "50835a9251bad008106177ef004b091a1e4235cd0da84fff54542b0ed755c1d6f251609d14ecf18f9e1ddfe69b946e32" + ), + s: &hex!( + "0475f3d30c6463b646e8d3bf2455830314611cbde404be518b14464fdb195fdcc92eb222e61f426a4a592c00a6a89721" + ), }, TestVector { - d: &hex!("23d9f4ea6d87b7d6163d64256e3449255db14786401a51daa7847161bf56d494325ad2ac8ba928394e01061d882c3528"), - q_x: &hex!("5d42d6301c54a438f65970bae2a098cbc567e98840006e356221966c86d82e8eca515bca850eaa3cd41f175f03a0cbfd"), - q_y: &hex!("4aef5a0ceece95d382bd70ab5ce1cb77408bae42b51a08816d5e5e1d3da8c18fcc95564a752730b0aabea983ccea4e2e"), - k: &hex!("67ba379366049008593eac124f59ab017358892ee0c063d38f3758bb849fd25d867c3561563cac1532a323b228dc0890"), - m: &hex!("a92784916a40feaebfeab16ea28c0c65e45c5e81eb634052944865708072e20110bd669a9838d7e722e94ac75245cdd3"), - r: &hex!("fb318f4cb1276282bb43f733a7fb7c567ce94f4d02924fc758635ab2d1107108bf159b85db080cdc3b30fbb5400016f3"), - s: &hex!("588e3d7af5da03eae255ecb1813100d95edc243476b724b22db8e85377660d7645ddc1c2c2ee4eaea8b683dbe22f86ca"), + d: &hex!( + "23d9f4ea6d87b7d6163d64256e3449255db14786401a51daa7847161bf56d494325ad2ac8ba928394e01061d882c3528" + ), + q_x: &hex!( + "5d42d6301c54a438f65970bae2a098cbc567e98840006e356221966c86d82e8eca515bca850eaa3cd41f175f03a0cbfd" + ), + q_y: &hex!( + "4aef5a0ceece95d382bd70ab5ce1cb77408bae42b51a08816d5e5e1d3da8c18fcc95564a752730b0aabea983ccea4e2e" + ), + k: &hex!( + "67ba379366049008593eac124f59ab017358892ee0c063d38f3758bb849fd25d867c3561563cac1532a323b228dc0890" + ), + m: &hex!( + "a92784916a40feaebfeab16ea28c0c65e45c5e81eb634052944865708072e20110bd669a9838d7e722e94ac75245cdd3" + ), + r: &hex!( + "fb318f4cb1276282bb43f733a7fb7c567ce94f4d02924fc758635ab2d1107108bf159b85db080cdc3b30fbb5400016f3" + ), + s: &hex!( + "588e3d7af5da03eae255ecb1813100d95edc243476b724b22db8e85377660d7645ddc1c2c2ee4eaea8b683dbe22f86ca" + ), }, TestVector { - d: &hex!("b5f670e98d8befc46f6f51fb2997069550c2a52ebfb4e5e25dd905352d9ef89eed5c2ecd16521853aadb1b52b8c42ae6"), - q_x: &hex!("44ffb2a3a95e12d87c72b5ea0a8a7cb89f56b3bd46342b2303608d7216301c21b5d2921d80b6628dc512ccb84e2fc278"), - q_y: &hex!("e4c1002f1828abaec768cadcb7cf42fbf93b1709ccae6df5b134c41fae2b9a188bfbe1eccff0bd348517d7227f2071a6"), - k: &hex!("229e67638f712f57bea4c2b02279d5ccad1e7c9e201c77f6f01aeb81ea90e62b44b2d2107fd66d35e56608fff65e28e4"), - m: &hex!("b2acf6b4ae1ba9985c1e657313d59157939c21868302f6f5c5dbf037867035ae7c2009bad9fce472579923f7b4b87795"), - r: &hex!("b11db592e4ebc75b6472b879b1d8ce57452c615aef20f67a280f8bca9b11a30ad4ac9d69541258c7dd5d0b4ab8dd7d49"), - s: &hex!("4eb51db8004e46d438359abf060a9444616cb46b4f99c9a05b53ba6df02e914c9c0b6cc3a9791d804d2e4c0984dab1cc"), + d: &hex!( + "b5f670e98d8befc46f6f51fb2997069550c2a52ebfb4e5e25dd905352d9ef89eed5c2ecd16521853aadb1b52b8c42ae6" + ), + q_x: &hex!( + "44ffb2a3a95e12d87c72b5ea0a8a7cb89f56b3bd46342b2303608d7216301c21b5d2921d80b6628dc512ccb84e2fc278" + ), + q_y: &hex!( + "e4c1002f1828abaec768cadcb7cf42fbf93b1709ccae6df5b134c41fae2b9a188bfbe1eccff0bd348517d7227f2071a6" + ), + k: &hex!( + "229e67638f712f57bea4c2b02279d5ccad1e7c9e201c77f6f01aeb81ea90e62b44b2d2107fd66d35e56608fff65e28e4" + ), + m: &hex!( + "b2acf6b4ae1ba9985c1e657313d59157939c21868302f6f5c5dbf037867035ae7c2009bad9fce472579923f7b4b87795" + ), + r: &hex!( + "b11db592e4ebc75b6472b879b1d8ce57452c615aef20f67a280f8bca9b11a30ad4ac9d69541258c7dd5d0b4ab8dd7d49" + ), + s: &hex!( + "4eb51db8004e46d438359abf060a9444616cb46b4f99c9a05b53ba6df02e914c9c0b6cc3a9791d804d2e4c0984dab1cc" + ), }, TestVector { - d: &hex!("de5975d8932533f092e76295ed6b23f10fc5fba48bfb82c6cc714826baf0126813247f8bd51d5738503654ab22459976"), - q_x: &hex!("f1fabafc01fec7e96d982528d9ef3a2a18b7fe8ae0fa0673977341c7ae4ae8d8d3d67420343d013a984f5f61da29ae38"), - q_y: &hex!("1a31cf902c46343d01b2ebb614bc789c313b5f91f9302ad9418e9c797563e2fa3d44500f47b4e26ad8fdec1a816d1dcf"), - k: &hex!("fc5940e661542436f9265c34bce407eff6364bd471aa79b90c906d923e15c9ed96eea4e86f3238ea86161d13b7d9359d"), - m: &hex!("ec21c9d03a7270ea9ce7e9ff83211bac2fb104d078217c370248a3aba81f6c586852f19ced56dc71f83f5251d7381c8a"), - r: &hex!("c2fbdd6a56789024082173725d797ef9fd6accb6ae664b7260f9e83cb8ab2490428c8b9c52e153612295432fec4d59cd"), - s: &hex!("8056c5bb57f41f73082888b234fcda320a33250b5da012ba1fdb4924355ae679012d81d2c08fc0f8634c708a4833232f"), + d: &hex!( + "de5975d8932533f092e76295ed6b23f10fc5fba48bfb82c6cc714826baf0126813247f8bd51d5738503654ab22459976" + ), + q_x: &hex!( + "f1fabafc01fec7e96d982528d9ef3a2a18b7fe8ae0fa0673977341c7ae4ae8d8d3d67420343d013a984f5f61da29ae38" + ), + q_y: &hex!( + "1a31cf902c46343d01b2ebb614bc789c313b5f91f9302ad9418e9c797563e2fa3d44500f47b4e26ad8fdec1a816d1dcf" + ), + k: &hex!( + "fc5940e661542436f9265c34bce407eff6364bd471aa79b90c906d923e15c9ed96eea4e86f3238ea86161d13b7d9359d" + ), + m: &hex!( + "ec21c9d03a7270ea9ce7e9ff83211bac2fb104d078217c370248a3aba81f6c586852f19ced56dc71f83f5251d7381c8a" + ), + r: &hex!( + "c2fbdd6a56789024082173725d797ef9fd6accb6ae664b7260f9e83cb8ab2490428c8b9c52e153612295432fec4d59cd" + ), + s: &hex!( + "8056c5bb57f41f73082888b234fcda320a33250b5da012ba1fdb4924355ae679012d81d2c08fc0f8634c708a4833232f" + ), }, TestVector { - d: &hex!("11e0d470dc31fab0f5722f87b74a6c8d7414115e58ceb38bfcdced367beac3adbf1fe9ba5a04f72e978b1eb54597eabc"), - q_x: &hex!("1950166989164cbfd97968c7e8adb6fbca1873ebef811ea259eb48b7d584627f0e6d6c64defe23cbc95236505a252aa1"), - q_y: &hex!("41ef424b5cb076d4e32accd9250ea75fcf4ffd81814040c050d58c0a29b06be11edf67c911b403e418b7277417e52906"), - k: &hex!("e56904028226eb04f8d071e3f9cefec91075a81ca0fa87b44cae148fe1ce9827b5d1910db2336d0eb9813ddba3e4d7b5"), - m: &hex!("f0272d0a51ee61f86d0875ca7800e12744ef6ffbac72bdda7c54ba24e5a5a6bd69ebe6f429cc20ac12b926d392efc4ce"), - r: &hex!("c38ef30f55624e8935680c29f8c24824877cf48ffc0ef015e62de1068893353030d1193bf9d34237d7ce6ba92c98b0fe"), - s: &hex!("651b8c3d5c9d5b936d300802a06d82ad54f7b1ba4327b2f031c0c5b0cb215ad4354edc7f932d934e877dfa1cf51b13fe"), + d: &hex!( + "11e0d470dc31fab0f5722f87b74a6c8d7414115e58ceb38bfcdced367beac3adbf1fe9ba5a04f72e978b1eb54597eabc" + ), + q_x: &hex!( + "1950166989164cbfd97968c7e8adb6fbca1873ebef811ea259eb48b7d584627f0e6d6c64defe23cbc95236505a252aa1" + ), + q_y: &hex!( + "41ef424b5cb076d4e32accd9250ea75fcf4ffd81814040c050d58c0a29b06be11edf67c911b403e418b7277417e52906" + ), + k: &hex!( + "e56904028226eb04f8d071e3f9cefec91075a81ca0fa87b44cae148fe1ce9827b5d1910db2336d0eb9813ddba3e4d7b5" + ), + m: &hex!( + "f0272d0a51ee61f86d0875ca7800e12744ef6ffbac72bdda7c54ba24e5a5a6bd69ebe6f429cc20ac12b926d392efc4ce" + ), + r: &hex!( + "c38ef30f55624e8935680c29f8c24824877cf48ffc0ef015e62de1068893353030d1193bf9d34237d7ce6ba92c98b0fe" + ), + s: &hex!( + "651b8c3d5c9d5b936d300802a06d82ad54f7b1ba4327b2f031c0c5b0cb215ad4354edc7f932d934e877dfa1cf51b13fe" + ), }, TestVector { - d: &hex!("5c6bbf9fbcbb7b97c9535f57b431ed1ccae1945b7e8a4f1b032016b07810bd24a9e20055c0e9306650df59ef7e2cd8c2"), - q_x: &hex!("2e01c5b59e619e00b79060a1e8ef695472e23bf9a511fc3d5ed77a334a242557098e40972713732c5291c97adf9cf2cf"), - q_y: &hex!("563e3fe4ad807e803b9e961b08da4dde4cea8925649da0d93221ce4cdceabc6a1db7612180a8c6bef3579c65539b97e9"), - k: &hex!("03d23f1277b949cb6380211ad9d338e6f76c3eedac95989b91d0243cfb734a54b19bca45a5d13d6a4b9f815d919eea77"), - m: &hex!("e114c6204bee5bf0bbdf9ffc139bb99f09e7ea2186da3ee1e011dd059185d57c4953a130d34ff0df3fc6782dda199ee8"), - r: &hex!("abab65308f0b79c4f3a9ff28dd490acb0c320434094cef93e75adfe17e5820dc1f77544cfaaacdc8cf9ac8b38e174bef"), - s: &hex!("11b783d879a6de054b316af7d56e526c3dce96c85289122e3ad927cfa77bfc50b4a96c97f85b1b8221be2df083ff58fb"), + d: &hex!( + "5c6bbf9fbcbb7b97c9535f57b431ed1ccae1945b7e8a4f1b032016b07810bd24a9e20055c0e9306650df59ef7e2cd8c2" + ), + q_x: &hex!( + "2e01c5b59e619e00b79060a1e8ef695472e23bf9a511fc3d5ed77a334a242557098e40972713732c5291c97adf9cf2cf" + ), + q_y: &hex!( + "563e3fe4ad807e803b9e961b08da4dde4cea8925649da0d93221ce4cdceabc6a1db7612180a8c6bef3579c65539b97e9" + ), + k: &hex!( + "03d23f1277b949cb6380211ad9d338e6f76c3eedac95989b91d0243cfb734a54b19bca45a5d13d6a4b9f815d919eea77" + ), + m: &hex!( + "e114c6204bee5bf0bbdf9ffc139bb99f09e7ea2186da3ee1e011dd059185d57c4953a130d34ff0df3fc6782dda199ee8" + ), + r: &hex!( + "abab65308f0b79c4f3a9ff28dd490acb0c320434094cef93e75adfe17e5820dc1f77544cfaaacdc8cf9ac8b38e174bef" + ), + s: &hex!( + "11b783d879a6de054b316af7d56e526c3dce96c85289122e3ad927cfa77bfc50b4a96c97f85b1b8221be2df083ff58fb" + ), }, TestVector { - d: &hex!("ffc7dedeff8343721f72046bc3c126626c177b0e48e247f44fd61f8469d4d5f0a74147fabaa334495cc1f986ebc5f0b1"), - q_x: &hex!("51c78c979452edd53b563f63eb3e854a5b23e87f1b2103942b65f77d024471f75c8ce1cc0dfef83292b368112aa5126e"), - q_y: &hex!("313e6aaf09caa3ba30f13072b2134878f14a4a01ee86326cccbff3d079b4df097dc57985e8c8c834a10cb9d766169366"), - k: &hex!("c3de91dbe4f777698773da70dd610ef1a7efe4dc00d734399c7dd100728006a502822a5a7ff9129ffd8adf6c1fc1211a"), - m: &hex!("f11e38f4037ae3ffd0fde97c08e2e5acbc26e3ac5828a86c182232be90ef6fc0f5d21a9b1a7b93472d78c103b4136019"), - r: &hex!("f4f477855819ad8b1763f53691b76afbc4a31a638b1e08c293f9bcd55decf797f9913ca128d4b45b2e2ea3e82c6cf565"), - s: &hex!("7c26be29569ef95480a6d0c1af49dc10a51a0a8931345e48c0c39498bfb94d62962980b56143a7b41a2fddc8794c1b7f"), + d: &hex!( + "ffc7dedeff8343721f72046bc3c126626c177b0e48e247f44fd61f8469d4d5f0a74147fabaa334495cc1f986ebc5f0b1" + ), + q_x: &hex!( + "51c78c979452edd53b563f63eb3e854a5b23e87f1b2103942b65f77d024471f75c8ce1cc0dfef83292b368112aa5126e" + ), + q_y: &hex!( + "313e6aaf09caa3ba30f13072b2134878f14a4a01ee86326cccbff3d079b4df097dc57985e8c8c834a10cb9d766169366" + ), + k: &hex!( + "c3de91dbe4f777698773da70dd610ef1a7efe4dc00d734399c7dd100728006a502822a5a7ff9129ffd8adf6c1fc1211a" + ), + m: &hex!( + "f11e38f4037ae3ffd0fde97c08e2e5acbc26e3ac5828a86c182232be90ef6fc0f5d21a9b1a7b93472d78c103b4136019" + ), + r: &hex!( + "f4f477855819ad8b1763f53691b76afbc4a31a638b1e08c293f9bcd55decf797f9913ca128d4b45b2e2ea3e82c6cf565" + ), + s: &hex!( + "7c26be29569ef95480a6d0c1af49dc10a51a0a8931345e48c0c39498bfb94d62962980b56143a7b41a2fddc8794c1b7f" + ), }, TestVector { - d: &hex!("adca364ef144a21df64b163615e8349cf74ee9dbf728104215c532073a7f74e2f67385779f7f74ab344cc3c7da061cf6"), - q_x: &hex!("ef948daae68242330a7358ef73f23b56c07e37126266db3fa6eea233a04a9b3e4915233dd6754427cd4b71b75854077d"), - q_y: &hex!("009453ef1828eaff9e17c856d4fc1895ab60051312c3e1db1e3766566438b2990cbf9945c2545619e3e0145bc6a79004"), - k: &hex!("a2da3fae2e6da3cf11b49861afb34fba357fea89f54b35ce5ed7434ae09103fe53e2be75b93fc579fedf919f6d5e407e"), - m: &hex!("f8d0170479b2d1a8f50c80556e67ff345592c8b7dcda4e4f6099f993c1a71bff6d3b60190715ae1215a8a759a8eb13df"), - r: &hex!("dda994b9c428b57e9f8bbaebba0d682e3aac6ed828e3a1e99a7fc4c804bff8df151137f539c7389d80e23d9f3ee497bf"), - s: &hex!("a0d6b10ceffd0e1b29cf784476f9173ba6ecd2cfc7929725f2d6e24e0db5a4721683640eaa2bbe151fb57560f9ce594b"), + d: &hex!( + "adca364ef144a21df64b163615e8349cf74ee9dbf728104215c532073a7f74e2f67385779f7f74ab344cc3c7da061cf6" + ), + q_x: &hex!( + "ef948daae68242330a7358ef73f23b56c07e37126266db3fa6eea233a04a9b3e4915233dd6754427cd4b71b75854077d" + ), + q_y: &hex!( + "009453ef1828eaff9e17c856d4fc1895ab60051312c3e1db1e3766566438b2990cbf9945c2545619e3e0145bc6a79004" + ), + k: &hex!( + "a2da3fae2e6da3cf11b49861afb34fba357fea89f54b35ce5ed7434ae09103fe53e2be75b93fc579fedf919f6d5e407e" + ), + m: &hex!( + "f8d0170479b2d1a8f50c80556e67ff345592c8b7dcda4e4f6099f993c1a71bff6d3b60190715ae1215a8a759a8eb13df" + ), + r: &hex!( + "dda994b9c428b57e9f8bbaebba0d682e3aac6ed828e3a1e99a7fc4c804bff8df151137f539c7389d80e23d9f3ee497bf" + ), + s: &hex!( + "a0d6b10ceffd0e1b29cf784476f9173ba6ecd2cfc7929725f2d6e24e0db5a4721683640eaa2bbe151fb57560f9ce594b" + ), }, TestVector { - d: &hex!("39bea008ec8a217866dcbdb1b93da34d1d3e851d011df9ef44b7828b3453a54aa70f1df9932170804eacd207e4f7e91d"), - q_x: &hex!("5709ec4305a9c3271c304face6c148142490b827a73a4c17affcfd01fffd7eaa65d2fdedfa2419fc64ed910823513faf"), - q_y: &hex!("b083cda1cf3be6371b6c06e729ea6299213428db57119347247ec1fcd44204386cc0bca3f452d9d864b39efbfc89d6b2"), - k: &hex!("3c90cc7b6984056f570542a51cbe497ce4c11aeae8fc35e8fd6a0d9adeb650e8644f9d1d5e4341b5adc81e27f284c08f"), - m: &hex!("86bc7536faf2de20028159ce93e293d0a7f5721fb6680b5b070c3f70aba845de2eaed9245144babc38c49cce59f3eac7"), - r: &hex!("d13646895afb1bfd1953551bb922809c95ad65d6abe94eb3719c899aa1f6dba6b01222c7f283900fe98628b7597b6ea6"), - s: &hex!("4a9a38afda04c0a6b0058943b679bd02205b14d0f3d49b8f31aac289129780cdb1c555def8c3f9106b478729e0c7efaa"), + d: &hex!( + "39bea008ec8a217866dcbdb1b93da34d1d3e851d011df9ef44b7828b3453a54aa70f1df9932170804eacd207e4f7e91d" + ), + q_x: &hex!( + "5709ec4305a9c3271c304face6c148142490b827a73a4c17affcfd01fffd7eaa65d2fdedfa2419fc64ed910823513faf" + ), + q_y: &hex!( + "b083cda1cf3be6371b6c06e729ea6299213428db57119347247ec1fcd44204386cc0bca3f452d9d864b39efbfc89d6b2" + ), + k: &hex!( + "3c90cc7b6984056f570542a51cbe497ce4c11aeae8fc35e8fd6a0d9adeb650e8644f9d1d5e4341b5adc81e27f284c08f" + ), + m: &hex!( + "86bc7536faf2de20028159ce93e293d0a7f5721fb6680b5b070c3f70aba845de2eaed9245144babc38c49cce59f3eac7" + ), + r: &hex!( + "d13646895afb1bfd1953551bb922809c95ad65d6abe94eb3719c899aa1f6dba6b01222c7f283900fe98628b7597b6ea6" + ), + s: &hex!( + "4a9a38afda04c0a6b0058943b679bd02205b14d0f3d49b8f31aac289129780cdb1c555def8c3f9106b478729e0c7efaa" + ), }, TestVector { - d: &hex!("e849cf948b241362e3e20c458b52df044f2a72deb0f41c1bb0673e7c04cdd70811215059032b5ca3cc69c345dcce4cf7"), - q_x: &hex!("06c037a0cbf43fdf335dff33de06d34348405353f9fdf2ce1361efba30fb204aea9dbd2e30da0a10fd2d876188371be6"), - q_y: &hex!("360d38f3940e34679204b98fbf70b8a4d97f25443e46d0807ab634ed5891ad864dd7703557aa933cd380e26eea662a43"), - k: &hex!("32386b2593c85e877b70e5e5495936f65dc49553caef1aa6cc14d9cd370c442a0ccfab4c0da9ec311b67913b1b575a9d"), - m: &hex!("1128c8b09573a993adaa0a68f3ca965db30870db46de70d29e3b9a7d110ba0cd57633f1713173c62331b36fb925fa874"), - r: &hex!("5886078d3495767e330c7507b7ca0fa07a50e59912a416d89f0ab1aa4e88153d6eaf00882d1b4aa64153153352d853b5"), - s: &hex!("2cc10023bf1bf8ccfd14b06b82cc2114449a352389c8ff9f6f78cdc4e32bde69f3869da0e17f691b329682ae7a36e1aa"), + d: &hex!( + "e849cf948b241362e3e20c458b52df044f2a72deb0f41c1bb0673e7c04cdd70811215059032b5ca3cc69c345dcce4cf7" + ), + q_x: &hex!( + "06c037a0cbf43fdf335dff33de06d34348405353f9fdf2ce1361efba30fb204aea9dbd2e30da0a10fd2d876188371be6" + ), + q_y: &hex!( + "360d38f3940e34679204b98fbf70b8a4d97f25443e46d0807ab634ed5891ad864dd7703557aa933cd380e26eea662a43" + ), + k: &hex!( + "32386b2593c85e877b70e5e5495936f65dc49553caef1aa6cc14d9cd370c442a0ccfab4c0da9ec311b67913b1b575a9d" + ), + m: &hex!( + "1128c8b09573a993adaa0a68f3ca965db30870db46de70d29e3b9a7d110ba0cd57633f1713173c62331b36fb925fa874" + ), + r: &hex!( + "5886078d3495767e330c7507b7ca0fa07a50e59912a416d89f0ab1aa4e88153d6eaf00882d1b4aa64153153352d853b5" + ), + s: &hex!( + "2cc10023bf1bf8ccfd14b06b82cc2114449a352389c8ff9f6f78cdc4e32bde69f3869da0e17f691b329682ae7a36e1aa" + ), }, TestVector { - d: &hex!("d89607475d509ef23dc9f476eae4280c986de741b63560670fa2bd605f5049f1972792c0413a5b3b4b34e7a38b70b7ca"), - q_x: &hex!("49a1c631f31cf5c45b2676b1f130cbf9be683d0a50dffae0d147c1e9913ab1090c6529a84f47ddc7cf025921b771355a"), - q_y: &hex!("1e207eece62f2bcc6bdabc1113158145170be97469a2904eaaa93aad85b86a19719207f3e423051f5b9cbbe2754eefcb"), - k: &hex!("78613c570c8d33b7dd1bd1561d87e36282e8cf4843e7c344a2b2bb6a0da94756d670eeaffe434f7ae7c780f7cf05ca08"), - m: &hex!("ab9a6d22c8d7675bc8e99e3cafed8318f33051ba5398ce0e9d8e8d3d537a6a908d4c2ace3e6d8204d0236d863eee3c28"), - r: &hex!("66f92b39aa3f4aeb9e2dc03ac3855406fa3ebbab0a6c88a78d7a03482f0c9868d7b78bc081ede0947c7f37bf193074ba"), - s: &hex!("e5c64ed98d7f3701193f25dd237d59c91c0da6e26215e0889d82e6d3e416693f8d58843cf30ab10ab8d0edd9170b53ad"), + d: &hex!( + "d89607475d509ef23dc9f476eae4280c986de741b63560670fa2bd605f5049f1972792c0413a5b3b4b34e7a38b70b7ca" + ), + q_x: &hex!( + "49a1c631f31cf5c45b2676b1f130cbf9be683d0a50dffae0d147c1e9913ab1090c6529a84f47ddc7cf025921b771355a" + ), + q_y: &hex!( + "1e207eece62f2bcc6bdabc1113158145170be97469a2904eaaa93aad85b86a19719207f3e423051f5b9cbbe2754eefcb" + ), + k: &hex!( + "78613c570c8d33b7dd1bd1561d87e36282e8cf4843e7c344a2b2bb6a0da94756d670eeaffe434f7ae7c780f7cf05ca08" + ), + m: &hex!( + "ab9a6d22c8d7675bc8e99e3cafed8318f33051ba5398ce0e9d8e8d3d537a6a908d4c2ace3e6d8204d0236d863eee3c28" + ), + r: &hex!( + "66f92b39aa3f4aeb9e2dc03ac3855406fa3ebbab0a6c88a78d7a03482f0c9868d7b78bc081ede0947c7f37bf193074ba" + ), + s: &hex!( + "e5c64ed98d7f3701193f25dd237d59c91c0da6e26215e0889d82e6d3e416693f8d58843cf30ab10ab8d0edd9170b53ad" + ), }, TestVector { - d: &hex!("083e7152734adf342520ae377087a223688de2899b10cfcb34a0b36bca500a4dfa530e2343e6a39da7ae1eb0862b4a0d"), - q_x: &hex!("70a0f16b6c61172659b027ed19b18fd8f57bd28dc0501f207bd6b0bb065b5671cf3dd1ed13d388dcf6ccc766597aa604"), - q_y: &hex!("4f845bf01c3c3f6126a7368c3454f51425801ee0b72e63fb6799b4420bfdebe3e37c7246db627cc82c09654979c700bb"), - k: &hex!("28096ababe29a075fbdf894709a20d0fdedb01ed3eeacb642a33a0da6aed726e13caf6cf206792ec359f0c9f9b567552"), - m: &hex!("68f858243fe465eb91dc2481333cbb1958883ef25099d45cf02721d17d2846d2cec4689884ae7c0412332e035a1fa3fc"), - r: &hex!("ee2923f9b9999ea05b5e57f505bed5c6ba0420def42c6fa90eef7a6ef770786525546de27cdeb2f8586f8f29fb4ee67c"), - s: &hex!("50ef923fb217c4cf65a48b94412fda430fac685f0da7bd574557c6c50f5b22e0c8354d99f2c2f2c2691f252f93c7d84a"), + d: &hex!( + "083e7152734adf342520ae377087a223688de2899b10cfcb34a0b36bca500a4dfa530e2343e6a39da7ae1eb0862b4a0d" + ), + q_x: &hex!( + "70a0f16b6c61172659b027ed19b18fd8f57bd28dc0501f207bd6b0bb065b5671cf3dd1ed13d388dcf6ccc766597aa604" + ), + q_y: &hex!( + "4f845bf01c3c3f6126a7368c3454f51425801ee0b72e63fb6799b4420bfdebe3e37c7246db627cc82c09654979c700bb" + ), + k: &hex!( + "28096ababe29a075fbdf894709a20d0fdedb01ed3eeacb642a33a0da6aed726e13caf6cf206792ec359f0c9f9b567552" + ), + m: &hex!( + "68f858243fe465eb91dc2481333cbb1958883ef25099d45cf02721d17d2846d2cec4689884ae7c0412332e035a1fa3fc" + ), + r: &hex!( + "ee2923f9b9999ea05b5e57f505bed5c6ba0420def42c6fa90eef7a6ef770786525546de27cdeb2f8586f8f29fb4ee67c" + ), + s: &hex!( + "50ef923fb217c4cf65a48b94412fda430fac685f0da7bd574557c6c50f5b22e0c8354d99f2c2f2c2691f252f93c7d84a" + ), }, TestVector { - d: &hex!("63578d416215aff2cc78f9b926d4c7740a77c142944e104aa7422b19a616898262d46a8a942d5e8d5db135ee8b09a368"), - q_x: &hex!("cadbacef4406099316db2ce3206adc636c2bb0a835847ed7941efb02862472f3150338f13f4860d47f39b7e098f0a390"), - q_y: &hex!("752ad0f22c9c264336cde11bbc95d1816ed4d1b1500db6b8dce259a42832e613c31178c2c7995206a62e201ba108f570"), - k: &hex!("7b69c5d5b4d05c9950dc94c27d58403b4c52c004b80a80418ad3a89aabc5d34f21926729e76afd280cc8ee88c9805a2a"), - m: &hex!("dca5ebfebeac1696eff4a89162469c6937b80f8f8cf17299856de2e13d8f8a199bff3085cee59366886164bcc03f7e90"), - r: &hex!("db054addb6161ee49c6ce2e4d646d7670754747b6737ca8516e9d1e87859937c3ef9b1d2663e10d7e4bd00ec85b7a97a"), - s: &hex!("fcc504e0f00ef29587e4bc22faada4db30e2cb1ac552680a65785ae87beb666c792513f2be7a3180fc544296841a0e27"), + d: &hex!( + "63578d416215aff2cc78f9b926d4c7740a77c142944e104aa7422b19a616898262d46a8a942d5e8d5db135ee8b09a368" + ), + q_x: &hex!( + "cadbacef4406099316db2ce3206adc636c2bb0a835847ed7941efb02862472f3150338f13f4860d47f39b7e098f0a390" + ), + q_y: &hex!( + "752ad0f22c9c264336cde11bbc95d1816ed4d1b1500db6b8dce259a42832e613c31178c2c7995206a62e201ba108f570" + ), + k: &hex!( + "7b69c5d5b4d05c9950dc94c27d58403b4c52c004b80a80418ad3a89aabc5d34f21926729e76afd280cc8ee88c9805a2a" + ), + m: &hex!( + "dca5ebfebeac1696eff4a89162469c6937b80f8f8cf17299856de2e13d8f8a199bff3085cee59366886164bcc03f7e90" + ), + r: &hex!( + "db054addb6161ee49c6ce2e4d646d7670754747b6737ca8516e9d1e87859937c3ef9b1d2663e10d7e4bd00ec85b7a97a" + ), + s: &hex!( + "fcc504e0f00ef29587e4bc22faada4db30e2cb1ac552680a65785ae87beb666c792513f2be7a3180fc544296841a0e27" + ), }, TestVector { - d: &hex!("ed4df19971658b74868800b3b81bc877807743b25c65740f1d6377542afe2c6427612c840ada31a8eb794718f37c7283"), - q_x: &hex!("33093a0568757e8b58df5b72ea5fe5bf26e6f7aeb541b4c6a8c189c93721749bcaceccf2982a2f0702586a9f812fc66f"), - q_y: &hex!("ebe320d09e1f0662189d50b85a20403b821ac0d000afdbf66a0a33f304726c69e354d81c50b94ba3a5250efc31319cd1"), - k: &hex!("d9b4cd1bdfa83e608289634dbfcee643f07315baf743fc91922880b55a2feda3b38ddf6040d3ba10985cd1285fc690d5"), - m: &hex!("f9b152150f7dc99d5262c9da04dde148009730fb2af9ac753b9c64488d27c817f68c17ae1ff61e50ebb6749230c59a71"), - r: &hex!("009c74063e206a4259b53decff5445683a03f44fa67252b76bd3581081c714f882f882df915e97dbeab061fa8b3cc4e7"), - s: &hex!("d40e09d3468b46699948007e8f59845766dbf694b9c62066890dd055c0cb9a0caf0aa611fb9f466ad0bbb00dbe29d7eb"), + d: &hex!( + "ed4df19971658b74868800b3b81bc877807743b25c65740f1d6377542afe2c6427612c840ada31a8eb794718f37c7283" + ), + q_x: &hex!( + "33093a0568757e8b58df5b72ea5fe5bf26e6f7aeb541b4c6a8c189c93721749bcaceccf2982a2f0702586a9f812fc66f" + ), + q_y: &hex!( + "ebe320d09e1f0662189d50b85a20403b821ac0d000afdbf66a0a33f304726c69e354d81c50b94ba3a5250efc31319cd1" + ), + k: &hex!( + "d9b4cd1bdfa83e608289634dbfcee643f07315baf743fc91922880b55a2feda3b38ddf6040d3ba10985cd1285fc690d5" + ), + m: &hex!( + "f9b152150f7dc99d5262c9da04dde148009730fb2af9ac753b9c64488d27c817f68c17ae1ff61e50ebb6749230c59a71" + ), + r: &hex!( + "009c74063e206a4259b53decff5445683a03f44fa67252b76bd3581081c714f882f882df915e97dbeab061fa8b3cc4e7" + ), + s: &hex!( + "d40e09d3468b46699948007e8f59845766dbf694b9c62066890dd055c0cb9a0caf0aa611fb9f466ad0bbb00dbe29d7eb" + ), }, TestVector { - d: &hex!("e9c7e9a79618d6ff3274da1abd0ff3ed0ec1ae3b54c3a4fd8d68d98fb04326b7633fc637e0b195228d0edba6bb1468fb"), - q_x: &hex!("a39ac353ca787982c577aff1e8601ce192aa90fd0de4c0ed627f66a8b6f02ae51315543f72ffc1c48a7269b25e7c289a"), - q_y: &hex!("9064a507b66b340b6e0e0d5ffaa67dd20e6dafc0ea6a6faee1635177af256f9108a22e9edf736ab4ae8e96dc207b1fa9"), - k: &hex!("b094cb3a5c1440cfab9dc56d0ec2eff00f2110dea203654c70757254aa5912a7e73972e607459b1f4861e0b08a5cc763"), - m: &hex!("14f785ebb5a3b1bdff516a6b580e245b3c81aff37e1035e354b084a6691e973e0de30bb2a0490fca2d757f8191d7560a"), - r: &hex!("ee82c0f90501136eb0dc0e459ad17bf3be1b1c8b8d05c60068a9306a346326ff7344776a95f1f7e2e2cf9477130e735c"), - s: &hex!("af10b90f203af23b7500e070536e64629ba19245d6ef39aab57fcdb1b73c4c6bf7070c6263544633d3d358c12a178138"), + d: &hex!( + "e9c7e9a79618d6ff3274da1abd0ff3ed0ec1ae3b54c3a4fd8d68d98fb04326b7633fc637e0b195228d0edba6bb1468fb" + ), + q_x: &hex!( + "a39ac353ca787982c577aff1e8601ce192aa90fd0de4c0ed627f66a8b6f02ae51315543f72ffc1c48a7269b25e7c289a" + ), + q_y: &hex!( + "9064a507b66b340b6e0e0d5ffaa67dd20e6dafc0ea6a6faee1635177af256f9108a22e9edf736ab4ae8e96dc207b1fa9" + ), + k: &hex!( + "b094cb3a5c1440cfab9dc56d0ec2eff00f2110dea203654c70757254aa5912a7e73972e607459b1f4861e0b08a5cc763" + ), + m: &hex!( + "14f785ebb5a3b1bdff516a6b580e245b3c81aff37e1035e354b084a6691e973e0de30bb2a0490fca2d757f8191d7560a" + ), + r: &hex!( + "ee82c0f90501136eb0dc0e459ad17bf3be1b1c8b8d05c60068a9306a346326ff7344776a95f1f7e2e2cf9477130e735c" + ), + s: &hex!( + "af10b90f203af23b7500e070536e64629ba19245d6ef39aab57fcdb1b73c4c6bf7070c6263544633d3d358c12a178138" + ), }, ]; diff --git a/p384/src/test_vectors/group.rs b/p384/src/test_vectors/group.rs index e95399c05..f07f04580 100644 --- a/p384/src/test_vectors/group.rs +++ b/p384/src/test_vectors/group.rs @@ -7,85 +7,165 @@ use hex_literal::hex; /// These are the first 20 test vectors from pub const ADD_TEST_VECTORS: &[([u8; 48], [u8; 48])] = &[ ( - hex!("AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"), - hex!("3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F") + hex!( + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" + ), + hex!( + "3617DE4A96262C6F5D9E98BF9292DC29F8F41DBD289A147CE9DA3113B5F0B8C00A60B1CE1D7E819D7A431D7C90EA0E5F" + ), ), - ( - hex!("08D999057BA3D2D969260045C55B97F089025959A6F434D651D207D19FB96E9E4FE0E86EBE0E64F85B96A9C75295DF61"), - hex!("8E80F1FA5B1B3CEDB7BFE8DFFD6DBA74B275D875BC6CC43E904E505F256AB4255FFD43E94D39E22D61501E700A940E80") + ( + hex!( + "08D999057BA3D2D969260045C55B97F089025959A6F434D651D207D19FB96E9E4FE0E86EBE0E64F85B96A9C75295DF61" + ), + hex!( + "8E80F1FA5B1B3CEDB7BFE8DFFD6DBA74B275D875BC6CC43E904E505F256AB4255FFD43E94D39E22D61501E700A940E80" + ), ), - ( - hex!("077A41D4606FFA1464793C7E5FDC7D98CB9D3910202DCD06BEA4F240D3566DA6B408BBAE5026580D02D7E5C70500C831"), - hex!("C995F7CA0B0C42837D0BBE9602A9FC998520B41C85115AA5F7684C0EDC111EACC24ABD6BE4B5D298B65F28600A2F1DF1") + ( + hex!( + "077A41D4606FFA1464793C7E5FDC7D98CB9D3910202DCD06BEA4F240D3566DA6B408BBAE5026580D02D7E5C70500C831" + ), + hex!( + "C995F7CA0B0C42837D0BBE9602A9FC998520B41C85115AA5F7684C0EDC111EACC24ABD6BE4B5D298B65F28600A2F1DF1" + ), ), - ( - hex!("138251CD52AC9298C1C8AAD977321DEB97E709BD0B4CA0ACA55DC8AD51DCFC9D1589A1597E3A5120E1EFD631C63E1835"), - hex!("CACAE29869A62E1631E8A28181AB56616DC45D918ABC09F3AB0E63CF792AA4DCED7387BE37BBA569549F1C02B270ED67") + ( + hex!( + "138251CD52AC9298C1C8AAD977321DEB97E709BD0B4CA0ACA55DC8AD51DCFC9D1589A1597E3A5120E1EFD631C63E1835" + ), + hex!( + "CACAE29869A62E1631E8A28181AB56616DC45D918ABC09F3AB0E63CF792AA4DCED7387BE37BBA569549F1C02B270ED67" + ), ), - ( - hex!("11DE24A2C251C777573CAC5EA025E467F208E51DBFF98FC54F6661CBE56583B037882F4A1CA297E60ABCDBC3836D84BC"), - hex!("8FA696C77440F92D0F5837E90A00E7C5284B447754D5DEE88C986533B6901AEB3177686D0AE8FB33184414ABE6C1713A") + ( + hex!( + "11DE24A2C251C777573CAC5EA025E467F208E51DBFF98FC54F6661CBE56583B037882F4A1CA297E60ABCDBC3836D84BC" + ), + hex!( + "8FA696C77440F92D0F5837E90A00E7C5284B447754D5DEE88C986533B6901AEB3177686D0AE8FB33184414ABE6C1713A" + ), ), - ( - hex!("627BE1ACD064D2B2226FE0D26F2D15D3C33EBCBB7F0F5DA51CBD41F26257383021317D7202FF30E50937F0854E35C5DF"), - hex!("09766A4CB3F8B1C21BE6DDA6C14F1575B2C95352644F774C99864F613715441604C45B8D84E165311733A408D3F0F934") + ( + hex!( + "627BE1ACD064D2B2226FE0D26F2D15D3C33EBCBB7F0F5DA51CBD41F26257383021317D7202FF30E50937F0854E35C5DF" + ), + hex!( + "09766A4CB3F8B1C21BE6DDA6C14F1575B2C95352644F774C99864F613715441604C45B8D84E165311733A408D3F0F934" + ), ), - ( - hex!("283C1D7365CE4788F29F8EBF234EDFFEAD6FE997FBEA5FFA2D58CC9DFA7B1C508B05526F55B9EBB2040F05B48FB6D0E1"), - hex!("9475C99061E41B88BA52EFDB8C1690471A61D867ED799729D9C92CD01DBD225630D84EDE32A78F9E64664CDAC512EF8C") + ( + hex!( + "283C1D7365CE4788F29F8EBF234EDFFEAD6FE997FBEA5FFA2D58CC9DFA7B1C508B05526F55B9EBB2040F05B48FB6D0E1" + ), + hex!( + "9475C99061E41B88BA52EFDB8C1690471A61D867ED799729D9C92CD01DBD225630D84EDE32A78F9E64664CDAC512EF8C" + ), ), - ( - hex!("1692778EA596E0BE75114297A6FA383445BF227FBE58190A900C3C73256F11FB5A3258D6F403D5ECE6E9B269D822C87D"), - hex!("DCD2365700D4106A835388BA3DB8FD0E22554ADC6D521CD4BD1C30C2EC0EEC196BADE1E9CDD1708D6F6ABFA4022B0AD2") + ( + hex!( + "1692778EA596E0BE75114297A6FA383445BF227FBE58190A900C3C73256F11FB5A3258D6F403D5ECE6E9B269D822C87D" + ), + hex!( + "DCD2365700D4106A835388BA3DB8FD0E22554ADC6D521CD4BD1C30C2EC0EEC196BADE1E9CDD1708D6F6ABFA4022B0AD2" + ), ), ( - hex!("8F0A39A4049BCB3EF1BF29B8B025B78F2216F7291E6FD3BAC6CB1EE285FB6E21C388528BFEE2B9535C55E4461079118B"), - hex!("62C77E1438B601D6452C4A5322C3A9799A9B3D7CA3C400C6B7678854AED9B3029E743EFEDFD51B68262DA4F9AC664AF8") + hex!( + "8F0A39A4049BCB3EF1BF29B8B025B78F2216F7291E6FD3BAC6CB1EE285FB6E21C388528BFEE2B9535C55E4461079118B" + ), + hex!( + "62C77E1438B601D6452C4A5322C3A9799A9B3D7CA3C400C6B7678854AED9B3029E743EFEDFD51B68262DA4F9AC664AF8" + ), ), ( - hex!("A669C5563BD67EEC678D29D6EF4FDE864F372D90B79B9E88931D5C29291238CCED8E85AB507BF91AA9CB2D13186658FB"), - hex!("A988B72AE7C1279F22D9083DB5F0ECDDF70119550C183C31C502DF78C3B705A8296D8195248288D997784F6AB73A21DD") + hex!( + "A669C5563BD67EEC678D29D6EF4FDE864F372D90B79B9E88931D5C29291238CCED8E85AB507BF91AA9CB2D13186658FB" + ), + hex!( + "A988B72AE7C1279F22D9083DB5F0ECDDF70119550C183C31C502DF78C3B705A8296D8195248288D997784F6AB73A21DD" + ), ), ( - hex!("099056E27DA7B998DA1EEEC2904816C57FE935ED5837C37456C9FD14892D3F8C4749B66E3AFB81D626356F3B55B4DDD8"), - hex!("2E4C0C234E30AB96688505544AC5E0396FC4EED8DFC363FD43FF93F41B52A3255466D51263AAFF357D5DBA8138C5E0BB") + hex!( + "099056E27DA7B998DA1EEEC2904816C57FE935ED5837C37456C9FD14892D3F8C4749B66E3AFB81D626356F3B55B4DDD8" + ), + hex!( + "2E4C0C234E30AB96688505544AC5E0396FC4EED8DFC363FD43FF93F41B52A3255466D51263AAFF357D5DBA8138C5E0BB" + ), ), ( - hex!("952A7A349BD49289AB3AC421DCF683D08C2ED5E41F6D0E21648AF2691A481406DA4A5E22DA817CB466DA2EA77D2A7022"), - hex!("A0320FAF84B5BC0563052DEAE6F66F2E09FB8036CE18A0EBB9028B096196B50D031AA64589743E229EF6BACCE21BD16E") + hex!( + "952A7A349BD49289AB3AC421DCF683D08C2ED5E41F6D0E21648AF2691A481406DA4A5E22DA817CB466DA2EA77D2A7022" + ), + hex!( + "A0320FAF84B5BC0563052DEAE6F66F2E09FB8036CE18A0EBB9028B096196B50D031AA64589743E229EF6BACCE21BD16E" + ), ), ( - hex!("A567BA97B67AEA5BAFDAF5002FFCC6AB9632BFF9F01F873F6267BCD1F0F11C139EE5F441ABD99F1BAAF1CA1E3B5CBCE7"), - hex!("DE1B38B3989F3318644E4147AF164ECC5185595046932EC086329BE057857D66776BCB8272218A7D6423A12736F429CC") + hex!( + "A567BA97B67AEA5BAFDAF5002FFCC6AB9632BFF9F01F873F6267BCD1F0F11C139EE5F441ABD99F1BAAF1CA1E3B5CBCE7" + ), + hex!( + "DE1B38B3989F3318644E4147AF164ECC5185595046932EC086329BE057857D66776BCB8272218A7D6423A12736F429CC" + ), ), ( - hex!("E8C8F94D44FBC2396BBEAC481B89D2B0877B1DFFD23E7DC95DE541EB651CCA2C41ABA24DBC02DE6637209ACCF0F59EA0"), - hex!("891AE44356FC8AE0932BCBF6DE52C8A933B86191E7728D79C8319413A09D0F48FC468BA05509DE22D7EE5C9E1B67B888") + hex!( + "E8C8F94D44FBC2396BBEAC481B89D2B0877B1DFFD23E7DC95DE541EB651CCA2C41ABA24DBC02DE6637209ACCF0F59EA0" + ), + hex!( + "891AE44356FC8AE0932BCBF6DE52C8A933B86191E7728D79C8319413A09D0F48FC468BA05509DE22D7EE5C9E1B67B888" + ), ), ( - hex!("B3D13FC8B32B01058CC15C11D813525522A94156FFF01C205B21F9F7DA7C4E9CA849557A10B6383B4B88701A9606860B"), - hex!("152919E7DF9162A61B049B2536164B1BEEBAC4A11D749AF484D1114373DFBFD9838D24F8B284AF50985D588D33F7BD62") + hex!( + "B3D13FC8B32B01058CC15C11D813525522A94156FFF01C205B21F9F7DA7C4E9CA849557A10B6383B4B88701A9606860B" + ), + hex!( + "152919E7DF9162A61B049B2536164B1BEEBAC4A11D749AF484D1114373DFBFD9838D24F8B284AF50985D588D33F7BD62" + ), ), ( - hex!("D5D89C3B5282369C5FBD88E2B231511A6B80DFF0E5152CF6A464FA9428A8583BAC8EBC773D157811A462B892401DAFCF"), - hex!("D815229DE12906D241816D5E9A9448F1D41D4FC40E2A3BDB9CABA57E440A7ABAD1210CB8F49BF2236822B755EBAB3673") + hex!( + "D5D89C3B5282369C5FBD88E2B231511A6B80DFF0E5152CF6A464FA9428A8583BAC8EBC773D157811A462B892401DAFCF" + ), + hex!( + "D815229DE12906D241816D5E9A9448F1D41D4FC40E2A3BDB9CABA57E440A7ABAD1210CB8F49BF2236822B755EBAB3673" + ), ), ( - hex!("4099952208B4889600A5EBBCB13E1A32692BEFB0733B41E6DCC614E42E5805F817012A991AF1F486CAF3A9ADD9FFCC03"), - hex!("5ECF94777833059839474594AF603598163AD3F8008AD0CD9B797D277F2388B304DA4D2FAA9680ECFA650EF5E23B09A0") + hex!( + "4099952208B4889600A5EBBCB13E1A32692BEFB0733B41E6DCC614E42E5805F817012A991AF1F486CAF3A9ADD9FFCC03" + ), + hex!( + "5ECF94777833059839474594AF603598163AD3F8008AD0CD9B797D277F2388B304DA4D2FAA9680ECFA650EF5E23B09A0" + ), ), ( - hex!("DFB1FE3A40F7AC9B64C41D39360A7423828B97CB088A4903315E402A7089FA0F8B6C2355169CC9C99DFB44692A9B93DD"), - hex!("453ACA1243B5EC6B423A68A25587E1613A634C1C42D2EE7E6C57F449A1C91DC89168B7036EC0A7F37A366185233EC522") + hex!( + "DFB1FE3A40F7AC9B64C41D39360A7423828B97CB088A4903315E402A7089FA0F8B6C2355169CC9C99DFB44692A9B93DD" + ), + hex!( + "453ACA1243B5EC6B423A68A25587E1613A634C1C42D2EE7E6C57F449A1C91DC89168B7036EC0A7F37A366185233EC522" + ), ), ( - hex!("8D481DAB912BC8AB16858A211D750B77E07DBECCA86CD9B012390B430467AABF59C8651060801C0E9599E68713F5D41B"), - hex!("A1592FF0121460857BE99F2A60669050B2291B68A1039AA0594B32FD7ADC0E8C11FFBA5608004E646995B07E75E52245") + hex!( + "8D481DAB912BC8AB16858A211D750B77E07DBECCA86CD9B012390B430467AABF59C8651060801C0E9599E68713F5D41B" + ), + hex!( + "A1592FF0121460857BE99F2A60669050B2291B68A1039AA0594B32FD7ADC0E8C11FFBA5608004E646995B07E75E52245" + ), ), ( - hex!("605508EC02C534BCEEE9484C86086D2139849E2B11C1A9CA1E2808DEC2EAF161AC8A105D70D4F85C50599BE5800A623F"), - hex!("5158EE87962AC6B81F00A103B8543A07381B7639A3A65F1353AEF11B733106DDE92E99B78DE367B48E238C38DAD8EEDD") - ) + hex!( + "605508EC02C534BCEEE9484C86086D2139849E2B11C1A9CA1E2808DEC2EAF161AC8A105D70D4F85C50599BE5800A623F" + ), + hex!( + "5158EE87962AC6B81F00A103B8543A07381B7639A3A65F1353AEF11B733106DDE92E99B78DE367B48E238C38DAD8EEDD" + ), + ), ]; /// Scalar multiplication with the generator. @@ -94,163 +174,355 @@ pub const ADD_TEST_VECTORS: &[([u8; 48], [u8; 48])] = &[ /// part of [`ADD_TEST_VECTORS`]. pub const MUL_TEST_VECTORS: &[([u8; 48], [u8; 48], [u8; 48])] = &[ ( - hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000018ebbb95eed0e13"), - hex!("A499EFE48839BC3ABCD1C5CEDBDD51904F9514DB44F4686DB918983B0C9DC3AEE05A88B72433E9515F91A329F5F4FA60"), - hex!("3B7CA28EF31F809C2F1BA24AAED847D0F8B406A4B8968542DE139DB5828CA410E615D1182E25B91B1131E230B727D36A"), - ), - ( - hex!("000000000000000000000000000000000000000000000000000000000000000000159d893d4cdd747246cdca43590e13"), - hex!("90A0B1CAC601676B083F21E07BC7090A3390FE1B9C7F61D842D27FA315FB38D83667A11A71438773E483F2A114836B24"), - hex!("3197D3C6123F0D6CD65D5F0DE106FEF36656CB16DC7CD1A6817EB1D51510135A8F492F72665CFD1053F75ED03A7D04C9"), - ), - ( - hex!("41ffc1fffffe01fffc0003fffe0007c001fff00003fff07ffe0007c000000003ffffff807fff8007fffff800fffe0000"), - hex!("F2A066BD332DC59BBC3D01DA1B124C687D8BB44611186422DE94C1DA4ECF150E664D353CCDB5CB2652685F8EB4D2CD49"), - hex!("D6ED0BF75FDD8E53D87765FA746835B673881D6D1907163A2C43990D75B454294F942EC571AD5AAE1806CAF2BB8E9A4A"), - ), - ( - hex!("400000003803ffffffcfffffe0800000001ffffe03ffff1ffff801fffffffff8000001fffff800ffffff8001fffc7fff"), - hex!("5C7F9845D1C4AA44747F9137B6F9C39B36B26B8A62E8AF97290434D5F3B214F5A0131550ADB19058DC4C8780C4165C4A"), - hex!("712F7FCCC86F647E70DB8798228CB16344AF3D00B139B6F8502939C2A965AF0EB4E39E2E16AB8F597B8D5630A50C9D85"), - ), - ( - hex!("4000008000fffffc000003f00000ffffffff800003800f8000e0000e000000ffffffe00000ffffffc0007e0000000fe0"), - hex!("DD5838F7EC3B8ACF1BECFD746F8B668C577107E93548ED93ED0D254C112E76B10F053109EF8428BFCD50D38C4C030C57"), - hex!("33244F479CDAC34F160D9E4CE2D19D2FF0E3305B5BF0EEF29E91E9DE6E28F678C61B773AA7E3C03740E1A49D1AA2493C"), - ), - ( - hex!("000000001ffc000000fff030001f0000fffff0000038000000000002003f007ffffff0000000000000ffe00000000000"), - hex!("CB8ED893530BFBA04B4CA655923AAAD109A62BC8411D5925316C32D33602459C33057A1FBCB5F70AEB295D90F9165FBC"), - hex!("426AEE3E91B08420F9B357B66D5AFCBCF3956590BF5564DBF9086042EB880493D19DA39AAA6436C6B5FC66CE5596B43F"), - ), - ( - hex!("000fffe0800001ff0001fffffff0000ffffffffffffff80000fffffc1fffffffffffff001ffffffffffffbffffe01ffc"), - hex!("67F714012B6B070182122DDD435CC1C2262A1AB88939BC6A2906CB2B4137C5E82B4582160F6403CAB887ACDF5786A268"), - hex!("90E31CF398CE2F8C5897C7380BF541075D1B4D3CB70547262B7095731252F181AC0597C66AF8311C7780DB39DEC0BD32"), - ), - ( - hex!("07fffe0001fffff800fff800001ffff0001fffffe001fffc0000003ffe03fffffff80ffff01ffff20001c0003f0001ff"), - hex!("55A79DF7B53A99D31462C7E1A5ED5623970715BB1021098CB973A7520CBD6365E613E4B2467486FB37E86E01CEE09B8F"), - hex!("B95AEB71693189911661B709A886A1867F056A0EFE401EE11C06030E46F7A87731DA4575863178012208707DD666727C"), - ), - ( - hex!("0000003fff87effe07fe7ffffe07ffe07f0000000003fe007fff03e07c07ffe0007f0017fffffe000003fffff007ffff"), - hex!("9539A968CF819A0E52E10EEA3BACA1B6480D7E4DF69BC07002C568569047110EE4FE72FCA423FDD5179D6E0E19C44844"), - hex!("A7728F37A0AE0DF2716061900D83A4DA149144129F89A214A8260464BAB609BB322E4E67DE5E4C4C6CB8D25983EC19B0"), - ), - ( - hex!("00ffffff0000007e07fffff80031ffeffdffffc3fffffffff01fffffffff80000000007fc000fc000000004003ffc000"), - hex!("933FC13276672AB360D909161CD02D830B1628935DF0D800C6ED602C59D575A86A8A97E3A2D697E3ED06BE741C0097D6"), - hex!("F35296BD7A6B4C6C025ED6D84338CCCC7522A45C5D4FBDB1442556CAEFB598128FA188793ADA510EB5F44E90A4E4BEF1"), - ), - ( - hex!("00001fff803ff8000001fff000ffffffe3fff000000007ffdff80000003fff007fffffc01ffffff9ffffe001fc000000"), - hex!("0CE31E1C4A937071E6EBACA026A93D783848BCC0C1585DAF639518125FCD1F1629D63041ABFB11FFC8F03FA8B6FCF6BF"), - hex!("A69EA55BE4BEAB2D5224050FEBFFBDFCFD614624C3B4F228909EB80012F003756D1C377E52F04FA539237F24DD080E2E"), - ), - ( - hex!("7ff0001fff000fffffffff80007ffc0003f80001fff8000000001fc000000fff000000007ffc01fffc020000003fc000"), - hex!("6842CFE3589AC268818291F31D44177A9168DCBC19F321ED66D81ECF59E31B54CCA0DDFD4C4136780171748D69A91C54"), - hex!("E3A5ECD5AC725F13DBC631F358C6E817EDCF3A613B83832741A9DB591A0BAE767FC714F70C2E7EA891E4312047DECCC0"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5295f"), - hex!("605508EC02C534BCEEE9484C86086D2139849E2B11C1A9CA1E2808DEC2EAF161AC8A105D70D4F85C50599BE5800A623F"), - hex!("AEA7117869D53947E0FF5EFC47ABC5F8C7E489C65C59A0ECAC510EE48CCEF92116D16647721C984B71DC73C825271122"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52960"), - hex!("8D481DAB912BC8AB16858A211D750B77E07DBECCA86CD9B012390B430467AABF59C8651060801C0E9599E68713F5D41B"), - hex!("5EA6D00FEDEB9F7A841660D59F996FAF4DD6E4975EFC655FA6B4CD028523F172EE0045A8F7FFB19B966A4F828A1ADDBA"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52961"), - hex!("DFB1FE3A40F7AC9B64C41D39360A7423828B97CB088A4903315E402A7089FA0F8B6C2355169CC9C99DFB44692A9B93DD"), - hex!("BAC535EDBC4A1394BDC5975DAA781E9EC59CB3E3BD2D118193A80BB65E36E2366E9748FB913F580C85C99E7BDCC13ADD"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52962"), - hex!("4099952208B4889600A5EBBCB13E1A32692BEFB0733B41E6DCC614E42E5805F817012A991AF1F486CAF3A9ADD9FFCC03"), - hex!("A1306B8887CCFA67C6B8BA6B509FCA67E9C52C07FF752F32648682D880DC774BFB25B2CF55697F13059AF10B1DC4F65F"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52963"), - hex!("D5D89C3B5282369C5FBD88E2B231511A6B80DFF0E5152CF6A464FA9428A8583BAC8EBC773D157811A462B892401DAFCF"), - hex!("27EADD621ED6F92DBE7E92A1656BB70E2BE2B03BF1D5C42463545A81BBF585442EDEF3460B640DDC97DD48AB1454C98C"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52964"), - hex!("B3D13FC8B32B01058CC15C11D813525522A94156FFF01C205B21F9F7DA7C4E9CA849557A10B6383B4B88701A9606860B"), - hex!("EAD6E618206E9D59E4FB64DAC9E9B4E411453B5EE28B650B7B2EEEBC8C2040257C72DB064D7B50AF67A2A773CC08429D"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52965"), - hex!("E8C8F94D44FBC2396BBEAC481B89D2B0877B1DFFD23E7DC95DE541EB651CCA2C41ABA24DBC02DE6637209ACCF0F59EA0"), - hex!("76E51BBCA903751F6CD4340921AD3756CC479E6E188D728637CE6BEC5F62F0B603B9745EAAF621DD2811A362E4984777"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52966"), - hex!("A567BA97B67AEA5BAFDAF5002FFCC6AB9632BFF9F01F873F6267BCD1F0F11C139EE5F441ABD99F1BAAF1CA1E3B5CBCE7"), - hex!("21E4C74C6760CCE79BB1BEB850E9B133AE7AA6AFB96CD13F79CD641FA87A82988894347C8DDE75829BDC5ED9C90BD633"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52967"), - hex!("952A7A349BD49289AB3AC421DCF683D08C2ED5E41F6D0E21648AF2691A481406DA4A5E22DA817CB466DA2EA77D2A7022"), - hex!("5FCDF0507B4A43FA9CFAD215190990D1F6047FC931E75F1446FD74F69E694AF1FCE559B9768BC1DD610945341DE42E91"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52968"), - hex!("099056E27DA7B998DA1EEEC2904816C57FE935ED5837C37456C9FD14892D3F8C4749B66E3AFB81D626356F3B55B4DDD8"), - hex!("D1B3F3DCB1CF5469977AFAABB53A1FC6903B1127203C9C02BC006C0BE4AD5CD9AB992AEC9C5500CA82A2457FC73A1F44"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52969"), - hex!("A669C5563BD67EEC678D29D6EF4FDE864F372D90B79B9E88931D5C29291238CCED8E85AB507BF91AA9CB2D13186658FB"), - hex!("567748D5183ED860DD26F7C24A0F132208FEE6AAF3E7C3CE3AFD20873C48FA56D6927E69DB7D77266887B09648C5DE22"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296a"), - hex!("8F0A39A4049BCB3EF1BF29B8B025B78F2216F7291E6FD3BAC6CB1EE285FB6E21C388528BFEE2B9535C55E4461079118B"), - hex!("9D3881EBC749FE29BAD3B5ACDD3C56866564C2835C3BFF39489877AB51264CFC618BC100202AE497D9D25B075399B507"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296b"), - hex!("1692778EA596E0BE75114297A6FA383445BF227FBE58190A900C3C73256F11FB5A3258D6F403D5ECE6E9B269D822C87D"), - hex!("232DC9A8FF2BEF957CAC7745C24702F1DDAAB52392ADE32B42E3CF3D13F113E594521E15322E8F729095405CFDD4F52D"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296c"), - hex!("283C1D7365CE4788F29F8EBF234EDFFEAD6FE997FBEA5FFA2D58CC9DFA7B1C508B05526F55B9EBB2040F05B48FB6D0E1"), - hex!("6B8A366F9E1BE47745AD102473E96FB8E59E2798128668D62636D32FE242DDA8CF27B120CD5870619B99B3263AED1073"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296d"), - hex!("627BE1ACD064D2B2226FE0D26F2D15D3C33EBCBB7F0F5DA51CBD41F26257383021317D7202FF30E50937F0854E35C5DF"), - hex!("F68995B34C074E3DE41922593EB0EA8A4D36ACAD9BB088B36679B09EC8EABBE8FB3BA4717B1E9ACEE8CC5BF82C0F06CB"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296e"), - hex!("11DE24A2C251C777573CAC5EA025E467F208E51DBFF98FC54F6661CBE56583B037882F4A1CA297E60ABCDBC3836D84BC"), - hex!("705969388BBF06D2F0A7C816F5FF183AD7B4BB88AB2A211773679ACC496FE513CE889791F51704CCE7BBEB55193E8EC5"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296f"), - hex!("138251CD52AC9298C1C8AAD977321DEB97E709BD0B4CA0ACA55DC8AD51DCFC9D1589A1597E3A5120E1EFD631C63E1835"), - hex!("35351D679659D1E9CE175D7E7E54A99E923BA26E7543F60C54F19C3086D55B22128C7840C8445A96AB60E3FE4D8F1298"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970"), - hex!("077A41D4606FFA1464793C7E5FDC7D98CB9D3910202DCD06BEA4F240D3566DA6B408BBAE5026580D02D7E5C70500C831"), - hex!("366A0835F4F3BD7C82F44169FD5603667ADF4BE37AEEA55A0897B3F123EEE1523DB542931B4A2D6749A0D7A0F5D0E20E"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52971"), - hex!("08D999057BA3D2D969260045C55B97F089025959A6F434D651D207D19FB96E9E4FE0E86EBE0E64F85B96A9C75295DF61"), - hex!("717F0E05A4E4C312484017200292458B4D8A278A43933BC16FB1AFA0DA954BD9A002BC15B2C61DD29EAFE190F56BF17F"), - ), - ( - hex!("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52972"), - hex!("AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7"), - hex!("C9E821B569D9D390A26167406D6D23D6070BE242D765EB831625CEEC4A0F473EF59F4E30E2817E6285BCE2846F15F1A0"), + hex!( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000018ebbb95eed0e13" + ), + hex!( + "A499EFE48839BC3ABCD1C5CEDBDD51904F9514DB44F4686DB918983B0C9DC3AEE05A88B72433E9515F91A329F5F4FA60" + ), + hex!( + "3B7CA28EF31F809C2F1BA24AAED847D0F8B406A4B8968542DE139DB5828CA410E615D1182E25B91B1131E230B727D36A" + ), + ), + ( + hex!( + "000000000000000000000000000000000000000000000000000000000000000000159d893d4cdd747246cdca43590e13" + ), + hex!( + "90A0B1CAC601676B083F21E07BC7090A3390FE1B9C7F61D842D27FA315FB38D83667A11A71438773E483F2A114836B24" + ), + hex!( + "3197D3C6123F0D6CD65D5F0DE106FEF36656CB16DC7CD1A6817EB1D51510135A8F492F72665CFD1053F75ED03A7D04C9" + ), + ), + ( + hex!( + "41ffc1fffffe01fffc0003fffe0007c001fff00003fff07ffe0007c000000003ffffff807fff8007fffff800fffe0000" + ), + hex!( + "F2A066BD332DC59BBC3D01DA1B124C687D8BB44611186422DE94C1DA4ECF150E664D353CCDB5CB2652685F8EB4D2CD49" + ), + hex!( + "D6ED0BF75FDD8E53D87765FA746835B673881D6D1907163A2C43990D75B454294F942EC571AD5AAE1806CAF2BB8E9A4A" + ), + ), + ( + hex!( + "400000003803ffffffcfffffe0800000001ffffe03ffff1ffff801fffffffff8000001fffff800ffffff8001fffc7fff" + ), + hex!( + "5C7F9845D1C4AA44747F9137B6F9C39B36B26B8A62E8AF97290434D5F3B214F5A0131550ADB19058DC4C8780C4165C4A" + ), + hex!( + "712F7FCCC86F647E70DB8798228CB16344AF3D00B139B6F8502939C2A965AF0EB4E39E2E16AB8F597B8D5630A50C9D85" + ), + ), + ( + hex!( + "4000008000fffffc000003f00000ffffffff800003800f8000e0000e000000ffffffe00000ffffffc0007e0000000fe0" + ), + hex!( + "DD5838F7EC3B8ACF1BECFD746F8B668C577107E93548ED93ED0D254C112E76B10F053109EF8428BFCD50D38C4C030C57" + ), + hex!( + "33244F479CDAC34F160D9E4CE2D19D2FF0E3305B5BF0EEF29E91E9DE6E28F678C61B773AA7E3C03740E1A49D1AA2493C" + ), + ), + ( + hex!( + "000000001ffc000000fff030001f0000fffff0000038000000000002003f007ffffff0000000000000ffe00000000000" + ), + hex!( + "CB8ED893530BFBA04B4CA655923AAAD109A62BC8411D5925316C32D33602459C33057A1FBCB5F70AEB295D90F9165FBC" + ), + hex!( + "426AEE3E91B08420F9B357B66D5AFCBCF3956590BF5564DBF9086042EB880493D19DA39AAA6436C6B5FC66CE5596B43F" + ), + ), + ( + hex!( + "000fffe0800001ff0001fffffff0000ffffffffffffff80000fffffc1fffffffffffff001ffffffffffffbffffe01ffc" + ), + hex!( + "67F714012B6B070182122DDD435CC1C2262A1AB88939BC6A2906CB2B4137C5E82B4582160F6403CAB887ACDF5786A268" + ), + hex!( + "90E31CF398CE2F8C5897C7380BF541075D1B4D3CB70547262B7095731252F181AC0597C66AF8311C7780DB39DEC0BD32" + ), + ), + ( + hex!( + "07fffe0001fffff800fff800001ffff0001fffffe001fffc0000003ffe03fffffff80ffff01ffff20001c0003f0001ff" + ), + hex!( + "55A79DF7B53A99D31462C7E1A5ED5623970715BB1021098CB973A7520CBD6365E613E4B2467486FB37E86E01CEE09B8F" + ), + hex!( + "B95AEB71693189911661B709A886A1867F056A0EFE401EE11C06030E46F7A87731DA4575863178012208707DD666727C" + ), + ), + ( + hex!( + "0000003fff87effe07fe7ffffe07ffe07f0000000003fe007fff03e07c07ffe0007f0017fffffe000003fffff007ffff" + ), + hex!( + "9539A968CF819A0E52E10EEA3BACA1B6480D7E4DF69BC07002C568569047110EE4FE72FCA423FDD5179D6E0E19C44844" + ), + hex!( + "A7728F37A0AE0DF2716061900D83A4DA149144129F89A214A8260464BAB609BB322E4E67DE5E4C4C6CB8D25983EC19B0" + ), + ), + ( + hex!( + "00ffffff0000007e07fffff80031ffeffdffffc3fffffffff01fffffffff80000000007fc000fc000000004003ffc000" + ), + hex!( + "933FC13276672AB360D909161CD02D830B1628935DF0D800C6ED602C59D575A86A8A97E3A2D697E3ED06BE741C0097D6" + ), + hex!( + "F35296BD7A6B4C6C025ED6D84338CCCC7522A45C5D4FBDB1442556CAEFB598128FA188793ADA510EB5F44E90A4E4BEF1" + ), + ), + ( + hex!( + "00001fff803ff8000001fff000ffffffe3fff000000007ffdff80000003fff007fffffc01ffffff9ffffe001fc000000" + ), + hex!( + "0CE31E1C4A937071E6EBACA026A93D783848BCC0C1585DAF639518125FCD1F1629D63041ABFB11FFC8F03FA8B6FCF6BF" + ), + hex!( + "A69EA55BE4BEAB2D5224050FEBFFBDFCFD614624C3B4F228909EB80012F003756D1C377E52F04FA539237F24DD080E2E" + ), + ), + ( + hex!( + "7ff0001fff000fffffffff80007ffc0003f80001fff8000000001fc000000fff000000007ffc01fffc020000003fc000" + ), + hex!( + "6842CFE3589AC268818291F31D44177A9168DCBC19F321ED66D81ECF59E31B54CCA0DDFD4C4136780171748D69A91C54" + ), + hex!( + "E3A5ECD5AC725F13DBC631F358C6E817EDCF3A613B83832741A9DB591A0BAE767FC714F70C2E7EA891E4312047DECCC0" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5295f" + ), + hex!( + "605508EC02C534BCEEE9484C86086D2139849E2B11C1A9CA1E2808DEC2EAF161AC8A105D70D4F85C50599BE5800A623F" + ), + hex!( + "AEA7117869D53947E0FF5EFC47ABC5F8C7E489C65C59A0ECAC510EE48CCEF92116D16647721C984B71DC73C825271122" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52960" + ), + hex!( + "8D481DAB912BC8AB16858A211D750B77E07DBECCA86CD9B012390B430467AABF59C8651060801C0E9599E68713F5D41B" + ), + hex!( + "5EA6D00FEDEB9F7A841660D59F996FAF4DD6E4975EFC655FA6B4CD028523F172EE0045A8F7FFB19B966A4F828A1ADDBA" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52961" + ), + hex!( + "DFB1FE3A40F7AC9B64C41D39360A7423828B97CB088A4903315E402A7089FA0F8B6C2355169CC9C99DFB44692A9B93DD" + ), + hex!( + "BAC535EDBC4A1394BDC5975DAA781E9EC59CB3E3BD2D118193A80BB65E36E2366E9748FB913F580C85C99E7BDCC13ADD" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52962" + ), + hex!( + "4099952208B4889600A5EBBCB13E1A32692BEFB0733B41E6DCC614E42E5805F817012A991AF1F486CAF3A9ADD9FFCC03" + ), + hex!( + "A1306B8887CCFA67C6B8BA6B509FCA67E9C52C07FF752F32648682D880DC774BFB25B2CF55697F13059AF10B1DC4F65F" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52963" + ), + hex!( + "D5D89C3B5282369C5FBD88E2B231511A6B80DFF0E5152CF6A464FA9428A8583BAC8EBC773D157811A462B892401DAFCF" + ), + hex!( + "27EADD621ED6F92DBE7E92A1656BB70E2BE2B03BF1D5C42463545A81BBF585442EDEF3460B640DDC97DD48AB1454C98C" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52964" + ), + hex!( + "B3D13FC8B32B01058CC15C11D813525522A94156FFF01C205B21F9F7DA7C4E9CA849557A10B6383B4B88701A9606860B" + ), + hex!( + "EAD6E618206E9D59E4FB64DAC9E9B4E411453B5EE28B650B7B2EEEBC8C2040257C72DB064D7B50AF67A2A773CC08429D" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52965" + ), + hex!( + "E8C8F94D44FBC2396BBEAC481B89D2B0877B1DFFD23E7DC95DE541EB651CCA2C41ABA24DBC02DE6637209ACCF0F59EA0" + ), + hex!( + "76E51BBCA903751F6CD4340921AD3756CC479E6E188D728637CE6BEC5F62F0B603B9745EAAF621DD2811A362E4984777" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52966" + ), + hex!( + "A567BA97B67AEA5BAFDAF5002FFCC6AB9632BFF9F01F873F6267BCD1F0F11C139EE5F441ABD99F1BAAF1CA1E3B5CBCE7" + ), + hex!( + "21E4C74C6760CCE79BB1BEB850E9B133AE7AA6AFB96CD13F79CD641FA87A82988894347C8DDE75829BDC5ED9C90BD633" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52967" + ), + hex!( + "952A7A349BD49289AB3AC421DCF683D08C2ED5E41F6D0E21648AF2691A481406DA4A5E22DA817CB466DA2EA77D2A7022" + ), + hex!( + "5FCDF0507B4A43FA9CFAD215190990D1F6047FC931E75F1446FD74F69E694AF1FCE559B9768BC1DD610945341DE42E91" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52968" + ), + hex!( + "099056E27DA7B998DA1EEEC2904816C57FE935ED5837C37456C9FD14892D3F8C4749B66E3AFB81D626356F3B55B4DDD8" + ), + hex!( + "D1B3F3DCB1CF5469977AFAABB53A1FC6903B1127203C9C02BC006C0BE4AD5CD9AB992AEC9C5500CA82A2457FC73A1F44" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52969" + ), + hex!( + "A669C5563BD67EEC678D29D6EF4FDE864F372D90B79B9E88931D5C29291238CCED8E85AB507BF91AA9CB2D13186658FB" + ), + hex!( + "567748D5183ED860DD26F7C24A0F132208FEE6AAF3E7C3CE3AFD20873C48FA56D6927E69DB7D77266887B09648C5DE22" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296a" + ), + hex!( + "8F0A39A4049BCB3EF1BF29B8B025B78F2216F7291E6FD3BAC6CB1EE285FB6E21C388528BFEE2B9535C55E4461079118B" + ), + hex!( + "9D3881EBC749FE29BAD3B5ACDD3C56866564C2835C3BFF39489877AB51264CFC618BC100202AE497D9D25B075399B507" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296b" + ), + hex!( + "1692778EA596E0BE75114297A6FA383445BF227FBE58190A900C3C73256F11FB5A3258D6F403D5ECE6E9B269D822C87D" + ), + hex!( + "232DC9A8FF2BEF957CAC7745C24702F1DDAAB52392ADE32B42E3CF3D13F113E594521E15322E8F729095405CFDD4F52D" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296c" + ), + hex!( + "283C1D7365CE4788F29F8EBF234EDFFEAD6FE997FBEA5FFA2D58CC9DFA7B1C508B05526F55B9EBB2040F05B48FB6D0E1" + ), + hex!( + "6B8A366F9E1BE47745AD102473E96FB8E59E2798128668D62636D32FE242DDA8CF27B120CD5870619B99B3263AED1073" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296d" + ), + hex!( + "627BE1ACD064D2B2226FE0D26F2D15D3C33EBCBB7F0F5DA51CBD41F26257383021317D7202FF30E50937F0854E35C5DF" + ), + hex!( + "F68995B34C074E3DE41922593EB0EA8A4D36ACAD9BB088B36679B09EC8EABBE8FB3BA4717B1E9ACEE8CC5BF82C0F06CB" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296e" + ), + hex!( + "11DE24A2C251C777573CAC5EA025E467F208E51DBFF98FC54F6661CBE56583B037882F4A1CA297E60ABCDBC3836D84BC" + ), + hex!( + "705969388BBF06D2F0A7C816F5FF183AD7B4BB88AB2A211773679ACC496FE513CE889791F51704CCE7BBEB55193E8EC5" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc5296f" + ), + hex!( + "138251CD52AC9298C1C8AAD977321DEB97E709BD0B4CA0ACA55DC8AD51DCFC9D1589A1597E3A5120E1EFD631C63E1835" + ), + hex!( + "35351D679659D1E9CE175D7E7E54A99E923BA26E7543F60C54F19C3086D55B22128C7840C8445A96AB60E3FE4D8F1298" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970" + ), + hex!( + "077A41D4606FFA1464793C7E5FDC7D98CB9D3910202DCD06BEA4F240D3566DA6B408BBAE5026580D02D7E5C70500C831" + ), + hex!( + "366A0835F4F3BD7C82F44169FD5603667ADF4BE37AEEA55A0897B3F123EEE1523DB542931B4A2D6749A0D7A0F5D0E20E" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52971" + ), + hex!( + "08D999057BA3D2D969260045C55B97F089025959A6F434D651D207D19FB96E9E4FE0E86EBE0E64F85B96A9C75295DF61" + ), + hex!( + "717F0E05A4E4C312484017200292458B4D8A278A43933BC16FB1AFA0DA954BD9A002BC15B2C61DD29EAFE190F56BF17F" + ), + ), + ( + hex!( + "ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52972" + ), + hex!( + "AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7" + ), + hex!( + "C9E821B569D9D390A26167406D6D23D6070BE242D765EB831625CEEC4A0F473EF59F4E30E2817E6285BCE2846F15F1A0" + ), ), ]; diff --git a/p384/tests/affine.rs b/p384/tests/affine.rs index 20b5f2bc3..eee68241a 100644 --- a/p384/tests/affine.rs +++ b/p384/tests/affine.rs @@ -5,7 +5,7 @@ #![cfg(all(feature = "arithmetic", feature = "test-vectors"))] use elliptic_curve::{ - group::{prime::PrimeCurveAffine, GroupEncoding}, + group::{GroupEncoding, prime::PrimeCurveAffine}, sec1::{FromEncodedPoint, ToEncodedPoint}, }; use hex_literal::hex; diff --git a/p384/tests/projective.rs b/p384/tests/projective.rs index 05d43dcf2..295f7151a 100644 --- a/p384/tests/projective.rs +++ b/p384/tests/projective.rs @@ -3,14 +3,14 @@ #![cfg(all(feature = "arithmetic", feature = "test-vectors"))] use elliptic_curve::{ - sec1::{self, ToEncodedPoint}, PrimeField, + sec1::{self, ToEncodedPoint}, }; use p384::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, AffinePoint, ProjectivePoint, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; -use primeorder::{impl_projective_arithmetic_tests, Double}; +use primeorder::{Double, impl_projective_arithmetic_tests}; impl_projective_arithmetic_tests!( AffinePoint, From c84dfbf7289b4972745997abbf1f828f377aef11 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:50:02 -0800 Subject: [PATCH 08/20] p521: bump to edition 2024; msrv 1.85 --- .github/workflows/p521.yml | 6 +- p521/Cargo.toml | 10 +- p521/README.md | 14 +- p521/benches/field.rs | 2 +- p521/benches/scalar.rs | 24 +- p521/src/arithmetic.rs | 15 +- p521/src/arithmetic/field.rs | 14 +- p521/src/arithmetic/field/loose.rs | 2 +- p521/src/arithmetic/hash2curve.rs | 16 +- p521/src/arithmetic/scalar.rs | 8 +- p521/src/ecdh.rs | 6 +- p521/src/ecdsa.rs | 14 +- p521/src/lib.rs | 8 +- p521/src/test_vectors/ecdsa.rs | 423 +++++++++++++----- p521/src/test_vectors/group.rs | 684 ++++++++++++++++++++--------- p521/tests/projective.rs | 4 +- 16 files changed, 871 insertions(+), 379 deletions(-) diff --git a/.github/workflows/p521.yml b/.github/workflows/p521.yml index 4b52838ef..badae9de4 100644 --- a/.github/workflows/p521.yml +++ b/.github/workflows/p521.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -58,7 +58,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -66,7 +66,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable diff --git a/p521/Cargo.toml b/p521/Cargo.toml index 8af4f4886..471aedcac 100644 --- a/p521/Cargo.toml +++ b/p521/Cargo.toml @@ -13,8 +13,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "nist", "secp521r1"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] base16ct = "0.2" @@ -25,7 +25,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, de hex-literal = { version = "0.4", optional = true } primefield = { version = "=0.14.0-pre.0", optional = true, path = "../primefield" } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -rand_core = { version = "0.6", optional = true, default-features = false } +rand_core = { version = "0.9", optional = true, default-features = false } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } @@ -35,7 +35,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = hex-literal = "0.4" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1.5" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } criterion = "0.5.1" [features] @@ -48,7 +48,7 @@ digest = ["ecdsa-core/digest", "ecdsa-core/hazmat"] ecdh = ["arithmetic", "elliptic-curve/ecdh"] ecdsa = ["arithmetic", "ecdsa-core/signing", "ecdsa-core/verifying", "sha512"] expose-field = ["arithmetic"] -getrandom = ["rand_core/getrandom"] +getrandom = ["rand_core/os_rng"] hash2curve = ["arithmetic", "elliptic-curve/hash2curve"] jwk = ["elliptic-curve/jwk"] pem = ["elliptic-curve/pem", "pkcs8"] diff --git a/p521/README.md b/p521/README.md index 9eb167ce3..c25cef5f4 100644 --- a/p521/README.md +++ b/p521/README.md @@ -37,18 +37,6 @@ Elliptic Curve Domain Parameters. Also known as secp521r1 (SECG). -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -73,7 +61,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p521.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p521.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/p521/benches/field.rs b/p521/benches/field.rs index 54bb78a88..924ff3b9e 100644 --- a/p521/benches/field.rs +++ b/p521/benches/field.rs @@ -1,7 +1,7 @@ //! secp521r1 field element benchmarks use criterion::{ - black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; use p521::FieldElement; diff --git a/p521/benches/scalar.rs b/p521/benches/scalar.rs index 2ce18936e..315569e31 100644 --- a/p521/benches/scalar.rs +++ b/p521/benches/scalar.rs @@ -1,10 +1,10 @@ //! secp521r1 scalar arithmetic benchmarks use criterion::{ - black_box, criterion_group, criterion_main, measurement::Measurement, BenchmarkGroup, Criterion, + BenchmarkGroup, Criterion, black_box, criterion_group, criterion_main, measurement::Measurement, }; use hex_literal::hex; -use p521::{elliptic_curve::group::ff::PrimeField, ProjectivePoint, Scalar}; +use p521::{ProjectivePoint, Scalar, elliptic_curve::group::ff::PrimeField}; fn test_scalar_x() -> Scalar { black_box(Scalar::from_repr( @@ -18,37 +18,37 @@ fn test_scalar_y() -> Scalar { ).unwrap()) } -fn bench_point_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_point_mul(group: &mut BenchmarkGroup<'_, M>) { let p = ProjectivePoint::GENERATOR; let m = test_scalar_x(); let s = Scalar::from_repr(m.into()).unwrap(); - group.bench_function("point-scalar mul", |b| b.iter(|| &p * &s)); + group.bench_function("point-scalar mul", |b| b.iter(|| p * s)); } -fn bench_scalar_sub<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_sub(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("sub", |b| b.iter(|| &x - &y)); + group.bench_function("sub", |b| b.iter(|| x - y)); } -fn bench_scalar_add<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_add(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("add", |b| b.iter(|| &x + &y)); + group.bench_function("add", |b| b.iter(|| x + y)); } -fn bench_scalar_mul<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_mul(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); let y = test_scalar_y(); - group.bench_function("mul", |b| b.iter(|| &x * &y)); + group.bench_function("mul", |b| b.iter(|| x * y)); } -fn bench_scalar_negate<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_negate(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("negate", |b| b.iter(|| -x)); } -fn bench_scalar_invert<'a, M: Measurement>(group: &mut BenchmarkGroup<'a, M>) { +fn bench_scalar_invert(group: &mut BenchmarkGroup<'_, M>) { let x = test_scalar_x(); group.bench_function("invert", |b| b.iter(|| x.invert())); } diff --git a/p521/src/arithmetic.rs b/p521/src/arithmetic.rs index b6d97ba48..0ca0bfbc2 100644 --- a/p521/src/arithmetic.rs +++ b/p521/src/arithmetic.rs @@ -15,7 +15,7 @@ pub use self::scalar::Scalar; use self::field::FieldElement; use crate::NistP521; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; @@ -48,8 +48,9 @@ impl PrimeCurveParams for NistP521 { /// b = 0x051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 /// b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 /// 3573df88 3d2c34f1 ef451fd4 6b503f00 - const EQUATION_B: FieldElement = - FieldElement::from_hex("0000000000000051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"); + const EQUATION_B: FieldElement = FieldElement::from_hex( + "0000000000000051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00", + ); /// Base point of P-521. /// @@ -62,7 +63,11 @@ impl PrimeCurveParams for NistP521 { /// 353c7086 a272c240 88be9476 9fd16650 /// ``` const GENERATOR: (FieldElement, FieldElement) = ( - FieldElement::from_hex("00000000000000c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"), - FieldElement::from_hex("000000000000011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"), + FieldElement::from_hex( + "00000000000000c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66", + ), + FieldElement::from_hex( + "000000000000011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650", + ), ); } diff --git a/p521/src/arithmetic/field.rs b/p521/src/arithmetic/field.rs index 725107232..fc9d30c52 100644 --- a/p521/src/arithmetic/field.rs +++ b/p521/src/arithmetic/field.rs @@ -36,15 +36,17 @@ use core::{ }; use elliptic_curve::ops::Invert; use elliptic_curve::{ + Error, FieldBytesEncoding, ff::{self, Field, PrimeField}, rand_core::RngCore, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeLess, CtOption}, zeroize::DefaultIsZeroes, - Error, FieldBytesEncoding, }; /// Field modulus: p = 2^{521} − 1 -pub(crate) const MODULUS: U576 = U576::from_be_hex("00000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +pub(crate) const MODULUS: U576 = U576::from_be_hex( + "00000000000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", +); /// Element of the secp521r1 base field used for curve coordinates. #[derive(Clone, Copy)] @@ -445,7 +447,9 @@ impl PrimeField for FieldElement { const TWO_INV: Self = Self::from_u64(2).invert_unchecked(); const MULTIPLICATIVE_GENERATOR: Self = Self::from_u64(3); const S: u32 = 1; - const ROOT_OF_UNITY: Self = Self::from_hex("00000000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe"); + const ROOT_OF_UNITY: Self = Self::from_hex( + "00000000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe", + ); const ROOT_OF_UNITY_INV: Self = Self::ROOT_OF_UNITY.invert_unchecked(); const DELTA: Self = Self::from_u64(9); @@ -668,7 +672,9 @@ mod tests { /// Regression test for RustCrypto/elliptic-curves#965 #[test] fn decode_invalid_field_element_returns_err() { - let overflowing_bytes = hex!("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); + let overflowing_bytes = hex!( + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + ); let ct_option = FieldElement::from_bytes(&overflowing_bytes.into()); assert!(bool::from(ct_option.is_none())); } diff --git a/p521/src/arithmetic/field/loose.rs b/p521/src/arithmetic/field/loose.rs index 51d2b62a0..e7415215f 100644 --- a/p521/src/arithmetic/field/loose.rs +++ b/p521/src/arithmetic/field/loose.rs @@ -1,4 +1,4 @@ -use super::{field_impl::*, FieldElement}; +use super::{FieldElement, field_impl::*}; use core::ops::Mul; /// "Loose" field element: unreduced and intended to be followed by an diff --git a/p521/src/arithmetic/hash2curve.rs b/p521/src/arithmetic/hash2curve.rs index 1eed93e43..b431669ca 100644 --- a/p521/src/arithmetic/hash2curve.rs +++ b/p521/src/arithmetic/hash2curve.rs @@ -100,10 +100,11 @@ impl FromOkm for Scalar { #[cfg(test)] mod tests { use crate::{ - arithmetic::field::{FieldElement, MODULUS}, NistP521, Scalar, + arithmetic::field::{FieldElement, MODULUS}, }; use elliptic_curve::{ + Curve, array::Array, bigint::{ArrayEncoding, CheckedSub, NonZero, U576, U896}, consts::U98, @@ -111,7 +112,6 @@ mod tests { hash2curve::{self, ExpandMsgXmd, FromOkm, GroupDigest, MapToCurve, OsswuMap}, ops::Reduce, sec1::{self, ToEncodedPoint}, - Curve, }; use hex_literal::hex; use proptest::{num, prelude::ProptestConfig, proptest}; @@ -265,19 +265,25 @@ mod tests { dst: b"DeriveKeyPairOPRFV1-\x00-P521-SHA512", key_info: &hex!("74657374206b6579"), seed: &hex!("a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3"), - sk_sm: &hex!("0153441b8faedb0340439036d6aed06d1217b34c42f17f8db4c5cc610a4a955d698a688831b16d0dc7713a1aa3611ec60703bffc7dc9c84e3ed673b3dbe1d5fccea6"), + sk_sm: &hex!( + "0153441b8faedb0340439036d6aed06d1217b34c42f17f8db4c5cc610a4a955d698a688831b16d0dc7713a1aa3611ec60703bffc7dc9c84e3ed673b3dbe1d5fccea6" + ), }, TestVector { dst: b"DeriveKeyPairOPRFV1-\x01-P521-SHA512", key_info: b"test key", seed: &hex!("a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3"), - sk_sm: &hex!("015c7fc1b4a0b1390925bae915bd9f3d72009d44d9241b962428aad5d13f22803311e7102632a39addc61ea440810222715c9d2f61f03ea424ec9ab1fe5e31cf9238"), + sk_sm: &hex!( + "015c7fc1b4a0b1390925bae915bd9f3d72009d44d9241b962428aad5d13f22803311e7102632a39addc61ea440810222715c9d2f61f03ea424ec9ab1fe5e31cf9238" + ), }, TestVector { dst: b"DeriveKeyPairOPRFV1-\x02-P521-SHA512", key_info: b"test key", seed: &hex!("a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3"), - sk_sm: &hex!("014893130030ce69cf714f536498a02ff6b396888f9bb507985c32928c4427d6d39de10ef509aca4240e8569e3a88debc0d392e3361bcd934cb9bdd59e339dff7b27"), + sk_sm: &hex!( + "014893130030ce69cf714f536498a02ff6b396888f9bb507985c32928c4427d6d39de10ef509aca4240e8569e3a88debc0d392e3361bcd934cb9bdd59e339dff7b27" + ), }, ]; diff --git a/p521/src/arithmetic/scalar.rs b/p521/src/arithmetic/scalar.rs index ef4abf02d..4603096c6 100644 --- a/p521/src/arithmetic/scalar.rs +++ b/p521/src/arithmetic/scalar.rs @@ -21,6 +21,7 @@ use core::{ ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Curve as _, Error, FieldBytesEncoding, Result, ScalarPrimitive, bigint::{self, Integer}, ff::{self, Field, PrimeField}, ops::{Invert, Reduce}, @@ -31,12 +32,11 @@ use elliptic_curve::{ CtOption, }, zeroize::DefaultIsZeroes, - Curve as _, Error, FieldBytesEncoding, Result, ScalarPrimitive, }; use primefield::{impl_bernstein_yang_invert, impl_field_op}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(doc)] use core::ops::Sub; @@ -546,7 +546,9 @@ impl PrimeField for Scalar { const TWO_INV: Self = Self::from_u64(2).invert_unchecked(); const MULTIPLICATIVE_GENERATOR: Self = Self::from_u64(3); const S: u32 = 3; - const ROOT_OF_UNITY: Self = Self::from_hex("000000000000009a0a650d44b28c17f3d708ad2fa8c4fbc7e6000d7c12dafa92fcc5673a3055276d535f79ff391dcdbcd998b7836647d3a72472b3da861ac810a7f9c7b7b63e2205"); + const ROOT_OF_UNITY: Self = Self::from_hex( + "000000000000009a0a650d44b28c17f3d708ad2fa8c4fbc7e6000d7c12dafa92fcc5673a3055276d535f79ff391dcdbcd998b7836647d3a72472b3da861ac810a7f9c7b7b63e2205", + ); const ROOT_OF_UNITY_INV: Self = Self::ROOT_OF_UNITY.invert_unchecked(); const DELTA: Self = Self::from_u64(6561); diff --git a/p521/src/ecdh.rs b/p521/src/ecdh.rs index 295fcb9d3..97794ca79 100644 --- a/p521/src/ecdh.rs +++ b/p521/src/ecdh.rs @@ -10,14 +10,14 @@ //! //! ``` //! use p521::{EncodedPoint, PublicKey, ecdh::EphemeralSecret}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Alice -//! let alice_secret = EphemeralSecret::random(&mut OsRng); +//! let alice_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let alice_pk_bytes = EncodedPoint::from(alice_secret.public_key()); //! //! // Bob -//! let bob_secret = EphemeralSecret::random(&mut OsRng); +//! let bob_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let bob_pk_bytes = EncodedPoint::from(bob_secret.public_key()); //! //! // Alice decodes Bob's serialized public key and computes a shared secret from it diff --git a/p521/src/ecdsa.rs b/p521/src/ecdsa.rs index 5ef9493d3..a91097683 100644 --- a/p521/src/ecdsa.rs +++ b/p521/src/ecdsa.rs @@ -22,10 +22,10 @@ //! # #[cfg(feature = "ecdsa")] //! # { //! use p521::ecdsa::{signature::Signer, Signature, SigningKey}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Signing -//! let signing_key = SigningKey::random(&mut OsRng); // Serialize with `::to_bytes()` +//! let signing_key = SigningKey::random(&mut OsRng.unwrap_mut()); // Serialize with `::to_bytes()` //! let message = b"ECDSA proves knowledge of a secret number in the context of a single message"; //! let signature: Signature = signing_key.sign(message); //! @@ -67,7 +67,7 @@ impl ecdsa_core::hazmat::DigestPrimitive for NistP521 { #[cfg(all(test, feature = "ecdsa"))] mod tests { - use crate::ecdsa::{signature::Signer, Signature, SigningKey}; + use crate::ecdsa::{Signature, SigningKey, signature::Signer}; use hex_literal::hex; // Test vector from RFC 6979 Appendix 2.7 (NIST P-521 + SHA-512) @@ -75,7 +75,9 @@ mod tests { // TODO(tarcieri): debug why this is failing #[test] fn rfc6979() { - let x = hex!("00FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538"); + let x = hex!( + "00FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538" + ); let signer = SigningKey::from_bytes(&x.into()).unwrap(); let signature: Signature = signer.sign(b"sample"); assert_eq!( @@ -88,12 +90,12 @@ mod tests { } mod sign { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP521}; + use crate::{NistP521, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_signing_test!(NistP521, ECDSA_TEST_VECTORS); } mod verify { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP521}; + use crate::{NistP521, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_verification_test!(NistP521, ECDSA_TEST_VECTORS); } diff --git a/p521/src/lib.rs b/p521/src/lib.rs index c6e1c8af8..c3bf394a5 100644 --- a/p521/src/lib.rs +++ b/p521/src/lib.rs @@ -38,7 +38,7 @@ pub mod ecdsa; pub mod test_vectors; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; #[cfg(feature = "expose-field")] pub use arithmetic::field::FieldElement; @@ -48,7 +48,7 @@ pub use elliptic_curve::{self, bigint::U576}; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; -use elliptic_curve::{array::Array, consts::U66, FieldBytesEncoding}; +use elliptic_curve::{FieldBytesEncoding, array::Array, consts::U66}; /// NIST P-521 elliptic curve. #[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd, Ord)] @@ -62,7 +62,9 @@ impl elliptic_curve::Curve for NistP521 { type Uint = U576; /// Order of NIST P-521's elliptic curve group (i.e. scalar modulus). - const ORDER: U576 = U576::from_be_hex("00000000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"); + const ORDER: U576 = U576::from_be_hex( + "00000000000001fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409", + ); } impl elliptic_curve::PrimeCurve for NistP521 {} diff --git a/p521/src/test_vectors/ecdsa.rs b/p521/src/test_vectors/ecdsa.rs index 2894828c9..d6b948d8e 100644 --- a/p521/src/test_vectors/ecdsa.rs +++ b/p521/src/test_vectors/ecdsa.rs @@ -11,141 +11,350 @@ use hex_literal::hex; /// /// The `m` field contains a SHA-512 prehash of the `Msg` field in the /// original `SigTen.txt`. - pub const ECDSA_TEST_VECTORS: &[TestVector] = &[ - TestVector { - m: &hex!("000065f83408092261bda599389df03382c5be01a81fe00a36f3f4bb6541263f801627c440e50809712b0cace7c217e6e5051af81de9bfec3204dcd63c4f9a741047"), - d: &hex!("00f749d32704bc533ca82cef0acf103d8f4fba67f08d2678e515ed7db886267ffaf02fab0080dca2359b72f574ccc29a0f218c8655c0cccf9fee6c5e567aa14cb926"), - q_x: &hex!("0061387fd6b95914e885f912edfbb5fb274655027f216c4091ca83e19336740fd81aedfe047f51b42bdf68161121013e0d55b117a14e4303f926c8debb77a7fdaad1"), - q_y: &hex!("00e7d0c75c38626e895ca21526b9f9fdf84dcecb93f2b233390550d2b1463b7ee3f58df7346435ff0434199583c97c665a97f12f706f2357da4b40288def888e59e6"), - k: &hex!("003af5ab6caa29a6de86a5bab9aa83c3b16a17ffcd52b5c60c769be3053cdddeac60812d12fecf46cfe1f3db9ac9dcf881fcec3f0aa733d4ecbb83c7593e864c6df1"), - r: &hex!("004de826ea704ad10bc0f7538af8a3843f284f55c8b946af9235af5af74f2b76e099e4bc72fd79d28a380f8d4b4c919ac290d248c37983ba05aea42e2dd79fdd33e8"), - s: &hex!("0087488c859a96fea266ea13bf6d114c429b163be97a57559086edb64aed4a18594b46fb9efc7fd25d8b2de8f09ca0587f54bd287299f47b2ff124aac566e8ee3b43"), + TestVector { + m: &hex!( + "000065f83408092261bda599389df03382c5be01a81fe00a36f3f4bb6541263f801627c440e50809712b0cace7c217e6e5051af81de9bfec3204dcd63c4f9a741047" + ), + d: &hex!( + "00f749d32704bc533ca82cef0acf103d8f4fba67f08d2678e515ed7db886267ffaf02fab0080dca2359b72f574ccc29a0f218c8655c0cccf9fee6c5e567aa14cb926" + ), + q_x: &hex!( + "0061387fd6b95914e885f912edfbb5fb274655027f216c4091ca83e19336740fd81aedfe047f51b42bdf68161121013e0d55b117a14e4303f926c8debb77a7fdaad1" + ), + q_y: &hex!( + "00e7d0c75c38626e895ca21526b9f9fdf84dcecb93f2b233390550d2b1463b7ee3f58df7346435ff0434199583c97c665a97f12f706f2357da4b40288def888e59e6" + ), + k: &hex!( + "003af5ab6caa29a6de86a5bab9aa83c3b16a17ffcd52b5c60c769be3053cdddeac60812d12fecf46cfe1f3db9ac9dcf881fcec3f0aa733d4ecbb83c7593e864c6df1" + ), + r: &hex!( + "004de826ea704ad10bc0f7538af8a3843f284f55c8b946af9235af5af74f2b76e099e4bc72fd79d28a380f8d4b4c919ac290d248c37983ba05aea42e2dd79fdd33e8" + ), + s: &hex!( + "0087488c859a96fea266ea13bf6d114c429b163be97a57559086edb64aed4a18594b46fb9efc7fd25d8b2de8f09ca0587f54bd287299f47b2ff124aac566e8ee3b43" + ), }, TestVector { - m: &hex!("0000a6200971c6a289e2fcb80f78ec08a5079ea2675efd68bcab479552aa5bcb8edf3c993c79d7cebcc23c20e5af41723052b871134cc71d5c57206182a7068cc39b"), - d: &hex!("01a4d2623a7d59c55f408331ba8d1523b94d6bf8ac83375ceb57a2b395a5bcf977cfc16234d4a97d6f6ee25a99aa5bff15ff535891bcb7ae849a583e01ac49e0e9b6"), - q_x: &hex!("004d5c8afee038984d2ea96681ec0dccb6b52dfa4ee2e2a77a23c8cf43ef19905a34d6f5d8c5cf0981ed804d89d175b17d1a63522ceb1e785c0f5a1d2f3d15e51352"), - q_y: &hex!("0014368b8e746807b2b68f3615cd78d761a464ddd7918fc8df51d225962fdf1e3dc243e265100ff0ec133359e332e44dd49afd8e5f38fe86133573432d33c02fa0a3"), - k: &hex!("00bc2c0f37155859303de6fa539a39714e195c37c6ea826e224c8218584ae09cd0d1cc14d94d93f2d83c96e4ef68517fdb3f383da5404e5a426bfc5d424e253c181b"), - r: &hex!("01a3c4a6386c4fb614fba2cb9e74201e1aaa0001aa931a2a939c92e04b8344535a20f53c6e3c69c75c2e5d2fe3549ed27e6713cb0f4a9a94f6189eb33bff7d453fce"), - s: &hex!("016a997f81aa0bea2e1469c8c1dab7df02a8b2086ba482c43af04f2174831f2b1761658795adfbdd44190a9b06fe10e578987369f3a2eced147cff89d8c2818f7471"), + m: &hex!( + "0000a6200971c6a289e2fcb80f78ec08a5079ea2675efd68bcab479552aa5bcb8edf3c993c79d7cebcc23c20e5af41723052b871134cc71d5c57206182a7068cc39b" + ), + d: &hex!( + "01a4d2623a7d59c55f408331ba8d1523b94d6bf8ac83375ceb57a2b395a5bcf977cfc16234d4a97d6f6ee25a99aa5bff15ff535891bcb7ae849a583e01ac49e0e9b6" + ), + q_x: &hex!( + "004d5c8afee038984d2ea96681ec0dccb6b52dfa4ee2e2a77a23c8cf43ef19905a34d6f5d8c5cf0981ed804d89d175b17d1a63522ceb1e785c0f5a1d2f3d15e51352" + ), + q_y: &hex!( + "0014368b8e746807b2b68f3615cd78d761a464ddd7918fc8df51d225962fdf1e3dc243e265100ff0ec133359e332e44dd49afd8e5f38fe86133573432d33c02fa0a3" + ), + k: &hex!( + "00bc2c0f37155859303de6fa539a39714e195c37c6ea826e224c8218584ae09cd0d1cc14d94d93f2d83c96e4ef68517fdb3f383da5404e5a426bfc5d424e253c181b" + ), + r: &hex!( + "01a3c4a6386c4fb614fba2cb9e74201e1aaa0001aa931a2a939c92e04b8344535a20f53c6e3c69c75c2e5d2fe3549ed27e6713cb0f4a9a94f6189eb33bff7d453fce" + ), + s: &hex!( + "016a997f81aa0bea2e1469c8c1dab7df02a8b2086ba482c43af04f2174831f2b1761658795adfbdd44190a9b06fe10e578987369f3a2eced147cff89d8c2818f7471" + ), }, TestVector { - m: &hex!("000046ff533622cc90321a3aeb077ec4db4fbf372c7a9db48b59de7c5d59e6314110676ba5491bd20d0f02774eef96fc2e88ca99857d21ef255184c93fb1ff4f01d3"), - d: &hex!("014787f95fb1057a2f3867b8407e54abb91740c097dac5024be92d5d65666bb16e4879f3d3904d6eab269cf5e7b632ab3c5f342108d1d4230c30165fba3a1bf1c66f"), - q_x: &hex!("00c2d540a7557f4530de35bbd94da8a6defbff783f54a65292f8f76341c996cea38795805a1b97174a9147a8644282e0d7040a6f83423ef2a0453248156393a1782e"), - q_y: &hex!("0119f746c5df8cec24e4849ac1870d0d8594c799d2ceb6c3bdf891dfbd2242e7ea24d6aec3166214734acc4cbf4da8f71e2429c5c187b2b3a048527c861f58a9b97f"), - k: &hex!("0186cd803e6e0c9925022e41cb68671adba3ead5548c2b1cd09348ab19612b7af3820fd14da5fe1d7b550ed1a3c8d2f30592cd7745a3c09ee7b5dcfa9ed31bdd0f1f"), - r: &hex!("010ed3ab6d07a15dc3376494501c27ce5f78c8a2b30cc809d3f9c3bf1aef437e590ef66abae4e49065ead1af5f752ec145acfa98329f17bca9991a199579c41f9229"), - s: &hex!("008c3457fe1f93d635bb52df9218bf3b49a7a345b8a8a988ac0a254340546752cddf02e6ce47eee58ea398fdc9130e55a4c09f5ae548c715f5bcd539f07a34034d78"), + m: &hex!( + "000046ff533622cc90321a3aeb077ec4db4fbf372c7a9db48b59de7c5d59e6314110676ba5491bd20d0f02774eef96fc2e88ca99857d21ef255184c93fb1ff4f01d3" + ), + d: &hex!( + "014787f95fb1057a2f3867b8407e54abb91740c097dac5024be92d5d65666bb16e4879f3d3904d6eab269cf5e7b632ab3c5f342108d1d4230c30165fba3a1bf1c66f" + ), + q_x: &hex!( + "00c2d540a7557f4530de35bbd94da8a6defbff783f54a65292f8f76341c996cea38795805a1b97174a9147a8644282e0d7040a6f83423ef2a0453248156393a1782e" + ), + q_y: &hex!( + "0119f746c5df8cec24e4849ac1870d0d8594c799d2ceb6c3bdf891dfbd2242e7ea24d6aec3166214734acc4cbf4da8f71e2429c5c187b2b3a048527c861f58a9b97f" + ), + k: &hex!( + "0186cd803e6e0c9925022e41cb68671adba3ead5548c2b1cd09348ab19612b7af3820fd14da5fe1d7b550ed1a3c8d2f30592cd7745a3c09ee7b5dcfa9ed31bdd0f1f" + ), + r: &hex!( + "010ed3ab6d07a15dc3376494501c27ce5f78c8a2b30cc809d3f9c3bf1aef437e590ef66abae4e49065ead1af5f752ec145acfa98329f17bca9991a199579c41f9229" + ), + s: &hex!( + "008c3457fe1f93d635bb52df9218bf3b49a7a345b8a8a988ac0a254340546752cddf02e6ce47eee58ea398fdc9130e55a4c09f5ae548c715f5bcd539f07a34034d78" + ), }, TestVector { - m: &hex!("00006b514f8d85145e30ced23b4b22c85d79ed2bfcfed5b6b2b03f7c730f1981d46d4dadd6699c28627d41c8684bac305b59eb1d9c966de184ae3d7470a801c99fd4"), - d: &hex!("015807c101099c8d1d3f24b212af2c0ce525432d7779262eed0709275de9a1d8a8eeeadf2f909cf08b4720815bc1205a23ad1f825618cb78bde747acad8049ca9742"), - q_x: &hex!("0160d7ea2e128ab3fabd1a3ad5455cb45e2f977c2354a1345d4ae0c7ce4e492fb9ff958eddc2aa61735e5c1971fa6c99beda0f424a20c3ce969380aaa52ef5f5daa8"), - q_y: &hex!("014e4c83f90d196945fb4fe1e41913488aa53e24c1d2142d35a1eed69fed784c0ef44d71bc21afe0a0065b3b87069217a5abab4355cf8f4ceae5657cd4b9c8008f1f"), - k: &hex!("0096731f8c52e72ffcc095dd2ee4eec3da13c628f570dba169b4a7460ab471149abdede0b63e4f96faf57eab809c7d2f203fd5ab406c7bd79869b7fae9c62f97c794"), - r: &hex!("01e2bf98d1186d7bd3509f517c220de51c9200981e9b344b9fb0d36f34d969026c80311e7e73bb13789a99e0d59e82ebe0e9595d9747204c5f5550c30d934aa30c05"), - s: &hex!("012fed45cc874dc3ed3a11dd70f7d5c61451fbea497dd63e226e10364e0718d3722c27c7b4e5027051d54b8f2a57fc58bc070a55b1a5877b0f388d768837ef2e9cec"), + m: &hex!( + "00006b514f8d85145e30ced23b4b22c85d79ed2bfcfed5b6b2b03f7c730f1981d46d4dadd6699c28627d41c8684bac305b59eb1d9c966de184ae3d7470a801c99fd4" + ), + d: &hex!( + "015807c101099c8d1d3f24b212af2c0ce525432d7779262eed0709275de9a1d8a8eeeadf2f909cf08b4720815bc1205a23ad1f825618cb78bde747acad8049ca9742" + ), + q_x: &hex!( + "0160d7ea2e128ab3fabd1a3ad5455cb45e2f977c2354a1345d4ae0c7ce4e492fb9ff958eddc2aa61735e5c1971fa6c99beda0f424a20c3ce969380aaa52ef5f5daa8" + ), + q_y: &hex!( + "014e4c83f90d196945fb4fe1e41913488aa53e24c1d2142d35a1eed69fed784c0ef44d71bc21afe0a0065b3b87069217a5abab4355cf8f4ceae5657cd4b9c8008f1f" + ), + k: &hex!( + "0096731f8c52e72ffcc095dd2ee4eec3da13c628f570dba169b4a7460ab471149abdede0b63e4f96faf57eab809c7d2f203fd5ab406c7bd79869b7fae9c62f97c794" + ), + r: &hex!( + "01e2bf98d1186d7bd3509f517c220de51c9200981e9b344b9fb0d36f34d969026c80311e7e73bb13789a99e0d59e82ebe0e9595d9747204c5f5550c30d934aa30c05" + ), + s: &hex!( + "012fed45cc874dc3ed3a11dd70f7d5c61451fbea497dd63e226e10364e0718d3722c27c7b4e5027051d54b8f2a57fc58bc070a55b1a5877b0f388d768837ef2e9cec" + ), }, TestVector { - m: &hex!("000053c86e0b08b28e22131324f6bfad52984879ab09363d6b6c051aac78bf3568be3faeade6a2dda57dece4527abaa148326d3adbd2d725374bdac9ccb8ac39e51e"), - d: &hex!("018692def0b516edcdd362f42669999cf27a65482f9358fcab312c6869e22ac469b82ca9036fe123935b8b9ed064acb347227a6e377fb156ec833dab9f170c2ac697"), - q_x: &hex!("01ceee0be3293d8c0fc3e38a78df55e85e6b4bbce0b9995251f0ac55234140f82ae0a434b2bb41dc0aa5ecf950d4628f82c7f4f67651b804d55d844a02c1da6606f7"), - q_y: &hex!("01f775eb6b3c5e43fc754052d1f7fc5b99137afc15d231a0199a702fc065c917e628a54e038cbfebe05c90988b65183b368a2061e5b5c1b025bbf2b748fae00ba297"), - k: &hex!("0161cf5d37953e09e12dc0091dc35d5fb3754c5c874e474d2b4a4f1a90b870dff6d99fb156498516e25b9a6a0763170702bb8507fdba4a6131c7258f6ffc3add81fd"), - r: &hex!("014dfa43046302b81fd9a34a454dea25ccb594ace8df4f9d98556ca5076bcd44b2a9775dfaca50282b2c8988868e5a31d9eb08e794016996942088d43ad3379eb9a1"), - s: &hex!("0120be63bd97691f6258b5e78817f2dd6bf5a7bf79d01b8b1c3382860c4b00f89894c72f93a69f3119cb74c90b03e9ede27bd298b357b9616a7282d176f3899aaa24"), + m: &hex!( + "000053c86e0b08b28e22131324f6bfad52984879ab09363d6b6c051aac78bf3568be3faeade6a2dda57dece4527abaa148326d3adbd2d725374bdac9ccb8ac39e51e" + ), + d: &hex!( + "018692def0b516edcdd362f42669999cf27a65482f9358fcab312c6869e22ac469b82ca9036fe123935b8b9ed064acb347227a6e377fb156ec833dab9f170c2ac697" + ), + q_x: &hex!( + "01ceee0be3293d8c0fc3e38a78df55e85e6b4bbce0b9995251f0ac55234140f82ae0a434b2bb41dc0aa5ecf950d4628f82c7f4f67651b804d55d844a02c1da6606f7" + ), + q_y: &hex!( + "01f775eb6b3c5e43fc754052d1f7fc5b99137afc15d231a0199a702fc065c917e628a54e038cbfebe05c90988b65183b368a2061e5b5c1b025bbf2b748fae00ba297" + ), + k: &hex!( + "0161cf5d37953e09e12dc0091dc35d5fb3754c5c874e474d2b4a4f1a90b870dff6d99fb156498516e25b9a6a0763170702bb8507fdba4a6131c7258f6ffc3add81fd" + ), + r: &hex!( + "014dfa43046302b81fd9a34a454dea25ccb594ace8df4f9d98556ca5076bcd44b2a9775dfaca50282b2c8988868e5a31d9eb08e794016996942088d43ad3379eb9a1" + ), + s: &hex!( + "0120be63bd97691f6258b5e78817f2dd6bf5a7bf79d01b8b1c3382860c4b00f89894c72f93a69f3119cb74c90b03e9ede27bd298b357b9616a7282d176f3899aaa24" + ), }, TestVector { - m: &hex!("0000a9e9a9cb1febc380a22c03bacd18f8c46761180badd2e58b94703bd82d5987c52baec418388bc3f1e6831a130c400b3c865c51b73514f5b0a9026d9e8da2e342"), - d: &hex!("00a63f9cdefbccdd0d5c9630b309027fa139c31e39ca26686d76c22d4093a2a5e5ec4e2308ce43eb8e563187b5bd811cc6b626eace4063047ac0420c3fdcff5bdc04"), - q_x: &hex!("014cab9759d4487987b8a00afd16d7199585b730fb0bfe63796272dde9135e7cb9e27cec51207c876d9214214b8c76f82e7363f5086902a577e1c50b4fbf35ce9966"), - q_y: &hex!("01a83f0caa01ca2166e1206292342f47f358009e8b891d3cb817aec290e0cf2f47e7fc637e39dca03949391839684f76b94d34e5abc7bb750cb44486cce525eb0093"), - k: &hex!("001e51fd877dbbcd2ab138fd215d508879298d10c7fcbdcc918802407088eb6ca0f18976a13f2c0a57867b0298512fc85515b209c4435e9ef30ab01ba649838bc7a0"), - r: &hex!("011a1323f6132d85482d9b0f73be838d8f9e78647934f2570fededca7c234cc46aa1b97da5ac1b27b714f7a171dc4209cbb0d90e4f793c4c192dc039c31310d6d99b"), - s: &hex!("00386a5a0fc55d36ca7231a9537fee6b9e51c2255363d9c9e7cb7185669b302660e23133eb21eb56d305d36e69a79f5b6fa25b46ec61b7f699e1e9e927fb0bceca06"), + m: &hex!( + "0000a9e9a9cb1febc380a22c03bacd18f8c46761180badd2e58b94703bd82d5987c52baec418388bc3f1e6831a130c400b3c865c51b73514f5b0a9026d9e8da2e342" + ), + d: &hex!( + "00a63f9cdefbccdd0d5c9630b309027fa139c31e39ca26686d76c22d4093a2a5e5ec4e2308ce43eb8e563187b5bd811cc6b626eace4063047ac0420c3fdcff5bdc04" + ), + q_x: &hex!( + "014cab9759d4487987b8a00afd16d7199585b730fb0bfe63796272dde9135e7cb9e27cec51207c876d9214214b8c76f82e7363f5086902a577e1c50b4fbf35ce9966" + ), + q_y: &hex!( + "01a83f0caa01ca2166e1206292342f47f358009e8b891d3cb817aec290e0cf2f47e7fc637e39dca03949391839684f76b94d34e5abc7bb750cb44486cce525eb0093" + ), + k: &hex!( + "001e51fd877dbbcd2ab138fd215d508879298d10c7fcbdcc918802407088eb6ca0f18976a13f2c0a57867b0298512fc85515b209c4435e9ef30ab01ba649838bc7a0" + ), + r: &hex!( + "011a1323f6132d85482d9b0f73be838d8f9e78647934f2570fededca7c234cc46aa1b97da5ac1b27b714f7a171dc4209cbb0d90e4f793c4c192dc039c31310d6d99b" + ), + s: &hex!( + "00386a5a0fc55d36ca7231a9537fee6b9e51c2255363d9c9e7cb7185669b302660e23133eb21eb56d305d36e69a79f5b6fa25b46ec61b7f699e1e9e927fb0bceca06" + ), }, TestVector { - m: &hex!("00007e324819033de8f2bffded5472853c3e68f4872ed25db79636249aecc24242cc3ca229ce7bd6d74eac8ba32f779e7002095f5d452d0bf24b30e1ce2eb56bb413"), - d: &hex!("0024f7d67dfc0d43a26cc7c19cb511d30a097a1e27e5efe29e9e76e43849af170fd9ad57d5b22b1c8840b59ebf562371871e12d2c1baefc1abaedc872ed5d2666ad6"), - q_x: &hex!("009da1536154b46e3169265ccba2b4da9b4b06a7462a067c6909f6c0dd8e19a7bc2ac1a47763ec4be06c1bec57d28c55ee936cb19588cc1398fe4ea3bd07e6676b7f"), - q_y: &hex!("014150cdf25da0925926422e1fd4dcfcffb05bdf8682c54d67a9bd438d21de5af43a15d979b320a847683b6d12ac1383a7183095e9da491c3b4a7c28874625e70f87"), - k: &hex!("01c1308f31716d85294b3b5f1dc87d616093b7654907f55289499b419f38ceeb906d2c9fe4cc3d80c5a38c53f9739311b0b198111fede72ebde3b0d2bc4c2ef090d2"), - r: &hex!("000dbf787ce07c453c6c6a67b0bf6850c8d6ca693a3e9818d7453487844c9048a7a2e48ff982b64eb9712461b26b5127c4dc57f9a6ad1e15d8cd56d4fd6da7186429"), - s: &hex!("00c6f1c7774caf198fc189beb7e21ca92ceccc3f9875f0e2d07dc1d15bcc8f210b6dd376bf65bb6a454bf563d7f563c1041d62d6078828a57538b25ba54723170665"), + m: &hex!( + "00007e324819033de8f2bffded5472853c3e68f4872ed25db79636249aecc24242cc3ca229ce7bd6d74eac8ba32f779e7002095f5d452d0bf24b30e1ce2eb56bb413" + ), + d: &hex!( + "0024f7d67dfc0d43a26cc7c19cb511d30a097a1e27e5efe29e9e76e43849af170fd9ad57d5b22b1c8840b59ebf562371871e12d2c1baefc1abaedc872ed5d2666ad6" + ), + q_x: &hex!( + "009da1536154b46e3169265ccba2b4da9b4b06a7462a067c6909f6c0dd8e19a7bc2ac1a47763ec4be06c1bec57d28c55ee936cb19588cc1398fe4ea3bd07e6676b7f" + ), + q_y: &hex!( + "014150cdf25da0925926422e1fd4dcfcffb05bdf8682c54d67a9bd438d21de5af43a15d979b320a847683b6d12ac1383a7183095e9da491c3b4a7c28874625e70f87" + ), + k: &hex!( + "01c1308f31716d85294b3b5f1dc87d616093b7654907f55289499b419f38ceeb906d2c9fe4cc3d80c5a38c53f9739311b0b198111fede72ebde3b0d2bc4c2ef090d2" + ), + r: &hex!( + "000dbf787ce07c453c6c6a67b0bf6850c8d6ca693a3e9818d7453487844c9048a7a2e48ff982b64eb9712461b26b5127c4dc57f9a6ad1e15d8cd56d4fd6da7186429" + ), + s: &hex!( + "00c6f1c7774caf198fc189beb7e21ca92ceccc3f9875f0e2d07dc1d15bcc8f210b6dd376bf65bb6a454bf563d7f563c1041d62d6078828a57538b25ba54723170665" + ), }, TestVector { - m: &hex!("00004541f9a04b289cd3b13d31d2f513d9243b7e8c3a0cbd3e0c790892235a4d4569ef8aef62444ecc64608509e6ad082bf7cd060d172550faa158b2fd396aa1e37b"), - d: &hex!("00349471460c205d836aa37dcd6c7322809e4e8ef81501e5da87284b267d843897746b33016f50a7b702964910361ed51d0afd9d8559a47f0b7c25b2bc952ce8ed9e"), - q_x: &hex!("000bbd4e8a016b0c254e754f68f0f4ed081320d529ecdc7899cfb5a67dd04bc85b3aa6891a3ed2c9861ae76c3847d81780c23ad84153ea2042d7fd5d517a26ff3ce4"), - q_y: &hex!("00645953afc3c1b3b74fdf503e7d3f982d7ee17611d60f8eb42a4bddbec2b67db1f09b54440c30b44e8071d404658285cb571462001218fc8c5e5b98b9fae28272e6"), - k: &hex!("000eb2bd8bb56b9d2e97c51247baf734cc655c39e0bfda35375f0ac2fe82fad699bf1989577e24afb33c3868f91111e24fefe7dec802f3323ac013bec6c048fe5568"), - r: &hex!("014bf63bdbc014aa352544bd1e83ede484807ed760619fa6bc38c4f8640840195e1f2f149b29903ca4b6934404fb1f7de5e39b1ea04dba42819c75dbef6a93ebe269"), - s: &hex!("005d1bcf2295240ce4415042306abd494b4bda7cf36f2ee2931518d2454faa01c606be120b057062f2f3a174cb09c14f57ab6ef41cb3802140da22074d0e46f908d4"), + m: &hex!( + "00004541f9a04b289cd3b13d31d2f513d9243b7e8c3a0cbd3e0c790892235a4d4569ef8aef62444ecc64608509e6ad082bf7cd060d172550faa158b2fd396aa1e37b" + ), + d: &hex!( + "00349471460c205d836aa37dcd6c7322809e4e8ef81501e5da87284b267d843897746b33016f50a7b702964910361ed51d0afd9d8559a47f0b7c25b2bc952ce8ed9e" + ), + q_x: &hex!( + "000bbd4e8a016b0c254e754f68f0f4ed081320d529ecdc7899cfb5a67dd04bc85b3aa6891a3ed2c9861ae76c3847d81780c23ad84153ea2042d7fd5d517a26ff3ce4" + ), + q_y: &hex!( + "00645953afc3c1b3b74fdf503e7d3f982d7ee17611d60f8eb42a4bddbec2b67db1f09b54440c30b44e8071d404658285cb571462001218fc8c5e5b98b9fae28272e6" + ), + k: &hex!( + "000eb2bd8bb56b9d2e97c51247baf734cc655c39e0bfda35375f0ac2fe82fad699bf1989577e24afb33c3868f91111e24fefe7dec802f3323ac013bec6c048fe5568" + ), + r: &hex!( + "014bf63bdbc014aa352544bd1e83ede484807ed760619fa6bc38c4f8640840195e1f2f149b29903ca4b6934404fb1f7de5e39b1ea04dba42819c75dbef6a93ebe269" + ), + s: &hex!( + "005d1bcf2295240ce4415042306abd494b4bda7cf36f2ee2931518d2454faa01c606be120b057062f2f3a174cb09c14f57ab6ef41cb3802140da22074d0e46f908d4" + ), }, TestVector { - m: &hex!("00007ec0906f9fbe0e001460852c0b6111b1cd01c9306c0c57a5e746d43f48f50ebb111551d04a90255b22690d79ea60e58bed88220d485daaf9b6431740bb499e39"), - d: &hex!("007788d34758b20efc330c67483be3999d1d1a16fd0da81ed28895ebb35ee21093d37ea1ac808946c275c44454a216195eb3eb3aea1b53a329eca4eb82dd48c784f5"), - q_x: &hex!("00157d80bd426f6c3cee903c24b73faa02e758607c3e102d6e643b7269c299684fdaba1acddb83ee686a60acca53cddb2fe976149205c8b8ab6ad1458bc00993cc43"), - q_y: &hex!("016e33cbed05721b284dacc8c8fbe2d118c347fc2e2670e691d5d53daf6ef2dfec464a5fbf46f8efce81ac226915e11d43c11c8229fca2327815e1f8da5fe95021fc"), - k: &hex!("00a73477264a9cc69d359464abb1ac098a18c0fb3ea35e4f2e6e1b060dab05bef1255d9f9c9b9fbb89712e5afe13745ae6fd5917a9aedb0f2860d03a0d8f113ea10c"), - r: &hex!("007e315d8d958b8ce27eaf4f3782294341d2a46fb1457a60eb9fe93a9ae86f3764716c4f5f124bd6b114781ed59c3f24e18aa35c903211b2f2039d85862932987d68"), - s: &hex!("01bcc1d211ebc120a97d465b603a1bb1e470109e0a55d2f1b5c597803931bd6d7718f010d7d289b31533e9fcef3d141974e5955bc7f0ee342b9cad05e29a3dded30e"), + m: &hex!( + "00007ec0906f9fbe0e001460852c0b6111b1cd01c9306c0c57a5e746d43f48f50ebb111551d04a90255b22690d79ea60e58bed88220d485daaf9b6431740bb499e39" + ), + d: &hex!( + "007788d34758b20efc330c67483be3999d1d1a16fd0da81ed28895ebb35ee21093d37ea1ac808946c275c44454a216195eb3eb3aea1b53a329eca4eb82dd48c784f5" + ), + q_x: &hex!( + "00157d80bd426f6c3cee903c24b73faa02e758607c3e102d6e643b7269c299684fdaba1acddb83ee686a60acca53cddb2fe976149205c8b8ab6ad1458bc00993cc43" + ), + q_y: &hex!( + "016e33cbed05721b284dacc8c8fbe2d118c347fc2e2670e691d5d53daf6ef2dfec464a5fbf46f8efce81ac226915e11d43c11c8229fca2327815e1f8da5fe95021fc" + ), + k: &hex!( + "00a73477264a9cc69d359464abb1ac098a18c0fb3ea35e4f2e6e1b060dab05bef1255d9f9c9b9fbb89712e5afe13745ae6fd5917a9aedb0f2860d03a0d8f113ea10c" + ), + r: &hex!( + "007e315d8d958b8ce27eaf4f3782294341d2a46fb1457a60eb9fe93a9ae86f3764716c4f5f124bd6b114781ed59c3f24e18aa35c903211b2f2039d85862932987d68" + ), + s: &hex!( + "01bcc1d211ebc120a97d465b603a1bb1e470109e0a55d2f1b5c597803931bd6d7718f010d7d289b31533e9fcef3d141974e5955bc7f0ee342b9cad05e29a3dded30e" + ), }, TestVector { - m: &hex!("00007230642b79eed2fd50f19f79f943d67d6ef609ec06c9adbb4b0a62126926080ecd474922d1af6c01f4c354affde016b284b13dbb3122555dea2a2e6ca2a357dc"), - d: &hex!("01f98696772221e6cccd5569ed8aed3c435ee86a04689c7a64d20c30f6fe1c59cc10c6d2910261d30c3b96117a669e19cfe5b696b68feeacf61f6a3dea55e6e5837a"), - q_x: &hex!("007002872c200e16d57e8e53f7bce6e9a7832c387f6f9c29c6b75526262c57bc2b56d63e9558c5761c1d62708357f586d3aab41c6a7ca3bf6c32d9c3ca40f9a2796a"), - q_y: &hex!("01fe3e52472ef224fb38d5a0a14875b52c2f50b82b99eea98d826c77e6a9ccf798de5ffa92a0d65965f740c702a3027be66b9c844f1b2e96c134eb3fdf3edddcf11c"), - k: &hex!("01a277cf0414c6adb621d1cc0311ec908401ce040c6687ed45a0cdf2910c42c9f1954a4572d8e659733d5e26cbd35e3260be40017b2f5d38ec42315f5c0b056c596d"), - r: &hex!("00d732ba8b3e9c9e0a495249e152e5bee69d94e9ff012d001b140d4b5d082aa9df77e10b65f115a594a50114722db42fa5fbe457c5bd05e7ac7ee510aa68fe7b1e7f"), - s: &hex!("0134ac5e1ee339727df80c35ff5b2891596dd14d6cfd137bafd50ab98e2c1ab4008a0bd03552618d217912a9ec502a902f2353e757c3b5776309f7f2cfebf913e9cd"), + m: &hex!( + "00007230642b79eed2fd50f19f79f943d67d6ef609ec06c9adbb4b0a62126926080ecd474922d1af6c01f4c354affde016b284b13dbb3122555dea2a2e6ca2a357dc" + ), + d: &hex!( + "01f98696772221e6cccd5569ed8aed3c435ee86a04689c7a64d20c30f6fe1c59cc10c6d2910261d30c3b96117a669e19cfe5b696b68feeacf61f6a3dea55e6e5837a" + ), + q_x: &hex!( + "007002872c200e16d57e8e53f7bce6e9a7832c387f6f9c29c6b75526262c57bc2b56d63e9558c5761c1d62708357f586d3aab41c6a7ca3bf6c32d9c3ca40f9a2796a" + ), + q_y: &hex!( + "01fe3e52472ef224fb38d5a0a14875b52c2f50b82b99eea98d826c77e6a9ccf798de5ffa92a0d65965f740c702a3027be66b9c844f1b2e96c134eb3fdf3edddcf11c" + ), + k: &hex!( + "01a277cf0414c6adb621d1cc0311ec908401ce040c6687ed45a0cdf2910c42c9f1954a4572d8e659733d5e26cbd35e3260be40017b2f5d38ec42315f5c0b056c596d" + ), + r: &hex!( + "00d732ba8b3e9c9e0a495249e152e5bee69d94e9ff012d001b140d4b5d082aa9df77e10b65f115a594a50114722db42fa5fbe457c5bd05e7ac7ee510aa68fe7b1e7f" + ), + s: &hex!( + "0134ac5e1ee339727df80c35ff5b2891596dd14d6cfd137bafd50ab98e2c1ab4008a0bd03552618d217912a9ec502a902f2353e757c3b5776309f7f2cfebf913e9cd" + ), }, TestVector { - m: &hex!("0000d209f43006e29ada2b9fe840afdf5fe6b0abeeef5662acf3fbca7e6d1bf4538f7e860332ef6122020e70104b541c30c3c0581e2b1daa0d767271769d0f073133"), - d: &hex!("013c3852a6bc8825b45fd7da1754078913d77f4e586216a6eb08b6f03adce7464f5dbc2bea0eb7b12d103870ef045f53d67e3600d7eba07aac5db03f71b64db1cceb"), - q_x: &hex!("00c97a4ebcbbe701c9f7be127e87079edf479b76d3c14bfbee693e1638e5bff8d4705ac0c14597529dbe13356ca85eb03a418edfe144ce6cbf3533016d4efc29dbd4"), - q_y: &hex!("011c75b7a8894ef64109ac2dea972e7fd5f79b75dab1bf9441a5b8b86f1dc1324426fa6cf4e7b973b44e3d0576c52e5c9edf8ce2fc18cb3c28742d44419f044667f8"), - k: &hex!("01e25b86db041f21c2503d547e2b1b655f0b99d5b6c0e1cf2bdbd8a8c6a053f5d79d78c55b4ef75bff764a74edc920b35536e3c470b6f6b8fd53898f3bbc467539ef"), - r: &hex!("01dce45ea592b34d016497882c48dc0c7afb1c8e0f81a051800d7ab8da9d237efd892207bc9401f1d30650f66af8d5349fc5b19727756270722d5a8adb0a49b72d0a"), - s: &hex!("00b79ffcdc33e028b1ab894cb751ec792a69e3011b201a76f3b878655bc31efd1c0bf3b98aea2b14f262c19d142e008b98e890ebbf464d3b025764dd2f73c4251b1a"), + m: &hex!( + "0000d209f43006e29ada2b9fe840afdf5fe6b0abeeef5662acf3fbca7e6d1bf4538f7e860332ef6122020e70104b541c30c3c0581e2b1daa0d767271769d0f073133" + ), + d: &hex!( + "013c3852a6bc8825b45fd7da1754078913d77f4e586216a6eb08b6f03adce7464f5dbc2bea0eb7b12d103870ef045f53d67e3600d7eba07aac5db03f71b64db1cceb" + ), + q_x: &hex!( + "00c97a4ebcbbe701c9f7be127e87079edf479b76d3c14bfbee693e1638e5bff8d4705ac0c14597529dbe13356ca85eb03a418edfe144ce6cbf3533016d4efc29dbd4" + ), + q_y: &hex!( + "011c75b7a8894ef64109ac2dea972e7fd5f79b75dab1bf9441a5b8b86f1dc1324426fa6cf4e7b973b44e3d0576c52e5c9edf8ce2fc18cb3c28742d44419f044667f8" + ), + k: &hex!( + "01e25b86db041f21c2503d547e2b1b655f0b99d5b6c0e1cf2bdbd8a8c6a053f5d79d78c55b4ef75bff764a74edc920b35536e3c470b6f6b8fd53898f3bbc467539ef" + ), + r: &hex!( + "01dce45ea592b34d016497882c48dc0c7afb1c8e0f81a051800d7ab8da9d237efd892207bc9401f1d30650f66af8d5349fc5b19727756270722d5a8adb0a49b72d0a" + ), + s: &hex!( + "00b79ffcdc33e028b1ab894cb751ec792a69e3011b201a76f3b878655bc31efd1c0bf3b98aea2b14f262c19d142e008b98e890ebbf464d3b025764dd2f73c4251b1a" + ), }, TestVector { - m: &hex!("0000c992314e8d282d10554b2e6e8769e8b10f85686cccafb30e7db62beaad080e0da6b5cf7cd1fc5614df56705fb1a841987cb950101e2f66d55f3a285fc75829ff"), - d: &hex!("01654eaa1f6eec7159ee2d36fb24d15d6d33a128f36c52e2437f7d1b5a44ea4fa965c0a26d0066f92c8b82bd136491e929686c8bde61b7c704daab54ed1e1bdf6b77"), - q_x: &hex!("01f269692c47a55242bb08731ff920f4915bfcecf4d4431a8b487c90d08565272c52ca90c47397f7604bc643982e34d05178e979c2cff7ea1b9eaec18d69ca7382de"), - q_y: &hex!("00750bdd866fba3e92c29599c002ac6f9e2bf39af8521b7b133f70510e9918a94d3c279edec97ab75ecda95e3dd7861af84c543371c055dc74eeeff7061726818327"), - k: &hex!("01b7519becd00d750459d63a72f13318b6ac61b8c8e7077cf9415c9b4b924f35514c9c28a0fae43d06e31c670a873716156aa7bc744577d62476e038b116576a9e53"), - r: &hex!("0183bddb46c249e868ef231a1ebd85d0773bf8105a092ab7d884d677a1e9b7d6014d6358c09538a99d9dca8f36f163ac1827df420c3f9360cc66900a9737a7f756f3"), - s: &hex!("00d05ee3e64bac4e56d9d8bd511c8a43941e953cba4e5d83c0553acb87091ff54f3aad4d69d9f15e520a2551cc14f2c86bb45513fef0295e381a7635486bd3917b50"), + m: &hex!( + "0000c992314e8d282d10554b2e6e8769e8b10f85686cccafb30e7db62beaad080e0da6b5cf7cd1fc5614df56705fb1a841987cb950101e2f66d55f3a285fc75829ff" + ), + d: &hex!( + "01654eaa1f6eec7159ee2d36fb24d15d6d33a128f36c52e2437f7d1b5a44ea4fa965c0a26d0066f92c8b82bd136491e929686c8bde61b7c704daab54ed1e1bdf6b77" + ), + q_x: &hex!( + "01f269692c47a55242bb08731ff920f4915bfcecf4d4431a8b487c90d08565272c52ca90c47397f7604bc643982e34d05178e979c2cff7ea1b9eaec18d69ca7382de" + ), + q_y: &hex!( + "00750bdd866fba3e92c29599c002ac6f9e2bf39af8521b7b133f70510e9918a94d3c279edec97ab75ecda95e3dd7861af84c543371c055dc74eeeff7061726818327" + ), + k: &hex!( + "01b7519becd00d750459d63a72f13318b6ac61b8c8e7077cf9415c9b4b924f35514c9c28a0fae43d06e31c670a873716156aa7bc744577d62476e038b116576a9e53" + ), + r: &hex!( + "0183bddb46c249e868ef231a1ebd85d0773bf8105a092ab7d884d677a1e9b7d6014d6358c09538a99d9dca8f36f163ac1827df420c3f9360cc66900a9737a7f756f3" + ), + s: &hex!( + "00d05ee3e64bac4e56d9d8bd511c8a43941e953cba4e5d83c0553acb87091ff54f3aad4d69d9f15e520a2551cc14f2c86bb45513fef0295e381a7635486bd3917b50" + ), }, TestVector { - m: &hex!("00006e14c91db5309a075fe69f6fe8ecd663a5ba7fab14770f96b05c22e1f631cde9e086c44335a25f63d5a43ddf57da899fcedbc4a3a4350ad2edd6f70c01bb051e"), - d: &hex!("01cba5d561bf18656991eba9a1dde8bde547885ea1f0abe7f2837e569ca52f53df5e64e4a547c4f26458b5d9626ed6d702e5ab1dd585cf36a0c84f768fac946cfd4c"), - q_x: &hex!("012857c2244fa04db3b73db4847927db63cce2fa6cb22724466d3e20bc950a9250a15eafd99f236a801e5271e8f90d9e8a97f37c12f7da65bce8a2c93bcd25526205"), - q_y: &hex!("00f394e37c17d5b8e35b488fa05a607dbc74264965043a1fb60e92edc212296ae72d7d6fe2e3457e67be853664e1da64f57e44bd259076b3bb2b06a2c604fea1be9d"), - k: &hex!("00e790238796fee7b5885dc0784c7041a4cc7ca4ba757d9f7906ad1fcbab5667e3734bc2309a48047442535ff89144b518f730ff55c0c67eeb4c880c2dfd2fb60d69"), - r: &hex!("01d7ce382295a2a109064ea03f0ad8761dd60eefb9c207a20e3c5551e82ac6d2ee5922b3e9655a65ba6c359dcbf8fa843fbe87239a5c3e3eaecec0407d2fcdb687c2"), - s: &hex!("0161963a6237b8955a8a756d8df5dbd303140bb90143b1da5f07b32f9cb64733dc6316080924733f1e2c81ade9d0be71b5b95b55666026a035a93ab3004d0bc0b19f"), + m: &hex!( + "00006e14c91db5309a075fe69f6fe8ecd663a5ba7fab14770f96b05c22e1f631cde9e086c44335a25f63d5a43ddf57da899fcedbc4a3a4350ad2edd6f70c01bb051e" + ), + d: &hex!( + "01cba5d561bf18656991eba9a1dde8bde547885ea1f0abe7f2837e569ca52f53df5e64e4a547c4f26458b5d9626ed6d702e5ab1dd585cf36a0c84f768fac946cfd4c" + ), + q_x: &hex!( + "012857c2244fa04db3b73db4847927db63cce2fa6cb22724466d3e20bc950a9250a15eafd99f236a801e5271e8f90d9e8a97f37c12f7da65bce8a2c93bcd25526205" + ), + q_y: &hex!( + "00f394e37c17d5b8e35b488fa05a607dbc74264965043a1fb60e92edc212296ae72d7d6fe2e3457e67be853664e1da64f57e44bd259076b3bb2b06a2c604fea1be9d" + ), + k: &hex!( + "00e790238796fee7b5885dc0784c7041a4cc7ca4ba757d9f7906ad1fcbab5667e3734bc2309a48047442535ff89144b518f730ff55c0c67eeb4c880c2dfd2fb60d69" + ), + r: &hex!( + "01d7ce382295a2a109064ea03f0ad8761dd60eefb9c207a20e3c5551e82ac6d2ee5922b3e9655a65ba6c359dcbf8fa843fbe87239a5c3e3eaecec0407d2fcdb687c2" + ), + s: &hex!( + "0161963a6237b8955a8a756d8df5dbd303140bb90143b1da5f07b32f9cb64733dc6316080924733f1e2c81ade9d0be71b5b95b55666026a035a93ab3004d0bc0b19f" + ), }, TestVector { - m: &hex!("000026b4f562053f7aed8b7268e95eff336ac80a448fae52329d2771b138c9c7f70de936ef54158446afa72b0a27c2a73ca45dfa38a2ba2bf323d31aba499651128f"), - d: &hex!("00972e7ff25adf8a032535e5b19463cfe306b90803bf27fabc6046ae0807d2312fbab85d1da61b80b2d5d48f4e5886f27fca050b84563aee1926ae6b2564cd756d63"), - q_x: &hex!("01d7f1e9e610619daa9d2efa563610a371677fe8b58048fdc55a98a49970f6afa6649c516f9c72085ca3722aa595f45f2803402b01c832d28aac63d9941f1a25dfea"), - q_y: &hex!("01571facce3fcfe733a8eef4e8305dfe99103a370f82b3f8d75085414f2592ad44969a2ef8196c8b9809f0eca2f7ddc71c47879e3f37a40b9fecf97992b97af29721"), - k: &hex!("00517f6e4002479dc89e8cbb55b7c426d128776ca82cf81be8c1da9557178783f40e3d047db7e77867f1af030a51de470ee3128c22e9c2d642d71e4904ab5a76edfa"), - r: &hex!("01c3262a3a3fb74fa5124b71a6c7f7b7e6d56738eabaf7666b372b299b0c99ee8a16be3df88dd955de093fc8c049f76ee83a4138cee41e5fe94755d27a52ee44032f"), - s: &hex!("0072fd88bb1684c4ca9531748dfce4c161037fcd6ae5c2803b7117fb60d3db5df7df380591aaf3073a3031306b76f062dcc547ded23f6690293c34a710e7e9a226c3"), + m: &hex!( + "000026b4f562053f7aed8b7268e95eff336ac80a448fae52329d2771b138c9c7f70de936ef54158446afa72b0a27c2a73ca45dfa38a2ba2bf323d31aba499651128f" + ), + d: &hex!( + "00972e7ff25adf8a032535e5b19463cfe306b90803bf27fabc6046ae0807d2312fbab85d1da61b80b2d5d48f4e5886f27fca050b84563aee1926ae6b2564cd756d63" + ), + q_x: &hex!( + "01d7f1e9e610619daa9d2efa563610a371677fe8b58048fdc55a98a49970f6afa6649c516f9c72085ca3722aa595f45f2803402b01c832d28aac63d9941f1a25dfea" + ), + q_y: &hex!( + "01571facce3fcfe733a8eef4e8305dfe99103a370f82b3f8d75085414f2592ad44969a2ef8196c8b9809f0eca2f7ddc71c47879e3f37a40b9fecf97992b97af29721" + ), + k: &hex!( + "00517f6e4002479dc89e8cbb55b7c426d128776ca82cf81be8c1da9557178783f40e3d047db7e77867f1af030a51de470ee3128c22e9c2d642d71e4904ab5a76edfa" + ), + r: &hex!( + "01c3262a3a3fb74fa5124b71a6c7f7b7e6d56738eabaf7666b372b299b0c99ee8a16be3df88dd955de093fc8c049f76ee83a4138cee41e5fe94755d27a52ee44032f" + ), + s: &hex!( + "0072fd88bb1684c4ca9531748dfce4c161037fcd6ae5c2803b7117fb60d3db5df7df380591aaf3073a3031306b76f062dcc547ded23f6690293c34a710e7e9a226c3" + ), }, TestVector { - m: &hex!("0000ea13b25b80ec89ffa649a00ce85a494892f9fb7389df56eed084d670efb020c05508ac3f04872843c92a67ee5ea02e0445dad8495cd823ca16f5510d5863002b"), - d: &hex!("01f0ec8da29295394f2f072672db014861be33bfd9f91349dad5566ff396bea055e53b1d61c8c4e5c9f6e129ed75a49f91cce1d5530ad4e78c2b793a63195eb9f0da"), - q_x: &hex!("009ec1a3761fe3958073b9647f34202c5e8ca2428d056facc4f3fedc7077fa87f1d1eb30cc74f6e3ff3d3f82df2641cea1eb3ff1529e8a3866ae2055aacec0bf68c4"), - q_y: &hex!("00bed0261b91f664c3ff53e337d8321cb988c3edc03b46754680097e5a8585245d80d0b7045c75a9c5be7f599d3b5eea08d828acb6294ae515a3df57a37f903ef62e"), - k: &hex!("00ac3b6d61ebda99e23301fa198d686a13c0832af594b289c9a55669ce6d62011384769013748b68465527a597ed6858a06a99d50493562b3a7dbcee975ad34657d8"), - r: &hex!("00cef3f4babe6f9875e5db28c27d6a197d607c3641a90f10c2cc2cb302ba658aa151dc76c507488b99f4b3c8bb404fb5c852f959273f412cbdd5e713c5e3f0e67f94"), - s: &hex!("00097ed9e005416fc944e26bcc3661a09b35c128fcccdc2742739c8a301a338dd77d9d13571612a3b9524a6164b09fe73643bbc31447ee31ef44a490843e4e7db23f"), + m: &hex!( + "0000ea13b25b80ec89ffa649a00ce85a494892f9fb7389df56eed084d670efb020c05508ac3f04872843c92a67ee5ea02e0445dad8495cd823ca16f5510d5863002b" + ), + d: &hex!( + "01f0ec8da29295394f2f072672db014861be33bfd9f91349dad5566ff396bea055e53b1d61c8c4e5c9f6e129ed75a49f91cce1d5530ad4e78c2b793a63195eb9f0da" + ), + q_x: &hex!( + "009ec1a3761fe3958073b9647f34202c5e8ca2428d056facc4f3fedc7077fa87f1d1eb30cc74f6e3ff3d3f82df2641cea1eb3ff1529e8a3866ae2055aacec0bf68c4" + ), + q_y: &hex!( + "00bed0261b91f664c3ff53e337d8321cb988c3edc03b46754680097e5a8585245d80d0b7045c75a9c5be7f599d3b5eea08d828acb6294ae515a3df57a37f903ef62e" + ), + k: &hex!( + "00ac3b6d61ebda99e23301fa198d686a13c0832af594b289c9a55669ce6d62011384769013748b68465527a597ed6858a06a99d50493562b3a7dbcee975ad34657d8" + ), + r: &hex!( + "00cef3f4babe6f9875e5db28c27d6a197d607c3641a90f10c2cc2cb302ba658aa151dc76c507488b99f4b3c8bb404fb5c852f959273f412cbdd5e713c5e3f0e67f94" + ), + s: &hex!( + "00097ed9e005416fc944e26bcc3661a09b35c128fcccdc2742739c8a301a338dd77d9d13571612a3b9524a6164b09fe73643bbc31447ee31ef44a490843e4e7db23f" + ), }, ]; diff --git a/p521/src/test_vectors/group.rs b/p521/src/test_vectors/group.rs index 0ddcba66f..7be7e7765 100644 --- a/p521/src/test_vectors/group.rs +++ b/p521/src/test_vectors/group.rs @@ -7,85 +7,165 @@ use hex_literal::hex; /// These are the first 20 test vectors for P-521 from: pub const ADD_TEST_VECTORS: &[([u8; 66], [u8; 66])] = &[ ( - hex!("00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"), - hex!("011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650"), + hex!( + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66" + ), + hex!( + "011839296A789A3BC0045C8A5FB42C7D1BD998F54449579B446817AFBD17273E662C97EE72995EF42640C550B9013FAD0761353C7086A272C24088BE94769FD16650" + ), ), - ( - hex!("00433C219024277E7E682FCB288148C282747403279B1CCC06352C6E5505D769BE97B3B204DA6EF55507AA104A3A35C5AF41CF2FA364D60FD967F43E3933BA6D783D"), - hex!("00F4BB8CC7F86DB26700A7F3ECEEEED3F0B5C6B5107C4DA97740AB21A29906C42DBBB3E377DE9F251F6B93937FA99A3248F4EAFCBE95EDC0F4F71BE356D661F41B02"), + ( + hex!( + "00433C219024277E7E682FCB288148C282747403279B1CCC06352C6E5505D769BE97B3B204DA6EF55507AA104A3A35C5AF41CF2FA364D60FD967F43E3933BA6D783D" + ), + hex!( + "00F4BB8CC7F86DB26700A7F3ECEEEED3F0B5C6B5107C4DA97740AB21A29906C42DBBB3E377DE9F251F6B93937FA99A3248F4EAFCBE95EDC0F4F71BE356D661F41B02" + ), ), - ( - hex!("01A73D352443DE29195DD91D6A64B5959479B52A6E5B123D9AB9E5AD7A112D7A8DD1AD3F164A3A4832051DA6BD16B59FE21BAEB490862C32EA05A5919D2EDE37AD7D"), - hex!("013E9B03B97DFA62DDD9979F86C6CAB814F2F1557FA82A9D0317D2F8AB1FA355CEEC2E2DD4CF8DC575B02D5ACED1DEC3C70CF105C9BC93A590425F588CA1EE86C0E5"), + ( + hex!( + "01A73D352443DE29195DD91D6A64B5959479B52A6E5B123D9AB9E5AD7A112D7A8DD1AD3F164A3A4832051DA6BD16B59FE21BAEB490862C32EA05A5919D2EDE37AD7D" + ), + hex!( + "013E9B03B97DFA62DDD9979F86C6CAB814F2F1557FA82A9D0317D2F8AB1FA355CEEC2E2DD4CF8DC575B02D5ACED1DEC3C70CF105C9BC93A590425F588CA1EE86C0E5" + ), ), - ( - hex!("0035B5DF64AE2AC204C354B483487C9070CDC61C891C5FF39AFC06C5D55541D3CEAC8659E24AFE3D0750E8B88E9F078AF066A1D5025B08E5A5E2FBC87412871902F3"), - hex!("0082096F84261279D2B673E0178EB0B4ABB65521AEF6E6E32E1B5AE63FE2F19907F279F283E54BA385405224F750A95B85EEBB7FAEF04699D1D9E21F47FC346E4D0D"), + ( + hex!( + "0035B5DF64AE2AC204C354B483487C9070CDC61C891C5FF39AFC06C5D55541D3CEAC8659E24AFE3D0750E8B88E9F078AF066A1D5025B08E5A5E2FBC87412871902F3" + ), + hex!( + "0082096F84261279D2B673E0178EB0B4ABB65521AEF6E6E32E1B5AE63FE2F19907F279F283E54BA385405224F750A95B85EEBB7FAEF04699D1D9E21F47FC346E4D0D" + ), ), - ( - hex!("00652BF3C52927A432C73DBC3391C04EB0BF7A596EFDB53F0D24CF03DAB8F177ACE4383C0C6D5E3014237112FEAF137E79A329D7E1E6D8931738D5AB5096EC8F3078"), - hex!("015BE6EF1BDD6601D6EC8A2B73114A8112911CD8FE8E872E0051EDD817C9A0347087BB6897C9072CF374311540211CF5FF79D1F007257354F7F8173CC3E8DEB090CB"), + ( + hex!( + "00652BF3C52927A432C73DBC3391C04EB0BF7A596EFDB53F0D24CF03DAB8F177ACE4383C0C6D5E3014237112FEAF137E79A329D7E1E6D8931738D5AB5096EC8F3078" + ), + hex!( + "015BE6EF1BDD6601D6EC8A2B73114A8112911CD8FE8E872E0051EDD817C9A0347087BB6897C9072CF374311540211CF5FF79D1F007257354F7F8173CC3E8DEB090CB" + ), ), - ( - hex!("01EE4569D6CDB59219532EFF34F94480D195623D30977FD71CF3981506ADE4AB01525FBCCA16153F7394E0727A239531BE8C2F66E95657F380AE23731BEDF79206B9"), - hex!("01DE0255AD0CC64F586AE2DD270546E3B1112AABBB73DA5A808E7240A926201A8A96CAB72D0E56648C9DF96C984DE274F2203DC7B8B55CA0DADE1EACCD7858D44F17"), + ( + hex!( + "01EE4569D6CDB59219532EFF34F94480D195623D30977FD71CF3981506ADE4AB01525FBCCA16153F7394E0727A239531BE8C2F66E95657F380AE23731BEDF79206B9" + ), + hex!( + "01DE0255AD0CC64F586AE2DD270546E3B1112AABBB73DA5A808E7240A926201A8A96CAB72D0E56648C9DF96C984DE274F2203DC7B8B55CA0DADE1EACCD7858D44F17" + ), ), - ( - hex!("0056D5D1D99D5B7F6346EEB65FDA0B073A0C5F22E0E8F5483228F018D2C2F7114C5D8C308D0ABFC698D8C9A6DF30DCE3BBC46F953F50FDC2619A01CEAD882816ECD4"), - hex!("003D2D1B7D9BAAA2A110D1D8317A39D68478B5C582D02824F0DD71DBD98A26CBDE556BD0F293CDEC9E2B9523A34591CE1A5F9E76712A5DDEFC7B5C6B8BC90525251B"), + ( + hex!( + "0056D5D1D99D5B7F6346EEB65FDA0B073A0C5F22E0E8F5483228F018D2C2F7114C5D8C308D0ABFC698D8C9A6DF30DCE3BBC46F953F50FDC2619A01CEAD882816ECD4" + ), + hex!( + "003D2D1B7D9BAAA2A110D1D8317A39D68478B5C582D02824F0DD71DBD98A26CBDE556BD0F293CDEC9E2B9523A34591CE1A5F9E76712A5DDEFC7B5C6B8BC90525251B" + ), ), - ( - hex!("000822C40FB6301F7262A8348396B010E25BD4E29D8A9B003E0A8B8A3B05F826298F5BFEA5B8579F49F08B598C1BC8D79E1AB56289B5A6F4040586F9EA54AA78CE68"), - hex!("016331911D5542FC482048FDAB6E78853B9A44F8EDE9E2C0715B5083DE610677A8F189E9C0AA5911B4BFF0BA0DF065C578699F3BA940094713538AD642F11F17801C"), + ( + hex!( + "000822C40FB6301F7262A8348396B010E25BD4E29D8A9B003E0A8B8A3B05F826298F5BFEA5B8579F49F08B598C1BC8D79E1AB56289B5A6F4040586F9EA54AA78CE68" + ), + hex!( + "016331911D5542FC482048FDAB6E78853B9A44F8EDE9E2C0715B5083DE610677A8F189E9C0AA5911B4BFF0BA0DF065C578699F3BA940094713538AD642F11F17801C" + ), ), ( - hex!("01585389E359E1E21826A2F5BF157156D488ED34541B988746992C4AB145B8C6B6657429E1396134DA35F3C556DF725A318F4F50BABD85CD28661F45627967CBE207"), - hex!("002A2E618C9A8AEDF39F0B55557A27AE938E3088A654EE1CEBB6C825BA263DDB446E0D69E5756057AC840FF56ECF4ABFD87D736C2AE928880F343AA0EA86B9AD2A4E"), + hex!( + "01585389E359E1E21826A2F5BF157156D488ED34541B988746992C4AB145B8C6B6657429E1396134DA35F3C556DF725A318F4F50BABD85CD28661F45627967CBE207" + ), + hex!( + "002A2E618C9A8AEDF39F0B55557A27AE938E3088A654EE1CEBB6C825BA263DDB446E0D69E5756057AC840FF56ECF4ABFD87D736C2AE928880F343AA0EA86B9AD2A4E" + ), ), ( - hex!("0190EB8F22BDA61F281DFCFE7BB6721EC4CD901D879AC09AC7C34A9246B11ADA8910A2C7C178FCC263299DAA4DA9842093F37C2E411F1A8E819A87FF09A04F2F3320"), - hex!("01EB5D96B8491614BA9DBAEAB3B0CA2BA760C2EEB2144251B20BA97FD78A62EF62D2BF5349D44D9864BB536F6163DC57EBEFF3689639739FAA172954BC98135EC759"), + hex!( + "0190EB8F22BDA61F281DFCFE7BB6721EC4CD901D879AC09AC7C34A9246B11ADA8910A2C7C178FCC263299DAA4DA9842093F37C2E411F1A8E819A87FF09A04F2F3320" + ), + hex!( + "01EB5D96B8491614BA9DBAEAB3B0CA2BA760C2EEB2144251B20BA97FD78A62EF62D2BF5349D44D9864BB536F6163DC57EBEFF3689639739FAA172954BC98135EC759" + ), ), ( - hex!("008A75841259FDEDFF546F1A39573B4315CFED5DC7ED7C17849543EF2C54F2991652F3DBC5332663DA1BD19B1AEBE3191085015C024FA4C9A902ECC0E02DDA0CDB9A"), - hex!("0096FB303FCBBA2129849D0CA877054FB2293ADD566210BD0493ED2E95D4E0B9B82B1BC8A90E8B42A4AB3892331914A95336DCAC80E3F4819B5D58874F92CE48C808"), + hex!( + "008A75841259FDEDFF546F1A39573B4315CFED5DC7ED7C17849543EF2C54F2991652F3DBC5332663DA1BD19B1AEBE3191085015C024FA4C9A902ECC0E02DDA0CDB9A" + ), + hex!( + "0096FB303FCBBA2129849D0CA877054FB2293ADD566210BD0493ED2E95D4E0B9B82B1BC8A90E8B42A4AB3892331914A95336DCAC80E3F4819B5D58874F92CE48C808" + ), ), ( - hex!("01C0D9DCEC93F8221C5DE4FAE9749C7FDE1E81874157958457B6107CF7A5967713A644E90B7C3FB81B31477FEE9A60E938013774C75C530928B17BE69571BF842D8C"), - hex!("014048B5946A4927C0FE3CE1D103A682CA4763FE65AB71494DA45E404ABF6A17C097D6D18843D86FCDB6CC10A6F951B9B630884BA72224F5AE6C79E7B1A3281B17F0"), + hex!( + "01C0D9DCEC93F8221C5DE4FAE9749C7FDE1E81874157958457B6107CF7A5967713A644E90B7C3FB81B31477FEE9A60E938013774C75C530928B17BE69571BF842D8C" + ), + hex!( + "014048B5946A4927C0FE3CE1D103A682CA4763FE65AB71494DA45E404ABF6A17C097D6D18843D86FCDB6CC10A6F951B9B630884BA72224F5AE6C79E7B1A3281B17F0" + ), ), ( - hex!("007E3E98F984C396AD9CD7865D2B4924861A93F736CDE1B4C2384EEDD2BEAF5B866132C45908E03C996A3550A5E79AB88EE94BEC3B00AB38EFF81887848D32FBCDA7"), - hex!("0108EE58EB6D781FEDA91A1926DAA3ED5A08CED50A386D5421C69C7A67AE5C1E212AC1BD5D5838BC763F26DFDD351CBFBBC36199EAAF9117E9F7291A01FB022A71C9"), + hex!( + "007E3E98F984C396AD9CD7865D2B4924861A93F736CDE1B4C2384EEDD2BEAF5B866132C45908E03C996A3550A5E79AB88EE94BEC3B00AB38EFF81887848D32FBCDA7" + ), + hex!( + "0108EE58EB6D781FEDA91A1926DAA3ED5A08CED50A386D5421C69C7A67AE5C1E212AC1BD5D5838BC763F26DFDD351CBFBBC36199EAAF9117E9F7291A01FB022A71C9" + ), ), ( - hex!("01875BC7DC551B1B65A9E1B8CCFAAF84DED1958B401494116A2FD4FB0BABE0B3199974FC06C8B897222D79DF3E4B7BC744AA6767F6B812EFBF5D2C9E682DD3432D74"), - hex!("005CA4923575DACB5BD2D66290BBABB4BDFB8470122B8E51826A0847CE9B86D7ED62D07781B1B4F3584C11E89BF1D133DC0D5B690F53A87C84BE41669F852700D54A"), + hex!( + "01875BC7DC551B1B65A9E1B8CCFAAF84DED1958B401494116A2FD4FB0BABE0B3199974FC06C8B897222D79DF3E4B7BC744AA6767F6B812EFBF5D2C9E682DD3432D74" + ), + hex!( + "005CA4923575DACB5BD2D66290BBABB4BDFB8470122B8E51826A0847CE9B86D7ED62D07781B1B4F3584C11E89BF1D133DC0D5B690F53A87C84BE41669F852700D54A" + ), ), ( - hex!("006B6AD89ABCB92465F041558FC546D4300FB8FBCC30B40A0852D697B532DF128E11B91CCE27DBD00FFE7875BD1C8FC0331D9B8D96981E3F92BDE9AFE337BCB8DB55"), - hex!("01B468DA271571391D6A7CE64D2333EDBF63DF0496A9BAD20CBA4B62106997485ED57E9062C899470A802148E2232C96C99246FD90CC446ABDD956343480A1475465"), + hex!( + "006B6AD89ABCB92465F041558FC546D4300FB8FBCC30B40A0852D697B532DF128E11B91CCE27DBD00FFE7875BD1C8FC0331D9B8D96981E3F92BDE9AFE337BCB8DB55" + ), + hex!( + "01B468DA271571391D6A7CE64D2333EDBF63DF0496A9BAD20CBA4B62106997485ED57E9062C899470A802148E2232C96C99246FD90CC446ABDD956343480A1475465" + ), ), ( - hex!("01D17D10D8A89C8AD05DDA97DA26AC743B0B2A87F66192FD3F3DD632F8D20B188A52943FF18861CA00A0E5965DA7985630DF0DBF5C8007DCDC533A6C508F81A8402F"), - hex!("007A37343C582D77001FC714B18D3D3E69721335E4C3B800D50EC7CA30C94B6B82C1C182E1398DB547AA0B3075AC9D9988529E3004D28D18633352E272F89BC73ABE"), + hex!( + "01D17D10D8A89C8AD05DDA97DA26AC743B0B2A87F66192FD3F3DD632F8D20B188A52943FF18861CA00A0E5965DA7985630DF0DBF5C8007DCDC533A6C508F81A8402F" + ), + hex!( + "007A37343C582D77001FC714B18D3D3E69721335E4C3B800D50EC7CA30C94B6B82C1C182E1398DB547AA0B3075AC9D9988529E3004D28D18633352E272F89BC73ABE" + ), ), ( - hex!("01B00DDB707F130EDA13A0B874645923906A99EE9E269FA2B3B4D66524F269250858760A69E674FE0287DF4E799B5681380FF8C3042AF0D1A41076F817A853110AE0"), - hex!("0085683F1D7DB16576DBC111D4E4AEDDD106B799534CF69910A98D68AC2B22A1323DF9DA564EF6DD0BF0D2F6757F16ADF420E6905594C2B755F535B9CB7C70E64647"), + hex!( + "01B00DDB707F130EDA13A0B874645923906A99EE9E269FA2B3B4D66524F269250858760A69E674FE0287DF4E799B5681380FF8C3042AF0D1A41076F817A853110AE0" + ), + hex!( + "0085683F1D7DB16576DBC111D4E4AEDDD106B799534CF69910A98D68AC2B22A1323DF9DA564EF6DD0BF0D2F6757F16ADF420E6905594C2B755F535B9CB7C70E64647" + ), ), ( - hex!("01BC33425E72A12779EACB2EDCC5B63D1281F7E86DBC7BF99A7ABD0CFE367DE4666D6EDBB8525BFFE5222F0702C3096DEC0884CE572F5A15C423FDF44D01DD99C61D"), - hex!("010D06E999885B63535DE3E74D33D9E63D024FB07CE0D196F2552C8E4A00AC84C044234AEB201F7A9133915D1B4B45209B9DA79FE15B19F84FD135D841E2D8F9A86A"), + hex!( + "01BC33425E72A12779EACB2EDCC5B63D1281F7E86DBC7BF99A7ABD0CFE367DE4666D6EDBB8525BFFE5222F0702C3096DEC0884CE572F5A15C423FDF44D01DD99C61D" + ), + hex!( + "010D06E999885B63535DE3E74D33D9E63D024FB07CE0D196F2552C8E4A00AC84C044234AEB201F7A9133915D1B4B45209B9DA79FE15B19F84FD135D841E2D8F9A86A" + ), ), ( - hex!("00998DCCE486419C3487C0F948C2D5A1A07245B77E0755DF547EFFF0ACDB3790E7F1FA3B3096362669679232557D7A45970DFECF431E725BBDE478FF0B2418D6A19B"), - hex!("0137D5DA0626A021ED5CC3942497535B245D67D28AEE2B7BCF4ACC50EEE36545772773AD963FF2EB8CF9B0EC39991631C377F5A4D89EA9FBFE44A9091A695BFD0575"), + hex!( + "00998DCCE486419C3487C0F948C2D5A1A07245B77E0755DF547EFFF0ACDB3790E7F1FA3B3096362669679232557D7A45970DFECF431E725BBDE478FF0B2418D6A19B" + ), + hex!( + "0137D5DA0626A021ED5CC3942497535B245D67D28AEE2B7BCF4ACC50EEE36545772773AD963FF2EB8CF9B0EC39991631C377F5A4D89EA9FBFE44A9091A695BFD0575" + ), ), ( - hex!("018BDD7F1B889598A4653DEEAE39CC6F8CC2BD767C2AB0D93FB12E968FBED342B51709506339CB1049CB11DD48B9BDB3CD5CAD792E43B74E16D8E2603BFB11B0344F"), - hex!("00C5AADBE63F68CA5B6B6908296959BF0AF89EE7F52B410B9444546C550952D311204DA3BDDDC6D4EAE7EDFAEC1030DA8EF837CCB22EEE9CFC94DD3287FED0990F94"), - ) + hex!( + "018BDD7F1B889598A4653DEEAE39CC6F8CC2BD767C2AB0D93FB12E968FBED342B51709506339CB1049CB11DD48B9BDB3CD5CAD792E43B74E16D8E2603BFB11B0344F" + ), + hex!( + "00C5AADBE63F68CA5B6B6908296959BF0AF89EE7F52B410B9444546C550952D311204DA3BDDDC6D4EAE7EDFAEC1030DA8EF837CCB22EEE9CFC94DD3287FED0990F94" + ), + ), ]; /// Scalar multiplication with the generator. @@ -94,163 +174,355 @@ pub const ADD_TEST_VECTORS: &[([u8; 66], [u8; 66])] = &[ /// that are not part of [`ADD_TEST_VECTORS`]. pub const MUL_TEST_VECTORS: &[([u8; 66], [u8; 66], [u8; 66])] = &[ ( - hex!("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018ebbb95eed0e13"), - hex!("01650048FBD63E8C30B305BF36BD7643B91448EF2206E8A0CA84A140789A99B0423A0A2533EA079CA7E049843E69E5FA2C25A163819110CEC1A30ACBBB3A422A40D8"), - hex!("010C9C64A0E0DB6052DBC5646687D06DECE5E9E0703153EFE9CB816FE025E85354D3C5F869D6DB3F4C0C01B5F97919A5E72CEEBE03042E5AA99112691CFFC2724828"), - ), - ( - hex!("000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000159d893d4cdd747246cdca43590e13"), - hex!("017E1370D39C9C63925DAEEAC571E21CAAF60BD169191BAEE8352E0F54674443B29786243564ABB705F6FC0FE5FC5D3F98086B67CA0BE7AC8A9DEC421D9F1BC6B37F"), - hex!("01CD559605EAD19FBD99E83600A6A81A0489E6F20306EE0789AE00CE16A6EFEA2F42F7534186CF1C60DF230BD9BCF8CB95E5028AD9820B2B1C0E15597EE54C4614A6"), - ), - ( - hex!("0083ff83fffffc03fff80007fffc000f8003ffe00007ffe0fffc000f8000000007ffffff00ffff000ffffff001fffc000000001c0000400000003803ffffffcfffff"), - hex!("00B45CB84651C9D4F08858B867F82D816E84E94FE4CAE3DA5F65E420B08398D0C5BF019253A6C26D20671BDEF0B8E6C1D348A4B0734687F73AC6A4CBB2E085C68B3F"), - hex!("01C84942BBF538903062170A4BA8B3410D385719BA2037D29CA5248BFCBC8478220FEC79244DCD45D31885A1764DEE479CE20B12CEAB62F9001C7AA4282CE4BE7F56"), - ), - ( - hex!("000001ffffe03ffff1ffff801fffffffff8000001fffff800ffffff8001fffc7ffff820000040007ffffe000001f800007fffffffc00001c007c0007000070000007"), - hex!("01CCEF4CDA108CEBE6568820B54A3CA3A3997E4EF0EDA6C350E7ED3DBB1861EDD80181C650CEBE5440FEBA880F9C8A7A86F8B82659794F6F5B88E501E5DD84E65D7E"), - hex!("01026565F8B195D03C3F6139C3A63EAA1C29F7090AB2A8F75027939EC05109035F1B38E6C508E0C14CE53AB7E2DA33AA28140EDBF3964862FB157119517454E60F07"), - ), - ( - hex!("00007fffffe0003f00000007f00007ffff80000000001ffc000000fff030001f0000fffff0000038000000000002003f007ffffff0000000000000ffe00000000000"), - hex!("00C1002DC2884EEDADB3F9B468BBEBD55980799852C506D37271FFCD006919DB3A96DF8FE91EF6ED4B9081B1809E8F2C2B28AF5FCBF524147C73CB0B913D6FAB0995"), - hex!("01614E8A62C8293DD2AA6EF27D30974A4FD185019FA8EF4F982DA48698CECF706581F69EE9ED67A9C231EC9D0934D0F674646153273BCBB345E923B1EC1386A1A4AD"), - ), - ( - hex!("00001fffc1000003fe0003ffffffe0001ffffffffffffff00001fffff83ffffffffffffe003ffffffffffff7ffffc03ff807fffe0001fffff800fff800001ffff000"), - hex!("010ED3E085ECDE1E66874286B5D5642B9D37853A026A0A025C7B84936E2ECEEC5F342E14C80C79CCF814D5AD085C5303F2823251F2B9276F88C9D7A43E387EBD87AC"), - hex!("01BE399A7666B29E79BBF3D277531A97CE05CAC0B49BECE4781E7AEE0D6E80FEE883C76E9F08453DC1ADE4E49300F3D56FEE6A1510DA1B1F12EEAA39A05AA0508119"), + hex!( + "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018ebbb95eed0e13" + ), + hex!( + "01650048FBD63E8C30B305BF36BD7643B91448EF2206E8A0CA84A140789A99B0423A0A2533EA079CA7E049843E69E5FA2C25A163819110CEC1A30ACBBB3A422A40D8" + ), + hex!( + "010C9C64A0E0DB6052DBC5646687D06DECE5E9E0703153EFE9CB816FE025E85354D3C5F869D6DB3F4C0C01B5F97919A5E72CEEBE03042E5AA99112691CFFC2724828" + ), + ), + ( + hex!( + "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000159d893d4cdd747246cdca43590e13" + ), + hex!( + "017E1370D39C9C63925DAEEAC571E21CAAF60BD169191BAEE8352E0F54674443B29786243564ABB705F6FC0FE5FC5D3F98086B67CA0BE7AC8A9DEC421D9F1BC6B37F" + ), + hex!( + "01CD559605EAD19FBD99E83600A6A81A0489E6F20306EE0789AE00CE16A6EFEA2F42F7534186CF1C60DF230BD9BCF8CB95E5028AD9820B2B1C0E15597EE54C4614A6" + ), + ), + ( + hex!( + "0083ff83fffffc03fff80007fffc000f8003ffe00007ffe0fffc000f8000000007ffffff00ffff000ffffff001fffc000000001c0000400000003803ffffffcfffff" + ), + hex!( + "00B45CB84651C9D4F08858B867F82D816E84E94FE4CAE3DA5F65E420B08398D0C5BF019253A6C26D20671BDEF0B8E6C1D348A4B0734687F73AC6A4CBB2E085C68B3F" + ), + hex!( + "01C84942BBF538903062170A4BA8B3410D385719BA2037D29CA5248BFCBC8478220FEC79244DCD45D31885A1764DEE479CE20B12CEAB62F9001C7AA4282CE4BE7F56" + ), + ), + ( + hex!( + "000001ffffe03ffff1ffff801fffffffff8000001fffff800ffffff8001fffc7ffff820000040007ffffe000001f800007fffffffc00001c007c0007000070000007" + ), + hex!( + "01CCEF4CDA108CEBE6568820B54A3CA3A3997E4EF0EDA6C350E7ED3DBB1861EDD80181C650CEBE5440FEBA880F9C8A7A86F8B82659794F6F5B88E501E5DD84E65D7E" + ), + hex!( + "01026565F8B195D03C3F6139C3A63EAA1C29F7090AB2A8F75027939EC05109035F1B38E6C508E0C14CE53AB7E2DA33AA28140EDBF3964862FB157119517454E60F07" + ), + ), + ( + hex!( + "00007fffffe0003f00000007f00007ffff80000000001ffc000000fff030001f0000fffff0000038000000000002003f007ffffff0000000000000ffe00000000000" + ), + hex!( + "00C1002DC2884EEDADB3F9B468BBEBD55980799852C506D37271FFCD006919DB3A96DF8FE91EF6ED4B9081B1809E8F2C2B28AF5FCBF524147C73CB0B913D6FAB0995" + ), + hex!( + "01614E8A62C8293DD2AA6EF27D30974A4FD185019FA8EF4F982DA48698CECF706581F69EE9ED67A9C231EC9D0934D0F674646153273BCBB345E923B1EC1386A1A4AD" + ), + ), + ( + hex!( + "00001fffc1000003fe0003ffffffe0001ffffffffffffff00001fffff83ffffffffffffe003ffffffffffff7ffffc03ff807fffe0001fffff800fff800001ffff000" + ), + hex!( + "010ED3E085ECDE1E66874286B5D5642B9D37853A026A0A025C7B84936E2ECEEC5F342E14C80C79CCF814D5AD085C5303F2823251F2B9276F88C9D7A43E387EBD87AC" + ), + hex!( + "01BE399A7666B29E79BBF3D277531A97CE05CAC0B49BECE4781E7AEE0D6E80FEE883C76E9F08453DC1ADE4E49300F3D56FEE6A1510DA1B1F12EEAA39A05AA0508119" + ), + ), + ( + hex!( + "000000000fff80fffffffe03fffc07fffc800070000fc0007ffc00000000000fffe1fbff81ff9fffff81fff81fc000000000ff801fffc0f81f01fff8001fc005ffff" + ), + hex!( + "013070A29B059D317AF37089E40FCB135868F52290EFF3E9F3E32CDADCA18EA234D8589C665A4B8E3D0714DE004A419DEA7091A3BBA97263C438FE9413AA598FD4A5" + ), + hex!( + "00238A27FD9E5E7324C8B538EF2E334B71AC2611A95F42F4F2544D8C4A65D2A32A8BAFA15EFD4FC2BD8AB2B0C51F65B680879589F4D5FE8A84CEB17A2E8D3587F011" + ), + ), + ( + hex!( + "000fffffc01ffffff01fffffe000000fc0ffffff00063ffdffbffff87ffffffffe03fffffffff0000000000ff8001f8000000008007ff800003ffff00000fffc01ff" + ), + hex!( + "01A3D88799878EC74E66FF1AD8C7DFA9A9B4445A17F0810FF8189DD27AE3B6C580D352476DBDAEB08D7DA0DE3866F7C7FDBEBB8418E19710F1F7AFA88C22280B1404" + ), + hex!( + "00B39703D2053EC7B8812BDFEBFD81B4CB76F245FE535A1F1E46801C35DE03C15063A99A203981529C146132863CA0E68544D0F0A638D8A2859D82B4DD266F27C3AE" + ), + ), + ( + hex!( + "000000003ffe001ffffffc7ffe00000000fffbff00000007ffe00ffffff803ffffff3ffffc003f8000000007fe03ff8000fff8007ffffffffc0003ffe0001fc0000f" + ), + hex!( + "01D16B4365DEFE6FD356DC1F31727AF2A32C7E86C5AE87ED2950A08BC8653F203C7F7860E80F95AA27C93EA76E8CD094127B15ED42CC5F96DC0A0F9A1C1E31D0D526" + ), + hex!( + "006E3710A0F9366E0BB8A14FFE8EBC2722EECF4A123EC9BA98DCCCA335D6FAFD289DC69FD90903C9AC982FEB46DF93F03A7C8C9549D32C1C386D17F37340E63822A8" + ), + ), + ( + hex!( + "00007f0000003ffc00000001fff007fff008000000ff0000000fffc03fffffff800000030fff80fe00000000c00001ffff8001ffffffffe0000000000003fffffff3" + ), + hex!( + "01B1220F67C985E9FC9C588C0C86BB16E6FE4CC11E168A98D701AE4670724B3D030ED9965FADF4207C7A1BE9BE0F40DEF2BBFFF0C7EABCB5B42526CE1D3CAA468F52" + ), + hex!( + "006CDAD2860F6D2C37159A5A866D11605F2E7D87430DCFE6E6816AB6423CD9003CA6F2527B9C2A2483C541D456C963D18A0D2A46E158CB2A44C0BF42D562881FB748" + ), + ), + ( + hex!( + "00f07f80ffffff00003ff8003ff87fffff007fe07e0000003ffffff80007fe0000000000000003fc00000000007ffc07ff807f7f1fffef07fffff8000000000003ff" + ), + hex!( + "00F25E545213C8C074BE38A0612EA9B66336B14A874372548D9716392DFA31CD0D13E94F86CD48B8D43B80B5299144E01245C873B39F6AC6C4FB397746AF034AD67C" + ), + hex!( + "01733ABB21147CC27E35F41FAF40290AFD1EEB221D983FFABBD88E5DC8776450A409EACDC1BCA2B9F517289C68645BB96781808FEAE42573C2BB289F16E2AECECE17" + ), + ), + ( + hex!( + "000000000003fff7ffffffffffffffe007ffffffe3fffffffffc01ffe0001fe01fffffff0000000000ffffffc0000000007ffffff03ff8000000000000c000000000" + ), + hex!( + "0172CD22CBE0634B6BFEE24BB1D350F384A945ED618ECAD48AADC6C1BC0DCC107F0FFE9FE14DC929F90153F390C25BE5D3A73A56F9ACCB0C72C768753869732D0DC4" + ), + hex!( + "00D249CFB570DA4CC48FB5426A928B43D7922F787373B6182408FBC71706E7527E8414C79167F3C999FF58DE352D238F1FE7168C658D338F72696F2F889A97DE23C5" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f5" + ), + hex!( + "018BDD7F1B889598A4653DEEAE39CC6F8CC2BD767C2AB0D93FB12E968FBED342B51709506339CB1049CB11DD48B9BDB3CD5CAD792E43B74E16D8E2603BFB11B0344F" + ), + hex!( + "013A552419C09735A49496F7D696A640F50761180AD4BEF46BBBAB93AAF6AD2CEEDFB25C4222392B1518120513EFCF257107C8334DD11163036B22CD78012F66F06B" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f6" + ), + hex!( + "00998DCCE486419C3487C0F948C2D5A1A07245B77E0755DF547EFFF0ACDB3790E7F1FA3B3096362669679232557D7A45970DFECF431E725BBDE478FF0B2418D6A19B" + ), + hex!( + "00C82A25F9D95FDE12A33C6BDB68ACA4DBA2982D7511D48430B533AF111C9ABA88D88C5269C00D1473064F13C666E9CE3C880A5B2761560401BB56F6E596A402FA8A" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f7" + ), + hex!( + "01BC33425E72A12779EACB2EDCC5B63D1281F7E86DBC7BF99A7ABD0CFE367DE4666D6EDBB8525BFFE5222F0702C3096DEC0884CE572F5A15C423FDF44D01DD99C61D" + ), + hex!( + "00F2F9166677A49CACA21C18B2CC2619C2FDB04F831F2E690DAAD371B5FF537B3FBBDCB514DFE0856ECC6EA2E4B4BADF646258601EA4E607B02ECA27BE1D27065795" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f8" + ), + hex!( + "01B00DDB707F130EDA13A0B874645923906A99EE9E269FA2B3B4D66524F269250858760A69E674FE0287DF4E799B5681380FF8C3042AF0D1A41076F817A853110AE0" + ), + hex!( + "017A97C0E2824E9A89243EEE2B1B51222EF94866ACB30966EF56729753D4DD5ECDC20625A9B10922F40F2D098A80E9520BDF196FAA6B3D48AA0ACA4634838F19B9B8" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f9" + ), + hex!( + "01D17D10D8A89C8AD05DDA97DA26AC743B0B2A87F66192FD3F3DD632F8D20B188A52943FF18861CA00A0E5965DA7985630DF0DBF5C8007DCDC533A6C508F81A8402F" + ), + hex!( + "0185C8CBC3A7D288FFE038EB4E72C2C1968DECCA1B3C47FF2AF13835CF36B4947D3E3E7D1EC6724AB855F4CF8A53626677AD61CFFB2D72E79CCCAD1D8D076438C541" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fa" + ), + hex!( + "006B6AD89ABCB92465F041558FC546D4300FB8FBCC30B40A0852D697B532DF128E11B91CCE27DBD00FFE7875BD1C8FC0331D9B8D96981E3F92BDE9AFE337BCB8DB55" + ), + hex!( + "004B9725D8EA8EC6E2958319B2DCCC12409C20FB6956452DF345B49DEF9668B7A12A816F9D3766B8F57FDEB71DDCD369366DB9026F33BB954226A9CBCB7F5EB8AB9A" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fb" + ), + hex!( + "01875BC7DC551B1B65A9E1B8CCFAAF84DED1958B401494116A2FD4FB0BABE0B3199974FC06C8B897222D79DF3E4B7BC744AA6767F6B812EFBF5D2C9E682DD3432D74" + ), + hex!( + "01A35B6DCA8A2534A42D299D6F44544B42047B8FEDD471AE7D95F7B831647928129D2F887E4E4B0CA7B3EE17640E2ECC23F2A496F0AC57837B41BE99607AD8FF2AB5" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fc" + ), + hex!( + "007E3E98F984C396AD9CD7865D2B4924861A93F736CDE1B4C2384EEDD2BEAF5B866132C45908E03C996A3550A5E79AB88EE94BEC3B00AB38EFF81887848D32FBCDA7" + ), + hex!( + "00F711A7149287E01256E5E6D9255C12A5F7312AF5C792ABDE3963859851A3E1DED53E42A2A7C74389C0D92022CAE340443C9E6615506EE81608D6E5FE04FDD58E36" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fd" + ), + hex!( + "01C0D9DCEC93F8221C5DE4FAE9749C7FDE1E81874157958457B6107CF7A5967713A644E90B7C3FB81B31477FEE9A60E938013774C75C530928B17BE69571BF842D8C" + ), + hex!( + "00BFB74A6B95B6D83F01C31E2EFC597D35B89C019A548EB6B25BA1BFB54095E83F68292E77BC2790324933EF5906AE4649CF77B458DDDB0A519386184E5CD7E4E80F" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fe" + ), + hex!( + "008A75841259FDEDFF546F1A39573B4315CFED5DC7ED7C17849543EF2C54F2991652F3DBC5332663DA1BD19B1AEBE3191085015C024FA4C9A902ECC0E02DDA0CDB9A" + ), + hex!( + "016904CFC03445DED67B62F35788FAB04DD6C522A99DEF42FB6C12D16A2B1F4647D4E43756F174BD5B54C76DCCE6EB56ACC923537F1C0B7E64A2A778B06D31B737F7" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863ff" + ), + hex!( + "0190EB8F22BDA61F281DFCFE7BB6721EC4CD901D879AC09AC7C34A9246B11ADA8910A2C7C178FCC263299DAA4DA9842093F37C2E411F1A8E819A87FF09A04F2F3320" + ), + hex!( + "0014A26947B6E9EB456245154C4F35D4589F3D114DEBBDAE4DF4568028759D109D2D40ACB62BB2679B44AC909E9C23A814100C9769C68C6055E8D6AB4367ECA138A6" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386400" + ), + hex!( + "01585389E359E1E21826A2F5BF157156D488ED34541B988746992C4AB145B8C6B6657429E1396134DA35F3C556DF725A318F4F50BABD85CD28661F45627967CBE207" + ), + hex!( + "01D5D19E736575120C60F4AAAA85D8516C71CF7759AB11E3144937DA45D9C224BB91F2961A8A9FA8537BF00A9130B54027828C93D516D777F0CBC55F15794652D5B1" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386401" + ), + hex!( + "000822C40FB6301F7262A8348396B010E25BD4E29D8A9B003E0A8B8A3B05F826298F5BFEA5B8579F49F08B598C1BC8D79E1AB56289B5A6F4040586F9EA54AA78CE68" + ), + hex!( + "009CCE6EE2AABD03B7DFB7025491877AC465BB0712161D3F8EA4AF7C219EF988570E76163F55A6EE4B400F45F20F9A3A879660C456BFF6B8ECAC7529BD0EE0E87FE3" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386402" + ), + hex!( + "0056D5D1D99D5B7F6346EEB65FDA0B073A0C5F22E0E8F5483228F018D2C2F7114C5D8C308D0ABFC698D8C9A6DF30DCE3BBC46F953F50FDC2619A01CEAD882816ECD4" + ), + hex!( + "01C2D2E48264555D5EEF2E27CE85C6297B874A3A7D2FD7DB0F228E242675D93421AA942F0D6C321361D46ADC5CBA6E31E5A061898ED5A2210384A3947436FADADAE4" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386403" + ), + hex!( + "01EE4569D6CDB59219532EFF34F94480D195623D30977FD71CF3981506ADE4AB01525FBCCA16153F7394E0727A239531BE8C2F66E95657F380AE23731BEDF79206B9" + ), + hex!( + "0021FDAA52F339B0A7951D22D8FAB91C4EEED554448C25A57F718DBF56D9DFE575693548D2F1A99B7362069367B21D8B0DDFC238474AA35F2521E1533287A72BB0E8" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386404" + ), + hex!( + "00652BF3C52927A432C73DBC3391C04EB0BF7A596EFDB53F0D24CF03DAB8F177ACE4383C0C6D5E3014237112FEAF137E79A329D7E1E6D8931738D5AB5096EC8F3078" + ), + hex!( + "00A41910E42299FE291375D48CEEB57EED6EE327017178D1FFAE1227E8365FCB8F7844976836F8D30C8BCEEABFDEE30A00862E0FF8DA8CAB0807E8C33C17214F6F34" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386405" + ), + hex!( + "0035B5DF64AE2AC204C354B483487C9070CDC61C891C5FF39AFC06C5D55541D3CEAC8659E24AFE3D0750E8B88E9F078AF066A1D5025B08E5A5E2FBC87412871902F3" + ), + hex!( + "017DF6907BD9ED862D498C1FE8714F4B5449AADE5109191CD1E4A519C01D0E66F80D860D7C1AB45C7ABFADDB08AF56A47A114480510FB9662E261DE0B803CB91B2F2" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386406" + ), + hex!( + "01A73D352443DE29195DD91D6A64B5959479B52A6E5B123D9AB9E5AD7A112D7A8DD1AD3F164A3A4832051DA6BD16B59FE21BAEB490862C32EA05A5919D2EDE37AD7D" + ), + hex!( + "00C164FC4682059D2226686079393547EB0D0EAA8057D562FCE82D0754E05CAA3113D1D22B30723A8A4FD2A5312E213C38F30EFA36436C5A6FBDA0A7735E11793F1A" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386407" + ), + hex!( + "00433C219024277E7E682FCB288148C282747403279B1CCC06352C6E5505D769BE97B3B204DA6EF55507AA104A3A35C5AF41CF2FA364D60FD967F43E3933BA6D783D" + ), + hex!( + "010B44733807924D98FF580C1311112C0F4A394AEF83B25688BF54DE5D66F93BD2444C1C882160DAE0946C6C805665CDB70B1503416A123F0B08E41CA9299E0BE4FD" + ), + ), + ( + hex!( + "01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386408" + ), + hex!( + "00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66" + ), + hex!( + "00E7C6D6958765C43FFBA375A04BD382E426670ABBB6A864BB97E85042E8D8C199D368118D66A10BD9BF3AAF46FEC052F89ECAC38F795D8D3DBF77416B89602E99AF" + ), ), - ( - hex!("000000000fff80fffffffe03fffc07fffc800070000fc0007ffc00000000000fffe1fbff81ff9fffff81fff81fc000000000ff801fffc0f81f01fff8001fc005ffff"), - hex!("013070A29B059D317AF37089E40FCB135868F52290EFF3E9F3E32CDADCA18EA234D8589C665A4B8E3D0714DE004A419DEA7091A3BBA97263C438FE9413AA598FD4A5"), - hex!("00238A27FD9E5E7324C8B538EF2E334B71AC2611A95F42F4F2544D8C4A65D2A32A8BAFA15EFD4FC2BD8AB2B0C51F65B680879589F4D5FE8A84CEB17A2E8D3587F011"), - ), - ( - hex!("000fffffc01ffffff01fffffe000000fc0ffffff00063ffdffbffff87ffffffffe03fffffffff0000000000ff8001f8000000008007ff800003ffff00000fffc01ff"), - hex!("01A3D88799878EC74E66FF1AD8C7DFA9A9B4445A17F0810FF8189DD27AE3B6C580D352476DBDAEB08D7DA0DE3866F7C7FDBEBB8418E19710F1F7AFA88C22280B1404"), - hex!("00B39703D2053EC7B8812BDFEBFD81B4CB76F245FE535A1F1E46801C35DE03C15063A99A203981529C146132863CA0E68544D0F0A638D8A2859D82B4DD266F27C3AE"), - ), - ( - hex!("000000003ffe001ffffffc7ffe00000000fffbff00000007ffe00ffffff803ffffff3ffffc003f8000000007fe03ff8000fff8007ffffffffc0003ffe0001fc0000f"), - hex!("01D16B4365DEFE6FD356DC1F31727AF2A32C7E86C5AE87ED2950A08BC8653F203C7F7860E80F95AA27C93EA76E8CD094127B15ED42CC5F96DC0A0F9A1C1E31D0D526"), - hex!("006E3710A0F9366E0BB8A14FFE8EBC2722EECF4A123EC9BA98DCCCA335D6FAFD289DC69FD90903C9AC982FEB46DF93F03A7C8C9549D32C1C386D17F37340E63822A8"), - ), - ( - hex!("00007f0000003ffc00000001fff007fff008000000ff0000000fffc03fffffff800000030fff80fe00000000c00001ffff8001ffffffffe0000000000003fffffff3"), - hex!("01B1220F67C985E9FC9C588C0C86BB16E6FE4CC11E168A98D701AE4670724B3D030ED9965FADF4207C7A1BE9BE0F40DEF2BBFFF0C7EABCB5B42526CE1D3CAA468F52"), - hex!("006CDAD2860F6D2C37159A5A866D11605F2E7D87430DCFE6E6816AB6423CD9003CA6F2527B9C2A2483C541D456C963D18A0D2A46E158CB2A44C0BF42D562881FB748"), - ), - ( - hex!("00f07f80ffffff00003ff8003ff87fffff007fe07e0000003ffffff80007fe0000000000000003fc00000000007ffc07ff807f7f1fffef07fffff8000000000003ff"), - hex!("00F25E545213C8C074BE38A0612EA9B66336B14A874372548D9716392DFA31CD0D13E94F86CD48B8D43B80B5299144E01245C873B39F6AC6C4FB397746AF034AD67C"), - hex!("01733ABB21147CC27E35F41FAF40290AFD1EEB221D983FFABBD88E5DC8776450A409EACDC1BCA2B9F517289C68645BB96781808FEAE42573C2BB289F16E2AECECE17"), - ), - ( - hex!("000000000003fff7ffffffffffffffe007ffffffe3fffffffffc01ffe0001fe01fffffff0000000000ffffffc0000000007ffffff03ff8000000000000c000000000"), - hex!("0172CD22CBE0634B6BFEE24BB1D350F384A945ED618ECAD48AADC6C1BC0DCC107F0FFE9FE14DC929F90153F390C25BE5D3A73A56F9ACCB0C72C768753869732D0DC4"), - hex!("00D249CFB570DA4CC48FB5426A928B43D7922F787373B6182408FBC71706E7527E8414C79167F3C999FF58DE352D238F1FE7168C658D338F72696F2F889A97DE23C5"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f5"), - hex!("018BDD7F1B889598A4653DEEAE39CC6F8CC2BD767C2AB0D93FB12E968FBED342B51709506339CB1049CB11DD48B9BDB3CD5CAD792E43B74E16D8E2603BFB11B0344F"), - hex!("013A552419C09735A49496F7D696A640F50761180AD4BEF46BBBAB93AAF6AD2CEEDFB25C4222392B1518120513EFCF257107C8334DD11163036B22CD78012F66F06B"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f6"), - hex!("00998DCCE486419C3487C0F948C2D5A1A07245B77E0755DF547EFFF0ACDB3790E7F1FA3B3096362669679232557D7A45970DFECF431E725BBDE478FF0B2418D6A19B"), - hex!("00C82A25F9D95FDE12A33C6BDB68ACA4DBA2982D7511D48430B533AF111C9ABA88D88C5269C00D1473064F13C666E9CE3C880A5B2761560401BB56F6E596A402FA8A"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f7"), - hex!("01BC33425E72A12779EACB2EDCC5B63D1281F7E86DBC7BF99A7ABD0CFE367DE4666D6EDBB8525BFFE5222F0702C3096DEC0884CE572F5A15C423FDF44D01DD99C61D"), - hex!("00F2F9166677A49CACA21C18B2CC2619C2FDB04F831F2E690DAAD371B5FF537B3FBBDCB514DFE0856ECC6EA2E4B4BADF646258601EA4E607B02ECA27BE1D27065795"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f8"), - hex!("01B00DDB707F130EDA13A0B874645923906A99EE9E269FA2B3B4D66524F269250858760A69E674FE0287DF4E799B5681380FF8C3042AF0D1A41076F817A853110AE0"), - hex!("017A97C0E2824E9A89243EEE2B1B51222EF94866ACB30966EF56729753D4DD5ECDC20625A9B10922F40F2D098A80E9520BDF196FAA6B3D48AA0ACA4634838F19B9B8"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863f9"), - hex!("01D17D10D8A89C8AD05DDA97DA26AC743B0B2A87F66192FD3F3DD632F8D20B188A52943FF18861CA00A0E5965DA7985630DF0DBF5C8007DCDC533A6C508F81A8402F"), - hex!("0185C8CBC3A7D288FFE038EB4E72C2C1968DECCA1B3C47FF2AF13835CF36B4947D3E3E7D1EC6724AB855F4CF8A53626677AD61CFFB2D72E79CCCAD1D8D076438C541"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fa"), - hex!("006B6AD89ABCB92465F041558FC546D4300FB8FBCC30B40A0852D697B532DF128E11B91CCE27DBD00FFE7875BD1C8FC0331D9B8D96981E3F92BDE9AFE337BCB8DB55"), - hex!("004B9725D8EA8EC6E2958319B2DCCC12409C20FB6956452DF345B49DEF9668B7A12A816F9D3766B8F57FDEB71DDCD369366DB9026F33BB954226A9CBCB7F5EB8AB9A"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fb"), - hex!("01875BC7DC551B1B65A9E1B8CCFAAF84DED1958B401494116A2FD4FB0BABE0B3199974FC06C8B897222D79DF3E4B7BC744AA6767F6B812EFBF5D2C9E682DD3432D74"), - hex!("01A35B6DCA8A2534A42D299D6F44544B42047B8FEDD471AE7D95F7B831647928129D2F887E4E4B0CA7B3EE17640E2ECC23F2A496F0AC57837B41BE99607AD8FF2AB5"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fc"), - hex!("007E3E98F984C396AD9CD7865D2B4924861A93F736CDE1B4C2384EEDD2BEAF5B866132C45908E03C996A3550A5E79AB88EE94BEC3B00AB38EFF81887848D32FBCDA7"), - hex!("00F711A7149287E01256E5E6D9255C12A5F7312AF5C792ABDE3963859851A3E1DED53E42A2A7C74389C0D92022CAE340443C9E6615506EE81608D6E5FE04FDD58E36"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fd"), - hex!("01C0D9DCEC93F8221C5DE4FAE9749C7FDE1E81874157958457B6107CF7A5967713A644E90B7C3FB81B31477FEE9A60E938013774C75C530928B17BE69571BF842D8C"), - hex!("00BFB74A6B95B6D83F01C31E2EFC597D35B89C019A548EB6B25BA1BFB54095E83F68292E77BC2790324933EF5906AE4649CF77B458DDDB0A519386184E5CD7E4E80F"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863fe"), - hex!("008A75841259FDEDFF546F1A39573B4315CFED5DC7ED7C17849543EF2C54F2991652F3DBC5332663DA1BD19B1AEBE3191085015C024FA4C9A902ECC0E02DDA0CDB9A"), - hex!("016904CFC03445DED67B62F35788FAB04DD6C522A99DEF42FB6C12D16A2B1F4647D4E43756F174BD5B54C76DCCE6EB56ACC923537F1C0B7E64A2A778B06D31B737F7"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e913863ff"), - hex!("0190EB8F22BDA61F281DFCFE7BB6721EC4CD901D879AC09AC7C34A9246B11ADA8910A2C7C178FCC263299DAA4DA9842093F37C2E411F1A8E819A87FF09A04F2F3320"), - hex!("0014A26947B6E9EB456245154C4F35D4589F3D114DEBBDAE4DF4568028759D109D2D40ACB62BB2679B44AC909E9C23A814100C9769C68C6055E8D6AB4367ECA138A6"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386400"), - hex!("01585389E359E1E21826A2F5BF157156D488ED34541B988746992C4AB145B8C6B6657429E1396134DA35F3C556DF725A318F4F50BABD85CD28661F45627967CBE207"), - hex!("01D5D19E736575120C60F4AAAA85D8516C71CF7759AB11E3144937DA45D9C224BB91F2961A8A9FA8537BF00A9130B54027828C93D516D777F0CBC55F15794652D5B1"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386401"), - hex!("000822C40FB6301F7262A8348396B010E25BD4E29D8A9B003E0A8B8A3B05F826298F5BFEA5B8579F49F08B598C1BC8D79E1AB56289B5A6F4040586F9EA54AA78CE68"), - hex!("009CCE6EE2AABD03B7DFB7025491877AC465BB0712161D3F8EA4AF7C219EF988570E76163F55A6EE4B400F45F20F9A3A879660C456BFF6B8ECAC7529BD0EE0E87FE3"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386402"), - hex!("0056D5D1D99D5B7F6346EEB65FDA0B073A0C5F22E0E8F5483228F018D2C2F7114C5D8C308D0ABFC698D8C9A6DF30DCE3BBC46F953F50FDC2619A01CEAD882816ECD4"), - hex!("01C2D2E48264555D5EEF2E27CE85C6297B874A3A7D2FD7DB0F228E242675D93421AA942F0D6C321361D46ADC5CBA6E31E5A061898ED5A2210384A3947436FADADAE4"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386403"), - hex!("01EE4569D6CDB59219532EFF34F94480D195623D30977FD71CF3981506ADE4AB01525FBCCA16153F7394E0727A239531BE8C2F66E95657F380AE23731BEDF79206B9"), - hex!("0021FDAA52F339B0A7951D22D8FAB91C4EEED554448C25A57F718DBF56D9DFE575693548D2F1A99B7362069367B21D8B0DDFC238474AA35F2521E1533287A72BB0E8"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386404"), - hex!("00652BF3C52927A432C73DBC3391C04EB0BF7A596EFDB53F0D24CF03DAB8F177ACE4383C0C6D5E3014237112FEAF137E79A329D7E1E6D8931738D5AB5096EC8F3078"), - hex!("00A41910E42299FE291375D48CEEB57EED6EE327017178D1FFAE1227E8365FCB8F7844976836F8D30C8BCEEABFDEE30A00862E0FF8DA8CAB0807E8C33C17214F6F34"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386405"), - hex!("0035B5DF64AE2AC204C354B483487C9070CDC61C891C5FF39AFC06C5D55541D3CEAC8659E24AFE3D0750E8B88E9F078AF066A1D5025B08E5A5E2FBC87412871902F3"), - hex!("017DF6907BD9ED862D498C1FE8714F4B5449AADE5109191CD1E4A519C01D0E66F80D860D7C1AB45C7ABFADDB08AF56A47A114480510FB9662E261DE0B803CB91B2F2"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386406"), - hex!("01A73D352443DE29195DD91D6A64B5959479B52A6E5B123D9AB9E5AD7A112D7A8DD1AD3F164A3A4832051DA6BD16B59FE21BAEB490862C32EA05A5919D2EDE37AD7D"), - hex!("00C164FC4682059D2226686079393547EB0D0EAA8057D562FCE82D0754E05CAA3113D1D22B30723A8A4FD2A5312E213C38F30EFA36436C5A6FBDA0A7735E11793F1A"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386407"), - hex!("00433C219024277E7E682FCB288148C282747403279B1CCC06352C6E5505D769BE97B3B204DA6EF55507AA104A3A35C5AF41CF2FA364D60FD967F43E3933BA6D783D"), - hex!("010B44733807924D98FF580C1311112C0F4A394AEF83B25688BF54DE5D66F93BD2444C1C882160DAE0946C6C805665CDB70B1503416A123F0B08E41CA9299E0BE4FD"), - ), - ( - hex!("01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386408"), - hex!("00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66"), - hex!("00E7C6D6958765C43FFBA375A04BD382E426670ABBB6A864BB97E85042E8D8C199D368118D66A10BD9BF3AAF46FEC052F89ECAC38F795D8D3DBF77416B89602E99AF"), - ) ]; diff --git a/p521/tests/projective.rs b/p521/tests/projective.rs index 4e0ebfac6..e860b3913 100644 --- a/p521/tests/projective.rs +++ b/p521/tests/projective.rs @@ -7,10 +7,10 @@ use elliptic_curve::{ sec1::{self, ToEncodedPoint}, }; use p521::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, AffinePoint, ProjectivePoint, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; -use primeorder::{impl_projective_arithmetic_tests, Double}; +use primeorder::{Double, impl_projective_arithmetic_tests}; impl_projective_arithmetic_tests!( AffinePoint, From 26b7b3c1e50dbeff34c1a0f676127015c6b2e984 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:51:10 -0800 Subject: [PATCH 09/20] sm2: bump to edition 2024; msrv 1.85 --- .github/workflows/sm2.yml | 6 +++--- Cargo.lock | 18 ++---------------- sm2/Cargo.toml | 10 +++++----- sm2/README.md | 14 +------------- sm2/src/arithmetic.rs | 2 +- sm2/src/arithmetic/scalar.rs | 6 +++--- sm2/src/distid.rs | 2 +- sm2/src/dsa.rs | 4 ++-- sm2/src/dsa/signing.rs | 18 +++++++++++------- sm2/src/dsa/verifying.rs | 10 +++++----- sm2/src/lib.rs | 6 +++--- sm2/src/pke.rs | 14 +++++++------- sm2/src/pke/decrypting.rs | 10 +++++----- sm2/src/pke/encrypting.rs | 8 ++++---- sm2/tests/pkcs8.rs | 4 +++- sm2/tests/sm2dsa.rs | 8 +++++--- sm2/tests/sm2pke.rs | 12 ++++++++---- 17 files changed, 69 insertions(+), 83 deletions(-) diff --git a/.github/workflows/sm2.yml b/.github/workflows/sm2.yml index 32f73e3cb..635c67ed2 100644 --- a/.github/workflows/sm2.yml +++ b/.github/workflows/sm2.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -48,7 +48,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -56,7 +56,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable diff --git a/Cargo.lock b/Cargo.lock index 25aca4136..4930cb9be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -356,20 +356,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "ecdsa" -version = "0.17.0-pre.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e62f2041a28c40b8884b79fbd19bc7457d76c6397767831e9ff4029fc0473a9" -dependencies = [ - "der", - "digest", - "elliptic-curve", - "rfc6979", - "serdect", - "signature", - "spki", -] [[package]] name = "either" @@ -1108,7 +1094,7 @@ dependencies = [ "hex-literal", "primeorder", "proptest", - "rand_core 0.6.4", + "rand_core 0.9.2", "rfc6979", "serdect", "signature", diff --git a/sm2/Cargo.toml b/sm2/Cargo.toml index 4af59da95..40063622b 100644 --- a/sm2/Cargo.toml +++ b/sm2/Cargo.toml @@ -14,23 +14,24 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "shangmi", "signature", "encryption"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } +rand_core = { version = "0.9", default-features = false } # optional dependencies primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } rfc6979 = { version = "=0.5.0-pre.4", optional = true } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } -signature = { version = "=2.3.0-pre.4", optional = true, features = ["rand_core"] } +signature = { version = "=2.3.0-pre.6", optional = true, features = ["rand_core"] } sm3 = { version = "=0.5.0-pre.4", optional = true, default-features = false } [dev-dependencies] hex-literal = "0.4" proptest = "1" -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } [features] default = ["arithmetic", "dsa", "pke", "pem", "std"] @@ -41,7 +42,6 @@ arithmetic = ["dep:primeorder", "elliptic-curve/arithmetic"] bits = ["arithmetic", "elliptic-curve/bits"] dsa = ["arithmetic", "dep:rfc6979", "dep:signature", "dep:sm3"] pke = ["arithmetic", "dep:sm3"] -getrandom = ["rand_core/getrandom"] pem = ["elliptic-curve/pem", "pkcs8"] pkcs8 = ["elliptic-curve/pkcs8"] serde = ["elliptic-curve/serde", "primeorder?/serde", "serdect"] diff --git a/sm2/README.md b/sm2/README.md index 136871554..020944063 100644 --- a/sm2/README.md +++ b/sm2/README.md @@ -35,18 +35,6 @@ The SM2 cryptosystem is composed of three distinct algorithms: - [ ] **SM2KEP**: key exchange protocol defined in [GBT.32918.3-2016] (SM2-3) - [x] **SM2PKE**: public key encryption algorithm defined in [GBT.32918.4-2016] (SM2-4) -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -71,7 +59,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/sm2.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/sm2.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/sm2/src/arithmetic.rs b/sm2/src/arithmetic.rs index c2aa66e37..4318671d6 100644 --- a/sm2/src/arithmetic.rs +++ b/sm2/src/arithmetic.rs @@ -13,7 +13,7 @@ pub use self::scalar::Scalar; use self::field::FieldElement; use crate::Sm2; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; diff --git a/sm2/src/arithmetic/scalar.rs b/sm2/src/arithmetic/scalar.rs index e1ec6afcc..1fefde0af 100644 --- a/sm2/src/arithmetic/scalar.rs +++ b/sm2/src/arithmetic/scalar.rs @@ -24,26 +24,26 @@ mod scalar_impl; use self::scalar_impl::*; -use crate::{FieldBytes, FieldBytesEncoding, SecretKey, Sm2, ORDER_HEX, U256}; +use crate::{FieldBytes, FieldBytesEncoding, ORDER_HEX, SecretKey, Sm2, U256}; use core::{ fmt::{self, Debug}, iter::{Product, Sum}, ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Curve as _, Error, Result, ScalarPrimitive, bigint::Limb, ff::PrimeField, ops::Reduce, scalar::{FromUintUnchecked, IsHigh}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, CtOption}, - Curve as _, Error, Result, ScalarPrimitive, }; #[cfg(feature = "bits")] use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(doc)] use core::ops::{Add, Mul, Sub}; diff --git a/sm2/src/distid.rs b/sm2/src/distid.rs index d74d3162b..9e93eea1c 100644 --- a/sm2/src/distid.rs +++ b/sm2/src/distid.rs @@ -2,8 +2,8 @@ use crate::{AffinePoint, Hash, Sm2}; use elliptic_curve::{ - sec1::{self, ToEncodedPoint}, Error, Result, + sec1::{self, ToEncodedPoint}, }; use primeorder::PrimeCurveParams; use sm3::{Digest, Sm3}; diff --git a/sm2/src/dsa.rs b/sm2/src/dsa.rs index b853f65b9..f066ba273 100644 --- a/sm2/src/dsa.rs +++ b/sm2/src/dsa.rs @@ -8,14 +8,14 @@ #![cfg_attr(feature = "std", doc = "```")] #![cfg_attr(not(feature = "std"), doc = "```ignore")] //! # fn example() -> Result<(), Box> { -//! use rand_core::OsRng; // requires 'getrandom` feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng` feature //! use sm2::{ //! dsa::{Signature, SigningKey, signature::Signer}, //! SecretKey //! }; //! //! // Signing -//! let secret_key = SecretKey::random(&mut OsRng); // serialize with `::to_bytes()` +//! let secret_key = SecretKey::random(&mut OsRng.unwrap_mut()); // serialize with `::to_bytes()` //! let distid = "example@rustcrypto.org"; // distinguishing identifier //! let signing_key = SigningKey::new(distid, &secret_key)?; //! let verifying_key_bytes = signing_key.verifying_key().to_sec1_bytes(); diff --git a/sm2/src/dsa/signing.rs b/sm2/src/dsa/signing.rs index c5b86f87e..9fd0b606c 100644 --- a/sm2/src/dsa/signing.rs +++ b/sm2/src/dsa/signing.rs @@ -20,16 +20,16 @@ use crate::{ }; use core::fmt::{self, Debug}; use elliptic_curve::{ + Curve, FieldBytesEncoding, PrimeField, array::typenum::Unsigned, ops::{MulByGenerator, Reduce}, point::AffineCoordinates, subtle::{Choice, ConstantTimeEq}, - Curve, FieldBytesEncoding, PrimeField, }; use signature::{ - hazmat::{PrehashSigner, RandomizedPrehashSigner}, - rand_core::CryptoRngCore, Error, KeypairRef, RandomizedSigner, Result, Signer, + hazmat::{PrehashSigner, RandomizedPrehashSigner}, + rand_core::TryCryptoRng, }; use sm3::Sm3; @@ -119,19 +119,23 @@ impl PrehashSigner for SigningKey { } impl RandomizedPrehashSigner for SigningKey { - fn sign_prehash_with_rng( + fn sign_prehash_with_rng( &self, - rng: &mut impl CryptoRngCore, + rng: &mut R, prehash: &[u8], ) -> Result { let mut data = FieldBytes::default(); - rng.try_fill_bytes(&mut data)?; + rng.try_fill_bytes(&mut data).map_err(|_| Error::new())?; sign_prehash_rfc6979(&self.secret_scalar, prehash, &data) } } impl RandomizedSigner for SigningKey { - fn try_sign_with_rng(&self, rng: &mut impl CryptoRngCore, msg: &[u8]) -> Result { + fn try_sign_with_rng( + &self, + rng: &mut R, + msg: &[u8], + ) -> Result { // A1: set M~=ZA || M let hash = self.verifying_key.hash_msg(msg); self.sign_prehash_with_rng(rng, &hash) diff --git a/sm2/src/dsa/verifying.rs b/sm2/src/dsa/verifying.rs index 76d4b2a6a..95379ee99 100644 --- a/sm2/src/dsa/verifying.rs +++ b/sm2/src/dsa/verifying.rs @@ -14,18 +14,18 @@ use super::Signature; use crate::{ - distid::hash_z, AffinePoint, DistId, EncodedPoint, FieldBytes, Hash, ProjectivePoint, - PublicKey, Scalar, Sm2, + AffinePoint, DistId, EncodedPoint, FieldBytes, Hash, ProjectivePoint, PublicKey, Scalar, Sm2, + distid::hash_z, }; use elliptic_curve::{ + Curve, Group, array::typenum::Unsigned, ops::{LinearCombination, Reduce}, point::AffineCoordinates, sec1::ToEncodedPoint, - Curve, Group, }; -use signature::{hazmat::PrehashVerifier, Error, Result, Verifier}; -use sm3::{digest::Digest, Sm3}; +use signature::{Error, Result, Verifier, hazmat::PrehashVerifier}; +use sm3::{Sm3, digest::Digest}; #[cfg(feature = "alloc")] use alloc::{boxed::Box, string::String}; diff --git a/sm2/src/lib.rs b/sm2/src/lib.rs index c81208198..c8f335111 100644 --- a/sm2/src/lib.rs +++ b/sm2/src/lib.rs @@ -42,16 +42,16 @@ mod distid; pub use elliptic_curve::{self, bigint::U256}; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; use elliptic_curve::{ - array::{typenum::U33, Array}, + FieldBytesEncoding, + array::{Array, typenum::U33}, bigint::ArrayEncoding, consts::U32, - FieldBytesEncoding, }; #[cfg(feature = "dsa")] diff --git a/sm2/src/pke.rs b/sm2/src/pke.rs index 61875511d..58b226df0 100644 --- a/sm2/src/pke.rs +++ b/sm2/src/pke.rs @@ -9,7 +9,7 @@ #![cfg_attr(feature = "std", doc = "```")] #![cfg_attr(not(feature = "std"), doc = "```ignore")] //! # fn example() -> Result<(), Box> { -//! use rand_core::OsRng; // requires 'getrandom` feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng` feature //! use sm2::{ //! pke::{EncryptingKey, Mode}, //! {SecretKey, PublicKey} @@ -17,7 +17,7 @@ //! }; //! //! // Encrypting -//! let secret_key = SecretKey::random(&mut OsRng); // serialize with `::to_bytes()` +//! let secret_key = SecretKey::random(&mut OsRng.unwrap_mut()); // serialize with `::to_bytes()` //! let public_key = secret_key.public_key(); //! let encrypting_key = EncryptingKey::new_with_mode(public_key, Mode::C1C2C3); //! let plaintext = b"plaintext"; @@ -49,16 +49,16 @@ use crate::AffinePoint; use alloc::vec; use elliptic_curve::{ - bigint::{Encoding, Uint, U256}, + bigint::{Encoding, U256, Uint}, pkcs8::der::{ - asn1::UintRef, Decode, DecodeValue, Encode, Length, Reader, Sequence, Tag, Writer, + Decode, DecodeValue, Encode, Length, Reader, Sequence, Tag, Writer, asn1::UintRef, }, }; use elliptic_curve::{ - pkcs8::der::{asn1::OctetStringRef, EncodeValue}, - sec1::ToEncodedPoint, Result, + pkcs8::der::{EncodeValue, asn1::OctetStringRef}, + sec1::ToEncodedPoint, }; use sm3::digest::DynDigest; @@ -91,7 +91,7 @@ pub struct Cipher<'a> { impl<'a> Sequence<'a> for Cipher<'a> {} -impl<'a> EncodeValue for Cipher<'a> { +impl EncodeValue for Cipher<'_> { fn value_len(&self) -> elliptic_curve::pkcs8::der::Result { UintRef::new(&self.x.to_be_bytes())?.encoded_len()? + UintRef::new(&self.y.to_be_bytes())?.encoded_len()? diff --git a/sm2/src/pke/decrypting.rs b/sm2/src/pke/decrypting.rs index 5a57a6336..71b320fee 100644 --- a/sm2/src/pke/decrypting.rs +++ b/sm2/src/pke/decrypting.rs @@ -1,24 +1,24 @@ use core::fmt::{self, Debug}; use crate::{ - arithmetic::field::FieldElement, AffinePoint, EncodedPoint, FieldBytes, NonZeroScalar, - PublicKey, Scalar, SecretKey, + AffinePoint, EncodedPoint, FieldBytes, NonZeroScalar, PublicKey, Scalar, SecretKey, + arithmetic::field::FieldElement, }; use alloc::{borrow::ToOwned, vec::Vec}; use elliptic_curve::{ + Error, Group, Result, bigint::U256, ops::Reduce, pkcs8::der::Decode, sec1::{FromEncodedPoint, ToEncodedPoint}, subtle::{Choice, ConstantTimeEq}, - Error, Group, Result, }; use primeorder::PrimeField; -use sm3::{digest::DynDigest, Digest, Sm3}; +use sm3::{Digest, Sm3, digest::DynDigest}; -use super::{encrypting::EncryptingKey, kdf, vec, Cipher, Mode}; +use super::{Cipher, Mode, encrypting::EncryptingKey, kdf, vec}; /// Represents a decryption key used for decrypting messages using elliptic curve cryptography. #[derive(Clone)] pub struct DecryptingKey { diff --git a/sm2/src/pke/encrypting.rs b/sm2/src/pke/encrypting.rs index a0bcb55a2..e1aa64053 100644 --- a/sm2/src/pke/encrypting.rs +++ b/sm2/src/pke/encrypting.rs @@ -1,26 +1,26 @@ use core::fmt::Debug; use crate::{ + AffinePoint, ProjectivePoint, PublicKey, Scalar, Sm2, arithmetic::field::FieldElement, pke::{kdf, vec}, - AffinePoint, ProjectivePoint, PublicKey, Scalar, Sm2, }; #[cfg(feature = "alloc")] use alloc::{borrow::ToOwned, boxed::Box, vec::Vec}; use elliptic_curve::{ - bigint::{RandomBits, Uint, Zero, U256}, + Curve, Error, Group, Result, + bigint::{RandomBits, U256, Uint, Zero}, ops::{MulByGenerator, Reduce}, pkcs8::der::Encode, rand_core, sec1::ToEncodedPoint, - Curve, Error, Group, Result, }; use primeorder::PrimeField; use sm3::{ - digest::{Digest, DynDigest}, Sm3, + digest::{Digest, DynDigest}, }; use super::{Cipher, Mode}; diff --git a/sm2/tests/pkcs8.rs b/sm2/tests/pkcs8.rs index abf01fb05..20b6f67d7 100644 --- a/sm2/tests/pkcs8.rs +++ b/sm2/tests/pkcs8.rs @@ -40,7 +40,9 @@ const PKCS8_PUBLIC_KEY_PEM: &str = include_str!("examples/pkcs8-public-key.pem") /// c8:c7:36:4c:8a /// ``` #[cfg(feature = "arithmetic")] -const SEC1_PUBLIC_KEY: [u8; 65] = hex!("0408D77AE04C01CC4C1104360DD8AF6B6F7DF334283D7C1A6AFD5652407B87BEE5014E2A57C36C150D16324DC664E31E6432359609C4E79847A5B161C8C7364C8A"); +const SEC1_PUBLIC_KEY: [u8; 65] = hex!( + "0408D77AE04C01CC4C1104360DD8AF6B6F7DF334283D7C1A6AFD5652407B87BEE5014E2A57C36C150D16324DC664E31E6432359609C4E79847A5B161C8C7364C8A" +); #[test] fn decode_pkcs8_private_key_from_der() { diff --git a/sm2/tests/sm2dsa.rs b/sm2/tests/sm2dsa.rs index f818eda67..21a7f69f9 100644 --- a/sm2/tests/sm2dsa.rs +++ b/sm2/tests/sm2dsa.rs @@ -6,14 +6,16 @@ use elliptic_curve::ops::Reduce; use hex_literal::hex; use proptest::prelude::*; use sm2::{ + NonZeroScalar, Scalar, U256, dsa::{ - signature::{Signer, Verifier}, Signature, SigningKey, VerifyingKey, + signature::{Signer, Verifier}, }, - NonZeroScalar, Scalar, U256, }; -const PUBLIC_KEY: [u8; 65] = hex!("0408D77AE04C01CC4C1104360DD8AF6B6F7DF334283D7C1A6AFD5652407B87BEE5014E2A57C36C150D16324DC664E31E6432359609C4E79847A5B161C8C7364C8A"); +const PUBLIC_KEY: [u8; 65] = hex!( + "0408D77AE04C01CC4C1104360DD8AF6B6F7DF334283D7C1A6AFD5652407B87BEE5014E2A57C36C150D16324DC664E31E6432359609C4E79847A5B161C8C7364C8A" +); const IDENTITY: &str = "example@rustcrypto.org"; const MSG: &[u8] = b"testing"; diff --git a/sm2/tests/sm2pke.rs b/sm2/tests/sm2pke.rs index 74d110f26..a16fad956 100644 --- a/sm2/tests/sm2pke.rs +++ b/sm2/tests/sm2pke.rs @@ -1,10 +1,10 @@ #![cfg(feature = "pke")] -use elliptic_curve::{ops::Reduce, NonZeroScalar}; +use elliptic_curve::{NonZeroScalar, ops::Reduce}; use hex_literal::hex; use proptest::prelude::*; -use sm2::{pke::DecryptingKey, Scalar, Sm2, U256}; +use sm2::{Scalar, Sm2, U256, pke::DecryptingKey}; // private key bytes const PRIVATE_KEY: [u8; 32] = @@ -12,9 +12,13 @@ const PRIVATE_KEY: [u8; 32] = const MSG: &[u8] = b"plaintext"; // starts with 04, ciphertext -const CIPHER: [u8; 106] = hex!("041ed68db303f5bc6bce516d5a62e1cd16781d3007df6864d970a56d46a6cecca0e0d33bfc71e78c440ae6afeef1a18cce473b3e27002189a058ddadc9182c80a3f13be66476ba6ef66d95a7fb11f30de441b3b66d566e48348bd830e584e7ec37f9b704ef32eba9055c"); +const CIPHER: [u8; 106] = hex!( + "041ed68db303f5bc6bce516d5a62e1cd16781d3007df6864d970a56d46a6cecca0e0d33bfc71e78c440ae6afeef1a18cce473b3e27002189a058ddadc9182c80a3f13be66476ba6ef66d95a7fb11f30de441b3b66d566e48348bd830e584e7ec37f9b704ef32eba9055c" +); // asn.1: openssl pkeyutl -encrypt -pubin -in plaintext -inkey sm2.pub -out cipher -const ASN1_CIPHER: [u8; 116] = hex!("307202206ba17ad462a75beeb2caf8a1282687ab7e2f248b776a481612d89425a519ce6002210083e1de8c57dae995137227839d3880eaf9fe82a885a750be29ebe58193c8e31a0420d513a555087c2b17a88dd62749435133d325a4afca675284c85d754ba35670f80409bd3a294a6d50184b37"); +const ASN1_CIPHER: [u8; 116] = hex!( + "307202206ba17ad462a75beeb2caf8a1282687ab7e2f248b776a481612d89425a519ce6002210083e1de8c57dae995137227839d3880eaf9fe82a885a750be29ebe58193c8e31a0420d513a555087c2b17a88dd62749435133d325a4afca675284c85d754ba35670f80409bd3a294a6d50184b37" +); #[test] fn decrypt_verify() { From 827d715e48a53961723e95f9f1193319653d2de9 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 22:24:53 -0800 Subject: [PATCH 10/20] primeorder: bump to edition 2024; msrv 1.85 --- .github/workflows/primeorder.yml | 4 ++-- primeorder/Cargo.toml | 4 ++-- primeorder/README.md | 14 +------------- primeorder/src/affine.rs | 6 +++--- primeorder/src/field.rs | 2 +- primeorder/src/lib.rs | 4 ++-- primeorder/src/point_arithmetic.rs | 2 +- primeorder/src/projective.rs | 9 ++++----- 8 files changed, 16 insertions(+), 29 deletions(-) diff --git a/.github/workflows/primeorder.yml b/.github/workflows/primeorder.yml index 89df99ef1..ce82fe6da 100644 --- a/.github/workflows/primeorder.yml +++ b/.github/workflows/primeorder.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -43,7 +43,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/primeorder/Cargo.toml b/primeorder/Cargo.toml index add3aecaa..b7fbb93b2 100644 --- a/primeorder/Cargo.toml +++ b/primeorder/Cargo.toml @@ -14,8 +14,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["arithmetic", "sec1"] } diff --git a/primeorder/README.md b/primeorder/README.md index 6204bf336..bae2b71fd 100644 --- a/primeorder/README.md +++ b/primeorder/README.md @@ -43,18 +43,6 @@ that generated assembly is constant time on common CPU architectures. USE AT YOUR OWN RISK! -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of: @@ -79,7 +67,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/primeorder.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/primeorder.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/primeorder/src/affine.rs b/primeorder/src/affine.rs index 02ae6e1d4..7d522eedf 100644 --- a/primeorder/src/affine.rs +++ b/primeorder/src/affine.rs @@ -8,9 +8,10 @@ use core::{ ops::{Mul, Neg}, }; use elliptic_curve::{ + Error, FieldBytes, FieldBytesEncoding, FieldBytesSize, PublicKey, Result, Scalar, array::ArraySize, ff::{Field, PrimeField}, - group::{prime::PrimeCurveAffine, GroupEncoding}, + group::{GroupEncoding, prime::PrimeCurveAffine}, point::{AffineCoordinates, DecompactPoint, DecompressPoint, Double}, sec1::{ self, CompressedPoint, EncodedPoint, FromEncodedPoint, ModulusSize, ToCompactEncodedPoint, @@ -18,11 +19,10 @@ use elliptic_curve::{ }, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, CtOption}, zeroize::DefaultIsZeroes, - Error, FieldBytes, FieldBytesEncoding, FieldBytesSize, PublicKey, Result, Scalar, }; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; /// Point on a Weierstrass curve in affine coordinates. #[derive(Clone, Copy, Debug)] diff --git a/primeorder/src/field.rs b/primeorder/src/field.rs index ffc79bcc4..fe02f875b 100644 --- a/primeorder/src/field.rs +++ b/primeorder/src/field.rs @@ -80,7 +80,7 @@ macro_rules! impl_mont_field_element { #[doc = stringify!($fe)] /// `] from a big endian byte slice. pub fn from_slice(slice: &[u8]) -> $crate::elliptic_curve::Result { - use $crate::elliptic_curve::array::{typenum::Unsigned, Array}; + use $crate::elliptic_curve::array::{Array, typenum::Unsigned}; if slice.len() != <$curve as $crate::elliptic_curve::Curve>::FieldBytesSize::USIZE { return Err($crate::elliptic_curve::Error); diff --git a/primeorder/src/lib.rs b/primeorder/src/lib.rs index 34d501bb2..48d5fb63e 100644 --- a/primeorder/src/lib.rs +++ b/primeorder/src/lib.rs @@ -21,11 +21,11 @@ mod field; mod projective; pub use crate::{affine::AffinePoint, projective::ProjectivePoint}; -pub use elliptic_curve::{self, array, point::Double, Field, FieldBytes, PrimeCurve, PrimeField}; +pub use elliptic_curve::{self, Field, FieldBytes, PrimeCurve, PrimeField, array, point::Double}; +use elliptic_curve::CurveArithmetic; use elliptic_curve::ops::Invert; use elliptic_curve::subtle::CtOption; -use elliptic_curve::CurveArithmetic; /// Parameters for elliptic curves of prime order which can be described by the /// short Weierstrass equation. diff --git a/primeorder/src/point_arithmetic.rs b/primeorder/src/point_arithmetic.rs index b41308992..994bea726 100644 --- a/primeorder/src/point_arithmetic.rs +++ b/primeorder/src/point_arithmetic.rs @@ -3,7 +3,7 @@ //! Support for formulas specialized to the short Weierstrass equation's //! 𝒂-coefficient. -use elliptic_curve::{subtle::ConditionallySelectable, Field}; +use elliptic_curve::{Field, subtle::ConditionallySelectable}; use crate::{AffinePoint, PrimeCurveParams, ProjectivePoint}; diff --git a/primeorder/src/projective.rs b/primeorder/src/projective.rs index 950167025..8699ffa62 100644 --- a/primeorder/src/projective.rs +++ b/primeorder/src/projective.rs @@ -2,20 +2,20 @@ #![allow(clippy::needless_range_loop, clippy::op_ref)] -use crate::{point_arithmetic::PointArithmetic, AffinePoint, Field, PrimeCurveParams}; +use crate::{AffinePoint, Field, PrimeCurveParams, point_arithmetic::PointArithmetic}; use core::{ borrow::Borrow, iter::Sum, ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign}, }; use elliptic_curve::{ + BatchNormalize, Error, FieldBytes, FieldBytesSize, PrimeField, PublicKey, Result, Scalar, array::ArraySize, bigint::ArrayEncoding, group::{ - self, + self, Group, GroupEncoding, cofactor::CofactorGroup, prime::{PrimeCurve, PrimeGroup}, - Group, GroupEncoding, }, ops::{BatchInvert, LinearCombination, MulByGenerator}, point::Double, @@ -26,7 +26,6 @@ use elliptic_curve::{ }, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption}, zeroize::DefaultIsZeroes, - BatchNormalize, Error, FieldBytes, FieldBytesSize, PrimeField, PublicKey, Result, Scalar, }; #[cfg(feature = "alloc")] @@ -776,7 +775,7 @@ where } } -impl<'a, C> Neg for &'a ProjectivePoint +impl Neg for &ProjectivePoint where C: PrimeCurveParams, { From ae814c7f700e976c4f519bd9e69d5b4253bd27d8 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 22:33:46 -0800 Subject: [PATCH 11/20] p224: bump to edition 2024; msrv 1.85 --- .github/workflows/p224.yml | 6 +++--- p224/Cargo.toml | 6 +++--- p224/README.md | 14 +------------- p224/src/arithmetic.rs | 2 +- p224/src/arithmetic/scalar.rs | 6 +++--- p224/src/ecdh.rs | 6 +++--- p224/src/ecdsa.rs | 10 +++++----- p224/src/lib.rs | 4 ++-- p224/src/test_vectors/ecdsa.rs | 1 - p224/tests/projective.rs | 4 ++-- 10 files changed, 23 insertions(+), 36 deletions(-) diff --git a/.github/workflows/p224.yml b/.github/workflows/p224.yml index 0d689131f..1ea66272b 100644 --- a/.github/workflows/p224.yml +++ b/.github/workflows/p224.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -51,7 +51,7 @@ jobs: include: # 32-bit Linux - target: i686-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV deps: sudo apt update && sudo apt install gcc-multilib - target: i686-unknown-linux-gnu rust: stable @@ -59,7 +59,7 @@ jobs: # 64-bit Linux - target: x86_64-unknown-linux-gnu - rust: 1.81.0 # MSRV + rust: 1.85.0 # MSRV - target: x86_64-unknown-linux-gnu rust: stable diff --git a/p224/Cargo.toml b/p224/Cargo.toml index b22a773c7..bcfedb642 100644 --- a/p224/Cargo.toml +++ b/p224/Cargo.toml @@ -13,8 +13,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "nist", "secp224r1"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } @@ -31,7 +31,7 @@ blobby = "0.3" ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } hex-literal = "0.4" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } -rand_core = { version = "0.6", features = ["getrandom"] } +rand_core = { version = "0.9", features = ["os_rng"] } [features] default = ["arithmetic", "ecdsa", "pem", "std"] diff --git a/p224/README.md b/p224/README.md index 36193c287..ba58a6ad7 100644 --- a/p224/README.md +++ b/p224/README.md @@ -40,18 +40,6 @@ Elliptic Curve Domain Parameters. Also known as secp224r1 (SECG). -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -76,7 +64,7 @@ dual licensed as above, without any additional terms or conditions. [build-image]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p224.yml/badge.svg [build-link]: https://github.com/RustCrypto/elliptic-curves/actions/workflows/p224.yml [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves diff --git a/p224/src/arithmetic.rs b/p224/src/arithmetic.rs index 1e28531bc..20edf3d0d 100644 --- a/p224/src/arithmetic.rs +++ b/p224/src/arithmetic.rs @@ -12,7 +12,7 @@ pub use self::scalar::Scalar; use self::field::FieldElement; use crate::NistP224; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; diff --git a/p224/src/arithmetic/scalar.rs b/p224/src/arithmetic/scalar.rs index e0a1f6db2..8bd77cac6 100644 --- a/p224/src/arithmetic/scalar.rs +++ b/p224/src/arithmetic/scalar.rs @@ -22,26 +22,26 @@ mod scalar_impl; use self::scalar_impl::*; -use crate::{FieldBytes, FieldBytesEncoding, NistP224, SecretKey, Uint, ORDER_HEX}; +use crate::{FieldBytes, FieldBytesEncoding, NistP224, ORDER_HEX, SecretKey, Uint}; use core::{ fmt::{self, Debug}, iter::{Product, Sum}, ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Curve as _, Error, Result, ScalarPrimitive, bigint::Limb, ff::PrimeField, ops::{Invert, Reduce}, scalar::{FromUintUnchecked, IsHigh}, subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, CtOption}, - Curve as _, Error, Result, ScalarPrimitive, }; #[cfg(feature = "bits")] use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits}; #[cfg(feature = "serde")] -use serdect::serde::{de, ser, Deserialize, Serialize}; +use serdect::serde::{Deserialize, Serialize, de, ser}; #[cfg(doc)] use core::ops::{Add, Mul, Sub}; diff --git a/p224/src/ecdh.rs b/p224/src/ecdh.rs index ce2c7f6ab..065cf3ecd 100644 --- a/p224/src/ecdh.rs +++ b/p224/src/ecdh.rs @@ -10,14 +10,14 @@ //! //! ``` //! use p224::{EncodedPoint, PublicKey, ecdh::EphemeralSecret}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Alice -//! let alice_secret = EphemeralSecret::random(&mut OsRng); +//! let alice_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let alice_pk_bytes = EncodedPoint::from(alice_secret.public_key()); //! //! // Bob -//! let bob_secret = EphemeralSecret::random(&mut OsRng); +//! let bob_secret = EphemeralSecret::random(&mut OsRng.unwrap_mut()); //! let bob_pk_bytes = EncodedPoint::from(bob_secret.public_key()); //! //! // Alice decodes Bob's serialized public key and computes a shared secret from it diff --git a/p224/src/ecdsa.rs b/p224/src/ecdsa.rs index 4b9783151..dcfb25037 100644 --- a/p224/src/ecdsa.rs +++ b/p224/src/ecdsa.rs @@ -22,10 +22,10 @@ //! # #[cfg(feature = "ecdsa")] //! # { //! use p224::ecdsa::{signature::Signer, Signature, SigningKey}; -//! use rand_core::OsRng; // requires 'getrandom' feature +//! use rand_core::{OsRng, TryRngCore}; // requires 'os_rng' feature //! //! // Signing -//! let signing_key = SigningKey::random(&mut OsRng); // Serialize with `::to_bytes()` +//! let signing_key = SigningKey::random(&mut OsRng.unwrap_mut()); // Serialize with `::to_bytes()` //! let message = b"ECDSA proves knowledge of a secret number in the context of a single message"; //! let signature: Signature = signing_key.sign(message); //! @@ -67,7 +67,7 @@ impl ecdsa_core::hazmat::DigestPrimitive for NistP224 { #[cfg(all(test, feature = "ecdsa"))] mod tests { - use crate::ecdsa::{signature::Signer, Signature, SigningKey}; + use crate::ecdsa::{Signature, SigningKey, signature::Signer}; use hex_literal::hex; // Test vector from RFC 6979 Appendix 2.4 (NIST P-224 + SHA-224) @@ -96,12 +96,12 @@ mod tests { } mod sign { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP224}; + use crate::{NistP224, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_signing_test!(NistP224, ECDSA_TEST_VECTORS); } mod verify { - use crate::{test_vectors::ecdsa::ECDSA_TEST_VECTORS, NistP224}; + use crate::{NistP224, test_vectors::ecdsa::ECDSA_TEST_VECTORS}; ecdsa_core::new_verification_test!(NistP224, ECDSA_TEST_VECTORS); } diff --git a/p224/src/lib.rs b/p224/src/lib.rs index b730fdcfe..d865e044d 100644 --- a/p224/src/lib.rs +++ b/p224/src/lib.rs @@ -30,15 +30,15 @@ pub mod test_vectors; pub use elliptic_curve; #[cfg(feature = "arithmetic")] -pub use arithmetic::{scalar::Scalar, AffinePoint, ProjectivePoint}; +pub use arithmetic::{AffinePoint, ProjectivePoint, scalar::Scalar}; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; use elliptic_curve::{ + FieldBytesEncoding, array::Array, consts::{U28, U29}, - FieldBytesEncoding, }; #[cfg(target_pointer_width = "32")] diff --git a/p224/src/test_vectors/ecdsa.rs b/p224/src/test_vectors/ecdsa.rs index e5810f301..15ebdece5 100644 --- a/p224/src/test_vectors/ecdsa.rs +++ b/p224/src/test_vectors/ecdsa.rs @@ -11,7 +11,6 @@ use hex_literal::hex; /// /// The `m` field contains a SHA-224 prehash of the `Msg` field in the /// original `SigTen.txt`. - pub const ECDSA_TEST_VECTORS: &[TestVector; 15] = &[ TestVector { m: &hex!("07eb2a50bf70eee87467600614a490e7600437d077ec651a27e65e67"), diff --git a/p224/tests/projective.rs b/p224/tests/projective.rs index be43fc26e..73276687b 100644 --- a/p224/tests/projective.rs +++ b/p224/tests/projective.rs @@ -7,10 +7,10 @@ use elliptic_curve::{ sec1::{self, ToEncodedPoint}, }; use p224::{ - test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, AffinePoint, ProjectivePoint, Scalar, + test_vectors::group::{ADD_TEST_VECTORS, MUL_TEST_VECTORS}, }; -use primeorder::{impl_projective_arithmetic_tests, Double}; +use primeorder::{Double, impl_projective_arithmetic_tests}; impl_projective_arithmetic_tests!( AffinePoint, From 874f139f41c5fc4d6d66588fd1d2b3a984b317fe Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 22:46:43 -0800 Subject: [PATCH 12/20] bp384: bump to edition 2024; msrv 1.85 --- .github/workflows/bp384.yml | 4 ++-- bp384/Cargo.toml | 4 ++-- bp384/README.md | 14 +------------- bp384/src/arithmetic/field.rs | 6 ++++-- bp384/src/arithmetic/scalar.rs | 6 ++++-- bp384/src/lib.rs | 2 +- bp384/src/r1.rs | 2 +- bp384/src/r1/arithmetic.rs | 20 +++++++++++++------- bp384/src/t1.rs | 2 +- bp384/src/t1/arithmetic.rs | 20 +++++++++++++------- 10 files changed, 42 insertions(+), 38 deletions(-) diff --git a/.github/workflows/bp384.yml b/.github/workflows/bp384.yml index dc16fa315..d533d6550 100644 --- a/.github/workflows/bp384.yml +++ b/.github/workflows/bp384.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -49,7 +49,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/bp384/Cargo.toml b/bp384/Cargo.toml index 2ed2bbd30..cf1316127 100644 --- a/bp384/Cargo.toml +++ b/bp384/Cargo.toml @@ -10,8 +10,8 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["brainpool", "crypto", "ecc"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" [dependencies] elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] } diff --git a/bp384/README.md b/bp384/README.md index 603842ce0..f820fe810 100644 --- a/bp384/README.md +++ b/bp384/README.md @@ -12,18 +12,6 @@ implemented in terms of traits from the [`elliptic-curve`] crate. [Documentation][docs-link] -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of @@ -46,7 +34,7 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/bp384/badge.svg [docs-link]: https://docs.rs/bp384/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.81+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260040-elliptic-curves [build-image]: https://github.com/RustCrypto/elliptic-curves/workflows/bp384/badge.svg?branch=master&event=push diff --git a/bp384/src/arithmetic/field.rs b/bp384/src/arithmetic/field.rs index a9bd53e99..f418089a9 100644 --- a/bp384/src/arithmetic/field.rs +++ b/bp384/src/arithmetic/field.rs @@ -23,10 +23,10 @@ use core::{ }; use elliptic_curve::ops::Invert; use elliptic_curve::{ + Error, Result, bigint::{ArrayEncoding, Integer, Limb}, ff::PrimeField, subtle::{Choice, ConstantTimeEq, ConstantTimeLess, CtOption}, - Error, Result, }; /// Constant representing the modulus serialized as hex. @@ -267,7 +267,9 @@ impl PrimeField for FieldElement { const TWO_INV: Self = Self::from_u64(2).invert_unchecked(); const MULTIPLICATIVE_GENERATOR: Self = Self::from_u64(3); const S: u32 = 1; - const ROOT_OF_UNITY: Self = Self::from_hex("8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec52"); + const ROOT_OF_UNITY: Self = Self::from_hex( + "8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec52", + ); const ROOT_OF_UNITY_INV: Self = Self::ROOT_OF_UNITY.invert_unchecked(); const DELTA: Self = Self::from_u64(9); diff --git a/bp384/src/arithmetic/scalar.rs b/bp384/src/arithmetic/scalar.rs index ef14b3004..434abf9e6 100644 --- a/bp384/src/arithmetic/scalar.rs +++ b/bp384/src/arithmetic/scalar.rs @@ -22,6 +22,7 @@ use core::{ ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign}, }; use elliptic_curve::{ + Error, Result, bigint::{ArrayEncoding, Integer, Limb}, ff::PrimeField, ops::{Invert, Reduce}, @@ -30,7 +31,6 @@ use elliptic_curve::{ Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreater, ConstantTimeLess, CtOption, }, - Error, Result, }; #[cfg(doc)] @@ -336,7 +336,9 @@ impl PrimeField for Scalar { const TWO_INV: Self = Self::from_u64(2).invert_unchecked(); const MULTIPLICATIVE_GENERATOR: Self = Self::from_u64(2); const S: u32 = 2; - const ROOT_OF_UNITY: Self = Self::from_hex("76cdc6369fb54dde55a851fce47cc5f830bb074c85684b3ee476be128dc50cfa8602aeecf53a1982fcf3b95f8d4258ff"); + const ROOT_OF_UNITY: Self = Self::from_hex( + "76cdc6369fb54dde55a851fce47cc5f830bb074c85684b3ee476be128dc50cfa8602aeecf53a1982fcf3b95f8d4258ff", + ); const ROOT_OF_UNITY_INV: Self = Self::ROOT_OF_UNITY.invert_unchecked(); const DELTA: Self = Self::from_u64(16); diff --git a/bp384/src/lib.rs b/bp384/src/lib.rs index 05769d84e..b345d7cb3 100644 --- a/bp384/src/lib.rs +++ b/bp384/src/lib.rs @@ -30,7 +30,7 @@ pub use crate::arithmetic::scalar::Scalar; #[cfg(feature = "pkcs8")] pub use elliptic_curve::pkcs8; -use elliptic_curve::array::{typenum::U48, Array}; +use elliptic_curve::array::{Array, typenum::U48}; #[cfg(feature = "wip-arithmetic-do-not-use")] pub(crate) use crate::arithmetic::field::FieldElement; diff --git a/bp384/src/r1.rs b/bp384/src/r1.rs index fa8aa761a..0c9e2f615 100644 --- a/bp384/src/r1.rs +++ b/bp384/src/r1.rs @@ -14,9 +14,9 @@ pub use { use crate::ORDER; use elliptic_curve::{ + FieldBytesEncoding, bigint::{ArrayEncoding, U384}, consts::U48, - FieldBytesEncoding, }; #[cfg(feature = "pkcs8")] diff --git a/bp384/src/r1/arithmetic.rs b/bp384/src/r1/arithmetic.rs index b039d864d..d747b5a72 100644 --- a/bp384/src/r1/arithmetic.rs +++ b/bp384/src/r1/arithmetic.rs @@ -3,7 +3,7 @@ use super::BrainpoolP384r1; use crate::{FieldElement, Scalar}; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; @@ -28,13 +28,19 @@ impl PrimeCurveParams for BrainpoolP384r1 { type FieldElement = FieldElement; type PointArithmetic = point_arithmetic::EquationAIsGeneric; - const EQUATION_A: FieldElement = - FieldElement::from_hex("7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826"); - const EQUATION_B: FieldElement = - FieldElement::from_hex("04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"); + const EQUATION_A: FieldElement = FieldElement::from_hex( + "7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826", + ); + const EQUATION_B: FieldElement = FieldElement::from_hex( + "04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11", + ); const GENERATOR: (FieldElement, FieldElement) = ( - FieldElement::from_hex("1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"), - FieldElement::from_hex("8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"), + FieldElement::from_hex( + "1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e", + ), + FieldElement::from_hex( + "8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315", + ), ); } diff --git a/bp384/src/t1.rs b/bp384/src/t1.rs index f56511b49..f53c021e6 100644 --- a/bp384/src/t1.rs +++ b/bp384/src/t1.rs @@ -14,9 +14,9 @@ pub use { use crate::ORDER; use elliptic_curve::{ + FieldBytesEncoding, bigint::{ArrayEncoding, U384}, consts::U48, - FieldBytesEncoding, }; #[cfg(feature = "pkcs8")] diff --git a/bp384/src/t1/arithmetic.rs b/bp384/src/t1/arithmetic.rs index f1b739d7d..987255d90 100644 --- a/bp384/src/t1/arithmetic.rs +++ b/bp384/src/t1/arithmetic.rs @@ -3,7 +3,7 @@ use super::BrainpoolP384t1; use crate::{FieldElement, Scalar}; use elliptic_curve::{CurveArithmetic, PrimeCurveArithmetic}; -use primeorder::{point_arithmetic, PrimeCurveParams}; +use primeorder::{PrimeCurveParams, point_arithmetic}; /// Elliptic curve point in affine coordinates. pub type AffinePoint = primeorder::AffinePoint; @@ -28,13 +28,19 @@ impl PrimeCurveParams for BrainpoolP384t1 { type FieldElement = FieldElement; type PointArithmetic = point_arithmetic::EquationAIsGeneric; - const EQUATION_A: FieldElement = - FieldElement::from_hex("8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50"); - const EQUATION_B: FieldElement = - FieldElement::from_hex("7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471ee"); + const EQUATION_A: FieldElement = FieldElement::from_hex( + "8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec50", + ); + const EQUATION_B: FieldElement = FieldElement::from_hex( + "7f519eada7bda81bd826dba647910f8c4b9346ed8ccdc64e4b1abd11756dce1d2074aa263b88805ced70355a33b471ee", + ); const GENERATOR: (FieldElement, FieldElement) = ( - FieldElement::from_hex("18de98b02db9a306f2afcd7235f72a819b80ab12ebd653172476fecd462aabffc4ff191b946a5f54d8d0aa2f418808cc"), - FieldElement::from_hex("25ab056962d30651a114afd2755ad336747f93475b7a1fca3b88f2b6a208ccfe469408584dc2b2912675bf5b9e582928"), + FieldElement::from_hex( + "18de98b02db9a306f2afcd7235f72a819b80ab12ebd653172476fecd462aabffc4ff191b946a5f54d8d0aa2f418808cc", + ), + FieldElement::from_hex( + "25ab056962d30651a114afd2755ad336747f93475b7a1fca3b88f2b6a208ccfe469408584dc2b2912675bf5b9e582928", + ), ); } From 14ffbe4c8faf4f11bcd34c4fd3d582ccd2c498a0 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Fri, 28 Feb 2025 19:33:58 -0800 Subject: [PATCH 13/20] primefield: bump to edition 2024; msrv 1.85 --- .github/workflows/primefield.yml | 4 ++-- primefield/Cargo.toml | 4 ++-- primefield/README.md | 12 ------------ primefield/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/.github/workflows/primefield.yml b/.github/workflows/primefield.yml index b94e954b0..6d4db0263 100644 --- a/.github/workflows/primefield.yml +++ b/.github/workflows/primefield.yml @@ -24,7 +24,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable target: - thumbv7em-none-eabi @@ -42,7 +42,7 @@ jobs: strategy: matrix: rust: - - 1.81.0 # MSRV + - 1.85.0 # MSRV - stable steps: - uses: actions/checkout@v4 diff --git a/primefield/Cargo.toml b/primefield/Cargo.toml index 502f20662..ddcd17fc8 100644 --- a/primefield/Cargo.toml +++ b/primefield/Cargo.toml @@ -10,5 +10,5 @@ repository = "https://github.com/RustCrypto/elliptic-curves" readme = "README.md" categories = ["cryptography", "no-std"] keywords = ["crypto", "ecc", "field", "prime"] -edition = "2021" -rust-version = "1.81" +edition = "2024" +rust-version = "1.85" diff --git a/primefield/README.md b/primefield/README.md index 658ab60c6..11073c62a 100644 --- a/primefield/README.md +++ b/primefield/README.md @@ -13,18 +13,6 @@ Used by [RustCrypto] to implement elliptic curves. [Documentation][docs-link] -## Minimum Supported Rust Version - -Rust **1.81** or higher. - -Minimum supported Rust version can be changed in the future, but it will be -done with a minor version bump. - -## SemVer Policy - -- All on-by-default features of this library are covered by SemVer -- MSRV is considered exempt from SemVer as noted above - ## License All crates licensed under either of: diff --git a/primefield/src/lib.rs b/primefield/src/lib.rs index 8da1aca17..747ccba24 100644 --- a/primefield/src/lib.rs +++ b/primefield/src/lib.rs @@ -90,7 +90,7 @@ macro_rules! impl_mont_field_element { #[doc = stringify!($fe)] /// `] from a big endian byte slice. pub fn from_slice(slice: &[u8]) -> $crate::elliptic_curve::Result { - use $crate::elliptic_curve::array::{typenum::Unsigned, Array}; + use $crate::elliptic_curve::array::{Array, typenum::Unsigned}; if slice.len() != <$curve as $crate::elliptic_curve::Curve>::FieldBytesSize::USIZE { return Err($crate::elliptic_curve::Error); From e16bb26843d1bf6af93ae971a8646466928d7f12 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 21:54:24 -0800 Subject: [PATCH 14/20] use git hashes and macs --- Cargo.lock | 142 ++++++++++++++++++++++++++++++++++------------------- Cargo.toml | 9 ++++ 2 files changed, 101 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4930cb9be..a771e4328 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,8 +50,7 @@ checksum = "d9aa1eef3994e2ccd304a78fe3fea4a73e5792007f85f09b79bb82143ca5f82b" [[package]] name = "belt-hash" version = "0.2.0-pre.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee5982dbf7d2f719b4237cd796ee600e9dcbef1eef460ece65380f9192a54ab5" +source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" dependencies = [ "belt-block", "digest", @@ -67,7 +66,7 @@ dependencies = [ "digest", "elliptic-curve", "hex", - "hex-literal", + "hex-literal 0.4.1", "hkdf", "hmac", "pkcs8", @@ -120,9 +119,9 @@ checksum = "847495c209977a90e8aad588b959d0ca9f5dc228096d29a6bd3defd53f35eaec" [[package]] name = "block-buffer" -version = "0.11.0-rc.2" +version = "0.11.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "939c0e62efa052fb0b2db2c0f7c479ad32e364c192c3aab605a7641de265a1a7" +checksum = "a229bfd78e4827c91b9b95784f69492c1b77c1ab75a45a8a037b139215086f94" dependencies = [ "hybrid-array", ] @@ -225,9 +224,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "const-oid" -version = "0.10.0-rc.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0d96d207edbe5135e55038e79ab9ad6d75ba83b14cdf62326ce5b12bc46ab5" +checksum = "1cb3c4a0d3776f7535c32793be81d6d5fec0d48ac70955d9834e643aa249a52f" [[package]] name = "cpufeatures" @@ -313,22 +312,21 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.6.0-rc.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d748d1f5b807ee6d0df5a548d0130417295c3aaed1dcbbb3d6a2e7106e11fcca" +version = "0.7.0-pre.0" +source = "git+https://github.com/RustCrypto/crypto-bigint.git#2f1b2efda801d6de58b2f011afb46ac33a4fbf7b" dependencies = [ "hybrid-array", "num-traits", - "rand_core 0.6.4", + "rand_core 0.9.2", "subtle", "zeroize", ] [[package]] name = "crypto-common" -version = "0.2.0-rc.1" +version = "0.2.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0b8ce8218c97789f16356e7896b3714f26c2ee1079b79c0b7ae7064bb9089fa" +checksum = "170d71b5b14dec99db7739f6fc7d6ec2db80b78c3acb77db48392ccc3d8a9ea0" dependencies = [ "hybrid-array", ] @@ -346,9 +344,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.11.0-pre.9" +version = "0.11.0-pre.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2e3d6615d99707295a9673e889bf363a04b2a466bd320c65a72536f7577379" +checksum = "6c478574b20020306f98d61c8ca3322d762e1ff08117422ac6106438605ea516" dependencies = [ "block-buffer", "const-oid", @@ -356,6 +354,19 @@ dependencies = [ "subtle", ] +[[package]] +name = "ecdsa" +version = "0.17.0-pre.9" +source = "git+https://github.com/RustCrypto/signatures.git#a3c930906b408c91c0c48ebe74c750a65b1012e4" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "serdect", + "signature", + "spki", +] [[package]] name = "either" @@ -366,8 +377,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" version = "0.14.0-rc.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc43715037532dc2d061e5c97e81b684c28993d52a4fa4eb7d2ce2826d78f2f2" +source = "git+https://github.com/RustCrypto/traits.git#3fa125f4ec6f7610de112220d38ce40113c18f2c" dependencies = [ "base16ct", "base64ct", @@ -375,12 +385,12 @@ dependencies = [ "digest", "ff", "group", - "hex-literal", + "hex-literal 1.0.0", "hkdf", "hybrid-array", "pem-rfc7468", "pkcs8", - "rand_core 0.6.4", + "rand_core 0.9.2", "sec1", "serde_json", "serdect", @@ -435,7 +445,19 @@ checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", ] [[package]] @@ -476,6 +498,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hex-literal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcaaec4551594c969335c98c903c1397853d4198408ea609190f420500f6be71" + [[package]] name = "hkdf" version = "0.13.0-pre.4" @@ -488,17 +516,16 @@ dependencies = [ [[package]] name = "hmac" version = "0.13.0-pre.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4b1fb14e4df79f9406b434b60acef9f45c26c50062cccf1346c6103b8c47d58" +source = "git+https://github.com/RustCrypto/MACs.git#c7cbed0bd3f7026cc01251cd4602d0db4d0495b9" dependencies = [ "digest", ] [[package]] name = "hybrid-array" -version = "0.2.0-rc.11" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5a41e5b0754cae5aaf7915f1df1147ba8d316fc6e019cfcc00fbaba96d5e030" +checksum = "4dab50e193aebe510fe0e40230145820e02f48dae0cf339ea4204e6e708ff7bd" dependencies = [ "typenum", "zeroize", @@ -549,7 +576,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "hex", - "hex-literal", + "hex-literal 0.4.1", "num-bigint", "num-traits", "once_cell", @@ -657,7 +684,7 @@ version = "0.14.0-pre" dependencies = [ "ecdsa", "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "primeorder", "sec1", "serdect", @@ -670,9 +697,9 @@ dependencies = [ "blobby", "ecdsa", "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "primeorder", - "rand_core 0.6.4", + "rand_core 0.9.2", "serdect", "sha2", ] @@ -685,10 +712,10 @@ dependencies = [ "criterion", "ecdsa", "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "primeorder", "proptest", - "rand_core 0.6.4", + "rand_core 0.9.2", "serdect", "sha2", ] @@ -701,10 +728,10 @@ dependencies = [ "criterion", "ecdsa", "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "primeorder", "proptest", - "rand_core 0.6.4", + "rand_core 0.9.2", "serdect", "sha2", ] @@ -718,11 +745,11 @@ dependencies = [ "criterion", "ecdsa", "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "primefield", "primeorder", "proptest", - "rand_core 0.6.4", + "rand_core 0.9.2", "serdect", "sha2", ] @@ -878,7 +905,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] [[package]] @@ -887,6 +914,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a509b1a2ffbe92afab0e55c8fd99dea1c280e8171bd2d88682bb20bc41cbc2c" dependencies = [ + "getrandom 0.3.1", "zerocopy 0.8.20", ] @@ -1000,9 +1028,9 @@ dependencies = [ [[package]] name = "sec1" -version = "0.8.0-rc.3" +version = "0.8.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1988446eff153796413a73669dfaa4caa3f5ce8b25fac89e3821a39c611772e" +checksum = "a017a4aa8f0bd51e9d0184d98042dfe9285218fec098493f47d9a8aa0f1a3f27" dependencies = [ "base16ct", "der", @@ -1047,9 +1075,9 @@ dependencies = [ [[package]] name = "serdect" -version = "0.3.0-rc.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a504c8ee181e3e594d84052f983d60afe023f4d94d050900be18062bbbf7b58" +checksum = "f42f67da2385b51a5f9652db9c93d78aeaf7610bf5ec366080b6de810604af53" dependencies = [ "base16ct", "serde", @@ -1058,8 +1086,7 @@ dependencies = [ [[package]] name = "sha2" version = "0.11.0-pre.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540c0893cce56cdbcfebcec191ec8e0f470dd1889b6e7a0b503e310a94a168f5" +source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" dependencies = [ "cfg-if", "cpufeatures", @@ -1069,8 +1096,7 @@ dependencies = [ [[package]] name = "sha3" version = "0.11.0-pre.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e485881f388c2818d709796dc883c1ffcadde9d1f0e054f3a5c14974185261a6" +source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" dependencies = [ "digest", "keccak", @@ -1078,12 +1104,11 @@ dependencies = [ [[package]] name = "signature" -version = "2.3.0-pre.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054d71959c7051b9042c26af337f05cc930575ed2604d7d3ced3158383e59734" +version = "2.3.0-pre.6" +source = "git+https://github.com/RustCrypto/traits.git#3fa125f4ec6f7610de112220d38ce40113c18f2c" dependencies = [ "digest", - "rand_core 0.6.4", + "rand_core 0.9.2", ] [[package]] @@ -1091,7 +1116,7 @@ name = "sm2" version = "0.14.0-pre" dependencies = [ "elliptic-curve", - "hex-literal", + "hex-literal 0.4.1", "primeorder", "proptest", "rand_core 0.9.2", @@ -1104,8 +1129,7 @@ dependencies = [ [[package]] name = "sm3" version = "0.5.0-pre.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07f9b2bb2253fa784d673b18790bafaa35f5757b27e6616b01f09417dd0003f9" +source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" dependencies = [ "digest", ] @@ -1209,6 +1233,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "wasm-bindgen" version = "0.2.95" @@ -1365,6 +1398,15 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index f4ae75a06..9827d48cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,12 @@ ecdsa = { git = "https://github.com/RustCrypto/signatures.git" } elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" } signature = { git = "https://github.com/RustCrypto/traits.git" } + +belt-hash = { git = "https://github.com/RustCrypto/hashes.git" } +sha2 = { git = "https://github.com/RustCrypto/hashes.git" } +sha3 = { git = "https://github.com/RustCrypto/hashes.git" } +sm3 = { git = "https://github.com/RustCrypto/hashes.git" } + +hmac = { git = "https://github.com/RustCrypto/MACs.git" } + +crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" } From be804bbfdf457906ff763ec883f3b1b5c8de7e0e Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 22:40:41 -0800 Subject: [PATCH 15/20] chore(deps): bump `hex-literal` to `1.0.0` --- bign256/Cargo.toml | 4 ++-- k256/Cargo.toml | 4 ++-- p192/Cargo.toml | 4 ++-- p224/Cargo.toml | 4 ++-- p256/Cargo.toml | 4 ++-- p384/Cargo.toml | 4 ++-- p521/Cargo.toml | 4 ++-- sm2/Cargo.toml | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bign256/Cargo.toml b/bign256/Cargo.toml index 27747e316..edb9cf795 100644 --- a/bign256/Cargo.toml +++ b/bign256/Cargo.toml @@ -24,7 +24,7 @@ elliptic-curve = { version = "0.14.0-rc.0", features = ["sec1"] } belt-hash = { version = "=0.2.0-pre.4", optional = true, default-features = false } der = { version = "0.8.0-rc.0" } digest = { version = "=0.11.0-pre.10", optional = true } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } hkdf = { version = "=0.13.0-pre.4", optional = true } hmac = { version = "=0.13.0-pre.4", optional = true } rand_core = "0.9" @@ -36,7 +36,7 @@ signature = { version = "=2.3.0-pre.6", optional = true } [dev-dependencies] criterion = "0.5" -hex-literal = "0.4" +hex-literal = "1" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1" rand_core = { version = "0.9", features = ["os_rng"] } diff --git a/k256/Cargo.toml b/k256/Cargo.toml index ba362d3d9..f8e8bee17 100644 --- a/k256/Cargo.toml +++ b/k256/Cargo.toml @@ -25,7 +25,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies once_cell = { version = "1.20", optional = true, default-features = false } ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } signature = { version = "=2.3.0-pre.6", optional = true } @@ -35,7 +35,7 @@ blobby = "0.3" criterion = "0.5" ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } hex = "0.4.3" -hex-literal = "0.4" +hex-literal = "1" num-bigint = "0.4" num-traits = "0.2" proptest = "1.5" diff --git a/p192/Cargo.toml b/p192/Cargo.toml index c64ad38e8..c7cc88073 100644 --- a/p192/Cargo.toml +++ b/p192/Cargo.toml @@ -22,13 +22,13 @@ sec1 = { version = "0.8.0-rc.1", default-features = false } # optional dependencies ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } [dev-dependencies] ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } -hex-literal = "0.4" +hex-literal = "1" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } [features] diff --git a/p224/Cargo.toml b/p224/Cargo.toml index bcfedb642..de0c0b78c 100644 --- a/p224/Cargo.toml +++ b/p224/Cargo.toml @@ -21,7 +21,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } @@ -29,7 +29,7 @@ sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } [dev-dependencies] blobby = "0.3" ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } -hex-literal = "0.4" +hex-literal = "1" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } rand_core = { version = "0.9", features = ["os_rng"] } diff --git a/p256/Cargo.toml b/p256/Cargo.toml index 1f06d8b31..678e6991a 100644 --- a/p256/Cargo.toml +++ b/p256/Cargo.toml @@ -22,7 +22,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } @@ -31,7 +31,7 @@ sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } blobby = "0.3" criterion = "0.5" ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } -hex-literal = "0.4" +hex-literal = "1" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1" rand_core = { version = "0.9", features = ["os_rng"] } diff --git a/p384/Cargo.toml b/p384/Cargo.toml index 34758b24f..1acf41dfc 100644 --- a/p384/Cargo.toml +++ b/p384/Cargo.toml @@ -22,7 +22,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } @@ -31,7 +31,7 @@ sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } blobby = "0.3" criterion = "0.5" ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } -hex-literal = "0.4" +hex-literal = "1" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1.5" rand_core = { version = "0.9", features = ["os_rng"] } diff --git a/p521/Cargo.toml b/p521/Cargo.toml index 471aedcac..6074b34f1 100644 --- a/p521/Cargo.toml +++ b/p521/Cargo.toml @@ -22,7 +22,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } -hex-literal = { version = "0.4", optional = true } +hex-literal = { version = "1", optional = true } primefield = { version = "=0.14.0-pre.0", optional = true, path = "../primefield" } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } rand_core = { version = "0.9", optional = true, default-features = false } @@ -32,7 +32,7 @@ sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } [dev-dependencies] blobby = "0.3" ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } -hex-literal = "0.4" +hex-literal = "1" primeorder = { version = "=0.14.0-pre.2", features = ["dev"], path = "../primeorder" } proptest = "1.5" rand_core = { version = "0.9", features = ["os_rng"] } diff --git a/sm2/Cargo.toml b/sm2/Cargo.toml index 40063622b..c59b4cb9e 100644 --- a/sm2/Cargo.toml +++ b/sm2/Cargo.toml @@ -29,7 +29,7 @@ signature = { version = "=2.3.0-pre.6", optional = true, features = ["rand_core" sm3 = { version = "=0.5.0-pre.4", optional = true, default-features = false } [dev-dependencies] -hex-literal = "0.4" +hex-literal = "1" proptest = "1" rand_core = { version = "0.9", features = ["os_rng"] } From b465fbcf33d4bb6fbf83a505eb1ce415aa7cab64 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 22:42:49 -0800 Subject: [PATCH 16/20] chore(deps): bump `serdect` to `0.3` --- Cargo.lock | 24 +++++++++--------------- k256/Cargo.toml | 2 +- p192/Cargo.toml | 2 +- p224/Cargo.toml | 2 +- p256/Cargo.toml | 2 +- p384/Cargo.toml | 2 +- p521/Cargo.toml | 2 +- primeorder/Cargo.toml | 2 +- sm2/Cargo.toml | 2 +- 9 files changed, 17 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a771e4328..0a4c09041 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -66,7 +66,7 @@ dependencies = [ "digest", "elliptic-curve", "hex", - "hex-literal 0.4.1", + "hex-literal", "hkdf", "hmac", "pkcs8", @@ -385,7 +385,7 @@ dependencies = [ "digest", "ff", "group", - "hex-literal 1.0.0", + "hex-literal", "hkdf", "hybrid-array", "pem-rfc7468", @@ -492,12 +492,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - [[package]] name = "hex-literal" version = "1.0.0" @@ -576,7 +570,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "hex", - "hex-literal 0.4.1", + "hex-literal", "num-bigint", "num-traits", "once_cell", @@ -684,7 +678,7 @@ version = "0.14.0-pre" dependencies = [ "ecdsa", "elliptic-curve", - "hex-literal 0.4.1", + "hex-literal", "primeorder", "sec1", "serdect", @@ -697,7 +691,7 @@ dependencies = [ "blobby", "ecdsa", "elliptic-curve", - "hex-literal 0.4.1", + "hex-literal", "primeorder", "rand_core 0.9.2", "serdect", @@ -712,7 +706,7 @@ dependencies = [ "criterion", "ecdsa", "elliptic-curve", - "hex-literal 0.4.1", + "hex-literal", "primeorder", "proptest", "rand_core 0.9.2", @@ -728,7 +722,7 @@ dependencies = [ "criterion", "ecdsa", "elliptic-curve", - "hex-literal 0.4.1", + "hex-literal", "primeorder", "proptest", "rand_core 0.9.2", @@ -745,7 +739,7 @@ dependencies = [ "criterion", "ecdsa", "elliptic-curve", - "hex-literal 0.4.1", + "hex-literal", "primefield", "primeorder", "proptest", @@ -1116,7 +1110,7 @@ name = "sm2" version = "0.14.0-pre" dependencies = [ "elliptic-curve", - "hex-literal 0.4.1", + "hex-literal", "primeorder", "proptest", "rand_core 0.9.2", diff --git a/k256/Cargo.toml b/k256/Cargo.toml index f8e8bee17..b6993e5e7 100644 --- a/k256/Cargo.toml +++ b/k256/Cargo.toml @@ -26,7 +26,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = once_cell = { version = "1.20", optional = true, default-features = false } ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } hex-literal = { version = "1", optional = true } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } signature = { version = "=2.3.0-pre.6", optional = true } diff --git a/p192/Cargo.toml b/p192/Cargo.toml index c7cc88073..5f552e79b 100644 --- a/p192/Cargo.toml +++ b/p192/Cargo.toml @@ -24,7 +24,7 @@ sec1 = { version = "0.8.0-rc.1", default-features = false } ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } [dev-dependencies] ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", default-features = false, features = ["dev"] } diff --git a/p224/Cargo.toml b/p224/Cargo.toml index de0c0b78c..59ca15791 100644 --- a/p224/Cargo.toml +++ b/p224/Cargo.toml @@ -23,7 +23,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } [dev-dependencies] diff --git a/p256/Cargo.toml b/p256/Cargo.toml index 678e6991a..171366b5c 100644 --- a/p256/Cargo.toml +++ b/p256/Cargo.toml @@ -24,7 +24,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } [dev-dependencies] diff --git a/p384/Cargo.toml b/p384/Cargo.toml index 1acf41dfc..c5b9062df 100644 --- a/p384/Cargo.toml +++ b/p384/Cargo.toml @@ -24,7 +24,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } [dev-dependencies] diff --git a/p521/Cargo.toml b/p521/Cargo.toml index 6074b34f1..9fb1521e0 100644 --- a/p521/Cargo.toml +++ b/p521/Cargo.toml @@ -26,7 +26,7 @@ hex-literal = { version = "1", optional = true } primefield = { version = "=0.14.0-pre.0", optional = true, path = "../primefield" } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } rand_core = { version = "0.9", optional = true, default-features = false } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } [dev-dependencies] diff --git a/primeorder/Cargo.toml b/primeorder/Cargo.toml index b7fbb93b2..658a07303 100644 --- a/primeorder/Cargo.toml +++ b/primeorder/Cargo.toml @@ -21,7 +21,7 @@ rust-version = "1.85" elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["arithmetic", "sec1"] } # optional dependencies -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } [features] alloc = ["elliptic-curve/alloc"] diff --git a/sm2/Cargo.toml b/sm2/Cargo.toml index c59b4cb9e..88c50349d 100644 --- a/sm2/Cargo.toml +++ b/sm2/Cargo.toml @@ -24,7 +24,7 @@ rand_core = { version = "0.9", default-features = false } # optional dependencies primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } rfc6979 = { version = "=0.5.0-pre.4", optional = true } -serdect = { version = "0.3.0-rc.0", optional = true, default-features = false } +serdect = { version = "0.3", optional = true, default-features = false } signature = { version = "=2.3.0-pre.6", optional = true, features = ["rand_core"] } sm3 = { version = "=0.5.0-pre.4", optional = true, default-features = false } From ace24af310314a7beccba85b265a351d7aeaee92 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Tue, 25 Feb 2025 22:45:07 -0800 Subject: [PATCH 17/20] clippy 1.85 --- .github/workflows/workspace.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index 7cc6af041..10b543984 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: 1.81.0 + toolchain: 1.85.0 components: clippy - run: cargo clippy --all --all-features -- -D warnings From ca135ab6da239a5af1818fb7be8615f2a3627841 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Wed, 5 Mar 2025 11:23:59 -0800 Subject: [PATCH 18/20] add changelog for next release --- bign256/CHANGELOG.md | 19 +++++++++++++++++++ bp256/CHANGELOG.md | 18 ++++++++++++++++++ bp384/CHANGELOG.md | 19 +++++++++++++++++++ k256/CHANGELOG.md | 25 +++++++++++++++++++++++++ p192/CHANGELOG.md | 21 +++++++++++++++++++++ p224/CHANGELOG.md | 23 +++++++++++++++++++++++ p256/CHANGELOG.md | 20 ++++++++++++++++++++ p384/CHANGELOG.md | 21 +++++++++++++++++++++ p521/CHANGELOG.md | 25 +++++++++++++++++++++++++ primefield/CHANGELOG.md | 4 ++++ primeorder/CHANGELOG.md | 10 ++++++++++ sm2/CHANGELOG.md | 14 ++++++++++++++ 12 files changed, 219 insertions(+) diff --git a/bign256/CHANGELOG.md b/bign256/CHANGELOG.md index b41428b28..e564d4aa9 100644 --- a/bign256/CHANGELOG.md +++ b/bign256/CHANGELOG.md @@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added +- ECDH and PKCS8 support ([#1046]) +- `bits`, `serde`, and `test-vectors` features ([#1062]) + +## Changed +- Update to `digest` v0.11 ([#1011]) +- Update to `pkcs8` v0.11 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1046]: https://github.com/RustCrypto/elliptic-curves/pull/1046 +[#1062]: https://github.com/RustCrypto/elliptic-curves/pull/1062 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.13.1 (2024-01-05) ### Added - Digital signature algorithm ([#935]) diff --git a/bp256/CHANGELOG.md b/bp256/CHANGELOG.md index dc817be28..6deae4fbd 100644 --- a/bp256/CHANGELOG.md +++ b/bp256/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.7.0 (UNRELEASED) +### Fixed +- `FieldElement::to_bytes` function ([#1052]) + +## Changed +- Update to `ecdsa` v0.11 ([#1011]) +- Update to `digest` v0.11 ([#1011]) +- Update to `pkcs8` v0.11 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1052]: https://github.com/RustCrypto/elliptic-curves/pull/1052 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.6.1 (2023-04-16) ### Added - WIP `arithmetic` implementation ([#870], [#871], [#874], [#876]) diff --git a/bp384/CHANGELOG.md b/bp384/CHANGELOG.md index 944765801..36d1b809e 100644 --- a/bp384/CHANGELOG.md +++ b/bp384/CHANGELOG.md @@ -4,6 +4,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.7.0 (UNRELEASED) +### Changed +- `sqrt` implementation to Atkin algorithm ([#918]) + +### Added +- `elliptic_curve::ops::Invert` implementation ([#971]) + +## Changed +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#918]: https://github.com/RustCrypto/elliptic-curves/pull/918 +[#971]: https://github.com/RustCrypto/elliptic-curves/pull/971 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.6.1 (2023-04-16) ### Added - WIP `arithmetic` implementation ([#869], [#872], [#873], [#875], [#877]) diff --git a/k256/CHANGELOG.md b/k256/CHANGELOG.md index eb2b07bfa..c3eebb505 100644 --- a/k256/CHANGELOG.md +++ b/k256/CHANGELOG.md @@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added +- Support for non-32-byte BIP340 signatures ([#1041]) + +### Fixed +- Batch Normalization `normalizes_to_zero()` bug fix ([#1029]) +- Prevent panic when creating a Schnorr from slice ([#1056]) + +## Changed +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1029]: https://github.com/RustCrypto/elliptic-curves/pull/1029 +[#1041]: https://github.com/RustCrypto/elliptic-curves/pull/1041 +[#1056]: https://github.com/RustCrypto/elliptic-curves/pull/1056 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + + ## 0.13.3 (2024-01-08) ### Added - More inlines for better efficiency ([#999]) diff --git a/p192/CHANGELOG.md b/p192/CHANGELOG.md index 46bc70fa0..85589d92b 100644 --- a/p192/CHANGELOG.md +++ b/p192/CHANGELOG.md @@ -4,5 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added +- `bits` feature ([#868]) +- `elliptic_curve::ops::Invert` implementation ([#971]) + +## Changed +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#868]: https://github.com/RustCrypto/elliptic-curves/pull/868 +[#971]: https://github.com/RustCrypto/elliptic-curves/pull/971 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.13.0 (2023-04-15) - Initial release diff --git a/p224/CHANGELOG.md b/p224/CHANGELOG.md index 403c282ac..926823f5c 100644 --- a/p224/CHANGELOG.md +++ b/p224/CHANGELOG.md @@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added +- `bits` feature ([#868]) +- `Scalar::sqrt` implementation ([#904]) +- `elliptic_curve::ops::Invert` implementation ([#971]) + +## Changed +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#868]: https://github.com/RustCrypto/elliptic-curves/pull/868 +[#904]: https://github.com/RustCrypto/elliptic-curves/pull/904 +[#971]: https://github.com/RustCrypto/elliptic-curves/pull/971 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.13.2 (2023-04-15) ### Changed - Enable `arithmetic` and `ecdsa` by default ([#833]) diff --git a/p256/CHANGELOG.md b/p256/CHANGELOG.md index a8f817282..cc888ceca 100644 --- a/p256/CHANGELOG.md +++ b/p256/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added +- hash2curve implementation ([#964]) +- `elliptic_curve::ops::Invert` implementation ([#971]) + +## Changed +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#964]: https://github.com/RustCrypto/elliptic-curves/pull/964 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.13.2 (2023-04-15) ### Changed - Enable `pem` feature by default ([#832]) diff --git a/p384/CHANGELOG.md b/p384/CHANGELOG.md index 451db2928..db52a3047 100644 --- a/p384/CHANGELOG.md +++ b/p384/CHANGELOG.md @@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added + +### Changed +- Better `Debug` for field elements ([#798]) +- Make `primeorder` dependency optional ([#799]) +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#798]: https://github.com/RustCrypto/elliptic-curves/pull/798 +[#799]: https://github.com/RustCrypto/elliptic-curves/pull/799 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.13.1 (2025-02-06) ### Fixed - Remove unused fiat-crypto variables ([#1035]) diff --git a/p521/CHANGELOG.md b/p521/CHANGELOG.md index a25dd4bf3..5000513ee 100644 --- a/p521/CHANGELOG.md +++ b/p521/CHANGELOG.md @@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +### Added +- `elliptic_curve::ops::Invert` implementation ([#971]) +- make `LooseFieldElement` pub ([#978]) + +### Changed +- merge `u576_to_le_bytes` into `FieldBytes::from_uint_unchecked` ([#969]) +- switch to upstream RFC6979-based ECDSA ([#1016]) +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `ecdsa` v0.17 ([#1011]) +- Update to `sec1` v0.8 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Update to `hybrid-array` v0.3 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#969]: https://github.com/RustCrypto/elliptic-curves/pull/969 +[#971]: https://github.com/RustCrypto/elliptic-curves/pull/971 +[#978]: https://github.com/RustCrypto/elliptic-curves/pull/978 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1016]: https://github.com/RustCrypto/elliptic-curves/pull/1016 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + ## 0.13.3 (2023-11-11) ### Added - Implement hash2curve ([#964]) diff --git a/primefield/CHANGELOG.md b/primefield/CHANGELOG.md index d6637e049..e00b8db76 100644 --- a/primefield/CHANGELOG.md +++ b/primefield/CHANGELOG.md @@ -3,3 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 0.14.0 (UNRELEASED) +- Initial release + diff --git a/primeorder/CHANGELOG.md b/primeorder/CHANGELOG.md index be0f9ca54..2c1d51e39 100644 --- a/primeorder/CHANGELOG.md +++ b/primeorder/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +## Changed +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 + ## 0.13.6 (2023-11-15) ### Removed - `Invert` bounds on `FieldElement` ([#985]) diff --git a/sm2/CHANGELOG.md b/sm2/CHANGELOG.md index 6714139a9..5a966055e 100644 --- a/sm2/CHANGELOG.md +++ b/sm2/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.14.0 (UNRELEASED) +## Changed +- Update to `elliptic-curve` v0.14 ([#1011]) +- Update to `secdect` v0.3 ([#1084]) +- Update to `rand_core` v0.9 ([#1125]) +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1125]) +- Relax MSRV policy and allow MSRV bumps in patch releases + +[#964]: https://github.com/RustCrypto/elliptic-curves/pull/964 +[#1011]: https://github.com/RustCrypto/elliptic-curves/pull/1011 +[#1084]: https://github.com/RustCrypto/elliptic-curves/pull/1084 +[#1125]: https://github.com/RustCrypto/elliptic-curves/pull/1125 + + ## 0.13.3 (2023-11-20) ### Added - Impl `Randomized*Signer` for `sm2::dsa::SigningKey` ([#993]) From b2c4a0aecb3e912094c72022b8af40ac05aecc71 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Thu, 6 Mar 2025 10:04:59 -0800 Subject: [PATCH 19/20] bump to hashes pre.5 releases --- Cargo.lock | 22 +++++++++++++--------- Cargo.toml | 5 ----- bign256/Cargo.toml | 2 +- bp256/Cargo.toml | 2 +- bp384/Cargo.toml | 2 +- k256/Cargo.toml | 4 ++-- p224/Cargo.toml | 2 +- p256/Cargo.toml | 2 +- p384/Cargo.toml | 2 +- p521/Cargo.toml | 2 +- sm2/Cargo.toml | 2 +- 11 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a4c09041..cac766a05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -49,8 +49,9 @@ checksum = "d9aa1eef3994e2ccd304a78fe3fea4a73e5792007f85f09b79bb82143ca5f82b" [[package]] name = "belt-hash" -version = "0.2.0-pre.4" -source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" +version = "0.2.0-pre.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92eecb3b8b1afdc0ea8eaa6f947ef9ebb0effdee09ea0a1b254d05d082bcb2a3" dependencies = [ "belt-block", "digest", @@ -510,7 +511,7 @@ dependencies = [ [[package]] name = "hmac" version = "0.13.0-pre.4" -source = "git+https://github.com/RustCrypto/MACs.git#c7cbed0bd3f7026cc01251cd4602d0db4d0495b9" +source = "git+https://github.com/RustCrypto/MACs.git#48d909bc7c028df8ccbc4bd746e9315d2cb8757a" dependencies = [ "digest", ] @@ -1079,8 +1080,9 @@ dependencies = [ [[package]] name = "sha2" -version = "0.11.0-pre.4" -source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" +version = "0.11.0-pre.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b4241d1a56954dce82cecda5c8e9c794eef6f53abe5e5216bac0a0ea71ffa7" dependencies = [ "cfg-if", "cpufeatures", @@ -1089,8 +1091,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.11.0-pre.4" -source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" +version = "0.11.0-pre.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bc997d7a5fa67cc1e352b2001124d28edb948b4e7a16567f9b3c1e51952524" dependencies = [ "digest", "keccak", @@ -1122,8 +1125,9 @@ dependencies = [ [[package]] name = "sm3" -version = "0.5.0-pre.4" -source = "git+https://github.com/RustCrypto/hashes.git#0d0369ff7dab69e98acfb8a08f4724dbda285e04" +version = "0.5.0-pre.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd69c486f3459d1b1595bd1391c6d8094084946971c18681465e43efa2bcb" dependencies = [ "digest", ] diff --git a/Cargo.toml b/Cargo.toml index 9827d48cd..f2c044855 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,11 +31,6 @@ ecdsa = { git = "https://github.com/RustCrypto/signatures.git" } elliptic-curve = { git = "https://github.com/RustCrypto/traits.git" } signature = { git = "https://github.com/RustCrypto/traits.git" } -belt-hash = { git = "https://github.com/RustCrypto/hashes.git" } -sha2 = { git = "https://github.com/RustCrypto/hashes.git" } -sha3 = { git = "https://github.com/RustCrypto/hashes.git" } -sm3 = { git = "https://github.com/RustCrypto/hashes.git" } - hmac = { git = "https://github.com/RustCrypto/MACs.git" } crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint.git" } diff --git a/bign256/Cargo.toml b/bign256/Cargo.toml index edb9cf795..c763adf07 100644 --- a/bign256/Cargo.toml +++ b/bign256/Cargo.toml @@ -21,7 +21,7 @@ rust-version = "1.85" elliptic-curve = { version = "0.14.0-rc.0", features = ["sec1"] } # optional dependencies -belt-hash = { version = "=0.2.0-pre.4", optional = true, default-features = false } +belt-hash = { version = "=0.2.0-pre.5", optional = true, default-features = false } der = { version = "0.8.0-rc.0" } digest = { version = "=0.11.0-pre.10", optional = true } hex-literal = { version = "1", optional = true } diff --git a/bp256/Cargo.toml b/bp256/Cargo.toml index ed110b020..842601dab 100644 --- a/bp256/Cargo.toml +++ b/bp256/Cargo.toml @@ -19,7 +19,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies ecdsa = { version = "=0.17.0-pre.9", optional = true, default-features = false, features = ["der"] } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } [features] default = ["pkcs8", "std"] diff --git a/bp384/Cargo.toml b/bp384/Cargo.toml index cf1316127..7a99e6255 100644 --- a/bp384/Cargo.toml +++ b/bp384/Cargo.toml @@ -19,7 +19,7 @@ elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = # optional dependencies ecdsa = { version = "=0.17.0-pre.9", optional = true, default-features = false, features = ["der"] } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } [features] default = ["pkcs8", "std"] diff --git a/k256/Cargo.toml b/k256/Cargo.toml index b6993e5e7..f5e6776f0 100644 --- a/k256/Cargo.toml +++ b/k256/Cargo.toml @@ -27,7 +27,7 @@ once_cell = { version = "1.20", optional = true, default-features = false } ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, default-features = false, features = ["der"] } hex-literal = { version = "1", optional = true } serdect = { version = "0.3", optional = true, default-features = false } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } signature = { version = "=2.3.0-pre.6", optional = true } [dev-dependencies] @@ -40,7 +40,7 @@ num-bigint = "0.4" num-traits = "0.2" proptest = "1.5" rand_core = { version = "0.9", features = ["os_rng"] } -sha3 = { version = "=0.11.0-pre.4", default-features = false } +sha3 = { version = "=0.11.0-pre.5", default-features = false } [features] default = ["arithmetic", "ecdsa", "pkcs8", "precomputed-tables", "schnorr", "std"] diff --git a/p224/Cargo.toml b/p224/Cargo.toml index 59ca15791..940fec70a 100644 --- a/p224/Cargo.toml +++ b/p224/Cargo.toml @@ -24,7 +24,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, de hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3", optional = true, default-features = false } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } [dev-dependencies] blobby = "0.3" diff --git a/p256/Cargo.toml b/p256/Cargo.toml index 171366b5c..0f73ed43b 100644 --- a/p256/Cargo.toml +++ b/p256/Cargo.toml @@ -25,7 +25,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, de hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3", optional = true, default-features = false } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } [dev-dependencies] blobby = "0.3" diff --git a/p384/Cargo.toml b/p384/Cargo.toml index c5b9062df..691e23dd5 100644 --- a/p384/Cargo.toml +++ b/p384/Cargo.toml @@ -25,7 +25,7 @@ ecdsa-core = { version = "=0.17.0-pre.9", package = "ecdsa", optional = true, de hex-literal = { version = "1", optional = true } primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } serdect = { version = "0.3", optional = true, default-features = false } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } [dev-dependencies] blobby = "0.3" diff --git a/p521/Cargo.toml b/p521/Cargo.toml index 9fb1521e0..d5ef954cc 100644 --- a/p521/Cargo.toml +++ b/p521/Cargo.toml @@ -27,7 +27,7 @@ primefield = { version = "=0.14.0-pre.0", optional = true, path = "../primefield primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder" } rand_core = { version = "0.9", optional = true, default-features = false } serdect = { version = "0.3", optional = true, default-features = false } -sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false } +sha2 = { version = "=0.11.0-pre.5", optional = true, default-features = false } [dev-dependencies] blobby = "0.3" diff --git a/sm2/Cargo.toml b/sm2/Cargo.toml index 88c50349d..53f1e78ab 100644 --- a/sm2/Cargo.toml +++ b/sm2/Cargo.toml @@ -26,7 +26,7 @@ primeorder = { version = "=0.14.0-pre.2", optional = true, path = "../primeorder rfc6979 = { version = "=0.5.0-pre.4", optional = true } serdect = { version = "0.3", optional = true, default-features = false } signature = { version = "=2.3.0-pre.6", optional = true, features = ["rand_core"] } -sm3 = { version = "=0.5.0-pre.4", optional = true, default-features = false } +sm3 = { version = "=0.5.0-pre.5", optional = true, default-features = false } [dev-dependencies] hex-literal = "1" From 6a9ac0e666ece7ec3f930655f9a6c57d27a1a671 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Thu, 6 Mar 2025 13:35:51 -0800 Subject: [PATCH 20/20] sm2: provide an external rng for encryption --- sm2/src/pke.rs | 4 ++-- sm2/src/pke/encrypting.rs | 41 ++++++++++++++++++++++++++------------- sm2/tests/sm2pke.rs | 7 ++++--- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/sm2/src/pke.rs b/sm2/src/pke.rs index 58b226df0..309de3bd1 100644 --- a/sm2/src/pke.rs +++ b/sm2/src/pke.rs @@ -21,7 +21,7 @@ //! let public_key = secret_key.public_key(); //! let encrypting_key = EncryptingKey::new_with_mode(public_key, Mode::C1C2C3); //! let plaintext = b"plaintext"; -//! let ciphertext = encrypting_key.encrypt(plaintext)?; +//! let ciphertext = encrypting_key.encrypt(&mut OsRng, plaintext)?; //! //! use sm2::pke::DecryptingKey; //! // Decrypting @@ -29,7 +29,7 @@ //! assert_eq!(decrypting_key.decrypt(&ciphertext)?, plaintext); //! //! // Encrypting ASN.1 DER -//! let ciphertext = encrypting_key.encrypt_der(plaintext)?; +//! let ciphertext = encrypting_key.encrypt_der(&mut OsRng, plaintext)?; //! //! // Decrypting ASN.1 DER //! assert_eq!(decrypting_key.decrypt_der(&ciphertext)?, plaintext); diff --git a/sm2/src/pke/encrypting.rs b/sm2/src/pke/encrypting.rs index e1aa64053..3924efa24 100644 --- a/sm2/src/pke/encrypting.rs +++ b/sm2/src/pke/encrypting.rs @@ -13,7 +13,7 @@ use elliptic_curve::{ bigint::{RandomBits, U256, Uint, Zero}, ops::{MulByGenerator, Reduce}, pkcs8::der::Encode, - rand_core, + rand_core::TryCryptoRng, sec1::ToEncodedPoint, }; @@ -76,34 +76,46 @@ impl EncryptingKey { /// Encrypts a message using the encryption key. /// /// This method calculates the digest using the `Sm3` hash function and then performs encryption. - pub fn encrypt(&self, msg: &[u8]) -> Result> { - self.encrypt_digest::(msg) + pub fn encrypt(&self, rng: &mut R, msg: &[u8]) -> Result> { + self.encrypt_digest::(rng, msg) } /// Encrypts a message and returns the result in ASN.1 format. /// /// This method calculates the digest using the `Sm3` hash function and performs encryption, /// then encodes the result in ASN.1 format. - pub fn encrypt_der(&self, msg: &[u8]) -> Result> { - self.encrypt_der_digest::(msg) + pub fn encrypt_der( + &self, + rng: &mut R, + msg: &[u8], + ) -> Result> { + self.encrypt_der_digest::(rng, msg) } /// Encrypts a message using a specified digest algorithm. - pub fn encrypt_digest(&self, msg: &[u8]) -> Result> + pub fn encrypt_digest( + &self, + rng: &mut R, + msg: &[u8], + ) -> Result> where D: 'static + Digest + DynDigest + Send + Sync, { let mut digest = D::new(); - encrypt(&self.public_key, self.mode, &mut digest, msg) + encrypt(rng, &self.public_key, self.mode, &mut digest, msg) } /// Encrypts a message using a specified digest algorithm and returns the result in ASN.1 format. - pub fn encrypt_der_digest(&self, msg: &[u8]) -> Result> + pub fn encrypt_der_digest( + &self, + rng: &mut R, + msg: &[u8], + ) -> Result> where D: 'static + Digest + DynDigest + Send + Sync, { let mut digest = D::new(); - let cipher = encrypt(&self.public_key, self.mode, &mut digest, msg)?; + let cipher = encrypt(rng, &self.public_key, self.mode, &mut digest, msg)?; let digest_size = digest.output_size(); let (_, cipher) = cipher.split_at(1); let (x, cipher) = cipher.split_at(32); @@ -133,7 +145,8 @@ impl From for EncryptingKey { } /// Encrypts a message using the specified public key, mode, and digest algorithm. -fn encrypt( +fn encrypt( + rng: &mut R, public_key: &PublicKey, mode: Mode, digest: &mut dyn DynDigest, @@ -145,7 +158,7 @@ fn encrypt( let mut hpb: AffinePoint; loop { // A1: generate a random number 𝑘 ∈ [1, 𝑛 − 1] with the random number generator - let k = Scalar::from_uint(next_k(N_BYTES)).unwrap(); + let k = Scalar::from_uint(next_k(rng, N_BYTES)?).unwrap(); // A2: compute point 𝐶1 = [𝑘]𝐺 = (𝑥1, 𝑦1) let kg = ProjectivePoint::mul_by_generator(&k).to_affine(); @@ -188,11 +201,11 @@ fn encrypt( }) } -fn next_k(bit_length: u32) -> U256 { +fn next_k(rng: &mut R, bit_length: u32) -> Result { loop { - let k = U256::random_bits(&mut rand_core::OsRng, bit_length); + let k = U256::try_random_bits(rng, bit_length).map_err(|_| Error)?; if !bool::from(k.is_zero()) && k < Sm2::ORDER { - return k; + return Ok(k); } } } diff --git a/sm2/tests/sm2pke.rs b/sm2/tests/sm2pke.rs index a16fad956..8256555d3 100644 --- a/sm2/tests/sm2pke.rs +++ b/sm2/tests/sm2pke.rs @@ -3,6 +3,7 @@ use elliptic_curve::{NonZeroScalar, ops::Reduce}; use hex_literal::hex; use proptest::prelude::*; +use rand_core::OsRng; use sm2::{Scalar, Sm2, U256, pke::DecryptingKey}; @@ -69,21 +70,21 @@ proptest! { #[test] fn encrypt_and_decrpyt_der(dk in decrypting_key()) { let ek = dk.encrypting_key(); - let cipher_bytes = ek.encrypt_der(MSG).unwrap(); + let cipher_bytes = ek.encrypt_der(&mut OsRng, MSG).unwrap(); prop_assert!(dk.decrypt_der(&cipher_bytes).is_ok()); } #[test] fn encrypt_and_decrpyt(dk in decrypting_key()) { let ek = dk.encrypting_key(); - let cipher_bytes = ek.encrypt(MSG).unwrap(); + let cipher_bytes = ek.encrypt(&mut OsRng, MSG).unwrap(); assert_eq!(dk.decrypt(&cipher_bytes).unwrap(), MSG); } #[test] fn encrypt_and_decrpyt_mode(dk in decrypting_key_c1c2c3()) { let ek = dk.encrypting_key(); - let cipher_bytes = ek.encrypt(MSG).unwrap(); + let cipher_bytes = ek.encrypt(&mut OsRng, MSG).unwrap(); assert_eq!( dk.decrypt(&cipher_bytes) .unwrap(),