Skip to content

Commit 7e7a437

Browse files
authored
chore: update rust and dependencies versions (#7)
* chore: update rust and dependencies versions * chore: remove llvm dependency * chore: clippy
1 parent ec14aef commit 7e7a437

File tree

28 files changed

+434
-224
lines changed

28 files changed

+434
-224
lines changed

Cargo.lock

Lines changed: 390 additions & 159 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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TOP := $(cur_dir)
66
# RUSTFLAGS that are likely to be tweaked by developers. For example,
77
# while we enable debug logs by default here, some might want to strip them
88
# for minimal code size / consumed cycles.
9-
CUSTOM_RUSTFLAGS := --cfg debug_assertions
9+
CUSTOM_RUSTFLAGS := -C debug-assertions
1010
# Additional cargo args to append here. For example, one can use
1111
# make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to
1212
# stdout in unit tests
@@ -71,7 +71,7 @@ check:
7171
cargo check $(CARGO_ARGS)
7272

7373
clippy:
74-
cargo clippy $(CARGO_ARGS)
74+
cargo clippy $(CARGO_ARGS) --target=riscv64imac-unknown-none-elf
7575

7676
fmt:
7777
cargo fmt $(CARGO_ARGS)
@@ -121,8 +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
125-
wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 18 && rm llvm.sh
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
126127

127128
ci: build
128129
ls -alht build/release

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/ed25519-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
ckb-std = { version = "0.15.3", features = ["build-with-clang"] }
9+
ckb-std = { version = "0.18.0", default-features = false, features = ["allocator", "dummy-atomic"]}
1010
ed25519-dalek = { version = "2.1.1", default-features = false, features = ["digest"] }
1111
curve25519-dalek = { version = "4.1.2", default-features = false, features = ["digest"] }
1212
hex-literal = "0.3"

contracts/ed25519-test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TOP := $(cur_dir)
66
# RUSTFLAGS that are likely to be tweaked by developers. For example,
77
# while we enable debug logs by default here, some might want to strip them
88
# for minimal code size / consumed cycles.
9-
CUSTOM_RUSTFLAGS := --cfg debug_assertions
9+
CUSTOM_RUSTFLAGS := -C debug-assertions
1010
# RUSTFLAGS that are less likely to be tweaked by developers. Most likely
1111
# one would want to keep the default values here.
1212
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS)

contracts/ed25519-test/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ impl From<SysError> for Error {
1818
LengthNotEnough(_) => Self::LengthNotEnough,
1919
Encoding => Self::Encoding,
2020
Unknown(err_code) => panic!("unexpected sys error {}", err_code),
21+
_ => panic!("unknown error"),
2122
}
2223
}
2324
}

contracts/k256-recovery-test/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
ckb-std = { version = "0.15.3", features = ["build-with-clang"] }
10-
k256 = { version = "=0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "alloc"] }
9+
ckb-std = { version = "0.18.0", default-features = false, features = ["allocator", "dummy-atomic"]}
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/k256-recovery-test/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TOP := $(cur_dir)
66
# RUSTFLAGS that are likely to be tweaked by developers. For example,
77
# while we enable debug logs by default here, some might want to strip them
88
# for minimal code size / consumed cycles.
9-
CUSTOM_RUSTFLAGS := --cfg debug_assertions
9+
CUSTOM_RUSTFLAGS := -C debug-assertions
1010
# RUSTFLAGS that are less likely to be tweaked by developers. Most likely
1111
# one would want to keep the default values here.
1212
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ fn gen() -> (Vec<u8>, Vec<u8>, Vec<u8>, u8) {
3636
let sk = SigningKey::from_slice(&SECRET_KEY).unwrap();
3737
let pk = sk.verifying_key();
3838
let msg_bytes = generate_msg();
39-
let (signature, rec_id) = sk.sign_recoverable(&msg_bytes).unwrap();
39+
40+
let (signature, rec_id) = sk.sign_prehash_recoverable(&msg_bytes).unwrap();
4041

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

@@ -63,7 +64,7 @@ fn gen() -> (Vec<u8>, Vec<u8>, Vec<u8>, u8) {
6364
hex::decode("68656c6c6f2c20776f726c640000000000000000000000000000000000000000").unwrap();
6465
let pub_bytes =
6566
hex::decode("030cec028ee08d09e02672a68310814354f9eabfff0de6dacc1cd3a774496076ae").unwrap();
66-
let sig_bytes = hex::decode("0370aa07db8be44caed0f4c77aa6a644fa97228feeb7082ae66f640fe0d7d728610c2a4e1655183d134e191c8a4a06d970bc7a94a25420f5026a0288ff47ad42").unwrap();
67+
let sig_bytes = hex::decode("bb54baa41daefb2b6931ddbbbb636054b9027e966a61c3bf5fb75e26b2f2a78f1c65827dba40d81242ae3362e3a936e18092f21d5be8a1ff1b7693cc85068d3a").unwrap();
6768
let rec_id = 1u8;
6869
(msg_bytes, pub_bytes, sig_bytes, rec_id)
6970
}
@@ -75,7 +76,8 @@ pub fn main() -> Result<(), Error> {
7576
let rec_id = RecoveryId::try_from(rec_id).unwrap();
7677

7778
let last = current_cycles();
78-
let recovered_key = VerifyingKey::recover_from_msg(&msg_bytes, &signature, rec_id).unwrap();
79+
let recovered_key =
80+
VerifyingKey::recover_from_prehash_noverify(&msg_bytes, &signature, rec_id).unwrap();
7981
assert_eq!(recovered_key, pk);
8082
let _recovered_key_bytes = recovered_key.to_sec1_bytes();
8183
let cycles = current_cycles() - last;

0 commit comments

Comments
 (0)