|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | + |
| 4 | +## step 1: verify binary |
| 5 | +function verify_binary() { |
| 6 | + get_expected_hash() { |
| 7 | + grep "build/release/c-sphincs-all-in-one-lock$" ../../checksums.txt | awk '{print $1}' |
| 8 | + } |
| 9 | + |
| 10 | + expected_hash=$(get_expected_hash) |
| 11 | + |
| 12 | + actual_hash=$(jq -r '.cell_tx.outputs_data[0]' info.json | xxd -r -p | shasum -a 256 | awk '{print $1}') |
| 13 | + |
| 14 | + if [ "$expected_hash" != "$actual_hash" ]; then |
| 15 | + echo "✗ Binary verification failed!" |
| 16 | + exit 1 |
| 17 | + fi |
| 18 | + echo "✓ Binary verification passed!" |
| 19 | +} |
| 20 | + |
| 21 | +verify_binary |
| 22 | + |
| 23 | + |
| 24 | +## step 2: verify lock script |
| 25 | + |
| 26 | +function verify_lock_script() { |
| 27 | + code_hash=$(jq -r '.cell_tx.outputs[0].lock.code_hash' info.json) |
| 28 | + hash_type=$(jq -r '.cell_tx.outputs[0].lock.hash_type' info.json) |
| 29 | + args=$(jq -r '.cell_tx.outputs[0].lock.args' info.json) |
| 30 | + |
| 31 | + # https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0024-ckb-genesis-script-list/0024-ckb-genesis-script-list.md#secp256k1multisig |
| 32 | + expected_code_hash="0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8" |
| 33 | + expected_hash_type="type" |
| 34 | + |
| 35 | + if [ "$code_hash" != "$expected_code_hash" ]; then |
| 36 | + echo "✗ code_hash verification failed!" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + |
| 40 | + if [ "$hash_type" != "$expected_hash_type" ]; then |
| 41 | + echo "✗ hash_type verification failed!" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + echo "✓ Lock script verification passed!" |
| 45 | + |
| 46 | + multisig_output=$(ckb-cli tx build-multisig-address \ |
| 47 | + --sighash-address ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqw8jqfpfe9lwsvs74j3a27aalhqshrslps8hlplq \ |
| 48 | + --sighash-address ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2u7q5rqr3nam68g2wfel9365l855m7fcg58j52a \ |
| 49 | + --sighash-address ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq2hvk2yvt998w799ra8t73gunvrjrlw4agv2t7np \ |
| 50 | + --sighash-address ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsqt4q36wdxa34k89g5snyw694jy0nxht8yshfyw55 \ |
| 51 | + --sighash-address ckb1qzda0cr08m85hc8jlnfp3zer7xulejywt49kt2rr0vthywaa50xwsq0jyvhms76lphfm56dmd2s06k9yxwkxy4gqzah69 \ |
| 52 | + --threshold 3 \ |
| 53 | + --require-first-n 0 \ |
| 54 | + --multisig-code-hash legacy) |
| 55 | + |
| 56 | + expected_args=$(echo "$multisig_output" | grep "lock-arg:" | awk '{print $2}') |
| 57 | + |
| 58 | + if [ "$args" != "$expected_args" ]; then |
| 59 | + echo "✗ Lock args verification failed!" |
| 60 | + echo " Expected: $expected_args" |
| 61 | + echo " Actual: $args" |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + echo "✓ Lock args verification passed!" |
| 65 | +} |
| 66 | + |
| 67 | +verify_lock_script |
| 68 | + |
| 69 | +## step 3: verify type script |
| 70 | +function verify_type_script() { |
| 71 | + code_hash=$(jq -r '.cell_tx.outputs[0].type.code_hash' info.json) |
| 72 | + hash_type=$(jq -r '.cell_tx.outputs[0].type.hash_type' info.json) |
| 73 | + args=$(jq -r '.cell_tx.outputs[0].type.args' info.json) |
| 74 | + |
| 75 | + # https://github.com/nervosnetwork/rfcs/blob/4b502ffcb02fc7019e0dd4b5f866b5f09819cfbe/rfcs/0024-ckb-genesis-script-list/0024-ckb-genesis-script-list.md#type-id |
| 76 | + expected_code_hash="0x00000000000000000000000000000000000000000000000000545950455f4944" |
| 77 | + expected_hash_type="type" |
| 78 | + |
| 79 | + if [ "$code_hash" != "$expected_code_hash" ]; then |
| 80 | + echo "✗ type script code_hash verification failed!" |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + |
| 84 | + if [ "$hash_type" != "$expected_hash_type" ]; then |
| 85 | + echo "✗ type script hash_type verification failed!" |
| 86 | + exit 1 |
| 87 | + fi |
| 88 | + |
| 89 | + echo "✓ Type script verification passed!" |
| 90 | +} |
| 91 | + |
| 92 | +verify_type_script |
0 commit comments