Update to {k, p}256 0.12

This commit is contained in:
Luke Parker 2023-03-06 08:22:04 -05:00
parent c37cc0b4e2
commit 2729882d65
No known key found for this signature in database
8 changed files with 84 additions and 33 deletions
Cargo.lock
coins/ethereum
crypto
ciphersuite
dleq
ff-group-tests
multiexp

75
Cargo.lock generated
View file

@ -915,7 +915,7 @@ dependencies = [
"flexible-transcript",
"group",
"hex",
"k256",
"k256 0.12.0",
"minimal-ed448",
"p256",
"rand_core 0.6.4",
@ -1034,7 +1034,7 @@ dependencies = [
"digest 0.10.6",
"getrandom 0.2.8",
"hmac 0.12.1",
"k256",
"k256 0.11.6",
"lazy_static",
"serde",
"sha2 0.10.6",
@ -1716,7 +1716,7 @@ dependencies = [
"flexible-transcript",
"group",
"hex-literal",
"k256",
"k256 0.12.0",
"multiexp",
"rand_core 0.6.4",
"thiserror",
@ -1793,7 +1793,19 @@ dependencies = [
"der",
"elliptic-curve",
"rfc6979",
"signature",
"signature 1.6.4",
]
[[package]]
name = "ecdsa"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12844141594ad74185a926d030f3b605f6a903b4e3fec351f3ea338ac5b7637e"
dependencies = [
"der",
"elliptic-curve",
"rfc6979",
"signature 2.0.0",
]
[[package]]
@ -1802,7 +1814,7 @@ version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369"
dependencies = [
"signature",
"signature 1.6.4",
]
[[package]]
@ -1998,11 +2010,12 @@ dependencies = [
"eyre",
"group",
"hex-literal",
"k256",
"k256 0.12.0",
"modular-frost",
"rand_core 0.6.4",
"serde",
"serde_json",
"sha2 0.10.6",
"sha3",
"thiserror",
"tokio",
@ -2126,7 +2139,7 @@ dependencies = [
"ethabi",
"generic-array 0.14.6",
"hex",
"k256",
"k256 0.11.6",
"once_cell",
"open-fastrlp",
"proc-macro2",
@ -2341,7 +2354,7 @@ name = "ff-group-tests"
version = "0.12.0"
dependencies = [
"group",
"k256",
"k256 0.12.0",
"p256",
"rand_core 0.6.4",
]
@ -2593,7 +2606,7 @@ dependencies = [
"frame-metadata",
"frame-support-procedural",
"impl-trait-for-tuples",
"k256",
"k256 0.11.6",
"log",
"once_cell",
"parity-scale-codec",
@ -3785,12 +3798,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b"
dependencies = [
"cfg-if",
"ecdsa",
"ecdsa 0.14.8",
"elliptic-curve",
"sha2 0.10.6",
"sha3",
]
[[package]]
name = "k256"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92a55e0ff3b72c262bcf041d9e97f1b84492b68f1c1a384de2323d3dc9403397"
dependencies = [
"cfg-if",
"ecdsa 0.15.1",
"elliptic-curve",
"once_cell",
"sha2 0.10.6",
"signature 2.0.0",
]
[[package]]
name = "keccak"
version = "0.1.3"
@ -4765,7 +4792,7 @@ dependencies = [
"dalek-ff-group",
"ff",
"group",
"k256",
"k256 0.12.0",
"rand_core 0.6.4",
"zeroize",
]
@ -5177,12 +5204,13 @@ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
[[package]]
name = "p256"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594"
checksum = "49c124b3cbce43bcbac68c58ec181d98ed6cc7e6d0aa7c3ba97b2563410b0e55"
dependencies = [
"ecdsa",
"ecdsa 0.15.1",
"elliptic-curve",
"primeorder",
"sha2 0.10.6",
]
@ -5844,6 +5872,15 @@ dependencies = [
"syn",
]
[[package]]
name = "primeorder"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b54f7131b3dba65a2f414cf5bd25b66d4682e4608610668eae785750ba4c5b2"
dependencies = [
"elliptic-curve",
]
[[package]]
name = "primitive-types"
version = "0.12.1"
@ -7963,6 +8000,16 @@ dependencies = [
"rand_core 0.6.4",
]
[[package]]
name = "signature"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fe458c98333f9c8152221191a77e2a44e8325d0193484af2e9421a53019e57d"
dependencies = [
"digest 0.10.6",
"rand_core 0.6.4",
]
[[package]]
name = "simba"
version = "0.5.1"

View file

@ -20,10 +20,11 @@ rand_core = "0.6"
serde_json = "1.0"
serde = "1.0"
sha2 = "0.10"
sha3 = "0.10"
group = "0.12"
k256 = { version = "0.11", features = ["arithmetic", "keccak256", "ecdsa"] }
k256 = { version = "0.12", features = ["arithmetic", "ecdsa"] }
frost = { package = "modular-frost", path = "../../crypto/frost", features = ["secp256k1", "tests"] }
eyre = "0.6"

View file

@ -2,7 +2,7 @@ use std::{convert::TryFrom, sync::Arc, time::Duration};
use rand_core::OsRng;
use k256::{elliptic_curve::bigint::ArrayEncoding, U256};
use ::k256::{elliptic_curve::bigint::ArrayEncoding, U256};
use ethers::{
prelude::*,

View file

@ -1,29 +1,32 @@
use ethereum_serai::crypto::*;
use frost::curve::Secp256k1;
use k256::{
elliptic_curve::{bigint::ArrayEncoding, ops::Reduce, sec1::ToEncodedPoint},
ProjectivePoint, Scalar, U256,
};
use frost::curve::Secp256k1;
use ethereum_serai::crypto::*;
#[test]
fn test_ecrecover() {
use k256::ecdsa::{
recoverable::Signature,
signature::{Signer, Verifier},
SigningKey, VerifyingKey,
};
use rand_core::OsRng;
use sha2::Sha256;
use sha3::{Digest, Keccak256};
use k256::ecdsa::{hazmat::SignPrimitive, signature::DigestVerifier, SigningKey, VerifyingKey};
let private = SigningKey::random(&mut OsRng);
let public = VerifyingKey::from(&private);
const MESSAGE: &[u8] = b"Hello, World!";
let sig: Signature = private.sign(MESSAGE);
public.verify(MESSAGE, &sig).unwrap();
let (sig, recovery_id) = private
.as_nonzero_scalar()
.try_sign_prehashed_rfc6979::<Sha256>(Keccak256::digest(MESSAGE), b"")
.unwrap();
assert_eq!(public.verify_digest(Keccak256::new_with_prefix(MESSAGE), &sig).unwrap(), ());
assert_eq!(
ecrecover(hash_to_scalar(MESSAGE), sig.as_ref()[64], *sig.r(), *sig.s()).unwrap(),
address(&ProjectivePoint::from(public))
ecrecover(hash_to_scalar(MESSAGE), recovery_id.unwrap().is_y_odd().into(), *sig.r(), *sig.s())
.unwrap(),
address(&ProjectivePoint::from(public.as_affine()))
);
}

View file

@ -29,8 +29,8 @@ group = "0.12"
dalek-ff-group = { path = "../dalek-ff-group", version = "^0.1.2", optional = true }
elliptic-curve = { version = "0.12", features = ["hash2curve"], optional = true }
p256 = { version = "0.11", features = ["arithmetic", "bits", "hash2curve"], optional = true }
k256 = { version = "0.11", features = ["arithmetic", "bits", "hash2curve"], optional = true }
p256 = { version = "0.12", features = ["arithmetic", "bits", "hash2curve"], optional = true }
k256 = { version = "0.12", features = ["arithmetic", "bits", "hash2curve"], optional = true }
minimal-ed448 = { path = "../ed448", version = "^0.1.2", optional = true }

View file

@ -31,7 +31,7 @@ hex-literal = "0.3"
blake2 = "0.10"
k256 = { version = "0.11", features = ["arithmetic", "bits"] }
k256 = { version = "0.12", features = ["arithmetic", "bits"] }
dalek-ff-group = { path = "../dalek-ff-group" }
transcript = { package = "flexible-transcript", path = "../transcript", features = ["recommended"] }

View file

@ -17,5 +17,5 @@ rand_core = "0.6"
group = "0.12"
[dev-dependencies]
k256 = { version = "0.11", features = ["bits"] }
p256 = { version = "0.11", features = ["bits"] }
k256 = { version = "0.12", features = ["bits"] }
p256 = { version = "0.12", features = ["bits"] }

View file

@ -23,7 +23,7 @@ rand_core = { version = "0.6", optional = true }
[dev-dependencies]
rand_core = "0.6"
k256 = { version = "0.11", features = ["bits"] }
k256 = { version = "0.12", features = ["bits"] }
dalek-ff-group = { path = "../dalek-ff-group" }
[features]