{"id":22191974,"url":"https://github.com/cryptape/quantum-resistant-lock-script","last_synced_at":"2025-07-26T22:31:49.971Z","repository":{"id":103041672,"uuid":"596365430","full_name":"cryptape/quantum-resistant-lock-script","owner":"cryptape","description":"Quantum resistant lock script on CKB, using SPHINCS+","archived":false,"fork":false,"pushed_at":"2024-05-07T08:41:15.000Z","size":3267,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-05-07T09:53:14.354Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cryptape.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-02T02:40:50.000Z","updated_at":"2024-05-07T08:41:20.000Z","dependencies_parsed_at":"2023-11-06T11:44:31.738Z","dependency_job_id":null,"html_url":"https://github.com/cryptape/quantum-resistant-lock-script","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fquantum-resistant-lock-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fquantum-resistant-lock-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fquantum-resistant-lock-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cryptape%2Fquantum-resistant-lock-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cryptape","download_url":"https://codeload.github.com/cryptape/quantum-resistant-lock-script/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227724139,"owners_count":17810036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T12:18:34.732Z","updated_at":"2024-12-02T12:18:35.500Z","avatar_url":"https://github.com/cryptape.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# quantum-resistant-lock-script\nQuantum resistant lock script on CKB, using [SPHINCS+](https://github.com/sphincs/sphincsplus).\n\n## Build\n\n### Compile contract\n``` shell\nmake all-via-docker\n```\n\n### Compile other hash type\n``` shell\nmake all-via-docker PARAMS=sphincs-shake-256f THASH=robust\n```\nDifferent 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).\n\n\n## Performance\nUse items for tests/sphincsplus/optimization/run-all-optimization.sh.\nThe script uses fixed signature data (tests/sphincsplus/test_data/), Because different signature data will have subtle differences.\n\n|               |  128s bit  |  128f bit  |  192s bit  |  192f bit  |  256s bit  |  256f bit  |\n| ------------- | ---------- | ---------- | ---------- | ---------- | ---------- | ---------- |\n|   pubkey size |       32   |       32   |       48   |       48   |       64   |       64   |\n|signature size |     7888   |    17120   |    16256   |    35696   |    29824   |    49888   |\n|  shake simple |    16.9M   |    49.6M   |    25.4M   |    73.8M   |    37.1M   |    72.4M   |\n|  shake robust |    34.3M   |    98.4M   |    49.1M   |   147.5M   |    73.2M   |   150.3M   |\n|   sha2 simple |    10.7M   |    33.9M   |    16.8M   |    48.7M   |    24.7M   |    47.5M   |\n|   sha2 robust |    22.5M   |    64.5M   |    34.1M   |    98.6M   |    60.4M   |   130.3M   |\n| haraka simple |    27.5M   |    73.9M   |    39.2M   |   105.8M   |    60.4M   |   114.9M   |\n| haraka robust |    45.7M   |   119.8M   |    70.5M   |   182.7M   |   102.8M   |   193.3M   |\n\nFind out more information about different [parameters](https://github.com/sphincs/sphincsplus#parameters).\n\n* Note: Default hash type: **shake-128f-simple** (Verify cycles: about 49.6M)\n\n## Tool\nThis tool is to **convert a default Lock(SECP256K1/blake160) to quantum resistant lock script.**. \n\nFollow steps below:\n\n1. compile.\n\n   By default, sphincsplus_lock file's size is about 85K bytes.\n2. Deploy the compiled contract to the test network.\n   \u003c/br\u003e\n   We use [ckb-cli](https://github.com/nervosnetwork/ckb-cli) to deploy this contract, You can refer to [here](https://github.com/nervosnetwork/ckb-cli/wiki/Handle-Complex-Transaction#a-demo).\n   * After the execution is successful, it is recommended to record the tx-hash to facilitate subsequent operations.\n3. Generate key file.\n   \u003c/br\u003e\n   Use this tool: tools/ckb-sphincs-tools.\n   ``` shell\n   cargo run -- gen-key key.json\n   ```\n   We can get a set of key files, including public and private keys.\n   * If the contract you compile does not use the default value, it needs to be the same here.\n   * Need to save this file.\n4. Convert a SECP256K1/blake160 lock script to quantum resistant lock script.\n   ``` shell\n   cargo run -- cc_to_sphincsplus --tx_hash \u003ctx-hash\u003e --tx_index \u003cindex\u003e --key_file key.json --prikey \u003cYou can use ckb-cli account export\u003e\n   ```\n5. Convert a quantum resistant lock script to SECP256K1/blake160 lock script.\n   ``` shell\n   cargo run -- cc_to_secp --tx_hash \u003ctx-hash\u003e --tx_index \u003cindex\u003e --key_file key.json --lock_arg \u003cLOCK-ARG\u003e --sp_tx_hash \u003cSPHINCS+ Script in step 2\u003e --sp_tx_index \u003cindex\u003e --fee 10000\n   ```\n\n## Deployment\n\n* Mirana(mainnet)\n\n| parameter | value        |\n| --------- | ------------ |\n| code_hash | not deployed |\n| hash_type | type         |\n| tx_hash   | not deployed |\n| index     | 0            |\n| dep_type  | code         |\n\n* Pudge(testnet)\n\n[CKB Explorer](https://pudge.explorer.nervos.org/transaction/0x35f51257673c7a7edd009fa2166e6f8645156207c9da38202f04ba4d94d9e519)\n| parameter | value                                                              |\n| --------- | ------------------------------------------------------------------ |\n| code_hash | 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 |\n| hash_type | type                                                               |\n| tx_hash   | 0x35f51257673c7a7edd009fa2166e6f8645156207c9da38202f04ba4d94d9e519 |\n| index     | 0                                                                  |\n| dep_type  | code                                                               |\n\n## Sample Transactions\n\n### Genetate a cell locked by this script\n* Note, This script should use \"hash_type=data1\" or \"hash_type=type\" to support RISC-V B extensions.\n\n[CKB Explorer](https://pudge.explorer.nervos.org/transaction/0x1a48fb4def03465ab826e56fbf77943db65fad57db19d02279465d954e28be64)\n| parameter | value                                                              |\n| --------- | ------------------------------------------------------------------ |\n| code_hash | 0x989ab456455509a1c2ad1cb8116b7d209df228144445c741b101ec3e55ee8351 |\n| hash_type | data1                                                              |\n| tx_hash   | 0x1a48fb4def03465ab826e56fbf77943db65fad57db19d02279465d954e28be64 |\n| index     | 0                                                                  |\n| dep_type  | code                                                               |\n\n### Unlock this cell\n\n[CKB Explorer](https://pudge.explorer.nervos.org/transaction/0x1e3fcf73f02bb98e90239ed01e4fec63dc3469471309a19ee4eec7cfc00a8637)\n| parameter | value                                                              |\n| --------- | ------------------------------------------------------------------ |\n| code_hash | 0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8 |\n| hash_type | type                                                               |\n| tx_hash   | 0x1e3fcf73f02bb98e90239ed01e4fec63dc3469471309a19ee4eec7cfc00a8637 |\n| index     | 0                                                                  |\n| dep_type  | code                                                               |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptape%2Fquantum-resistant-lock-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptape%2Fquantum-resistant-lock-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptape%2Fquantum-resistant-lock-script/lists"}