From e6838256927a0e700a513cd71268dbe78a3e6dec Mon Sep 17 00:00:00 2001 From: tea2x Date: Wed, 8 Jan 2025 13:47:06 +0700 Subject: [PATCH 1/9] add rust workspace configuration --- .gitignore | 2 ++ Cargo.toml | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 Cargo.toml diff --git a/.gitignore b/.gitignore index a5d8b92..0607fd4 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,5 @@ dkms.conf .DS_Store build/ .vscode/ +target/ +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..860bf19 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[workspace] +members = [ + "tests/sphincsplus_rust", + "tools/ckb-sphincs-tools", + "tools/ckb-sphincs-utils" +] From de99eb11d6c322e662aff1ae6a7c412533d22d88 Mon Sep 17 00:00:00 2001 From: tea2x Date: Fri, 10 Jan 2025 13:11:44 +0700 Subject: [PATCH 2/9] auto-trim 0x prefix and leading zeros for 256-bit inputs --- tools/ckb-sphincs-tools/src/main.rs | 31 +++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tools/ckb-sphincs-tools/src/main.rs b/tools/ckb-sphincs-tools/src/main.rs index 60d2330..54ec5d1 100644 --- a/tools/ckb-sphincs-tools/src/main.rs +++ b/tools/ckb-sphincs-tools/src/main.rs @@ -64,8 +64,11 @@ fn main() { Some(("signature", sub_matches)) => { let key_file = sub_matches.get_one::("key_file").expect("required"); let message = - H256::from_trimmed_str(sub_matches.get_one::("message").expect("required")) - .unwrap(); + H256::from_trimmed_str( + sub_matches.get_one::("message").expect("required") + .trim_start_matches("0x") + .trim_start_matches('0') + ).unwrap(); sub_sign::sub_sign( sub_gen_key::parse_key_file(PathBuf::from(key_file)), message, @@ -81,9 +84,17 @@ fn main() { sub_conversion::cc_to_sphincsplus( sub_gen_key::parse_key_file(PathBuf::from(key_file)), &ckb_rpc, - H256::from_trimmed_str(tx_hash).unwrap(), + H256::from_trimmed_str( + tx_hash + .trim_start_matches("0x") + .trim_start_matches('0') + ).unwrap(), tx_index.parse::().unwrap(), - H256::from_trimmed_str(prikey).unwrap(), + H256::from_trimmed_str( + prikey + .trim_start_matches("0x") + .trim_start_matches('0') + ).unwrap(), ); } Some(("cc_to_secp", sub_matches)) => { @@ -107,10 +118,18 @@ fn main() { sub_conversion::cc_to_def_lock_script( sub_gen_key::parse_key_file(PathBuf::from(key_file)), &ckb_rpc, - H256::from_trimmed_str(tx_hash).unwrap(), + H256::from_trimmed_str( + tx_hash + .trim_start_matches("0x") + .trim_start_matches('0') + ).unwrap(), tx_index.parse::().unwrap(), &str_to_bytes(&lock_arg), - H256::from_trimmed_str(sp_tx_hash).unwrap(), + H256::from_trimmed_str( + sp_tx_hash + .trim_start_matches("0x") + .trim_start_matches('0') + ).unwrap(), sp_tx_index.parse::().unwrap(), fee.clone(), ); From a249cd37dd221cc9565559059d7678bd99c10d8d Mon Sep 17 00:00:00 2001 From: tea2x Date: Fri, 10 Jan 2025 13:20:35 +0700 Subject: [PATCH 3/9] semantics --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e753d3..b2b901b 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Find out more information about different [parameters](https://github.com/sphinc * Note: Default hash type: **shake-128f-simple** (Verify cycles: about 49.6M) ## Tool -This tool is to **convert a default Lock(SECP256K1/blake160) to quantum resistant lock script.**. +This tool is to **migrate a default Lock(SECP256K1/blake160) to quantum resistant lock script.**. Follow steps below: @@ -55,11 +55,11 @@ Follow steps below: We can get a set of key files, including public and private keys. * If the contract you compile does not use the default value, it needs to be the same here. * Need to save this file. -4. Convert a SECP256K1/blake160 lock script to quantum resistant lock script. +4. Migrate from SECP256K1/blake160 lock script to quantum resistant lock script. ``` shell cargo run -- cc_to_sphincsplus --tx_hash --tx_index --key_file key.json --prikey ``` -5. Convert a quantum resistant lock script to SECP256K1/blake160 lock script. +5. Migrate a quantum resistant lock script to SECP256K1/blake160 lock script. ``` shell cargo run -- cc_to_secp --tx_hash --tx_index --key_file key.json --lock_arg --sp_tx_hash --sp_tx_index --fee 10000 ``` From 3a81cf8638f754baf13f0b7ca418ac6c0f6a6877 Mon Sep 17 00:00:00 2001 From: tea2x Date: Sat, 11 Jan 2025 14:14:31 +0700 Subject: [PATCH 4/9] ocnfigure workspace.resolver to '2' --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 860bf19..ba769cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "tests/sphincsplus_rust", "tools/ckb-sphincs-tools", From 8d6d7bd8f56eb8a3f81b02f5aa257c73ffeb650a Mon Sep 17 00:00:00 2001 From: tea2x Date: Sat, 11 Jan 2025 16:46:01 +0700 Subject: [PATCH 5/9] update build file if forget to make clean before building different sphics+ variants --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d1d0bbd..3633b45 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,7 @@ BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:7601a814be2595ad471288fe all: build/sphincsplus_lock all-via-docker: + rm -rf build/ docker run --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make PARAMS=$(PARAMS) THASH=$(THASH)" build/convert_asm: c/ref/fips202_asm.S @@ -87,4 +88,4 @@ build/sphincsplus_lock: c/ckb-sphincsplus-lock.c $(SOURCES) $(HEADERS) $(OBJCOPY) --strip-debug --strip-all $@ clean: - rm -rf build/sphincsplus_lock \ No newline at end of file + rm -rf build/ \ No newline at end of file From 7442d87b6fe43061f81d733fe85dd058a584c39d Mon Sep 17 00:00:00 2001 From: tea2x Date: Sat, 11 Jan 2025 17:29:33 +0700 Subject: [PATCH 6/9] semantics --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2b901b..74954ad 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Find out more information about different [parameters](https://github.com/sphinc * Note: Default hash type: **shake-128f-simple** (Verify cycles: about 49.6M) ## Tool -This tool is to **migrate a default Lock(SECP256K1/blake160) to quantum resistant lock script.**. +This tool is to **migrate from default Lock(SECP256K1/blake160) to quantum resistant lock script.**. Follow steps below: From fe7269965f78441b8ae97a776496d1026644ae2a Mon Sep 17 00:00:00 2001 From: tea2x Date: Sat, 11 Jan 2025 20:11:28 +0700 Subject: [PATCH 7/9] update README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 74954ad..d115da1 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Find out more information about different [parameters](https://github.com/sphinc * Note: Default hash type: **shake-128f-simple** (Verify cycles: about 49.6M) ## Tool -This tool is to **migrate from default Lock(SECP256K1/blake160) to quantum resistant lock script.**. +This tool is to **migrate Cells from default lock(SECP256K1/blake160) to quantum resistant lock.** Follow steps below: @@ -55,11 +55,11 @@ Follow steps below: We can get a set of key files, including public and private keys. * If the contract you compile does not use the default value, it needs to be the same here. * Need to save this file. -4. Migrate from SECP256K1/blake160 lock script to quantum resistant lock script. +4. Update a Cell's Lock Script from SECP256K1/blake160 to quantum resistant. ``` shell cargo run -- cc_to_sphincsplus --tx_hash --tx_index --key_file key.json --prikey ``` -5. Migrate a quantum resistant lock script to SECP256K1/blake160 lock script. +5. Update a Cell's Lock Script from quantum resistant to SECP256K1/blake160. ``` shell cargo run -- cc_to_secp --tx_hash --tx_index --key_file key.json --lock_arg --sp_tx_hash --sp_tx_index --fee 10000 ``` From 7ed28419e09d5a6ae027204158215e76389b0b13 Mon Sep 17 00:00:00 2001 From: tea2x Date: Fri, 17 Jan 2025 14:51:47 +0700 Subject: [PATCH 8/9] correct testnet sphincs deployment info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d115da1..f8e4fab 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Follow steps below: [CKB Explorer](https://pudge.explorer.nervos.org/transaction/0x35f51257673c7a7edd009fa2166e6f8645156207c9da38202f04ba4d94d9e519) | parameter | value | | --------- | ------------------------------------------------------------------ | -| code_hash | 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 | +| code_hash | 0x989ab456455509a1c2ad1cb8116b7d209df228144445c741b101ec3e55ee8351 | | hash_type | type | | tx_hash | 0x35f51257673c7a7edd009fa2166e6f8645156207c9da38202f04ba4d94d9e519 | | index | 0 | From 4a9456b5d07e9f82684920f53a8978bfad979852 Mon Sep 17 00:00:00 2001 From: tea2x Date: Sat, 18 Jan 2025 10:14:51 +0700 Subject: [PATCH 9/9] update test net deployment info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8e4fab..d1528ef 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Follow steps below: | parameter | value | | --------- | ------------------------------------------------------------------ | | code_hash | 0x989ab456455509a1c2ad1cb8116b7d209df228144445c741b101ec3e55ee8351 | -| hash_type | type | +| hash_type | data1 | | tx_hash | 0x35f51257673c7a7edd009fa2166e6f8645156207c9da38202f04ba4d94d9e519 | | index | 0 | | dep_type | code |