|
4 | 4 | from Crypto.Hash import keccak |
5 | 5 |
|
6 | 6 |
|
7 | | -def encode_call(file): |
| 7 | +def encode_call(file, sender_address): |
8 | 8 | with open(file) as f: |
9 | 9 | data = load(f) |
10 | 10 |
|
11 | | - verification_data_commitment = data['verification_data_commitment'] |
12 | | - proof_commitment = bytearray(verification_data_commitment['proof_commitment']) |
13 | | - pub_input_commitment = bytearray(verification_data_commitment['pub_input_commitment']) |
14 | | - proving_system_aux_data_commitment = bytearray( |
15 | | - verification_data_commitment['proving_system_aux_data_commitment']) |
16 | | - proof_generator_addr = bytearray(verification_data_commitment['proof_generator_addr']) |
17 | | - batch_merkle_root = bytearray(data['batch_merkle_root']) |
| 11 | + proof_commitment = bytearray.fromhex(data['proof_commitment']) |
| 12 | + pub_input_commitment = bytearray.fromhex(data['pub_input_commitment']) |
| 13 | + proving_system_aux_data_commitment = bytearray.fromhex(data['program_id_commitment']) |
| 14 | + proof_generator_addr = bytearray.fromhex(data['proof_generator_addr']) |
| 15 | + batch_merkle_root = bytearray.fromhex(data['batch_merkle_root']) |
| 16 | + merkle_proof = bytearray.fromhex(data['merkle_proof']) |
| 17 | + verification_data_batch_index = data['verification_data_batch_index'] |
18 | 18 |
|
19 | | - merkle_path_arr = data['batch_inclusion_proof']['merkle_path'] |
20 | | - merkle_proof = bytearray() |
21 | | - for i in range(0, len(merkle_path_arr)): |
22 | | - merkle_proof += bytearray(merkle_path_arr[i]) |
23 | | - |
24 | | - index = data['index_in_batch'] |
25 | | - |
26 | | - output = encode(['bytes32', 'bytes32', 'bytes32', 'bytes20', 'bytes32', 'bytes', 'uint256'], |
| 19 | + output = encode(['bytes32', 'bytes32', 'bytes32', 'bytes20', 'bytes32', 'bytes', 'uint256', 'address'], |
27 | 20 | [proof_commitment, pub_input_commitment, proving_system_aux_data_commitment, |
28 | | - proof_generator_addr, batch_merkle_root, merkle_proof, index]) |
| 21 | + proof_generator_addr, batch_merkle_root, merkle_proof, verification_data_batch_index, |
| 22 | + sender_address]) |
29 | 23 |
|
30 | 24 | k = keccak.new(digest_bits=256) |
31 | | - k.update(b'verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256)') |
| 25 | + k.update(b'verifyBatchInclusion(bytes32,bytes32,bytes32,bytes20,bytes32,bytes,uint256,address)') |
32 | 26 | signature = k.hexdigest()[:8] |
33 | | - |
34 | 27 | return '0x' + signature + output.hex() |
35 | 28 |
|
36 | 29 |
|
37 | 30 | if __name__ == "__main__": |
38 | 31 | parser = ArgumentParser() |
39 | 32 | parser.add_argument('--aligned-verification-data', help='Path to JSON file with the verification data') |
| 33 | + parser.add_argument('--sender-address', help='Address that sent the batch to Aligned') |
40 | 34 | args = parser.parse_args() |
41 | 35 |
|
42 | | - data = encode_call(args.aligned_verification_data) |
| 36 | + data = encode_call(args.aligned_verification_data, args.sender_address) |
43 | 37 | print(data) |
0 commit comments