Skip to content

Commit 422dae8

Browse files
committed
Add a tool for management SPHINCS+ Script
1 parent a07b472 commit 422dae8

File tree

10 files changed

+3401
-13
lines changed

10 files changed

+3401
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ifneq (,$(findstring sha2,$(PARAMS)))
6666
HEADERS += $(SPHINCS_PLUS_DIR)sha2.h
6767
endif
6868

69-
CFLAGS := $(CFLAGS) -g -DCKB_C_STDLIB_PRINTF
69+
# CFLAGS := $(CFLAGS) -g -DCKB_C_STDLIB_PRINTF
7070

7171
# docker pull nervos/ckb-riscv-gnu-toolchain:gnu-jammy-20230214
7272
BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:7601a814be2595ad471288fefc176356b31101837a514ddb0fc93b11c1cf5135

README.md

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
11
# quantum-resistant-lock-script
22
Qantum resistant lock script on CKB, using SPHINCS+
33

4+
## SPHINCS+
5+
6+
## Build
7+
8+
### Compile contract
9+
``` shell
10+
make all-via-docker
11+
```
12+
13+
### Compile other hash type
14+
``` shell
15+
make all-via-docker PARAMS=sphincs-shake-256f THASH=robust
16+
```
17+
Different hash types will have large performance differences when verifying. For specific performance differences, please refer to the table below. You can also refer to this script to generate and execute contracts (tests/sphincsplus_rust/run_example.sh).
18+
419

520
## Performance
6-
Use items for tests/sphincsplus/optimization/run-all-optimization.sh
7-
8-
| | 128s bit | 256s bit |
9-
| ------------- | ---------- | --------- |
10-
| pubkey size | 32 | 64 |
11-
| sign size | 7888 | 29824 |
12-
| shake simple | 16.9M | 37.1M |
13-
| shake robust | 34.3M | 73.2M |
14-
| sha2 simple | 10.7M | 24.7M |
15-
| sha2 robust | 22.5M | 60.4M |
16-
| haraka simple | 27.5M | 60.4M |
17-
| haraka robust | 45.7M | 102.8M |
21+
Use items for tests/sphincsplus/optimization/run-all-optimization.sh.
22+
The script uses fixed signature data (tests/sphincsplus/test_data/), Because different signature data will have subtle differences.
23+
24+
| | 128s bit | 128f bit | 192s bit | 192f bit | 256s bit | 256f bit |
25+
| ------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- |
26+
| pubkey size | 32 | 32 | 48 | 48 | 64 | 64 |
27+
| sign size | 7888 | 17120 | 16256 | 35696 | 29824 | 49888 |
28+
| shake simple | 16.9M | 49.6M | 25.4M | 73.8M | 37.1M | 72.4M |
29+
| shake robust | 34.3M | 98.4M | 49.1M | 147.5M | 73.2M | 150.3M |
30+
| sha2 simple | 10.7M | 33.9M | 16.8M | 48.7M | 24.7M | 47.5M |
31+
| sha2 robust | 22.5M | 64.5M | 34.1M | 98.6M | 60.4M | 130.3M |
32+
| haraka simple | 27.5M | 73.9M | 39.2M | 105.8M | 60.4M | 114.9M |
33+
| haraka robust | 45.7M | 119.8M | 70.5M | 182.7M | 102.8M | 193.3M |
34+
35+
* Note: Default hash type: **shake-128f-simple** (Verify cycles: about 70M)
36+
37+
## Sample
38+
39+
```shell
40+
tx init --tx-file tx.json
41+
wallet get-capacity --address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqfkmqr3ry0crq4w88n86mk4h99am3dlldsuydg36
42+
wallet get-live-cells --address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqfkmqr3ry0crq4w88n86mk4h99am3dlldsuydg36
43+
tx add-input --tx-hash 0x1ff88a5f9cb719abd86978b05c39d82fd83473519272013afdbee20d5c7ff162 --index 1 --tx-file tx.json
44+
tx add-output --to-sighash-address ckt1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqfkmqr3ry0crq4w88n86mk4h99am3dlldsuydg36 --capacity 15096.20139385 --tx-file tx.json
45+
```

tools/ckb-sphincs-tools/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
.vscode

0 commit comments

Comments
 (0)