Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ contracts/c/build/*
build/*
!.gitkeep
.tmp/
.cursor
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = ["contracts/p256-test", "contracts/k256-test", "contracts/k256-recovery-test", "contracts/rsa-test", "contracts/ed25519-test", "contracts/schnorr-test", "contracts/sp1-test"]
# ml-dsa has conflict dependencies with others(e.g. k256)
exclude = ["tests", "contracts/ml-dsa-test", "tools/ml-dsa-signing-tool"]
exclude = ["tests", "contracts/ml-dsa-test", "tools/ml-dsa-signing-tool", "tools/update-report"]
resolver = "2"

[profile.release]
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ ci: build
ckb-debugger --bin build/release/sp1-test
# The ml-dsa contract depends on the latest version of the `signature` crate, which conflicts with the versions used in other parts of this project.
make ml-dsa

make sp1-test

sp1-test:
# Update the clang version to match your environment. The ckb-alt-bn128 in test-sp1 requires clang-19+.
CLANG=clang-19 make build CONTRACT=sp1-test
Expand All @@ -153,9 +154,13 @@ ml-dsa:
args=$$(cd tools/ml-dsa-signing-tool && cargo run -- MlDsa87 2>/dev/null); \
ckb-debugger --bin build/release/ml-dsa-test -- $$args

update-report:
cargo build --manifest-path tools/update-report/Cargo.toml --release
make ci 2>&1 | tools/update-report/target/release/update-report

# Generate checksum info for reproducible build
CHECKSUM_FILE := build/checksums-$(MODE).txt
checksum: build
shasum -a 256 build/$(MODE)/* > $(CHECKSUM_FILE)

.PHONY: build test check clippy fmt cargo clean prepare checksum ml-dsa sp1-test
.PHONY: build test check clippy fmt cargo clean prepare checksum ml-dsa sp1-test update-report
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ make ci
## Benchmark Matrix
Test with [ckb-debugger 1.1.0](https://github.com/nervosnetwork/ckb-standalone-debugger)

| Curve | Cycles | Binary Size | Additional Information |
| Algorithm | Cycles | Binary Size | Additional Information |
|-------------|----------|----------|-----------------------|
| p256 | 4.8M Cycles | 73K Bytes | N/A |
| k256 | 3.6M Cycles | 94K Bytes | No precomputed table |
| RSA-2048 | 5.7M Cycles | 135K Bytes | N/A |
| ed25519 | 2.0M Cycles | 63K Bytes | N/A |
| schnorr | 3.5M Cycles | 80K Bytes | N/A |
| k256 | 3.8M Cycles | 97K Bytes | Recovery |
| sp1 verifier| 63.2M Cycles | 246K Bytes | Plonk |
| ml-dsa-44 | 3.2M Cycles | 119K Bytes | N/A |
| ml-dsa-65 | 4.8M cycles | 119K Bytes | N/A |
| ml-dsa-87 | 7.5M Cycles | 119K Bytes | N/A |
| p256 | 6.4M Cycles | 95K Bytes | N/A |
| k256 | 3.8M Cycles | 116K Bytes | No precomputed table |
| RSA-2048 | 6.5M Cycles | 158K Bytes | N/A |
| ed25519 | 1.9M Cycles | 88K Bytes | N/A |
| schnorr | 3.7M Cycles | 102K Bytes | N/A |
| k256 | 4.0M Cycles | 118K Bytes | Recovery |
| sp1 verifier | 66.2M Cycles | 262K Bytes | Plonk |
| ml-dsa-44 | 3.3M Cycles | 137K Bytes | N/A |
| ml-dsa-65 | 5.0M Cycles | 137K Bytes | N/A |
| ml-dsa-87 | 7.6M Cycles | 137K Bytes | N/A |
4 changes: 2 additions & 2 deletions contracts/ed25519-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub fn main() -> Result<(), Error> {
);
let cycles = current_cycles() - start_cycles;
debug(format!(
"cost of ed25519 verifying cycles: {} K",
cycles / 1024
"cost of ed25519 verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions contracts/k256-recovery-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ pub fn main() -> Result<(), Error> {
let _recovered_key_bytes = recovered_key.to_sec1_bytes();
let cycles = current_cycles() - last;
debug(format!(
"cost of k256(recovery) verifying cycles: {} K",
cycles / 1024
"cost of k256(recovery) verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions contracts/k256-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ pub fn main() -> Result<(), Error> {
pk.verify(&msg_bytes, &signature).unwrap();
let cycles = current_cycles() - last;
debug(format!(
"cost of k256 verifying cycles: {} K",
cycles / 1024
"cost of k256 verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions contracts/ml-dsa-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ pub fn main() -> Result<(), Error> {

let cycles = current_cycles() - last;
debug(format!(
"cost of ml-dsa ({}) verifying cycles: {} K",
"cost of ml-dsa ({}) verifying cycles: {:.1} M",
core::str::from_utf8(type_bytes).unwrap_or("?"),
cycles / 1024
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions contracts/p256-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ pub fn main() -> Result<(), Error> {
pk.verify(&msg_bytes, &signature).unwrap();
let cycles = current_cycles() - last;
debug(format!(
"cost of p256 verifying cycles: {} K",
cycles / 1024
"cost of p256 verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions contracts/rsa-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ pub fn test_rsa_2048(msg: &[u8]) {
verifying_key.verify(msg, &signature).unwrap();
let cycles = current_cycles() - last;
debug(format!(
"cost of rsa-2048 verifying cycles: {} K",
cycles / 1024
"cost of rsa-2048 verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/schnorr-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ pub fn main() -> Result<(), Error> {
pk.verify(&msg_bytes, &signature).unwrap();
let cycles = current_cycles() - last;
debug(format!(
"cost of schnorr verifying cycles: {} K",
cycles / 1024
"cost of schnorr verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions contracts/sp1-test/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ pub fn main() -> Result<(), Error> {
let cycles = current_cycles() - last;

debug(format!(
"cost of sp1(zkVM) verifying cycles: {} K",
cycles / 1024
"cost of sp1(zkVM) verifying cycles: {:.1} M",
cycles as f64 / (1000.0 * 1000.0)
));

Ok(())
Expand Down
54 changes: 54 additions & 0 deletions tools/update-report/Cargo.lock

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

9 changes: 9 additions & 0 deletions tools/update-report/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[workspace]

[package]
name = "update-report"
version = "0.1.0"
edition = "2021"

[dependencies]
regex = "1"
Loading