Skip to content

Commit 2e13a05

Browse files
Add ecdsa module to openvm_p256
1 parent f99b6f4 commit 2e13a05

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

guest-libs/p256/guest/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ ecdsa = { workspace = true }
2121
serde = { workspace = true }
2222
hex-literal = { workspace = true }
2323
ff = { workspace = true }
24+
p256 = { workspace = true }
25+
26+
[features]
27+
default = ["ecdsa"]
28+
ecdsa = ["p256/ecdsa", "ecdsa-core"]
29+
ecdsa-core = ["p256/ecdsa-core"]
2430

2531
[target.'cfg(not(target_os = "zkvm"))'.dependencies]
2632
num-bigint = { workspace = true }

guest-libs/p256/guest/src/ecdsa.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// re-export types that are visible in the p256 crate for API compatibility
2+
3+
pub use p256::ecdsa::Error;
4+
5+
/// ECDSA/secp256k1 signature (fixed-size)
6+
pub type Signature = ecdsa::Signature<crate::P256>;
7+
8+
/// ECDSA/secp256k1 signing key
9+
#[cfg(feature = "ecdsa")]
10+
pub type SigningKey = ecdsa::SigningKey<crate::P256>;
11+
12+
/// ECDSA/secp256k1 verification key (i.e. public key)
13+
#[cfg(feature = "ecdsa")]
14+
pub type VerifyingKey = ecdsa::VerifyingKey<crate::P256>;

guest-libs/p256/guest/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ mod internal;
1313
mod point;
1414
mod scalar;
1515

16+
#[cfg(feature = "ecdsa-core")]
17+
pub mod ecdsa;
18+
1619
// Needs to be public so that the `sw_init` macro can access it
1720
pub use internal::{
1821
P256Point, P256Point as AffinePoint, P256Point as ProjectivePoint, P256Scalar as Scalar,
@@ -34,8 +37,7 @@ impl Curve for P256 {
3437
/// 32-byte serialized field elements.
3538
type FieldBytesSize = U32;
3639

37-
// I don't think any arithmetic is done on Curve::Uint, so it's fine to use the U256 type
38-
// instead of the OpenVM ruint impl
40+
// Perf: Use the U256 type from openvm_ruint here
3941
type Uint = U256;
4042

4143
/// Curve order.

0 commit comments

Comments
 (0)