Skip to content

Commit c3f8a52

Browse files
committed
chore: update
1 parent 76570fa commit c3f8a52

File tree

9 files changed

+127
-104
lines changed

9 files changed

+127
-104
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ overflow-checks = true
88
opt-level = 3
99
panic = 'abort'
1010
strip = true
11-
lto = true
11+
codegen-units = 1
1212

1313
[profile.dev]
1414
strip = true

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ generate:
121121

122122
prepare:
123123
rustup target add riscv64imac-unknown-none-elf
124-
cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger --tag v0.118.0
124+
wget 'https://github.com/nervosnetwork/ckb-standalone-debugger/releases/download/v0.200.2/ckb-debugger_v0.200.2_x86_64-unknown-linux-gnu.tar.gz'
125+
tar xzvf ckb-debugger_v0.200.2_x86_64-unknown-linux-gnu.tar.gz
126+
mv ckb-debugger ~/.cargo/bin
125127
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 && rm llvm.sh
126128

127129
ci: build

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ make ci
2222
```
2323

2424
## Benchmark Matrix
25-
Test with [ckb-debugger 0.118](https://github.com/nervosnetwork/ckb-standalone-debugger)
25+
Test with [ckb-debugger 0.200.2](https://github.com/nervosnetwork/ckb-standalone-debugger)
2626

2727
| Curve | Cycles | Binary Size | Additional Information |
2828
|----------|----------|----------|-----------------------|
29-
| p256 | 3.8M Cycles | 75K Bytes | N/A |
30-
| k256 | 3.7M Cycles | 107K Bytes | No precomputed table |
31-
| RSA-2048 | 5.4M Cycles | 113K Bytes | N/A |
32-
| ed25519 | 2.0M Cycles | 55K Bytes | N/A |
33-
| schnorr | 3.8M Cycles | 84K Bytes | N/A |
34-
| k256 | 7.8M Cycles | 122K Bytes | Recovery |
35-
36-
The k256 recovery can be boosted with this [PR](https://github.com/RustCrypto/signatures/pull/831).
29+
| p256 | 4.8M Cycles | 73K Bytes | N/A |
30+
| k256 | 3.6M Cycles | 94K Bytes | No precomputed table |
31+
| RSA-2048 | 5.7M Cycles | 135K Bytes | N/A |
32+
| ed25519 | 2.0M Cycles | 63K Bytes | N/A |
33+
| schnorr | 3.5M Cycles | 80K Bytes | N/A |
34+
| k256 | 3.8M Cycles | 97K Bytes | Recovery |

contracts/k256-recovery-test/src/entry.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use k256::ecdsa::{
1414
signature::{Signer, Verifier},
1515
RecoveryId, Signature, SigningKey, VerifyingKey,
1616
};
17+
use k256::sha2::{Digest, Sha256};
1718
// Import CKB syscalls and structures
1819
// https://docs.rs/ckb-std/
1920
use crate::error::Error;
@@ -36,7 +37,8 @@ fn gen() -> (Vec<u8>, Vec<u8>, Vec<u8>, u8) {
3637
let sk = SigningKey::from_slice(&SECRET_KEY).unwrap();
3738
let pk = sk.verifying_key();
3839
let msg_bytes = generate_msg();
39-
let (signature, rec_id) = sk.sign_recoverable(&msg_bytes).unwrap();
40+
41+
let (signature, rec_id) = sk.sign_prehash_recoverable(&msg_bytes).unwrap();
4042

4143
debug(format!("msg_bytes = {}", hex::encode(&msg_bytes)));
4244

@@ -63,7 +65,7 @@ fn gen() -> (Vec<u8>, Vec<u8>, Vec<u8>, u8) {
6365
hex::decode("68656c6c6f2c20776f726c640000000000000000000000000000000000000000").unwrap();
6466
let pub_bytes =
6567
hex::decode("030cec028ee08d09e02672a68310814354f9eabfff0de6dacc1cd3a774496076ae").unwrap();
66-
let sig_bytes = hex::decode("0370aa07db8be44caed0f4c77aa6a644fa97228feeb7082ae66f640fe0d7d728610c2a4e1655183d134e191c8a4a06d970bc7a94a25420f5026a0288ff47ad42").unwrap();
68+
let sig_bytes = hex::decode("bb54baa41daefb2b6931ddbbbb636054b9027e966a61c3bf5fb75e26b2f2a78f1c65827dba40d81242ae3362e3a936e18092f21d5be8a1ff1b7693cc85068d3a").unwrap();
6769
let rec_id = 1u8;
6870
(msg_bytes, pub_bytes, sig_bytes, rec_id)
6971
}
@@ -75,7 +77,8 @@ pub fn main() -> Result<(), Error> {
7577
let rec_id = RecoveryId::try_from(rec_id).unwrap();
7678

7779
let last = current_cycles();
78-
let recovered_key = VerifyingKey::recover_from_msg(&msg_bytes, &signature, rec_id).unwrap();
80+
let recovered_key =
81+
VerifyingKey::recover_from_prehash_noverify(&msg_bytes, &signature, rec_id).unwrap();
7982
assert_eq!(recovered_key, pk);
8083
let _recovered_key_bytes = recovered_key.to_sec1_bytes();
8184
let cycles = current_cycles() - last;

contracts/k256-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
ckb-std = { version = "0.18.0", default-features = false, features = ["allocator", "dummy-atomic"]}
10-
k256 = { version = "=0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "alloc"] }
10+
k256 = { version = "0.14.0-pre.11", default-features = false, features = ["arithmetic", "ecdsa", "alloc"] }
1111
hex = { version = "0.4", default-features = false, features = ["alloc"] }
1212

1313
[features]

contracts/rsa-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ edition = "2021"
77

88
[dependencies]
99
ckb-std = { version = "0.18.0", default-features = false, features = ["allocator", "dummy-atomic"]}
10-
rsa = { version = "0.9.2", default-features = false, features = ["u64_digit", "sha2"]}
10+
rsa = { version = "0.9.8", default-features = false, features = ["u64_digit", "sha2"]}
1111
num-traits = { version= "0.2.9", default-features = false, features = ["libm"] }
1212
signature = { version = "2.0.0", default-features = false , features = ["alloc", "digest", "rand_core"] }

contracts/schnorr-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
ckb-std = { version = "0.18.0", default-features = false, features = ["allocator", "dummy-atomic"]}
10-
k256 = { version = "=0.13.1", default-features = false, features = ["arithmetic", "schnorr", "alloc"] }
10+
k256 = { version = "0.14.0-pre.11", default-features = false, features = ["arithmetic", "ecdsa", "alloc", "schnorr"] }
1111
hex = { version = "0.4", default-features = false, features = ["alloc"] }
1212

1313
[features]

contracts/schnorr-test/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn gen() -> (Vec<u8>, Vec<u8>, Vec<u8>) {
5656
pub fn main() -> Result<(), Error> {
5757
let (msg_bytes, pub_bytes, sig_bytes) = gen();
5858
let signature = Signature::try_from(sig_bytes.as_slice()).unwrap();
59-
let pk = VerifyingKey::from_bytes(&pub_bytes).unwrap();
59+
let pk = VerifyingKey::from_bytes(pub_bytes.as_slice().try_into().unwrap()).unwrap();
6060

6161
let last = current_cycles();
6262
pk.verify(&msg_bytes, &signature).unwrap();

0 commit comments

Comments
 (0)