diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 2359997c1..2e6f8c526 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -3824,6 +3824,7 @@ dependencies = [ "alloy-primitives 0.8.14", "curve25519-dalek", "curve25519-dalek-ng 4.1.1 (git+https://github.com/sp1-patches/curve25519-dalek-ng?tag=curve25519_dalek_ng-v4.1.1-patch-v1)", + "ecdsa 0.16.9 (git+https://github.com/sp1-patches/signatures?branch=ecdsa-v0.16.9-patch-v4.0.0-rc.2)", "ed25519-consensus", "ed25519-dalek", "k256", @@ -5901,7 +5902,7 @@ dependencies = [ [[package]] name = "sp1-lib" version = "4.0.0-rc.1" -source = "git+https://github.com/succinctlabs/sp1.git?branch=v4.0.0-rc.2#9bb49f4c6a5757c597e5b13a3e9e8a2b6e18cd41" +source = "git+https://github.com/succinctlabs/sp1.git?branch=v4.0.0-rc.2#e48676d15b83c9349439e61ad6e2803f270c85e7" dependencies = [ "bincode", "serde", diff --git a/examples/elf/riscv32im-succinct-zkvm-elf b/examples/elf/riscv32im-succinct-zkvm-elf index a3e78afb2..d16b4f194 100755 Binary files a/examples/elf/riscv32im-succinct-zkvm-elf and b/examples/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/patch-testing/program/Cargo.toml b/examples/patch-testing/program/Cargo.toml index a9d4feff9..f8b299e17 100644 --- a/examples/patch-testing/program/Cargo.toml +++ b/examples/patch-testing/program/Cargo.toml @@ -19,6 +19,7 @@ curve25519-dalek = { version = "4.1.3", default-features = false, features = ["a curve25519-dalek-ng = { version = "4.1", default-features = false, features = ["u32_backend", "alloc"] } k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] } p256 = { version = "0.13.2", default-features = false, features = ["ecdsa"] } +ecdsa-core = { version = "0.16.9", package = "ecdsa" } alloy-primitives = { version = "0.8", features = ["k256"] } secp256k1 = { version = "0.29", features = ["recovery", "global-context"] } diff --git a/examples/patch-testing/program/src/main.rs b/examples/patch-testing/program/src/main.rs index 26e231c4d..17254f30b 100644 --- a/examples/patch-testing/program/src/main.rs +++ b/examples/patch-testing/program/src/main.rs @@ -6,6 +6,7 @@ use alloy_primitives::{address, bytes, hex}; use alloy_primitives::{B256, B512}; use curve25519_dalek::edwards::CompressedEdwardsY as CompressedEdwardsY_dalek; use curve25519_dalek_ng::edwards::CompressedEdwardsY as CompressedEdwardsY_dalek_ng; +use ecdsa_core::RecoveryId as ecdsaRecoveryId; use ed25519_consensus::{ Signature as Ed25519ConsensusSignature, VerificationKey as Ed25519ConsensusVerificationKey, }; @@ -13,7 +14,7 @@ use ed25519_dalek::{ Signature as Ed25519DalekSignature, Verifier, VerifyingKey as Ed25519DalekVerifyingKey, }; use p256::{ - ecdsa::{Signature, SigningKey, VerifyingKey}, + ecdsa::{Signature as P256Signature, SigningKey, VerifyingKey as P256VerifyingKey}, elliptic_curve::rand_core::OsRng, }; @@ -150,13 +151,22 @@ fn test_p256_patch() { println!("message_prehash: {:?}", message_prehash); let signing_key = SigningKey::random(&mut OsRng); - let (signature, recid) = signing_key.sign_prehash_recoverable(&message_prehash).unwrap(); + let (mut signature, recid) = signing_key.sign_prehash_recoverable(&message_prehash).unwrap(); println!("signature: {:?}", signature); println!("recid: {:?}", recid); + let mut recid_byte = recid.to_byte(); + + if let Some(sig_normalized) = signature.normalize_s() { + signature = sig_normalized; + recid_byte ^= 1; + } + + let recid = ecdsaRecoveryId::from_byte(recid_byte).unwrap(); + println!("cycle-tracker-start: p256 recovery"); let recovered_key = - VerifyingKey::recover_from_prehash(&message_prehash, &signature, recid).unwrap(); + P256VerifyingKey::recover_from_prehash(&message_prehash, &signature, recid).unwrap(); println!("cycle-tracker-end: p256 recovery"); println!("recovered_key: {:?}", recovered_key); } @@ -245,7 +255,8 @@ pub fn main() { test_ed25519_dalek(); test_ed25519_consensus(); - test_p256_patch(); test_k256_patch(); + test_p256_patch(); + test_secp256k1_patch(); }