Skip to content

Commit

Permalink
passes
Browse files Browse the repository at this point in the history
  • Loading branch information
umadayal committed Dec 5, 2024
1 parent e48676d commit b4a2e86
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified examples/elf/riscv32im-succinct-zkvm-elf
Binary file not shown.
1 change: 1 addition & 0 deletions examples/patch-testing/program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }

Expand Down
19 changes: 15 additions & 4 deletions examples/patch-testing/program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ 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,
};
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,
};

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}

0 comments on commit b4a2e86

Please sign in to comment.