diff --git a/generators/all.sh b/generators/all.sh index cb14dc4..fc58d8a 100755 --- a/generators/all.sh +++ b/generators/all.sh @@ -1,47 +1,47 @@ #!/bin/bash -TESTS_PATH=./test-vectors/precompile/tests -FIXTS_PATH=./test-vectors/precompile/fixtures +TESTS_PATH=./test-vectors/txn/tests/precompile +FIXTS_PATH=./test-vectors/txn/fixtures/precompile -# rm -r ${TESTS_PATH}/ed25519 ; mkdir -p ${TESTS_PATH}/ed25519 -# python3 generators/ed25519.py -# rm -r ${FIXTS_PATH}/ed25519 ; mkdir -p ${FIXTS_PATH}/ed25519 -# solana-test-suite create-fixtures -i ${TESTS_PATH}/ed25519 -o ${FIXTS_PATH}/ed25519 -s ./impl/lib/libsolfuzz_agave_v2.0.so +rm -r ${TESTS_PATH}/ed25519 ; mkdir -p ${TESTS_PATH}/ed25519 +python3 generators/ed25519.py +rm -r ${FIXTS_PATH}/ed25519 ; mkdir -p ${FIXTS_PATH}/ed25519 +HARNESS_TYPE=TxnHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/ed25519 -o ${FIXTS_PATH}/ed25519 -s ./impl/lib/libsolfuzz_agave_v2.0.so -# rm -r ${TESTS_PATH}/secp256k1 ; mkdir -p ${TESTS_PATH}/secp256k1 -# python3 generators/secp256k1.py -# rm -r ${FIXTS_PATH}/secp256k1 ; mkdir -p ${FIXTS_PATH}/secp256k1 -# solana-test-suite create-fixtures -i ${TESTS_PATH}/secp256k1 -o ${FIXTS_PATH}/secp256k1 -s ./impl/lib/libsolfuzz_agave_v2.0.so +rm -r ${TESTS_PATH}/secp256k1 ; mkdir -p ${TESTS_PATH}/secp256k1 +python3 generators/secp256k1.py +rm -r ${FIXTS_PATH}/secp256k1 ; mkdir -p ${FIXTS_PATH}/secp256k1 +HARNESS_TYPE=TxnHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/secp256k1 -o ${FIXTS_PATH}/secp256k1 -s ./impl/lib/libsolfuzz_agave_v2.0.so -TESTS_PATH=./test-vectors/syscall/tests -FIXTS_PATH=./test-vectors/syscall/fixtures +# TESTS_PATH=./test-vectors/syscall/tests +# FIXTS_PATH=./test-vectors/syscall/fixtures -rm -r ${TESTS_PATH}/curve25519 ; mkdir -p ${TESTS_PATH}/curve25519 -python3 generators/syscalls_curve25519.py -rm -r ${FIXTS_PATH}/curve25519 ; mkdir -p ${FIXTS_PATH}/curve25519 -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/curve25519 -o ${FIXTS_PATH}/curve25519 -s ./impl/lib/libsolfuzz_agave_v2.0.so +# rm -r ${TESTS_PATH}/curve25519 ; mkdir -p ${TESTS_PATH}/curve25519 +# python3 generators/syscalls_curve25519.py +# rm -r ${FIXTS_PATH}/curve25519 ; mkdir -p ${FIXTS_PATH}/curve25519 +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/curve25519 -o ${FIXTS_PATH}/curve25519 -s ./impl/lib/libsolfuzz_agave_v2.0.so -rm -r ${TESTS_PATH}/secp256k1 ; mkdir -p ${TESTS_PATH}/secp256k1 -python3 generators/syscalls_secp256k1.py -rm -r ${FIXTS_PATH}/secp256k1 ; mkdir -p ${FIXTS_PATH}/secp256k1 -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/secp256k1 -o ${FIXTS_PATH}/secp256k1 -s ./impl/lib/libsolfuzz_agave_v2.0.so - -rm -r ${TESTS_PATH}/poseidon ; mkdir -p ${TESTS_PATH}/poseidon -python3 generators/syscalls_poseidon.py -rm -r ${FIXTS_PATH}/poseidon ; mkdir -p ${FIXTS_PATH}/poseidon -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/poseidon -o ${FIXTS_PATH}/poseidon -s ./impl/lib/libsolfuzz_agave_v2.0.so - -rm -r ${TESTS_PATH}/alt_bn128 ; mkdir -p ${TESTS_PATH}/alt_bn128 -python3 generators/syscalls_alt_bn128.py -rm -r ${FIXTS_PATH}/alt_bn128 ; mkdir -p ${FIXTS_PATH}/alt_bn128 -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/alt_bn128 -o ${FIXTS_PATH}/alt_bn128 -s ./impl/lib/libsolfuzz_agave_v2.0.so - -rm -r ${TESTS_PATH}/sha256 ; mkdir -p ${TESTS_PATH}/sha256 -rm -r ${TESTS_PATH}/keccak256 ; mkdir -p ${TESTS_PATH}/keccak256 -rm -r ${TESTS_PATH}/blake3 ; mkdir -p ${TESTS_PATH}/blake3 -python3 generators/syscalls_hash.py -rm -r ${FIXTS_PATH}/sha256 ; mkdir -p ${FIXTS_PATH}/sha256 -rm -r ${FIXTS_PATH}/keccak256 ; mkdir -p ${FIXTS_PATH}/keccak256 -rm -r ${FIXTS_PATH}/blake3 ; mkdir -p ${FIXTS_PATH}/blake3 -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/sha256 -o ${FIXTS_PATH}/sha256 -s ./impl/lib/libsolfuzz_agave_v2.0.so -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/keccak256 -o ${FIXTS_PATH}/keccak256 -s ./impl/lib/libsolfuzz_agave_v2.0.so -HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/blake3 -o ${FIXTS_PATH}/blake3 -s ./impl/lib/libsolfuzz_agave_v2.0.so +# rm -r ${TESTS_PATH}/secp256k1 ; mkdir -p ${TESTS_PATH}/secp256k1 +# python3 generators/syscalls_secp256k1.py +# rm -r ${FIXTS_PATH}/secp256k1 ; mkdir -p ${FIXTS_PATH}/secp256k1 +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/secp256k1 -o ${FIXTS_PATH}/secp256k1 -s ./impl/lib/libsolfuzz_agave_v2.0.so + +# rm -r ${TESTS_PATH}/poseidon ; mkdir -p ${TESTS_PATH}/poseidon +# python3 generators/syscalls_poseidon.py +# rm -r ${FIXTS_PATH}/poseidon ; mkdir -p ${FIXTS_PATH}/poseidon +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/poseidon -o ${FIXTS_PATH}/poseidon -s ./impl/lib/libsolfuzz_agave_v2.0.so + +# rm -r ${TESTS_PATH}/alt_bn128 ; mkdir -p ${TESTS_PATH}/alt_bn128 +# python3 generators/syscalls_alt_bn128.py +# rm -r ${FIXTS_PATH}/alt_bn128 ; mkdir -p ${FIXTS_PATH}/alt_bn128 +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/alt_bn128 -o ${FIXTS_PATH}/alt_bn128 -s ./impl/lib/libsolfuzz_agave_v2.0.so + +# rm -r ${TESTS_PATH}/sha256 ; mkdir -p ${TESTS_PATH}/sha256 +# rm -r ${TESTS_PATH}/keccak256 ; mkdir -p ${TESTS_PATH}/keccak256 +# rm -r ${TESTS_PATH}/blake3 ; mkdir -p ${TESTS_PATH}/blake3 +# python3 generators/syscalls_hash.py +# rm -r ${FIXTS_PATH}/sha256 ; mkdir -p ${FIXTS_PATH}/sha256 +# rm -r ${FIXTS_PATH}/keccak256 ; mkdir -p ${FIXTS_PATH}/keccak256 +# rm -r ${FIXTS_PATH}/blake3 ; mkdir -p ${FIXTS_PATH}/blake3 +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/sha256 -o ${FIXTS_PATH}/sha256 -s ./impl/lib/libsolfuzz_agave_v2.0.so +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/keccak256 -o ${FIXTS_PATH}/keccak256 -s ./impl/lib/libsolfuzz_agave_v2.0.so +# HARNESS_TYPE=SyscallHarness solana-test-suite create-fixtures -i ${TESTS_PATH}/blake3 -o ${FIXTS_PATH}/blake3 -s ./impl/lib/libsolfuzz_agave_v2.0.so diff --git a/generators/ed25519.py b/generators/ed25519.py index 1a29578..d12d151 100644 --- a/generators/ed25519.py +++ b/generators/ed25519.py @@ -1,16 +1,17 @@ import fd58 import hashlib -import test_suite.invoke_pb2 as invoke_pb import test_suite.context_pb2 as context_pb +import test_suite.txn_pb2 as txn_pb from dataclasses import dataclass import requests -OUTPUT_DIR = "./test-vectors/precompile/tests/ed25519" +OUTPUT_DIR = "./test-vectors/txn/tests/precompile/ed25519" program_id = "Ed25519SigVerify111111111111111111111111111" accounts = [] # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L181 +# fmt: off test_vectors_agave = [ # InvalidDataOffsets (result: 4) # invalid offset @@ -30,245 +31,9 @@ [1, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], # Ok() (result: 0) # valid signature - [ - 1, - 0, - 48, - 0, - 255, - 255, - 16, - 0, - 255, - 255, - 112, - 0, - 5, - 0, - 255, - 255, - 75, - 214, - 129, - 151, - 244, - 149, - 70, - 192, - 102, - 135, - 224, - 99, - 199, - 172, - 238, - 204, - 3, - 67, - 253, - 92, - 104, - 212, - 24, - 116, - 243, - 199, - 49, - 42, - 20, - 156, - 143, - 83, - 1, - 148, - 145, - 203, - 46, - 109, - 182, - 75, - 135, - 218, - 65, - 3, - 176, - 77, - 9, - 53, - 33, - 86, - 42, - 178, - 80, - 169, - 11, - 169, - 251, - 61, - 180, - 51, - 167, - 39, - 34, - 189, - 140, - 51, - 151, - 209, - 50, - 76, - 167, - 90, - 205, - 1, - 57, - 197, - 149, - 97, - 99, - 241, - 191, - 66, - 222, - 90, - 0, - 251, - 220, - 145, - 101, - 24, - 220, - 32, - 183, - 0, - 19, - 5, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 0, 48, 0, 255, 255, 16, 0, 255, 255, 112, 0, 5, 0, 255, 255, 75, 214, 129, 151, 244, 149, 70, 192, 102, 135, 224, 99, 199, 172, 238, 204, 3, 67, 253, 92, 104, 212, 24, 116, 243, 199, 49, 42, 20, 156, 143, 83, 1, 148, 145, 203, 46, 109, 182, 75, 135, 218, 65, 3, 176, 77, 9, 53, 33, 86, 42, 178, 80, 169, 11, 169, 251, 61, 180, 51, 167, 39, 34, 189, 140, 51, 151, 209, 50, 76, 167, 90, 205, 1, 57, 197, 149, 97, 99, 241, 191, 66, 222, 90, 0, 251, 220, 145, 101, 24, 220, 32, 183, 0, 19, 5, 104, 101, 108, 108, 111, ], # InvalidPublicKey (result: 1) - [ - 1, - 0, - 48, - 0, - 255, - 255, - 16, - 0, - 255, - 255, - 112, - 0, - 5, - 0, - 255, - 255, - 75, - 214, - 129, - 151, - 0, - 149, - 70, - 192, - 102, - 135, - 224, - 99, - 199, - 172, - 238, - 204, - 3, - 67, - 253, - 92, - 104, - 212, - 24, - 116, - 243, - 199, - 49, - 42, - 20, - 156, - 143, - 83, - 1, - 148, - 145, - 203, - 46, - 109, - 182, - 75, - 135, - 218, - 65, - 3, - 176, - 77, - 9, - 53, - 33, - 86, - 42, - 178, - 80, - 169, - 11, - 169, - 251, - 61, - 180, - 51, - 167, - 39, - 34, - 189, - 140, - 51, - 151, - 209, - 50, - 76, - 167, - 90, - 205, - 1, - 57, - 197, - 149, - 97, - 99, - 241, - 191, - 66, - 222, - 90, - 0, - 251, - 220, - 145, - 101, - 24, - 220, - 32, - 183, - 0, - 19, - 5, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 0, 48, 0, 255, 255, 16, 0, 255, 255, 112, 0, 5, 0, 255, 255, 75, 214, 129, 151, 0, 149, 70, 192, 102, 135, 224, 99, 199, 172, 238, 204, 3, 67, 253, 92, 104, 212, 24, 116, 243, 199, 49, 42, 20, 156, 143, 83, 1, 148, 145, 203, 46, 109, 182, 75, 135, 218, 65, 3, 176, 77, 9, 53, 33, 86, 42, 178, 80, 169, 11, 169, 251, 61, 180, 51, 167, 39, 34, 189, 140, 51, 151, 209, 50, 76, 167, 90, 205, 1, 57, 197, 149, 97, 99, 241, 191, 66, 222, 90, 0, 251, 220, 145, 101, 24, 220, 32, 183, 0, 19, 5, 104, 101, 108, 108, 111, ], ] # manual code cov @@ -292,1099 +57,30 @@ # InvalidSignature (result: 3) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L123-L124 # signature fails to decode - [ - 1, - 0, - 48, - 0, - 255, - 255, - 16, - 0, - 255, - 255, - 112, - 0, - 5, - 0, - 255, - 255, - 77, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 255, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 0, 48, 0, 255, 255, 16, 0, 255, 255, 112, 0, 5, 0, 255, 255, 77, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 255, 104, 101, 108, 108, 111, ], # InvalidDataOffsets (result: 4) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L127-L133 # tested above # InvalidPublicKey (result: 1) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L135-L136 - [ - 1, - 0, - 48, - 0, - 255, - 255, - 16, - 0, - 255, - 255, - 112, - 0, - 5, - 0, - 255, - 255, - 88, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 9, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 0, 48, 0, 255, 255, 16, 0, 255, 255, 112, 0, 5, 0, 255, 255, 88, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 9, 104, 101, 108, 108, 111, ], # InvalidDataOffsets (result: 4) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L139-L145 # tested above # InvalidSignature (result: 3) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/ed25519_instruction.rs#L147-L149 # signature fails to verify - [ - 1, - 0, - 48, - 0, - 255, - 255, - 16, - 0, - 255, - 255, - 112, - 0, - 5, - 0, - 255, - 255, - 77, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 16, - 104, - 101, - 108, - 108, - 111, - ], - [ - 2, - 0, - 62, - 0, - 255, - 255, - 30, - 0, - 255, - 255, - 126, - 0, - 5, - 0, - 255, - 255, - 163, - 0, - 255, - 255, - 131, - 0, - 255, - 255, - 227, - 0, - 5, - 0, - 255, - 255, - 77, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 9, - 104, - 101, - 108, - 108, - 111, - 75, - 214, - 129, - 151, - 244, - 149, - 70, - 192, - 102, - 135, - 224, - 99, - 199, - 172, - 238, - 204, - 3, - 67, - 253, - 92, - 104, - 212, - 24, - 116, - 243, - 199, - 49, - 42, - 20, - 156, - 143, - 83, - 1, - 148, - 145, - 203, - 46, - 109, - 182, - 75, - 135, - 218, - 65, - 3, - 176, - 77, - 9, - 53, - 33, - 86, - 42, - 178, - 80, - 169, - 11, - 169, - 251, - 61, - 180, - 51, - 167, - 39, - 34, - 189, - 140, - 51, - 151, - 209, - 50, - 76, - 167, - 90, - 205, - 1, - 57, - 197, - 149, - 97, - 99, - 241, - 191, - 66, - 222, - 90, - 0, - 251, - 220, - 145, - 101, - 24, - 220, - 32, - 183, - 0, - 19, - 16, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 0, 48, 0, 255, 255, 16, 0, 255, 255, 112, 0, 5, 0, 255, 255, 77, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 16, 104, 101, 108, 108, 111, ], + [ 2, 0, 62, 0, 255, 255, 30, 0, 255, 255, 126, 0, 5, 0, 255, 255, 163, 0, 255, 255, 131, 0, 255, 255, 227, 0, 5, 0, 255, 255, 77, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 9, 104, 101, 108, 108, 111, 75, 214, 129, 151, 244, 149, 70, 192, 102, 135, 224, 99, 199, 172, 238, 204, 3, 67, 253, 92, 104, 212, 24, 116, 243, 199, 49, 42, 20, 156, 143, 83, 1, 148, 145, 203, 46, 109, 182, 75, 135, 218, 65, 3, 176, 77, 9, 53, 33, 86, 42, 178, 80, 169, 11, 169, 251, 61, 180, 51, 167, 39, 34, 189, 140, 51, 151, 209, 50, 76, 167, 90, 205, 1, 57, 197, 149, 97, 99, 241, 191, 66, 222, 90, 0, 251, 220, 145, 101, 24, 220, 32, 183, 0, 19, 16, 104, 101, 108, 108, 111, ], # Ok() # valid - [ - 1, - 0, - 48, - 0, - 255, - 255, - 16, - 0, - 255, - 255, - 112, - 0, - 5, - 0, - 255, - 255, - 77, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 9, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 0, 48, 0, 255, 255, 16, 0, 255, 255, 112, 0, 5, 0, 255, 255, 77, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 9, 104, 101, 108, 108, 111, ], # valid (add 14 to offsets, dupe the struct) - [ - 2, - 0, - 62, - 0, - 255, - 255, - 30, - 0, - 255, - 255, - 126, - 0, - 5, - 0, - 255, - 255, - 62, - 0, - 255, - 255, - 30, - 0, - 255, - 255, - 126, - 0, - 5, - 0, - 255, - 255, - 77, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 9, - 104, - 101, - 108, - 108, - 111, - ], + [ 2, 0, 62, 0, 255, 255, 30, 0, 255, 255, 126, 0, 5, 0, 255, 255, 62, 0, 255, 255, 30, 0, 255, 255, 126, 0, 5, 0, 255, 255, 77, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 9, 104, 101, 108, 108, 111, ], # 2 valid - [ - 2, - 0, - 62, - 0, - 255, - 255, - 30, - 0, - 255, - 255, - 126, - 0, - 5, - 0, - 255, - 255, - 163, - 0, - 255, - 255, - 131, - 0, - 255, - 255, - 227, - 0, - 5, - 0, - 255, - 255, - 77, - 24, - 168, - 156, - 166, - 0, - 87, - 128, - 189, - 248, - 212, - 58, - 28, - 154, - 34, - 186, - 179, - 37, - 7, - 189, - 36, - 105, - 135, - 255, - 37, - 58, - 68, - 162, - 199, - 239, - 98, - 214, - 47, - 43, - 230, - 141, - 139, - 231, - 170, - 75, - 55, - 76, - 78, - 200, - 97, - 43, - 17, - 24, - 225, - 143, - 160, - 169, - 12, - 27, - 16, - 219, - 4, - 218, - 114, - 30, - 149, - 132, - 33, - 178, - 94, - 40, - 150, - 10, - 243, - 203, - 248, - 194, - 243, - 66, - 51, - 212, - 101, - 196, - 7, - 121, - 101, - 161, - 171, - 161, - 88, - 6, - 129, - 191, - 191, - 157, - 230, - 170, - 180, - 16, - 67, - 9, - 104, - 101, - 108, - 108, - 111, - 75, - 214, - 129, - 151, - 244, - 149, - 70, - 192, - 102, - 135, - 224, - 99, - 199, - 172, - 238, - 204, - 3, - 67, - 253, - 92, - 104, - 212, - 24, - 116, - 243, - 199, - 49, - 42, - 20, - 156, - 143, - 83, - 1, - 148, - 145, - 203, - 46, - 109, - 182, - 75, - 135, - 218, - 65, - 3, - 176, - 77, - 9, - 53, - 33, - 86, - 42, - 178, - 80, - 169, - 11, - 169, - 251, - 61, - 180, - 51, - 167, - 39, - 34, - 189, - 140, - 51, - 151, - 209, - 50, - 76, - 167, - 90, - 205, - 1, - 57, - 197, - 149, - 97, - 99, - 241, - 191, - 66, - 222, - 90, - 0, - 251, - 220, - 145, - 101, - 24, - 220, - 32, - 183, - 0, - 19, - 5, - 104, - 101, - 108, - 108, - 111, - ], + [ 2, 0, 62, 0, 255, 255, 30, 0, 255, 255, 126, 0, 5, 0, 255, 255, 163, 0, 255, 255, 131, 0, 255, 255, 227, 0, 5, 0, 255, 255, 77, 24, 168, 156, 166, 0, 87, 128, 189, 248, 212, 58, 28, 154, 34, 186, 179, 37, 7, 189, 36, 105, 135, 255, 37, 58, 68, 162, 199, 239, 98, 214, 47, 43, 230, 141, 139, 231, 170, 75, 55, 76, 78, 200, 97, 43, 17, 24, 225, 143, 160, 169, 12, 27, 16, 219, 4, 218, 114, 30, 149, 132, 33, 178, 94, 40, 150, 10, 243, 203, 248, 194, 243, 66, 51, 212, 101, 196, 7, 121, 101, 161, 171, 161, 88, 6, 129, 191, 191, 157, 230, 170, 180, 16, 67, 9, 104, 101, 108, 108, 111, 75, 214, 129, 151, 244, 149, 70, 192, 102, 135, 224, 99, 199, 172, 238, 204, 3, 67, 253, 92, 104, 212, 24, 116, 243, 199, 49, 42, 20, 156, 143, 83, 1, 148, 145, 203, 46, 109, 182, 75, 135, 218, 65, 3, 176, 77, 9, 53, 33, 86, 42, 178, 80, 169, 11, 169, 251, 61, 180, 51, 167, 39, 34, 189, 140, 51, 151, 209, 50, 76, 167, 90, 205, 1, 57, 197, 149, 97, 99, 241, 191, 66, 222, 90, 0, 251, 220, 145, 101, 24, 220, 32, 183, 0, 19, 5, 104, 101, 108, 108, 111, ], ] +# fmt: on # test vectors from wycheproofs and cctv @@ -1414,6 +110,9 @@ def wycheproofs_ed25519(): continue pubkey = bytes.fromhex(group["key"]["pk"]) for test in group["tests"]: + # skip test #83 because it exceeds tx size + if test["tcId"] == 83: + continue verify_tests.append( EddsaVerify( tcId=test["tcId"], @@ -1521,23 +220,41 @@ def _into_key_data(key_prefix, test_vectors): ) program_id = fd58.dec32(bytes(program_id, "utf-8")) -program_owner = fd58.dec32( - bytes("NativeLoader1111111111111111111111111111111", "utf-8") -) + +signer = fd58.dec32(bytes("BWbmXj5ckAaWCAtzMZ97qnJhBAKegoXtgNrv9BUpAB11", "utf-8")) +signer_owner = bytes([0] * 32) +signer_lamports = 1_000_000_000 + for key, test in test_vectors: - instr_ctx = invoke_pb.InstrContext() - instr_ctx.program_id = program_id - instr_ctx.data = bytes(test) + txn_ctx = txn_pb.TxnContext() + + txn_ctx.tx.message.account_keys.extend( + [ + signer, + program_id, + ] + ) - account = context_pb.AcctState() - account.address = program_id - account.owner = program_owner - instr_ctx.accounts.extend([account]) - instr_ctx.epoch_context.features.features.extend([0x91a7af96555ea309]) + signer_account = context_pb.AcctState() + signer_account.address = signer + signer_account.owner = signer_owner + signer_account.lamports = signer_lamports + txn_ctx.tx.message.account_shared_data.extend([signer_account]) + + ix = txn_pb.CompiledInstruction() + ix.program_id_index = 1 + ix.data = bytes(test) + txn_ctx.tx.message.instructions.extend([ix]) + + txn_ctx.epoch_ctx.features.features.extend( + [ + 0x91A7AF96555EA309, # ed25519_precompile_verify_strict + ] + ) - serialized_instr = instr_ctx.SerializeToString(deterministic=True) - filename = str(key) + "_" + hashlib.sha3_256(serialized_instr).hexdigest()[:16] + serialized_txn = txn_ctx.SerializeToString(deterministic=True) + filename = str(key) + "_" + hashlib.sha3_256(serialized_txn).hexdigest()[:16] with open(f"{OUTPUT_DIR}/{filename}.bin", "wb") as f: - f.write(serialized_instr) + f.write(serialized_txn) print("done!") diff --git a/generators/secp256k1.py b/generators/secp256k1.py index 47bbf83..8b5b8c9 100644 --- a/generators/secp256k1.py +++ b/generators/secp256k1.py @@ -1,17 +1,16 @@ import fd58 import hashlib from eth_hash.auto import keccak -import test_suite.invoke_pb2 as invoke_pb import test_suite.context_pb2 as context_pb +import test_suite.txn_pb2 as txn_pb from dataclasses import dataclass -import requests -OUTPUT_DIR = "./test-vectors/precompile/tests/secp256k1" +OUTPUT_DIR = "./test-vectors/txn/tests/precompile/secp256k1" program_id = "KeccakSecp256k11111111111111111111111111111" -accounts = [] # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/secp256k1_instruction.rs#L1039 +# fmt: off test_vectors_agave = [ # test_count_is_zero_but_sig_data_exists [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], @@ -32,602 +31,20 @@ [1, 0, 0, 0, 0, 0, 0, 100, 0, 232, 3, 0], [1, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0], # test_secp256k1 - [ - 1, - 32, - 0, - 0, - 12, - 0, - 0, - 97, - 0, - 5, - 0, - 0, - 129, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, - 14, - 196, - 198, - 193, - 237, - 0, - 14, - 83, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, - 1, - 104, - 101, - 108, - 108, - 111, - ], - [ - 1, - 32, - 12, - 0, - 12, - 0, - 0, - 97, - 0, - 5, - 0, - 0, - 129, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, - 14, - 196, - 198, - 193, - 237, - 0, - 14, - 83, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, - 1, - 104, - 101, - 108, - 108, - 111, - ], + [ 1, 32, 0, 0, 12, 0, 0, 97, 0, 5, 0, 0, 129, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101, 14, 196, 198, 193, 237, 0, 14, 83, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, 1, 104, 101, 108, 108, 111, ], + [ 1, 32, 12, 0, 12, 0, 0, 97, 0, 5, 0, 0, 129, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101, 14, 196, 198, 193, 237, 0, 14, 83, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, 1, 104, 101, 108, 108, 111, ], # test_malleability - [ - 2, - 23, - 0, - 0, - 88, - 0, - 0, - 108, - 0, - 5, - 0, - 0, - 113, - 0, - 0, - 178, - 0, - 0, - 198, - 0, - 5, - 0, - 0, - 8, - 106, - 2, - 17, - 228, - 135, - 168, - 210, - 219, - 113, - 75, - 102, - 239, - 51, - 218, - 230, - 218, - 125, - 149, - 73, - 201, - 61, - 102, - 253, - 170, - 115, - 201, - 14, - 162, - 243, - 11, - 22, - 90, - 90, - 242, - 118, - 196, - 38, - 97, - 5, - 74, - 132, - 110, - 172, - 168, - 204, - 248, - 224, - 162, - 249, - 64, - 95, - 48, - 88, - 72, - 56, - 157, - 16, - 4, - 2, - 165, - 47, - 207, - 113, - 0, - 45, - 237, - 4, - 121, - 189, - 201, - 77, - 37, - 225, - 171, - 23, - 82, - 196, - 28, - 174, - 59, - 124, - 136, - 139, - 245, - 104, - 101, - 108, - 108, - 111, - 8, - 106, - 2, - 17, - 228, - 135, - 168, - 210, - 219, - 113, - 75, - 102, - 239, - 51, - 218, - 230, - 218, - 125, - 149, - 73, - 201, - 61, - 102, - 253, - 170, - 115, - 201, - 14, - 162, - 243, - 11, - 22, - 165, - 165, - 13, - 137, - 59, - 217, - 158, - 250, - 181, - 123, - 145, - 83, - 87, - 51, - 7, - 30, - 23, - 181, - 156, - 135, - 126, - 240, - 88, - 3, - 34, - 194, - 90, - 138, - 43, - 6, - 113, - 208, - 1, - 45, - 237, - 4, - 121, - 189, - 201, - 77, - 37, - 225, - 171, - 23, - 82, - 196, - 28, - 174, - 59, - 124, - 136, - 139, - 245, - 104, - 101, - 108, - 108, - 111, - ], + [ 2, 23, 0, 0, 88, 0, 0, 108, 0, 5, 0, 0, 113, 0, 0, 178, 0, 0, 198, 0, 5, 0, 0, 8, 106, 2, 17, 228, 135, 168, 210, 219, 113, 75, 102, 239, 51, 218, 230, 218, 125, 149, 73, 201, 61, 102, 253, 170, 115, 201, 14, 162, 243, 11, 22, 90, 90, 242, 118, 196, 38, 97, 5, 74, 132, 110, 172, 168, 204, 248, 224, 162, 249, 64, 95, 48, 88, 72, 56, 157, 16, 4, 2, 165, 47, 207, 113, 0, 45, 237, 4, 121, 189, 201, 77, 37, 225, 171, 23, 82, 196, 28, 174, 59, 124, 136, 139, 245, 104, 101, 108, 108, 111, 8, 106, 2, 17, 228, 135, 168, 210, 219, 113, 75, 102, 239, 51, 218, 230, 218, 125, 149, 73, 201, 61, 102, 253, 170, 115, 201, 14, 162, 243, 11, 22, 165, 165, 13, 137, 59, 217, 158, 250, 181, 123, 145, 83, 87, 51, 7, 30, 23, 181, 156, 135, 126, 240, 88, 3, 34, 194, 90, 138, 43, 6, 113, 208, 1, 45, 237, 4, 121, 189, 201, 77, 37, 225, 171, 23, 82, 196, 28, 174, 59, 124, 136, 139, 245, 104, 101, 108, 108, 111, ], ] prefix = [1, 32, 0, 0, 12, 0, 0, 97, 0, 5, 0, 0] prefix_alt = [1, 37, 0, 0, 12, 0, 0, 32, 0, 5, 0, 0] ## swap sig, msg -pubkey = [ - 129, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, -] -pubkey_err = [ - 111, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, -] -sig = [ - 14, - 196, - 198, - 193, - 237, - 0, - 14, - 83, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, -] +pubkey = [ 129, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101, ] +pubkey_err = [ 111, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101 ] sig_invalid = [255] * 64 -sig_err = [ - 14, - 196, - 198, - 193, - 237, - 0, - 14, - 255, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, -] -# ^^^ modified byte +sig = [ 14, 196, 198, 193, 237, 0, 14, 83, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, ] +sig_err = [ 14, 196, 198, 193, 237, 0, 14, 255, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, ] +# ^^^ modified byte recid = 1 msg = [104, 101, 108, 108, 111] # hello @@ -656,111 +73,8 @@ # tested above # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/secp256k1_instruction.rs#L975-L978 # signature fails to decode - [ - 1, - 32, - 0, - 0, - 12, - 0, - 0, - 97, - 0, - 5, - 0, - 0, - 129, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, - 255, - 196, - 198, - 193, - 237, - 0, - 14, - 83, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, - 1, - 104, - 101, - 108, - 108, - 111, - ], - # \--- pubkey (eth) ---/ \--- sig ---/ \--- msg ---/ + [ 1, 32, 0, 0, 12, 0, 0, 97, 0, 5, 0, 0, 129, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101, 255, 196, 198, 193, 237, 0, 14, 83, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, 1, 104, 101, 108, 108, 111, ], + # \--- pubkey (eth) ---/ \--- sig ---/ \--- msg ---/ # InvalidRecoveryId (result: 2) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/secp256k1_instruction.rs#L981C43-L981C60 prefix + pubkey + sig + [4] + msg, @@ -774,423 +88,14 @@ # InvalidSignature (result: 3) # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/secp256k1_instruction.rs#L1003-L1008 # signature fails to verify - [ - 1, - 32, - 0, - 0, - 12, - 0, - 0, - 97, - 0, - 5, - 0, - 0, - 129, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, - 14, - 196, - 198, - 193, - 237, - 0, - 14, - 83, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, - 1, - 104, - 101, - 108, - 108, - 255, - ], - [ - 2, - 23, - 0, - 0, - 88, - 0, - 0, - 108, - 0, - 5, - 0, - 0, - 113, - 0, - 0, - 178, - 0, - 0, - 198, - 0, - 5, - 0, - 0, - 8, - 106, - 2, - 17, - 228, - 135, - 168, - 210, - 219, - 113, - 75, - 102, - 239, - 51, - 218, - 230, - 218, - 125, - 149, - 73, - 201, - 61, - 102, - 253, - 170, - 115, - 201, - 14, - 162, - 243, - 11, - 22, - 90, - 90, - 242, - 118, - 196, - 38, - 97, - 5, - 74, - 132, - 110, - 172, - 168, - 204, - 248, - 224, - 162, - 249, - 64, - 95, - 48, - 88, - 72, - 56, - 157, - 16, - 4, - 2, - 165, - 47, - 207, - 113, - 0, - 45, - 237, - 4, - 121, - 189, - 201, - 77, - 37, - 225, - 171, - 23, - 82, - 196, - 28, - 174, - 59, - 124, - 136, - 139, - 245, - 104, - 101, - 108, - 108, - 111, - 8, - 106, - 2, - 17, - 228, - 135, - 168, - 210, - 219, - 113, - 75, - 102, - 239, - 51, - 218, - 230, - 218, - 125, - 149, - 73, - 201, - 61, - 102, - 253, - 170, - 115, - 201, - 14, - 162, - 243, - 11, - 22, - 165, - 165, - 13, - 137, - 59, - 217, - 158, - 250, - 181, - 123, - 145, - 83, - 87, - 51, - 7, - 30, - 23, - 181, - 156, - 135, - 126, - 240, - 88, - 3, - 34, - 194, - 90, - 138, - 43, - 6, - 113, - 208, - 1, - 45, - 237, - 4, - 121, - 189, - 201, - 77, - 37, - 225, - 171, - 23, - 82, - 196, - 28, - 174, - 59, - 124, - 136, - 139, - 245, - 104, - 101, - 108, - 108, - 255, - ], + [ 1, 32, 0, 0, 12, 0, 0, 97, 0, 5, 0, 0, 129, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101, 14, 196, 198, 193, 237, 0, 14, 83, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, 1, 104, 101, 108, 108, 255, ], + [ 2, 23, 0, 0, 88, 0, 0, 108, 0, 5, 0, 0, 113, 0, 0, 178, 0, 0, 198, 0, 5, 0, 0, 8, 106, 2, 17, 228, 135, 168, 210, 219, 113, 75, 102, 239, 51, 218, 230, 218, 125, 149, 73, 201, 61, 102, 253, 170, 115, 201, 14, 162, 243, 11, 22, 90, 90, 242, 118, 196, 38, 97, 5, 74, 132, 110, 172, 168, 204, 248, 224, 162, 249, 64, 95, 48, 88, 72, 56, 157, 16, 4, 2, 165, 47, 207, 113, 0, 45, 237, 4, 121, 189, 201, 77, 37, 225, 171, 23, 82, 196, 28, 174, 59, 124, 136, 139, 245, 104, 101, 108, 108, 111, 8, 106, 2, 17, 228, 135, 168, 210, 219, 113, 75, 102, 239, 51, 218, 230, 218, 125, 149, 73, 201, 61, 102, 253, 170, 115, 201, 14, 162, 243, 11, 22, 165, 165, 13, 137, 59, 217, 158, 250, 181, 123, 145, 83, 87, 51, 7, 30, 23, 181, 156, 135, 126, 240, 88, 3, 34, 194, 90, 138, 43, 6, 113, 208, 1, 45, 237, 4, 121, 189, 201, 77, 37, 225, 171, 23, 82, 196, 28, 174, 59, 124, 136, 139, 245, 104, 101, 108, 108, 255, ], # https://github.com/anza-xyz/agave/blob/v1.18.12/sdk/src/secp256k1_instruction.rs#L1003-L1008 # sig returns incorrect pubkey - [ - 1, - 32, - 0, - 0, - 12, - 0, - 0, - 97, - 0, - 5, - 0, - 0, - 111, - 246, - 169, - 169, - 105, - 76, - 208, - 128, - 223, - 135, - 27, - 68, - 249, - 42, - 201, - 69, - 55, - 2, - 173, - 101, - 14, - 196, - 198, - 193, - 237, - 0, - 14, - 83, - 87, - 183, - 25, - 69, - 136, - 43, - 251, - 73, - 44, - 194, - 141, - 230, - 102, - 16, - 220, - 6, - 46, - 214, - 214, - 125, - 120, - 16, - 103, - 254, - 39, - 121, - 88, - 223, - 156, - 229, - 186, - 211, - 38, - 101, - 196, - 233, - 125, - 150, - 136, - 177, - 123, - 197, - 48, - 219, - 28, - 26, - 10, - 76, - 198, - 127, - 91, - 80, - 88, - 191, - 6, - 3, - 1, - 104, - 101, - 108, - 108, - 111, - ], - # \--- pubkey (eth) ---/ \--- sig ---/ \--- msg ---/ + [ 1, 32, 0, 0, 12, 0, 0, 97, 0, 5, 0, 0, 111, 246, 169, 169, 105, 76, 208, 128, 223, 135, 27, 68, 249, 42, 201, 69, 55, 2, 173, 101, 14, 196, 198, 193, 237, 0, 14, 83, 87, 183, 25, 69, 136, 43, 251, 73, 44, 194, 141, 230, 102, 16, 220, 6, 46, 214, 214, 125, 120, 16, 103, 254, 39, 121, 88, 223, 156, 229, 186, 211, 38, 101, 196, 233, 125, 150, 136, 177, 123, 197, 48, 219, 28, 26, 10, 76, 198, 127, 91, 80, 88, 191, 6, 3, 1, 104, 101, 108, 108, 111, ], + # \--- pubkey (eth) ---/ \--- sig ---/ \--- msg ---/ ] +# fmt: on def _into_key_data(key_prefix, test_vectors): @@ -1204,24 +109,42 @@ def _into_key_data(key_prefix, test_vectors): ) program_id = fd58.dec32(bytes(program_id, "utf-8")) -program_owner = fd58.dec32( - bytes("NativeLoader1111111111111111111111111111111", "utf-8") -) + +signer = fd58.dec32(bytes("BWbmXj5ckAaWCAtzMZ97qnJhBAKegoXtgNrv9BUpAB11", "utf-8")) +signer_owner = bytes([0] * 32) +signer_lamports = 1_000_000_000 + for key, test in test_vectors: - instr_ctx = invoke_pb.InstrContext() - instr_ctx.program_id = program_id - instr_ctx.data = bytes(test) + txn_ctx = txn_pb.TxnContext() + + txn_ctx.tx.message.account_keys.extend( + [ + signer, + program_id, + ] + ) + + signer_account = context_pb.AcctState() + signer_account.address = signer + signer_account.owner = signer_owner + signer_account.lamports = signer_lamports + txn_ctx.tx.message.account_shared_data.extend([signer_account]) + + ix = txn_pb.CompiledInstruction() + ix.program_id_index = 1 + ix.data = bytes(test) + txn_ctx.tx.message.instructions.extend([ix]) - account = context_pb.AcctState() - account.address = program_id - account.owner = program_owner - instr_ctx.accounts.extend([account]) - instr_ctx.instr_accounts.extend([invoke_pb.InstrAcct()]) - instr_ctx.epoch_context.features.features.extend([0x1A6958DB2FF09870]) + txn_ctx.epoch_ctx.features.features.extend( + [ + 0x1A6958DB2FF09870, # libsecp256k1_fail_on_bad_count + 0x15766BA9A908483C, # libsecp256k1_fail_on_bad_count2 + ] + ) - serialized_instr = instr_ctx.SerializeToString(deterministic=True) - filename = str(key) + "_" + hashlib.sha3_256(serialized_instr).hexdigest()[:16] + serialized_txn = txn_ctx.SerializeToString(deterministic=True) + filename = str(key) + "_" + hashlib.sha3_256(serialized_txn).hexdigest()[:16] with open(f"{OUTPUT_DIR}/{filename}.bin", "wb") as f: - f.write(serialized_instr) + f.write(serialized_txn) print("done!") diff --git a/generators/zksdk.py b/generators/zksdk.py index 8011d1d..53cb268 100644 --- a/generators/zksdk.py +++ b/generators/zksdk.py @@ -10,35 +10,37 @@ program_id = "ZkE1Gama1Proof11111111111111111111111111111" accounts = [] + class ix(Enum): - CloseContextState = 0, - VerifyZeroCiphertext = 1, - VerifyCiphertextCiphertextEquality = 2, - VerifyCiphertextCommitmentEquality = 3, - VerifyPubkeyValidity = 4, - VerifyPercentageWithCap = 5, - VerifyBatchedRangeProofU64 = 6, - VerifyBatchedRangeProofU128 = 7, - VerifyBatchedRangeProofU256 = 8, - VerifyGroupedCiphertext2HandlesValidity = 9, - VerifyBatchedGroupedCiphertext2HandlesValidity = 10, - VerifyGroupedCiphertext3HandlesValidity = 11, - VerifyBatchedGroupedCiphertext3HandlesValidity = 12, + CloseContextState = (0,) + VerifyZeroCiphertext = (1,) + VerifyCiphertextCiphertextEquality = (2,) + VerifyCiphertextCommitmentEquality = (3,) + VerifyPubkeyValidity = (4,) + VerifyPercentageWithCap = (5,) + VerifyBatchedRangeProofU64 = (6,) + VerifyBatchedRangeProofU128 = (7,) + VerifyBatchedRangeProofU256 = (8,) + VerifyGroupedCiphertext2HandlesValidity = (9,) + VerifyBatchedGroupedCiphertext2HandlesValidity = (10,) + VerifyGroupedCiphertext3HandlesValidity = (11,) + VerifyBatchedGroupedCiphertext3HandlesValidity = (12,) + CTX_STATE_LEN = [ 0, - 3 * 32, # VerifyZeroCiphertext - 6 * 32, # VerifyCiphertextCiphertextEquality - 4 * 32, # VerifyCiphertextCommitmentEquality - 1 * 32, # VerifyPubkeyValidity + 3 * 32, # VerifyZeroCiphertext + 6 * 32, # VerifyCiphertextCiphertextEquality + 4 * 32, # VerifyCiphertextCommitmentEquality + 1 * 32, # VerifyPubkeyValidity 3 * 32 + 8, # VerifyPercentageWithCap 8 * 32 + 8, # VerifyBatchedRangeProofU64 8 * 32 + 8, # VerifyBatchedRangeProofU128 8 * 32 + 8, # VerifyBatchedRangeProofU256 - 5 * 32, # VerifyGroupedCiphertext2HandlesValidity - 8 * 32, # VerifyBatchedGroupedCiphertext2HandlesValidity - 7 * 32, # VerifyGroupedCiphertext3HandlesValidity - 11 * 32, # VerifyBatchedGroupedCiphertext3HandlesValidity + 5 * 32, # VerifyGroupedCiphertext2HandlesValidity + 8 * 32, # VerifyBatchedGroupedCiphertext2HandlesValidity + 7 * 32, # VerifyGroupedCiphertext3HandlesValidity + 11 * 32, # VerifyBatchedGroupedCiphertext3HandlesValidity ] test_vectors_agave = [ @@ -54,13 +56,13 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", - ] + ], }, { # general case: encryption of > 0 @@ -69,107 +71,107 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "5ebdea7de36c7b07cdfd618167c91252834ef484cde91d1bf6d57a46b994973c", "8243dac0622ff89fbe3adaf65517510002bdd89262724749383fb5631e394e51", - "a682b5ec9826c088eec4e73eb32e44dd6aafe82e4dc81a8232228674c44a0f0f", # proof + "a682b5ec9826c088eec4e73eb32e44dd6aafe82e4dc81a8232228674c44a0f0f", # proof "12e1f9a9b28f8369087d2634a6ace3bc5c022f1c0c8b75e7e6f9e74d2134177c", "e3f971442fb3980feb89723edb8371cf55d313591b26c27dbfc7922e82811200", - ] + ], }, { # amount = 0 "ix": ix.VerifyCiphertextCiphertextEquality, "cu": 8_000, "data": [ - "6203276d8810327eeccbe1fcde04630ff250e94d49a437e51a6f2d4d9590bd21", # context + "6203276d8810327eeccbe1fcde04630ff250e94d49a437e51a6f2d4d9590bd21", # context "745458e97ec64727f8a67a7436b7557c0b8f891e44c9c136f6d58014fae34b5a", "e646b35db798d5405795bd1bb214059a7fc216237124732f1b823e30f8a78a18", "448ff1b685a53c6762d5e99dccd7eca83ffadc42f7e91bd58e4eed3d60bef743", "b8c6766f725b6788522d2bf259acc441286e38744a0511324d4ca4f5e1b17425", "6edc925435cd6472ba90e2c2e3a5c2ffd69d2902beb8ede2b1a6cc1e27f2e609", - "7e6104e02e4351bb8de580abe38bad577e9eeb71b3542d4ea55ef10768487c45", # proof + "7e6104e02e4351bb8de580abe38bad577e9eeb71b3542d4ea55ef10768487c45", # proof "20b2366fc926ff2e8ce9a9e1a89e3f1ff0ccae530284dd71ae3a44988924014b", "58f080067a2d07c1e54ae6fbc4371cf1cea6bf4bc3297f29c244e3f85ea7785f", "02f827c666a2de308bfa6329a69f75eb90badf1ebf8db02567fd93bcfc98ba68", "408a076b4ee323504aa7d3486c815b0ff5d5d1706e7a5d95580dbe298247880e", "1e7705737c330ecc93565ce24156259c680e1ff9035038498ae87d4b1977cd05", "b2db2991ecb27bb6178d878dec5a791634faca7a9d6e829e2777335f32c01b07", - ] + ], }, { # amount = 55 "ix": ix.VerifyCiphertextCiphertextEquality, "cu": 8_000, "data": [ - "6203276d8810327eeccbe1fcde04630ff250e94d49a437e51a6f2d4d9590bd21", # context + "6203276d8810327eeccbe1fcde04630ff250e94d49a437e51a6f2d4d9590bd21", # context "745458e97ec64727f8a67a7436b7557c0b8f891e44c9c136f6d58014fae34b5a", "8865734bf7df68f0b38fb912e01d8649aa8a36b9b76060c974caac3ad3cb3c01", "feac55eb5566f7b291bd04fbcf734ea39f33f70eb8bb9c838a6f94b4a4055018", "2c7ebfb0fc1cd268575d73e5580cb1b567e00a27f46c0efb0d3324335d1bee78", "cc3cde7f28a2fb54fc1f09ebd12792de31fd56bc3532b3f3d5b11c110533e95e", - "d2507d05a62c466d34f86c93a079697c3590bb9003e7ccbe2148f1fd35379b1b", # proof + "d2507d05a62c466d34f86c93a079697c3590bb9003e7ccbe2148f1fd35379b1b", # proof "5c4aa6ff20096d0f3fc9124d1ba6ad00e20d80fe87781ccfea6581aa7f822055", "2e2e4479069f8701a546c82b9e3f12f11b43f913f6e6225f87675fabdbc3a528", "769a3f877a9b69e3d380d130b11378a0d89634baaece3957136a79717ef0fc79", "3a16a7543fcbb935bf5ffa0338b3b443ec520712286abaaa8a79ae09340c2c05", "d55a9406112b1c42ff0f9be91306825e319e3e23cba8d526217b0c64bafee80b", "37e9774e91868cdf3a80d4176b2735b5238509782beb46ac9639949e5d49df0b", - ] + ], }, { # amount = u64::MAX "ix": ix.VerifyCiphertextCiphertextEquality, "cu": 8_000, "data": [ - "6203276d8810327eeccbe1fcde04630ff250e94d49a437e51a6f2d4d9590bd21", # context + "6203276d8810327eeccbe1fcde04630ff250e94d49a437e51a6f2d4d9590bd21", # context "745458e97ec64727f8a67a7436b7557c0b8f891e44c9c136f6d58014fae34b5a", "acdb17462a7ee7e143ef0c4ab0dd9b53fa50ea4baedce266c940b13e09080903", "bc671397d5e16e6ad4e752e3e0025dd9cef5012d68b6b6a91b1d151322259410", "ae79869896b1c732dff245c6a970a81922f5b3b0c877da30b2bf2e39393d087e", "06c0b007cb5bc06c9d2bb78eda95d63ece9371d5aec89c1c8518b62ec2eff836", - "dc0238da29425bb40588e3f3593c246e359e10d11f23cd5393db6b4268b4e954", # proof + "dc0238da29425bb40588e3f3593c246e359e10d11f23cd5393db6b4268b4e954", # proof "0c3cecc3425401561f828dd95bd8b2e05c53145fa602d4445330b3bf442c6541", "b61d64ca455b8d7eedeaac7f6e71603a817bd9ed29b4e6ad69176cfa26886174", "5cb1bb0d52afe8ab1ea0854c8f8da83f53f33a245e5c6f2765e456e232fc0178", "487717f393bb1a75f4b82c79e4876299c58109e2cf7202d172f565d461810402", "68afd7dbe77d8ef21be7f9454df8cd31164b2a52b72c3f1009128ab7f6776c07", "b18a7d0ce6e3b781b31620fe1e9e76eb6ca84def8b05235b451f6d0aaaaa5501", - ] + ], }, { "ix": ix.VerifyCiphertextCommitmentEquality, "cu": 6_400, "data": [ - "da90fe53085362f1a2c9e744c9e63ef22e25e92244da958b26353be64927456f", # context + "da90fe53085362f1a2c9e744c9e63ef22e25e92244da958b26353be64927456f", # context "a87b22ff89e686cb2e77d7c41a511a32b4f6005acf9729b509e6ed277d65666b", "9e02767403d9f601f97fdc6b994781c95b498ffc0da248ebd361da78e324a455", "226ca48cb9f90f5a314d0d5498dfcd61087bb788f356eea98aa63bc00ba30764", - "50e3d9247328ee1316c821904878378950b1f1e4c7c4f084ccf6d7ca96725e59", # proof + "50e3d9247328ee1316c821904878378950b1f1e4c7c4f084ccf6d7ca96725e59", # proof "f857d456e45d927d5fa61bb22ee9617ef1fbeb3bb83d4b80802e22d5e9588716", "b6047476954068f3dc0f0cd8636a149f4722f71ea4f2d68287f352539c43b901", "6fafc54f9817635113f6615a198c81650ddb8f4284853d83feee69469be0790f", "e03048146cf8982c356dbdfa3d2431e579afd3a8e2836a8c640cb65b7bf54803", "3fa0f9bf71497419e542b1e454ae14700622b1beee05a86d06ec5dd4e60ed90a", - ] + ], }, { "ix": ix.VerifyPubkeyValidity, "cu": 2_600, "data": [ - "fa89ae0c8312aba69e727036a794b5add351b020e43c65ea94cdda8d8f8c2037", # context - "80395515497f92fa09ebdb5f14b7f6b32ab8abc3bf7349394b538fb3959c8c4b", # proof + "fa89ae0c8312aba69e727036a794b5add351b020e43c65ea94cdda8d8f8c2037", # context + "80395515497f92fa09ebdb5f14b7f6b32ab8abc3bf7349394b538fb3959c8c4b", # proof "0e5cdb1f8f9aeb2fd374b89beafaf2f47a0b83558a7ef94629b07101f50b0007", - ] + ], }, { "ix": ix.VerifyPercentageWithCap, "cu": 6_500, "data": [ - "c033774789b2fc16b632192638070e15b6b59852488d9f2a92c758e90b30a45f", # context + "c033774789b2fc16b632192638070e15b6b59852488d9f2a92c758e90b30a45f", # context "f8691d53d5d8e1444e9a3eefd1f6e0fb6c6ed08f31a0b86e265454e097e1f219", "7649f6d240769e77c186a610ea5a9c9942d1e6f98031ac38693f1f63d9023107", - "0300000000000000", # proof + "0300000000000000", # proof "747e6ea4ae760a10728adf0916526562f3ce32e905c4fc724a6ae4be7cca1e1b", "8bb081de00196a204258893e3b1b6af6c55b2e90f91a2d91fbc01c0fe8f20a08", "d3b14114d91fee677cbd6471a27a2c3df2cfe680cd9f169cc19a3837668e5209", @@ -178,16 +180,16 @@ class ix(Enum): "d1034395df8f507896d247f1003333b0bc1d31514c4d56ec774713c9cd70e200", "b47e3d15dcadd2dabd8bf392fa564b0a0b170cf4341e6f4bbeb6656600038d03", "48bc7b57bf09b1c432d9f66c925cb4fad1c3d5ae37a90235a56ef21d7f0c6000", - ] + ], }, { "ix": ix.VerifyPercentageWithCap, "cu": 6_500, "data": [ - "1223b394709edb8003d23630597f5a58eac0894d1bcef409cbb597e8b5269f5f", # context + "1223b394709edb8003d23630597f5a58eac0894d1bcef409cbb597e8b5269f5f", # context "242777cd165c5b2931163d1712bf0aaba3ee58176b01d29afe5ab424d5b7b705", "dc4ccbd5728ceb309b1d49d18f3bee3f62b4e290a514a8e28d0600245b99722c", - "0300000000000000", # proof + "0300000000000000", # proof "5678659d22f233faf43255f4e2965f01eb9bcb6081ef5638e8547b40e048d452", "8525ea544486c7d5c0c49367fc195023e734a81f97eb27f5ac7846dab4a34407", "b94684c2752461882c61b7d202d8885aeda0356629265ae7427d69f6fd62fb0f", @@ -196,7 +198,7 @@ class ix(Enum): "f262079021451a0970b49646b60462cf4ac4bd6feb709ba6df1d90f84fc74b0a", "bfc6497a0661a4379447de1038017a43833d4b77f7aff40d0f6c31eb5a81a605", "3d0af260d8a61f67fec606424d6ebdd20b62435e230ed75366d052f475e4130a", - ] + ], }, { "ix": ix.VerifyBatchedRangeProofU64, @@ -232,7 +234,7 @@ class ix(Enum): "268fb9acbc6a043d84f9c57c6c0d67f0300a48b288a1b95e7d444a3f118a3038", "122dd6f4f0880a6fea2f0133478920aa417a46bf9cc022ac8374855eedab5c0f", "32725bbda4ec74db73868fbc7b7f432c7456800d5ca582dbda673f402a097a00", - ] + ], }, { # error @@ -269,7 +271,7 @@ class ix(Enum): "ae51e45566a606bf2e430b19cbdd8bb23bf9bc812bc4a53184a395e334397e51", "28bb560f21664b30cc9b06a9e38291ad7b3e4b5897acb4eab18946fc93745101", "ba1910e4218177c32ea0cbbdef4b13ddb080470bc96d09803efcc1bf87ca260d", - ] + ], }, { "ix": ix.VerifyBatchedRangeProofU128, @@ -307,7 +309,7 @@ class ix(Enum): "1a6de22b76e8abf1f173941ad96122f71368c2a1f3b601f659898b4e3fd1e724", "450e0eac07d13ee2a717b3bf112f3004c651b1d1ceb630239ca972189fa1cb01", "376177ca7611edcdfbe559ccf054995bc070d3b65a0372498407729ef6ccc108", - ] + ], }, { # error @@ -346,7 +348,7 @@ class ix(Enum): "20b1256f8a3c315f4dc5259ffe939342339d9b68e1a7520aa062ea57dd7ca734", "847bea4cd799436f329e812f466c38a6156f28f1da43b068aa5ccc33161e380e", "67d3f6a21ef6a21b8bb77167ba7fde55741354a320dea17559ce9f6230a01508", - ] + ], }, { "ix": ix.VerifyBatchedRangeProofU256, @@ -386,7 +388,7 @@ class ix(Enum): "b669829fac57cd909057f8e05e43bfe67f00ee354963d336eabd584591adac43", "70e2258cdbdb260391aa226872d6d08df229ad3f80714ee8f3201c7045f51106", "41994266ce2f2e5eb9fe716ec1725ed66851995379887ecc58e48f74a5a5cc03", - ] + ], }, { # error @@ -427,29 +429,29 @@ class ix(Enum): "42eaf0ea920d897c30e7d853b818a57fc1d3c97b1ed33e5fb8cd9b97706bd361", "a8b6cdecfc711505dcb8383eeb8fb3df0af310741e116676f113c86db1cf6c07", "4ee5835aa263322fa24081745b33d7ce09a0841488941efff45da0f68cbe210d", - ] + ], }, { "ix": ix.VerifyGroupedCiphertext2HandlesValidity, "cu": 6_400, "data": [ - "be62251c7add74d775e10bf73f2b0ec9b9c90402fafa0ebd852f71fedd455362", # context + "be62251c7add74d775e10bf73f2b0ec9b9c90402fafa0ebd852f71fedd455362", # context "3645c13036eeaf849cb60fef10d68e4a1cd75ae24a3349ba856ae03066ec2330", "be0f4307defa2df4333eae951deac2a1e8c2e486f9974bb19acd6f727ab9693b", "942d695f6faded93be0ce6be58011416b0b7f78b872781e78b10f1ed8a0bcd6c", "5c46ec3e2cbf74dc2e1676ecf7bad5184dd64d67b6bb839330200f880d828673", - "0007dca6dd7e48f5b4065f37d099025d446e0de24a8890f861892522a4a69e61", # proof + "0007dca6dd7e48f5b4065f37d099025d446e0de24a8890f861892522a4a69e61", # proof "30007df0f98bf353173121c371756767da8b05d18e1ae607f47a92cdc3253108", "9257a74e93503a07617b702faaff558c40a2d480a96ea26c4e9f1573c430eb5d", "01a1f3c59403042008a197914902145470af007509a9c4261535db407f91f30d", "bfb586be5dea7f9e40315db6c111f35c1d44af7d878ac99cae03a3d166c1c40f", - ] + ], }, { "ix": ix.VerifyBatchedGroupedCiphertext2HandlesValidity, "cu": 13_000, "data": [ - "60612761dd6a8f1ed24bd67876dd6049c8b467095de391f4ece89e4f92b84e06", # context + "60612761dd6a8f1ed24bd67876dd6049c8b467095de391f4ece89e4f92b84e06", # context "628411b120cc9b6511da50016bcba22b578ea20015b76d4e2c8ddce4f5bfe875", "6c3234003259908268ffec19643c8dd9c25f576256167ed43320f7eac30b4176", "48c55b4be6d7a6c2eb607e7dadfce1a393cee5b776d48a8bd72451cbe9518b56", @@ -457,37 +459,37 @@ class ix(Enum): "82f9bfcce4e3d22bcec6590588796774f42c4f43562959eab0a3ef9db5661861", "80e3f0fc3faae381747ff912ab160401dbed49487103e2933b3f5fc8895b5a7c", "20cefb7f025fff1f0c24d04323ed3379c7876f7227be59afdaced91c19eff16b", - "aa1c9e26986cd4b5001a32f7bf050091084d98f7c44c54649e7f3e7e51b6ae3c", # proof + "aa1c9e26986cd4b5001a32f7bf050091084d98f7c44c54649e7f3e7e51b6ae3c", # proof "0896653095838a68539ee8d4a80260ef28a64c258bea5365f93a4bc1c1c85045", "64ed2adabc59b1efbb4c86837084568996516492809017837eb4aa3e5e36bd2b", "4206231378561cf497c190c3138c0c3b5a5385e09d04589b9374bb8e233bec0f", "f12b1058acc6e88673575065feaa1f5fc0f010c99dc0e4670643b1fc35155504", - ] + ], }, { "ix": ix.VerifyGroupedCiphertext3HandlesValidity, "cu": 8_100, "data": [ - "2c1e381203cfa2bb3b964e2863776aaf30176afc57e101c1ea8f0eb0f8cc5d5d", # context + "2c1e381203cfa2bb3b964e2863776aaf30176afc57e101c1ea8f0eb0f8cc5d5d", # context "485a15910b4882e8108d3e7266ece60a152fe7007d16d2c85d0f8514e743d825", "76385ddba81d932da799ddea964f9ae68628449c3f4bb802f998ddbc2797a978", "001ac6fb636a66d9ec677fbb58dab15a9889de74c76a32bfe82fc66ad4655a62", "8a2ee1fb2c06a91b1ef94f1907f2470833d076ae3b00f40da90286263a208073", "18053754653815c3f55c05e78bb5df7a98f99d112e7492460703f375d4b69629", "1ce7670beefb038eeeecdd4ad4a449428c4696fc00de63cdec5352e97f531267", - "7a9c1b463cc73ce83b635f58de5945bac4bfda10ec5bfb579674f2e083918d19", # proof + "7a9c1b463cc73ce83b635f58de5945bac4bfda10ec5bfb579674f2e083918d19", # proof "f00cd2eff5cf88d18b9a6959a3ab59b305264d84bd84be735608d12e42f5a25a", "78fa7d7ef8294d4f8c4931dcc94dc7c1f38982166b2a1cf2f170a3134fb8601b", "def50033244acb0eb0872f64435cfd69735e6812e0ae9cae7aa3bbad88382136", "60fc5981df779d3e4e35e2a96a0b90786703fd4fa933298ee01d2e5dfe165c04", "fc109d335735d894d2a18fdf5d68b710dd42d2e669671b0bceb5d62b16368e09", - ] + ], }, { "ix": ix.VerifyBatchedGroupedCiphertext3HandlesValidity, "cu": 16_400, "data": [ - "fe2c3db3f7a880950e51b7a9af3f3be489674d09f85dcb03fac06d99b2672b36", # context + "fe2c3db3f7a880950e51b7a9af3f3be489674d09f85dcb03fac06d99b2672b36", # context "ae3be9774285cbec5b1b0abf3cff387d501a3224920b32eeef8a7c4e725a9414", "2e3b971852aec1c512f405d125a13f19b3402a658e0e59cdcfad10d01a5c4042", "6610b6ef18ca43f9f285320ab8c5c989a51f725f501ead595fa63a541c348514", @@ -498,17 +500,17 @@ class ix(Enum): "0eee829d7dce7911d2c3b832f07ca53deb65380df73d757eb093c13e9e9aad26", "88b8ff8e1a02fdbf61768dbd9aba4e9f14d669a168d0c77ba181be327792534e", "8a3f47dca830330c97728812bdc8b66a1c057e8804301c7705d0b83a78e90f66", - "120b16282af1c2c1a3ded5bdf09fe5309b740c48e7e93c742ec49bf2e4ebbc36", # proof + "120b16282af1c2c1a3ded5bdf09fe5309b740c48e7e93c742ec49bf2e4ebbc36", # proof "6cc720b5aa33e6951f95138e5808853f178cf8f4d96d749083b41536b226f302", "a8d52b600177636ae3c9baf0b400fdbf534d7ebdcb9ab4b247c7cafc45c4a60c", "8407a35f0496ac37c048e39bd5a6f51575d49c8e46c1584586b032a2820a4b06", "9952beff7a02bc2fc00c4657d960a6a3b40ea79d71a62bf74971cd2c87bf1e0a", "479d96f9dfa7c96f46f789e099d875fa505b9228c2d0e915e361c39556f1190f", - ] + ], }, ] for test in test_vectors_agave: - test["data"] = base64.b16decode(''.join(test.get("data")), True) + test["data"] = base64.b16decode("".join(test.get("data")), True) # test cases for close_context_state ix test_vectors_close = [ @@ -516,28 +518,38 @@ class ix(Enum): # success "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "00" + "00", ], "is_writable": True, }, { # destination - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), # "is_writable": True, "is_signer": True, }, @@ -547,23 +559,30 @@ class ix(Enum): # success "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "ff" + "ff", ], "is_writable": True, }, { # destination + owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), "is_writable": True, "is_signer": True, }, @@ -580,23 +599,34 @@ class ix(Enum): "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "00" + "00", ], "is_writable": True, }, { # destination - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), "is_signer": True, }, ], @@ -605,28 +635,36 @@ class ix(Enum): # invalid proof account's owner "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), # "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "00" + "00", ], "is_writable": True, }, { # destination - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), "is_signer": True, }, ], @@ -636,28 +674,38 @@ class ix(Enum): # https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L136 "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "01" + "01", ], "is_writable": True, }, { # destination - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), # "is_signer": True, }, ], @@ -667,23 +715,30 @@ class ix(Enum): # https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L148 "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof == dest - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "01" + "01", ], "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), "is_signer": True, }, ], @@ -694,13 +749,17 @@ class ix(Enum): # https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L153-L154 "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", @@ -710,12 +769,18 @@ class ix(Enum): }, { # destination - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), "is_signer": True, }, ], @@ -725,44 +790,50 @@ class ix(Enum): # https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L158 "ix": ix.CloseContextState, "cu": 3300, - "data": [ - ], + "data": [], "accounts": [ { # proof - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "lamports": 12345, "data": [ "ff5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", - "01" + "01", ], "is_writable": True, }, { # destination - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "is_writable": True, }, { # owner - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), "is_signer": True, }, ], }, ] for test in test_vectors_close: - test["data"] = base64.b16decode(''.join(test.get("data", [])), True) + test["data"] = base64.b16decode("".join(test.get("data", [])), True) for account in test["accounts"]: - account["data"] = base64.b16decode(''.join(account.get("data", [])), True) + account["data"] = base64.b16decode("".join(account.get("data", [])), True) test_vectors_cu = [ - { - "ix": ix.CloseContextState, - "cu": 3300 - 1, - "data": bytes([]) - }, + {"ix": ix.CloseContextState, "cu": 3300 - 1, "data": bytes([])}, ] for test in test_vectors_agave: new_test = test.copy() @@ -791,11 +862,15 @@ class ix(Enum): test_vectors_account = [] for test in test_vectors_agave: new_test = test.copy() - new_test["accounts"] = [{ - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), - "data": test.get("data"), - }] - new_test["data"] = bytes([0]*4) # offset in account data + new_test["accounts"] = [ + { + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True + ), + "data": test.get("data"), + } + ] + new_test["data"] = bytes([0] * 4) # offset in account data test_vectors_account.append(new_test) # success tests where ctx is written in an account @@ -803,14 +878,23 @@ class ix(Enum): for test in test_vectors_agave: new_test = test.copy() ctx_state_len = 33 + CTX_STATE_LEN[test.get("ix").value[0]] - new_test["accounts"] = [{ - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), - "data": bytes([0]*ctx_state_len), - "is_writable": True, - }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - }] + new_test["accounts"] = [ + { + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), + "data": bytes([0] * ctx_state_len), + "is_writable": True, + }, + { + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True + ), + }, + ] test_vectors_write.append(new_test) # success tests where proof_data is read from an account and ctx is written in an account @@ -818,25 +902,36 @@ class ix(Enum): for test in test_vectors_agave: new_test = test.copy() ctx_state_len = 33 + CTX_STATE_LEN[test.get("ix").value[0]] - new_test["accounts"] = [{ - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), - "data": test.get("data"), - }, { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), - "data": bytes([0]*ctx_state_len), - "is_writable": True, - }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - }] - new_test["data"] = bytes([0]*4) # offset in account data + new_test["accounts"] = [ + { + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True + ), + "data": test.get("data"), + }, + { + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), + "data": bytes([0] * ctx_state_len), + "is_writable": True, + }, + { + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True + ), + }, + ] + new_test["data"] = bytes([0] * 4) # offset in account data test_vectors_account_write.append(new_test) # test cases for process_verify_proof workflow # we use VerifyZeroCiphertext as an example of ZKP test_vectors_verify = [ # Part I. Verify ZKP. - # Case 1. Proof data from account data. # https://github.com/anza-xyz/agave/blob/v2.0.1/programs/zk-elgamal-proof/src/lib.rs#L45-L76 { @@ -856,27 +951,40 @@ class ix(Enum): # ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], - }, { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + }, + { + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, - }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), + }, + { + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), }, ], }, @@ -906,7 +1014,10 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), } ], }, @@ -920,12 +1031,15 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", # "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], @@ -941,15 +1055,18 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", - "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra + "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra ], } ], @@ -963,16 +1080,19 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", - "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra + "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra ], } ], @@ -987,16 +1107,19 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", - "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra + "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra ], } ], @@ -1009,17 +1132,15 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", - "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra + "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", # extra ], }, - - # Part II. Store context data. { # fail - no accounts @@ -1027,14 +1148,14 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], - "accounts": [] + "accounts": [], }, { # fail - missing one account @@ -1042,16 +1163,19 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), }, ], }, @@ -1065,12 +1189,15 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], @@ -1087,18 +1214,24 @@ class ix(Enum): ], "accounts": [ { - "address": base64.b16decode("246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", True), + "address": base64.b16decode( + "246965896e3577be29b6edcd2b9a986539ce7a5478e89a029067e3f999b23fb5", + True, + ), "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], }, { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), }, ], }, @@ -1108,16 +1241,19 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), # "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), # "data": [ # "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof @@ -1128,8 +1264,11 @@ class ix(Enum): # "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1138,28 +1277,34 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), # "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], # "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1167,17 +1312,22 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), # "data": [ # "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof # "0000000000000000000000000000000000000000000000000000000000000000", # context @@ -1187,8 +1337,11 @@ class ix(Enum): # "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1197,16 +1350,19 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), # "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), # "data": [ # "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof @@ -1217,8 +1373,11 @@ class ix(Enum): "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1227,28 +1386,36 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], # "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1257,28 +1424,34 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), # "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1287,17 +1460,22 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), # "data": [ # "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof # "0000000000000000000000000000000000000000000000000000000000000000", # context @@ -1307,8 +1485,11 @@ class ix(Enum): "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1317,28 +1498,36 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", # "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1347,29 +1536,37 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", - "0000000000000000000000000000000000000000000000000000000000000000", # extra + "0000000000000000000000000000000000000000000000000000000000000000", # extra ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1378,28 +1575,36 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "000000000000000000000000000000000000000000000000000000000000000001", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000001", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1408,28 +1613,36 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "0000000000000000000000000000000000000000000000000000000000000000ff", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "0000000000000000000000000000000000000000000000000000000000000000ff", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1437,28 +1650,36 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "010000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0000000000000000000000000000000000000000000000000000000000000000", # context + "010000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0000000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, { @@ -1466,35 +1687,44 @@ class ix(Enum): "ix": ix.VerifyZeroCiphertext, "cu": 6_000, "data": [ - "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context + "e849bc396675d659c14fd2e0619abd9124bf1be40f3ef0e9b81cfe87e3e16b35", # context "7670194b708b5728e62b5bdac8fe672b13d378b746e7630c12f13cac3c179e26", "c883cc653e0737f7c866596d739ed3cfa3dcae9f4ce87306998e44ec4a073360", - "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof + "6467faff06ec0729956a25a76fd0af5219305cc6a963707928af35c29db13d2f", # proof "1ca133e5e58bcd46eb4927d55f487d98f6b6d3ce0a73c84be7084233f71ab864", "572e427f0f5a41d2ea66b90d07e3ab5ad9a2e3ba8b391b2eceec38e5a0e0650f", ], "accounts": [ { - "address": base64.b16decode("86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", True), - "owner": fd58.dec32(bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8")), + "address": base64.b16decode( + "86ddc6585609faef7c746983e0b198e432e9d1771d615ce2406e320c779f4a3d", + True, + ), + "owner": fd58.dec32( + bytes("ZkE1Gama1Proof11111111111111111111111111111", "utf-8") + ), "data": [ - "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof - "0100000000000000000000000000000000000000000000000000000000000000", # context + "000000000000000000000000000000000000000000000000000000000000000000", # authority + proof + "0100000000000000000000000000000000000000000000000000000000000000", # context "0000000000000000000000000000000000000000000000000000000000000000", "0000000000000000000000000000000000000000000000000000000000000000", ], "is_writable": True, }, { - "address": base64.b16decode("be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", True), - } + "address": base64.b16decode( + "be5b54cdb01762497c7fd98bfcaaec1d2a2cad1c2bb5134857b68f0214935ebb", + True, + ), + }, ], }, ] for test in test_vectors_verify: - test["data"] = base64.b16decode(''.join(test.get("data", [])), True) + test["data"] = base64.b16decode("".join(test.get("data", [])), True) for account in test.get("accounts", []): - account["data"] = base64.b16decode(''.join(account.get("data", [])), True) + account["data"] = base64.b16decode("".join(account.get("data", [])), True) + def _into_key_data(key_prefix, test_vectors): return [(key_prefix + str(j), test) for j, test in enumerate(test_vectors)] @@ -1502,15 +1732,17 @@ def _into_key_data(key_prefix, test_vectors): print("Generating zk-sdk tests...") -test_vectors = _into_key_data("a", test_vectors_agave) \ - + _into_key_data("cu", test_vectors_cu) \ - + _into_key_data("c", test_vectors_ctx) \ - + _into_key_data("p", test_vectors_proof) \ - + _into_key_data("acc", test_vectors_account) \ - + _into_key_data("w", test_vectors_write) \ - + _into_key_data("wacc", test_vectors_account_write) \ - + _into_key_data("close", test_vectors_close) \ +test_vectors = ( + _into_key_data("a", test_vectors_agave) + + _into_key_data("cu", test_vectors_cu) + + _into_key_data("c", test_vectors_ctx) + + _into_key_data("p", test_vectors_proof) + + _into_key_data("acc", test_vectors_account) + + _into_key_data("w", test_vectors_write) + + _into_key_data("wacc", test_vectors_account_write) + + _into_key_data("close", test_vectors_close) + _into_key_data("verif", test_vectors_verify) +) program_id = fd58.dec32(bytes(program_id, "utf-8")) program_owner = fd58.dec32( @@ -1528,7 +1760,7 @@ def _into_key_data(key_prefix, test_vectors): # account acc = context_pb.AcctState() acc.address = account.get("address") - acc.owner = account.get("owner", bytes([0]*32)) + acc.owner = account.get("owner", bytes([0] * 32)) acc.lamports = account.get("lamports", 0) acc.data = account.get("data", bytes([])) accounts.append(acc) @@ -1552,7 +1784,7 @@ def _into_key_data(key_prefix, test_vectors): instr_ctx.accounts.extend(accounts) instr_ctx.instr_accounts.extend(instr_accounts) - instr_ctx.epoch_context.features.features.extend([0x8e1411a93085cb0e]) + instr_ctx.epoch_context.features.features.extend([0x8E1411A93085CB0E]) serialized_instr = instr_ctx.SerializeToString(deterministic=True) filename = str(key) + "_" + hashlib.sha3_256(serialized_instr).hexdigest()[:16] diff --git a/src/test_suite/txn/codec_utils.py b/src/test_suite/txn/codec_utils.py index 9041dae..1af3240 100644 --- a/src/test_suite/txn/codec_utils.py +++ b/src/test_suite/txn/codec_utils.py @@ -11,7 +11,9 @@ def decode_input(txn_context: txn_pb.TxnContext): - txn_context (txn_pb.TxnContext): Transaction context (will be modified). """ # Message hash - txn_context.tx.message_hash = fd58.dec32(txn_context.tx.message_hash) + txn_context.tx.message_hash = fd58.dec32( + txn_context.tx.message_hash or bytes([0] * 32) + ) # Signatures for i in range(len(txn_context.tx.signatures)): @@ -43,7 +45,7 @@ def decode_input(txn_context: txn_pb.TxnContext): # Recent blockhash txn_context.tx.message.recent_blockhash = fd58.dec32( - txn_context.tx.message.recent_blockhash + txn_context.tx.message.recent_blockhash or bytes([0] * 32) ) # Address table lookups @@ -79,7 +81,9 @@ def encode_input(txn_context: txn_pb.TxnContext): - txn_context (txn_pb.TxnContext): Transaction context (will be modified). """ # Message hash - txn_context.tx.message_hash = fd58.enc32(txn_context.tx.message_hash) + txn_context.tx.message_hash = fd58.enc32( + txn_context.tx.message_hash or bytes([0] * 32) + ) # Signatures for i in range(len(txn_context.tx.signatures)): @@ -111,7 +115,7 @@ def encode_input(txn_context: txn_pb.TxnContext): # Recent blockhash txn_context.tx.message.recent_blockhash = fd58.enc32( - txn_context.tx.message.recent_blockhash + txn_context.tx.message.recent_blockhash or bytes([0] * 32) ) # Address table lookups