Skip to content

Commit 0b8206c

Browse files
authored
integrate secp256k1 decompress precompiles (#1156)
Related to #1141 respective commit in `ceno-patch` scroll-tech/ceno-patch@9a85bc9 ### benchmarks - decompress step cycles consumption reduce from 257273 -> 1942, reduce **99.24%** - overall cycles proving block `23817600` reduce from 452M to 401M **11.44%** reduction
1 parent c2b73d6 commit 0b8206c

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

.github/workflows/integration.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ jobs:
141141
RUSTFLAGS: "-C opt-level=3"
142142
run: cargo run --release --package ceno_zkvm --bin e2e -- --platform=ceno examples/target/riscv32im-ceno-zkvm-elf/release/examples/bn254_curve_syscalls
143143

144+
- name: Run k256 ecrecover (release)
145+
env:
146+
RUSTFLAGS: "-C opt-level=3"
147+
run: cargo run --release --package ceno_zkvm --bin e2e -- --platform=ceno examples/target/riscv32im-ceno-zkvm-elf/release/examples/secp256k1_ecrecover
148+
144149
- name: Run uint256_mul_syscall (release)
145150
env:
146151
RUSTFLAGS: "-C opt-level=3"

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ opt-level = 3
100100
[profile.release]
101101
lto = "thin"
102102

103+
#[patch."https://github.com/scroll-tech/elliptic-curves"]
104+
#k256 = { path = "../elliptic-curves/k256", default-features = false, features = ["std", "ecdsa"] }
105+
#
106+
#[patch."https://github.com/scroll-tech/ceno-patch.git"]
107+
#ceno_crypto_primitives = { path = "../ceno-patch/crypto-primitives", package = "ceno_crypto_primitives" }
108+
#ceno_syscall = { path = "../ceno-patch/syscall", package = "ceno_syscall" }
109+
103110
# [patch."https://github.com/scroll-tech/ceno-gpu-mock.git"]
104111
# ceno_gpu = { path = "../ceno-gpu/cuda_hal", package = "cuda_hal", default-features = false, features=["bb31"] }
105112

examples/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ rkyv = { version = "0.8", default-features = false, features = [
3030
"bytecheck",
3131
] }
3232
substrate-bn.workspace = true
33+
34+
[features]
35+
profiling = ["k256/std", "k256/ecdsa", "k256/profiling"]

guest_libs/crypto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ alloy-primitives = "1.4"
2323
revm-precompile = "27"
2424

2525
[features]
26-
profiling = []
26+
profiling = ["k256/profiling"]

guest_libs/crypto/src/secp256k1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ pub fn secp256k1_ecrecover(
2424
}
2525
let recid = RecoveryId::from_byte(recid).expect("recovery ID is valid");
2626

27+
#[cfg(feature = "profiling")]
28+
syscall_phantom_log_pc_cycle("recover_from_prehash start");
2729
// recover key
2830
let recovered_key = VerifyingKey::recover_from_prehash(&msg[..], &sig, recid)?;
31+
#[cfg(feature = "profiling")]
32+
syscall_phantom_log_pc_cycle("recover_from_prehash end");
2933
// hash it
3034
let mut hasher = Keccak::v256();
3135
let mut hash = [0u8; 32];

0 commit comments

Comments
 (0)