diff --git a/cairo0/builtins/bitwise_builtin.cairo b/cairo0/builtins/bitwise_builtin.cairo new file mode 100644 index 0000000..64f655c --- /dev/null +++ b/cairo0/builtins/bitwise_builtin.cairo @@ -0,0 +1,15 @@ +%builtins bitwise + +from starkware.cairo.common.cairo_builtins import BitwiseBuiltin + +func main{bitwise_ptr: BitwiseBuiltin*}() { + assert bitwise_ptr.x = 12; // Binary 1100 + assert bitwise_ptr.y = 10; // Binary 1010 + assert bitwise_ptr.x_and_y = 8; // Binary 1000 + assert bitwise_ptr.x_xor_y = 6; // Binary 0110 + assert bitwise_ptr.x_or_y = 14; // Binary 1110 + + let bitwise_ptr = bitwise_ptr + BitwiseBuiltin.SIZE; + + return (); +} diff --git a/cairo0/builtins/bitwise_buitin.json b/cairo0/builtins/bitwise_buitin.json new file mode 100644 index 0000000..59b1572 --- /dev/null +++ b/cairo0/builtins/bitwise_buitin.json @@ -0,0 +1,749 @@ +{ + "attributes": [], + "builtins": ["bitwise"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0xc", + "0x400280007ffd7fff", + "0x480680017fff8000", + "0xa", + "0x400280017ffd7fff", + "0x480680017fff8000", + "0x8", + "0x400280027ffd7fff", + "0x480680017fff8000", + "0x6", + "0x400280037ffd7fff", + "0x480680017fff8000", + "0xe", + "0x400280047ffd7fff", + "0x482680017ffd8000", + "0x5", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 28, + "start_line": 6 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 6 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 28, + "start_line": 7 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "6": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 35, + "end_line": 8, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 34, + "start_line": 8 + } + }, + "8": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 36, + "end_line": 8, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 8 + } + }, + "9": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 35, + "end_line": 9, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 34, + "start_line": 9 + } + }, + "11": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 36, + "end_line": 9, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 9 + } + }, + "12": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 35, + "end_line": 10, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 33, + "start_line": 10 + } + }, + "14": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.bitwise_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 36, + "end_line": 10, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 10 + } + }, + "15": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.bitwise_ptr": 6 + } + }, + "hints": [], + "inst": { + "end_col": 56, + "end_line": 12, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 39, + "end_line": 5, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 14 + }, + "While trying to retrieve the implicit argument 'bitwise_ptr' in:" + ], + "start_col": 11, + "start_line": 5 + }, + "While expanding the reference 'bitwise_ptr' in:" + ], + "start_col": 23, + "start_line": 12 + } + }, + "17": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.bitwise_ptr": 6 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/bitwise_builtin.cairo" + }, + "start_col": 5, + "start_line": 14 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.BitwiseBuiltin": { + "destination": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin", + "type": "alias" + }, + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "bitwise_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp1": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp1", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp2": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp2", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp3": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp3", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp4": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp4", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.bitwise_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin*", + "full_name": "__main__.main.bitwise_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.BitwiseBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 15, + "value": "cast([fp + (-3)] + 5, starkware.cairo.common.cairo_builtins.BitwiseBuiltin*)" + } + ], + "type": "reference" + }, + "starkware.cairo.common.cairo_builtins.BitwiseBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "x_and_y": { + "cairo_type": "felt", + "offset": 2 + }, + "x_or_y": { + "cairo_type": "felt", + "offset": 4 + }, + "x_xor_y": { + "cairo_type": "felt", + "offset": 3 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 5, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcOpBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.EcOpBuiltin", + "members": { + "m": { + "cairo_type": "felt", + "offset": 4 + }, + "p": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 0 + }, + "q": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 2 + }, + "r": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 5 + } + }, + "size": 7, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcPoint": { + "destination": "starkware.cairo.common.ec_point.EcPoint", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.HashBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "members": { + "result": { + "cairo_type": "felt", + "offset": 2 + }, + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 3, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.KeccakBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 8 + } + }, + "size": 16, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltinState": { + "destination": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 3 + } + }, + "size": 6, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltinState": { + "destination": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.SignatureBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.SignatureBuiltin", + "members": { + "message": { + "cairo_type": "felt", + "offset": 1 + }, + "pub_key": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.ec_point.EcPoint": { + "full_name": "starkware.cairo.common.ec_point.EcPoint", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.keccak_state.KeccakBuiltinState": { + "full_name": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + }, + "s3": { + "cairo_type": "felt", + "offset": 3 + }, + "s4": { + "cairo_type": "felt", + "offset": 4 + }, + "s5": { + "cairo_type": "felt", + "offset": 5 + }, + "s6": { + "cairo_type": "felt", + "offset": 6 + }, + "s7": { + "cairo_type": "felt", + "offset": 7 + } + }, + "size": 8, + "type": "struct" + }, + "starkware.cairo.common.poseidon_state.PoseidonBuiltinState": { + "full_name": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + } + }, + "size": 3, + "type": "struct" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.BitwiseBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 15, + "value": "cast([fp + (-3)] + 5, starkware.cairo.common.cairo_builtins.BitwiseBuiltin*)" + } + ] + } +} diff --git a/cairo0/builtins/ecop_builtin.cairo b/cairo0/builtins/ecop_builtin.cairo new file mode 100644 index 0000000..ef02f9f --- /dev/null +++ b/cairo0/builtins/ecop_builtin.cairo @@ -0,0 +1,27 @@ +%builtins ec_op + +from starkware.cairo.common.cairo_builtins import EcOpBuiltin +from starkware.cairo.common.ec_point import EcPoint + +func main{ec_op_ptr: EcOpBuiltin*}() { + let p = EcPoint( + 0x6a4beaef5a93425b973179cdba0c9d42f30e01a5f1e2db73da0884b8d6756fc, + 0x72565ec81bc09ff53fbfad99324a92aa5b39fb58267e395e8abe36290ebf24f, + ); + let m = 34; + let q = EcPoint( + 0x654fd7e67a123dd13868093b3b7777f1ffef596c2e324f25ceaf9146698482c, + 0x4fad269cbf860980e38768fe9cb6b0b9ab03ee3fe84cfde2eccce597c874fd8, + ); + + assert ec_op_ptr.p = p; + assert ec_op_ptr.q = q; + assert ec_op_ptr.m = m; + + let r = ec_op_ptr.r; + let ec_op_ptr = ec_op_ptr + EcOpBuiltin.SIZE; + + assert r.x = 108925483682366235368969256555281508851459278989259552980345066351008608800; + assert r.y = 1592365885972480102953613056006596671718206128324372995731808913669237079419; + return (); +} diff --git a/cairo0/builtins/ecop_builtin.json b/cairo0/builtins/ecop_builtin.json new file mode 100644 index 0000000..76e90b9 --- /dev/null +++ b/cairo0/builtins/ecop_builtin.json @@ -0,0 +1,1127 @@ +{ + "attributes": [], + "builtins": ["ec_op"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0x6a4beaef5a93425b973179cdba0c9d42f30e01a5f1e2db73da0884b8d6756fc", + "0x400280007ffd7fff", + "0x480680017fff8000", + "0x72565ec81bc09ff53fbfad99324a92aa5b39fb58267e395e8abe36290ebf24f", + "0x400280017ffd7fff", + "0x480680017fff8000", + "0x654fd7e67a123dd13868093b3b7777f1ffef596c2e324f25ceaf9146698482c", + "0x400280027ffd7fff", + "0x480680017fff8000", + "0x4fad269cbf860980e38768fe9cb6b0b9ab03ee3fe84cfde2eccce597c874fd8", + "0x400280037ffd7fff", + "0x480680017fff8000", + "0x22", + "0x400280047ffd7fff", + "0x480680017fff8000", + "0x3da64ebd8ba9f51fe5f91314a5cf9e8aa426189d2b28407622e99f1a9ef220", + "0x400280057ffd7fff", + "0x480680017fff8000", + "0x3853f456249dba2cef3645c4530934cbfe4812619fb5c0b2700a7b11b417d7b", + "0x400280067ffd7fff", + "0x482680017ffd8000", + "0x7", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 74, + "end_line": 8, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 27, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 26, + "start_line": 17 + }, + "While expanding the reference 'p' in:" + ], + "start_col": 9, + "start_line": 8 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 28, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 17 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 74, + "end_line": 9, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 27, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 26, + "start_line": 17 + }, + "While expanding the reference 'p' in:" + ], + "start_col": 9, + "start_line": 9 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 28, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 17 + } + }, + "6": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 74, + "end_line": 13, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 27, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 26, + "start_line": 18 + }, + "While expanding the reference 'q' in:" + ], + "start_col": 9, + "start_line": 13 + } + }, + "8": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 28, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 18 + } + }, + "9": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 74, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 27, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 26, + "start_line": 18 + }, + "While expanding the reference 'q' in:" + ], + "start_col": 9, + "start_line": 14 + } + }, + "11": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 28, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 18 + } + }, + "12": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 11, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 27, + "end_line": 19, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 26, + "start_line": 19 + }, + "While expanding the reference 'm' in:" + ], + "start_col": 13, + "start_line": 11 + } + }, + "14": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.ec_op_ptr": 0, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3 + } + }, + "hints": [], + "inst": { + "end_col": 28, + "end_line": 19, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 19 + } + }, + "15": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.ec_op_ptr": 10, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3, + "__main__.main.r": 9 + } + }, + "hints": [], + "inst": { + "end_col": 93, + "end_line": 24, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 18, + "start_line": 24 + } + }, + "17": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.__temp5": 11, + "__main__.main.ec_op_ptr": 10, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3, + "__main__.main.r": 9 + } + }, + "hints": [], + "inst": { + "end_col": 94, + "end_line": 24, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 24 + } + }, + "18": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.__temp5": 11, + "__main__.main.ec_op_ptr": 10, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3, + "__main__.main.r": 9 + } + }, + "hints": [], + "inst": { + "end_col": 94, + "end_line": 25, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 18, + "start_line": 25 + } + }, + "20": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.__temp5": 11, + "__main__.main.__temp6": 12, + "__main__.main.ec_op_ptr": 10, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3, + "__main__.main.r": 9 + } + }, + "hints": [], + "inst": { + "end_col": 95, + "end_line": 25, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 25 + } + }, + "21": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.__temp5": 11, + "__main__.main.__temp6": 12, + "__main__.main.ec_op_ptr": 10, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3, + "__main__.main.r": 9 + } + }, + "hints": [], + "inst": { + "end_col": 49, + "end_line": 22, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 34, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 26, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 26 + }, + "While trying to retrieve the implicit argument 'ec_op_ptr' in:" + ], + "start_col": 11, + "start_line": 6 + }, + "While expanding the reference 'ec_op_ptr' in:" + ], + "start_col": 21, + "start_line": 22 + } + }, + "23": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 4, + "__main__.main.__temp1": 5, + "__main__.main.__temp2": 6, + "__main__.main.__temp3": 7, + "__main__.main.__temp4": 8, + "__main__.main.__temp5": 11, + "__main__.main.__temp6": 12, + "__main__.main.ec_op_ptr": 10, + "__main__.main.m": 2, + "__main__.main.p": 1, + "__main__.main.q": 3, + "__main__.main.r": 9 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 26, + "input_file": { + "filename": "cairo0/Builtins/ecop_builtin.cairo" + }, + "start_col": 5, + "start_line": 26 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.EcOpBuiltin": { + "destination": "starkware.cairo.common.cairo_builtins.EcOpBuiltin", + "type": "alias" + }, + "__main__.EcPoint": { + "destination": "starkware.cairo.common.ec_point.EcPoint", + "type": "alias" + }, + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "ec_op_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.EcOpBuiltin*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp1": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp1", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp2": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp2", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp3": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp3", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp4": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp4", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp5": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp5", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp6": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp6", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.ec_op_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.EcOpBuiltin*", + "full_name": "__main__.main.ec_op_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.EcOpBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 15, + "value": "cast([fp + (-3)] + 7, starkware.cairo.common.cairo_builtins.EcOpBuiltin*)" + } + ], + "type": "reference" + }, + "__main__.main.m": { + "cairo_type": "felt", + "full_name": "__main__.main.m", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "cast(34, felt)" + } + ], + "type": "reference" + }, + "__main__.main.p": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "full_name": "__main__.main.p", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "cast((\n -613546729835149738153172335852414873347724530319251923384994262514641971461,\n -386236054595386575795345623791920124827519018828430310912260655089307618738,\n ), starkware.cairo.common.ec_point.EcPoint)" + } + ], + "type": "reference" + }, + "__main__.main.q": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "full_name": "__main__.main.q", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "cast((\n -754460994032675295310182951485722347902509860686012970362047256018157025237,\n -1366087409130671796804238617330118192196579054701207714430850815087571677225,\n ), starkware.cairo.common.ec_point.EcPoint)" + } + ], + "type": "reference" + }, + "__main__.main.r": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "full_name": "__main__.main.r", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 15, + "value": "[cast([fp + (-3)] + 5, starkware.cairo.common.ec_point.EcPoint*)]" + } + ], + "type": "reference" + }, + "starkware.cairo.common.cairo_builtins.BitwiseBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "x_and_y": { + "cairo_type": "felt", + "offset": 2 + }, + "x_or_y": { + "cairo_type": "felt", + "offset": 4 + }, + "x_xor_y": { + "cairo_type": "felt", + "offset": 3 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 5, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcOpBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.EcOpBuiltin", + "members": { + "m": { + "cairo_type": "felt", + "offset": 4 + }, + "p": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 0 + }, + "q": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 2 + }, + "r": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 5 + } + }, + "size": 7, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcPoint": { + "destination": "starkware.cairo.common.ec_point.EcPoint", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.HashBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "members": { + "result": { + "cairo_type": "felt", + "offset": 2 + }, + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 3, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.KeccakBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 8 + } + }, + "size": 16, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltinState": { + "destination": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 3 + } + }, + "size": 6, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltinState": { + "destination": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.SignatureBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.SignatureBuiltin", + "members": { + "message": { + "cairo_type": "felt", + "offset": 1 + }, + "pub_key": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.ec_point.EcPoint": { + "full_name": "starkware.cairo.common.ec_point.EcPoint", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.keccak_state.KeccakBuiltinState": { + "full_name": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + }, + "s3": { + "cairo_type": "felt", + "offset": 3 + }, + "s4": { + "cairo_type": "felt", + "offset": 4 + }, + "s5": { + "cairo_type": "felt", + "offset": 5 + }, + "s6": { + "cairo_type": "felt", + "offset": 6 + }, + "s7": { + "cairo_type": "felt", + "offset": 7 + } + }, + "size": 8, + "type": "struct" + }, + "starkware.cairo.common.poseidon_state.PoseidonBuiltinState": { + "full_name": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + } + }, + "size": 3, + "type": "struct" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.EcOpBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "cast((\n -613546729835149738153172335852414873347724530319251923384994262514641971461,\n -386236054595386575795345623791920124827519018828430310912260655089307618738,\n ), starkware.cairo.common.ec_point.EcPoint)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "cast(34, felt)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "cast((\n -754460994032675295310182951485722347902509860686012970362047256018157025237,\n -1366087409130671796804238617330118192196579054701207714430850815087571677225,\n ), starkware.cairo.common.ec_point.EcPoint)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 15, + "value": "[cast([fp + (-3)] + 5, starkware.cairo.common.ec_point.EcPoint*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 15, + "value": "cast([fp + (-3)] + 7, starkware.cairo.common.cairo_builtins.EcOpBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + } + ] + } +} diff --git a/cairo0/builtins/keccak_builtin.cairo b/cairo0/builtins/keccak_builtin.cairo new file mode 100644 index 0000000..6e8042d --- /dev/null +++ b/cairo0/builtins/keccak_builtin.cairo @@ -0,0 +1,19 @@ +%builtins keccak + +from starkware.cairo.common.cairo_builtins import KeccakBuiltin +from starkware.cairo.common.keccak_state import KeccakBuiltinState + +func main{keccak_ptr: KeccakBuiltin*}() { + assert keccak_ptr[0].input = KeccakBuiltinState(1, 2, 3, 4, 5, 6, 7, 8); + let result = keccak_ptr[0].output; + assert result.s0 = 0x5437ca4807beb9df3871c8467f0c8c2ac42e1f2100e18198f6; + assert result.s1 = 0x7a753f70755cbbde7882962e5969b2874c2dff11a91716ab31; + assert result.s2 = 0xe561082c7d6621e7480f773a54870b0dab0ad6151b08ee303a; + assert result.s3 = 0xb744cd390af9518a46a3d88b6003f7393c7ead3f9a131638be; + assert result.s4 = 0xf16079da5c848e9f6b99afdf72720169e5209e171f8ef7582e; + assert result.s5 = 0xe108fbbcea9d86a6d76f01b63c33ffffd896ad8e2b71026060; + assert result.s6 = 0x9c7aa8a62187936713012ec096925a78b1c1a140ab7a061ca3; + assert result.s7 = 0xd5774bd1793a6b3940c0a54888a6a3c1e57251a7e727590b40; + let keccak_ptr = keccak_ptr + KeccakBuiltin.SIZE; + return (); +} diff --git a/cairo0/builtins/keccak_builtin.json b/cairo0/builtins/keccak_builtin.json new file mode 100644 index 0000000..5399e46 --- /dev/null +++ b/cairo0/builtins/keccak_builtin.json @@ -0,0 +1,1817 @@ +{ + "attributes": [], + "builtins": ["keccak"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0x1", + "0x400280007ffd7fff", + "0x480680017fff8000", + "0x2", + "0x400280017ffd7fff", + "0x480680017fff8000", + "0x3", + "0x400280027ffd7fff", + "0x480680017fff8000", + "0x4", + "0x400280037ffd7fff", + "0x480680017fff8000", + "0x5", + "0x400280047ffd7fff", + "0x480680017fff8000", + "0x6", + "0x400280057ffd7fff", + "0x480680017fff8000", + "0x7", + "0x400280067ffd7fff", + "0x480680017fff8000", + "0x8", + "0x400280077ffd7fff", + "0x480680017fff8000", + "0x5437ca4807beb9df3871c8467f0c8c2ac42e1f2100e18198f6", + "0x400280087ffd7fff", + "0x480680017fff8000", + "0x7a753f70755cbbde7882962e5969b2874c2dff11a91716ab31", + "0x400280097ffd7fff", + "0x480680017fff8000", + "0xe561082c7d6621e7480f773a54870b0dab0ad6151b08ee303a", + "0x4002800a7ffd7fff", + "0x480680017fff8000", + "0xb744cd390af9518a46a3d88b6003f7393c7ead3f9a131638be", + "0x4002800b7ffd7fff", + "0x480680017fff8000", + "0xf16079da5c848e9f6b99afdf72720169e5209e171f8ef7582e", + "0x4002800c7ffd7fff", + "0x480680017fff8000", + "0xe108fbbcea9d86a6d76f01b63c33ffffd896ad8e2b71026060", + "0x4002800d7ffd7fff", + "0x480680017fff8000", + "0x9c7aa8a62187936713012ec096925a78b1c1a140ab7a061ca3", + "0x4002800e7ffd7fff", + "0x480680017fff8000", + "0xd5774bd1793a6b3940c0a54888a6a3c1e57251a7e727590b40", + "0x4002800f7ffd7fff", + "0x482680017ffd8000", + "0x10", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 54, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 53, + "start_line": 7 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 57, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 56, + "start_line": 7 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "6": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 60, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 59, + "start_line": 7 + } + }, + "8": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "9": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 63, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 62, + "start_line": 7 + } + }, + "11": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "12": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 66, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 65, + "start_line": 7 + } + }, + "14": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "15": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 69, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 68, + "start_line": 7 + } + }, + "17": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "18": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 72, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 71, + "start_line": 7 + } + }, + "20": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "21": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 75, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 74, + "start_line": 7 + } + }, + "23": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.keccak_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 7, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "24": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 9, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 9 + } + }, + "26": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 9 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 9, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 9 + } + }, + "27": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 9 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 10, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 10 + } + }, + "29": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 10 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 10, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 10 + } + }, + "30": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 10 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 11, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 11 + } + }, + "32": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 11 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 11, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 11 + } + }, + "33": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 11 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 12, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 12 + } + }, + "35": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 12 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 12, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 12 + } + }, + "36": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 12 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 13, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 13 + } + }, + "38": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 13 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 13, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 13 + } + }, + "39": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 13 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 14, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 14 + } + }, + "41": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 14 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 14, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 14 + } + }, + "42": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 14 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 15, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 15 + } + }, + "44": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 15 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp14": 16, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 15, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 15 + } + }, + "45": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 15 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp14": 16, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 76, + "end_line": 16, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 24, + "start_line": 16 + } + }, + "47": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 16 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp14": 16, + "__main__.main.__temp15": 17, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 0, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 77, + "end_line": 16, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 16 + } + }, + "48": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 16 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp14": 16, + "__main__.main.__temp15": 17, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 18, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 53, + "end_line": 17, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 37, + "end_line": 6, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 18, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 18 + }, + "While trying to retrieve the implicit argument 'keccak_ptr' in:" + ], + "start_col": 11, + "start_line": 6 + }, + "While expanding the reference 'keccak_ptr' in:" + ], + "start_col": 22, + "start_line": 17 + } + }, + "50": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 17 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 12, + "__main__.main.__temp11": 13, + "__main__.main.__temp12": 14, + "__main__.main.__temp13": 15, + "__main__.main.__temp14": 16, + "__main__.main.__temp15": 17, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 4, + "__main__.main.__temp4": 5, + "__main__.main.__temp5": 6, + "__main__.main.__temp6": 7, + "__main__.main.__temp7": 8, + "__main__.main.__temp8": 10, + "__main__.main.__temp9": 11, + "__main__.main.keccak_ptr": 18, + "__main__.main.result": 9 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 18, + "input_file": { + "filename": "cairo0/builtins/keccak_builtin.cairo" + }, + "start_col": 5, + "start_line": 18 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.KeccakBuiltin": { + "destination": "starkware.cairo.common.cairo_builtins.KeccakBuiltin", + "type": "alias" + }, + "__main__.KeccakBuiltinState": { + "destination": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "type": "alias" + }, + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "keccak_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.KeccakBuiltin*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp1": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp1", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp10": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp10", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 11 + }, + "pc": 32, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp11": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp11", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 35, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp12": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp12", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 13 + }, + "pc": 38, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp13": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp13", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 14 + }, + "pc": 41, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp14": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp14", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 15 + }, + "pc": 44, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp15": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp15", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 16 + }, + "pc": 47, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp2": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp2", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp3": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp3", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp4": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp4", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp5": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp5", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp6": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp6", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp7": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp7", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 23, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp8": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp8", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 26, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp9": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp9", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 10 + }, + "pc": 29, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.keccak_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.KeccakBuiltin*", + "full_name": "__main__.main.keccak_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.KeccakBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 16 + }, + "pc": 48, + "value": "cast([fp + (-3)] + 16, starkware.cairo.common.cairo_builtins.KeccakBuiltin*)" + } + ], + "type": "reference" + }, + "__main__.main.result": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "full_name": "__main__.main.result", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 24, + "value": "[cast([fp + (-3)] + 8, starkware.cairo.common.keccak_state.KeccakBuiltinState*)]" + } + ], + "type": "reference" + }, + "starkware.cairo.common.cairo_builtins.BitwiseBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "x_and_y": { + "cairo_type": "felt", + "offset": 2 + }, + "x_or_y": { + "cairo_type": "felt", + "offset": 4 + }, + "x_xor_y": { + "cairo_type": "felt", + "offset": 3 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 5, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcOpBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.EcOpBuiltin", + "members": { + "m": { + "cairo_type": "felt", + "offset": 4 + }, + "p": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 0 + }, + "q": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 2 + }, + "r": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 5 + } + }, + "size": 7, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcPoint": { + "destination": "starkware.cairo.common.ec_point.EcPoint", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.HashBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "members": { + "result": { + "cairo_type": "felt", + "offset": 2 + }, + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 3, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.KeccakBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 8 + } + }, + "size": 16, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltinState": { + "destination": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 3 + } + }, + "size": 6, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltinState": { + "destination": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.SignatureBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.SignatureBuiltin", + "members": { + "message": { + "cairo_type": "felt", + "offset": 1 + }, + "pub_key": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.ec_point.EcPoint": { + "full_name": "starkware.cairo.common.ec_point.EcPoint", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.keccak_state.KeccakBuiltinState": { + "full_name": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + }, + "s3": { + "cairo_type": "felt", + "offset": 3 + }, + "s4": { + "cairo_type": "felt", + "offset": 4 + }, + "s5": { + "cairo_type": "felt", + "offset": 5 + }, + "s6": { + "cairo_type": "felt", + "offset": 6 + }, + "s7": { + "cairo_type": "felt", + "offset": 7 + } + }, + "size": 8, + "type": "struct" + }, + "starkware.cairo.common.poseidon_state.PoseidonBuiltinState": { + "full_name": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + } + }, + "size": 3, + "type": "struct" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.KeccakBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 23, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 24, + "value": "[cast([fp + (-3)] + 8, starkware.cairo.common.keccak_state.KeccakBuiltinState*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 26, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 10 + }, + "pc": 29, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 11 + }, + "pc": 32, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 35, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 13 + }, + "pc": 38, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 14 + }, + "pc": 41, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 15 + }, + "pc": 44, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 16 + }, + "pc": 47, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 16 + }, + "pc": 48, + "value": "cast([fp + (-3)] + 16, starkware.cairo.common.cairo_builtins.KeccakBuiltin*)" + } + ] + } +} diff --git a/cairo0/builtins/pedersen_builtin.cairo b/cairo0/builtins/pedersen_builtin.cairo new file mode 100644 index 0000000..d6daaed --- /dev/null +++ b/cairo0/builtins/pedersen_builtin.cairo @@ -0,0 +1,27 @@ +%builtins pedersen + +from starkware.cairo.common.cairo_builtins import HashBuiltin + +func main{pedersen_ptr: HashBuiltin*}() { + assert pedersen_ptr.x = 0; + assert pedersen_ptr.y = 0; + assert pedersen_ptr.result = 0x49ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804; + let pedersen_ptr = pedersen_ptr + HashBuiltin.SIZE; + + assert pedersen_ptr.x = 0; + assert pedersen_ptr.y = 1; + assert pedersen_ptr.result = 0x46c9aeb066cc2f41c7124af30514f9e607137fbac950524f5fdace5788f9d43; + let pedersen_ptr = pedersen_ptr + HashBuiltin.SIZE; + + assert pedersen_ptr.x = 1; + assert pedersen_ptr.y = 0; + assert pedersen_ptr.result = 0x268a9d47dde48af4b6e2c33932ed1c13adec25555abaa837c376af4ea2f8a94; + let pedersen_ptr = pedersen_ptr + HashBuiltin.SIZE; + + assert pedersen_ptr.x = 54; + assert pedersen_ptr.y = 1249832432; + assert pedersen_ptr.result = 0x20120a7d08fd21654c72a9281841406543b16d00faaca1069332053c41c07b8; + let pedersen_ptr = pedersen_ptr + HashBuiltin.SIZE; + + return (); +} diff --git a/cairo0/builtins/pedersen_builtin.json b/cairo0/builtins/pedersen_builtin.json new file mode 100644 index 0000000..b572200 --- /dev/null +++ b/cairo0/builtins/pedersen_builtin.json @@ -0,0 +1,1420 @@ +{ + "attributes": [], + "builtins": ["pedersen"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0x0", + "0x400280007ffd7fff", + "0x480680017fff8000", + "0x0", + "0x400280017ffd7fff", + "0x480680017fff8000", + "0x49ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804", + "0x400280027ffd7fff", + "0x480680017fff8000", + "0x0", + "0x400280037ffd7fff", + "0x480680017fff8000", + "0x1", + "0x400280047ffd7fff", + "0x480680017fff8000", + "0x46c9aeb066cc2f41c7124af30514f9e607137fbac950524f5fdace5788f9d43", + "0x400280057ffd7fff", + "0x480680017fff8000", + "0x1", + "0x400280067ffd7fff", + "0x480680017fff8000", + "0x0", + "0x400280077ffd7fff", + "0x480680017fff8000", + "0x268a9d47dde48af4b6e2c33932ed1c13adec25555abaa837c376af4ea2f8a94", + "0x400280087ffd7fff", + "0x480680017fff8000", + "0x36", + "0x400280097ffd7fff", + "0x480680017fff8000", + "0x4a7eedf0", + "0x4002800a7ffd7fff", + "0x480680017fff8000", + "0x20120a7d08fd21654c72a9281841406543b16d00faaca1069332053c41c07b8", + "0x4002800b7ffd7fff", + "0x482680017ffd8000", + "0xc", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.pedersen_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 6 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.pedersen_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 6 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.pedersen_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 7 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.pedersen_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "6": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.pedersen_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 99, + "end_line": 8, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 34, + "start_line": 8 + } + }, + "8": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.pedersen_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 8, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 8 + } + }, + "9": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.pedersen_ptr": 4 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 11, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 11 + } + }, + "11": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.pedersen_ptr": 4 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 11, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 11 + } + }, + "12": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.pedersen_ptr": 4 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 12, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 12 + } + }, + "14": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.pedersen_ptr": 4 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 12, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 12 + } + }, + "15": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.pedersen_ptr": 4 + } + }, + "hints": [], + "inst": { + "end_col": 99, + "end_line": 13, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 34, + "start_line": 13 + } + }, + "17": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.pedersen_ptr": 4 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 13, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 13 + } + }, + "18": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.pedersen_ptr": 8 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 16, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 16 + } + }, + "20": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.pedersen_ptr": 8 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 16, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 16 + } + }, + "21": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.pedersen_ptr": 8 + } + }, + "hints": [], + "inst": { + "end_col": 30, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 17 + } + }, + "23": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.pedersen_ptr": 8 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 17 + } + }, + "24": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.pedersen_ptr": 8 + } + }, + "hints": [], + "inst": { + "end_col": 99, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 34, + "start_line": 18 + } + }, + "26": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 9 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.pedersen_ptr": 8 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 18 + } + }, + "27": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 9 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.pedersen_ptr": 12 + } + }, + "hints": [], + "inst": { + "end_col": 31, + "end_line": 21, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 21 + } + }, + "29": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 10 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 12 + } + }, + "hints": [], + "inst": { + "end_col": 32, + "end_line": 21, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 21 + } + }, + "30": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 10 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 12 + } + }, + "hints": [], + "inst": { + "end_col": 39, + "end_line": 22, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 29, + "start_line": 22 + } + }, + "32": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 11 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 14, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 12 + } + }, + "hints": [], + "inst": { + "end_col": 40, + "end_line": 22, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 22 + } + }, + "33": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 11 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 14, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 12 + } + }, + "hints": [], + "inst": { + "end_col": 99, + "end_line": 23, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 34, + "start_line": 23 + } + }, + "35": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 12 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 14, + "__main__.main.__temp11": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 12 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 23, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 23 + } + }, + "36": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 12 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 14, + "__main__.main.__temp11": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 16 + } + }, + "hints": [], + "inst": { + "end_col": 55, + "end_line": 24, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 37, + "end_line": 5, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 26, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 26 + }, + "While trying to retrieve the implicit argument 'pedersen_ptr' in:" + ], + "start_col": 11, + "start_line": 5 + }, + "While expanding the reference 'pedersen_ptr' in:" + ], + "start_col": 24, + "start_line": 24 + } + }, + "38": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 13 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 14, + "__main__.main.__temp11": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 5, + "__main__.main.__temp4": 6, + "__main__.main.__temp5": 7, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 13, + "__main__.main.pedersen_ptr": 16 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 26, + "input_file": { + "filename": "cairo0/Builtins/pedersen_builtin.cairo" + }, + "start_col": 5, + "start_line": 26 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.HashBuiltin": { + "destination": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "type": "alias" + }, + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "pedersen_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.HashBuiltin*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp1": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp1", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp10": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp10", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 11 + }, + "pc": 32, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp11": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp11", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 35, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp2": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp2", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp3": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp3", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp4": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp4", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp5": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp5", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp6": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp6", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp7": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp7", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 23, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp8": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp8", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 26, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp9": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp9", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 10 + }, + "pc": 29, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.pedersen_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.HashBuiltin*", + "full_name": "__main__.main.pedersen_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.HashBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 9, + "value": "cast([fp + (-3)] + 3, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 18, + "value": "cast([fp + (-3)] + 6, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 27, + "value": "cast([fp + (-3)] + 9, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 36, + "value": "cast([fp + (-3)] + 12, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + } + ], + "type": "reference" + }, + "starkware.cairo.common.cairo_builtins.BitwiseBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "x_and_y": { + "cairo_type": "felt", + "offset": 2 + }, + "x_or_y": { + "cairo_type": "felt", + "offset": 4 + }, + "x_xor_y": { + "cairo_type": "felt", + "offset": 3 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 5, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcOpBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.EcOpBuiltin", + "members": { + "m": { + "cairo_type": "felt", + "offset": 4 + }, + "p": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 0 + }, + "q": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 2 + }, + "r": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 5 + } + }, + "size": 7, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcPoint": { + "destination": "starkware.cairo.common.ec_point.EcPoint", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.HashBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "members": { + "result": { + "cairo_type": "felt", + "offset": 2 + }, + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 3, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.KeccakBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 8 + } + }, + "size": 16, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltinState": { + "destination": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 3 + } + }, + "size": 6, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltinState": { + "destination": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.SignatureBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.SignatureBuiltin", + "members": { + "message": { + "cairo_type": "felt", + "offset": 1 + }, + "pub_key": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.ec_point.EcPoint": { + "full_name": "starkware.cairo.common.ec_point.EcPoint", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.keccak_state.KeccakBuiltinState": { + "full_name": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + }, + "s3": { + "cairo_type": "felt", + "offset": 3 + }, + "s4": { + "cairo_type": "felt", + "offset": 4 + }, + "s5": { + "cairo_type": "felt", + "offset": 5 + }, + "s6": { + "cairo_type": "felt", + "offset": 6 + }, + "s7": { + "cairo_type": "felt", + "offset": 7 + } + }, + "size": 8, + "type": "struct" + }, + "starkware.cairo.common.poseidon_state.PoseidonBuiltinState": { + "full_name": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + } + }, + "size": 3, + "type": "struct" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.HashBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 9, + "value": "cast([fp + (-3)] + 3, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 18, + "value": "cast([fp + (-3)] + 6, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 23, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 26, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 27, + "value": "cast([fp + (-3)] + 9, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 10 + }, + "pc": 29, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 11 + }, + "pc": 32, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 35, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 36, + "value": "cast([fp + (-3)] + 12, starkware.cairo.common.cairo_builtins.HashBuiltin*)" + } + ] + } +} diff --git a/cairo0/builtins/poseidon_builtin.cairo b/cairo0/builtins/poseidon_builtin.cairo new file mode 100644 index 0000000..94cf48e --- /dev/null +++ b/cairo0/builtins/poseidon_builtin.cairo @@ -0,0 +1,21 @@ +%builtins poseidon + +from starkware.cairo.common.cairo_builtins import PoseidonBuiltin +from starkware.cairo.common.poseidon_state import PoseidonBuiltinState + +func main{poseidon_ptr: PoseidonBuiltin*}() { + assert poseidon_ptr[0].input = PoseidonBuiltinState(1, 2, 3); + let result = poseidon_ptr[0].output; + let poseidon_ptr = poseidon_ptr + PoseidonBuiltin.SIZE; + assert result.s0 = 442682200349489646213731521593476982257703159825582578145778919623645026501; + assert result.s1 = 2233832504250924383748553933071188903279928981104663696710686541536735838182; + assert result.s2 = 2512222140811166287287541003826449032093371832913959128171347018667852712082; + + assert poseidon_ptr[0].input = PoseidonBuiltinState(13, 40, 36); + let result = poseidon_ptr[0].output; + let poseidon_ptr = poseidon_ptr + PoseidonBuiltin.SIZE; + assert result.s0 = 1444012836772460926284672162976355419809540186674760964183552435963176573742; + assert result.s1 = 1541263763841611133055414279879179440960986686052381666910348740660012074535; + assert result.s2 = 2502492865904268664943542226035155619416122443735694424675086833952759734985; + return (); +} diff --git a/cairo0/builtins/poseidon_builtin.json b/cairo0/builtins/poseidon_builtin.json new file mode 100644 index 0000000..9e88e1d --- /dev/null +++ b/cairo0/builtins/poseidon_builtin.json @@ -0,0 +1,1451 @@ +{ + "attributes": [], + "builtins": ["poseidon"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0x1", + "0x400280007ffd7fff", + "0x480680017fff8000", + "0x2", + "0x400280017ffd7fff", + "0x480680017fff8000", + "0x3", + "0x400280027ffd7fff", + "0x480680017fff8000", + "0xfa8c9b6742b6176139365833d001e30e932a9bf7456d009b1b174f36d558c5", + "0x400280037ffd7fff", + "0x480680017fff8000", + "0x4f04deca4cb7f9f2bd16b1d25b817ca2d16fba2151e4252a2e2111cde08bfe6", + "0x400280047ffd7fff", + "0x480680017fff8000", + "0x58dde0a2a785b395ee2dc7b60b79e9472ab826e9bb5383a8018b59772964892", + "0x400280057ffd7fff", + "0x480680017fff8000", + "0xd", + "0x400280067ffd7fff", + "0x480680017fff8000", + "0x28", + "0x400280077ffd7fff", + "0x480680017fff8000", + "0x24", + "0x400280087ffd7fff", + "0x480680017fff8000", + "0x3314844f551d723c07039394d16ceabebb5178983820576d393ed4725465b2e", + "0x400280097ffd7fff", + "0x480680017fff8000", + "0x368530a53a48b47a14e8e4e5cc1e531ec1c7fd92a0480ac5143ad6dc5794627", + "0x4002800a7ffd7fff", + "0x480680017fff8000", + "0x5885c5b4d797dbae20b78bbfbb6e5ba02cc0a21ae05a9cac3606a21805be2c9", + "0x4002800b7ffd7fff", + "0x482680017ffd8000", + "0xc", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.poseidon_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 58, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 57, + "start_line": 7 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.poseidon_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 66, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.poseidon_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 61, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 60, + "start_line": 7 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.poseidon_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 66, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "6": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.poseidon_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 64, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 63, + "start_line": 7 + } + }, + "8": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.poseidon_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 66, + "end_line": 7, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 7 + } + }, + "9": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 3 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 99, + "end_line": 10, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 24, + "start_line": 10 + } + }, + "11": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 10, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 10 + } + }, + "12": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 4 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 11, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 24, + "start_line": 11 + } + }, + "14": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 101, + "end_line": 11, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 11 + } + }, + "15": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 5 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 12, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 24, + "start_line": 12 + } + }, + "17": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 101, + "end_line": 12, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 12 + } + }, + "18": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 6 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 59, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 57, + "start_line": 14 + } + }, + "20": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 69, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 14 + } + }, + "21": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 7 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 63, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 61, + "start_line": 14 + } + }, + "23": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 69, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 14 + } + }, + "24": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 8 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 67, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 65, + "start_line": 14 + } + }, + "26": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 9 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.poseidon_ptr": 5, + "__main__.main.result": 4 + } + }, + "hints": [], + "inst": { + "end_col": 69, + "end_line": 14, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 14 + } + }, + "27": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 9 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 24, + "start_line": 17 + } + }, + "29": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 10 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 101, + "end_line": 17, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 17 + } + }, + "30": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 10 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 24, + "start_line": 18 + } + }, + "32": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 11 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 101, + "end_line": 18, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 18 + } + }, + "33": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 11 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 15, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 100, + "end_line": 19, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 24, + "start_line": 19 + } + }, + "35": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 12 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 15, + "__main__.main.__temp11": 16, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 101, + "end_line": 19, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 19 + } + }, + "36": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 12 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 15, + "__main__.main.__temp11": 16, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 59, + "end_line": 16, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 41, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 20, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 20 + }, + "While trying to retrieve the implicit argument 'poseidon_ptr' in:" + ], + "start_col": 11, + "start_line": 6 + }, + "While expanding the reference 'poseidon_ptr' in:" + ], + "start_col": 24, + "start_line": 16 + } + }, + "38": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 13 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.__temp1": 2, + "__main__.main.__temp10": 15, + "__main__.main.__temp11": 16, + "__main__.main.__temp2": 3, + "__main__.main.__temp3": 6, + "__main__.main.__temp4": 7, + "__main__.main.__temp5": 8, + "__main__.main.__temp6": 9, + "__main__.main.__temp7": 10, + "__main__.main.__temp8": 11, + "__main__.main.__temp9": 14, + "__main__.main.poseidon_ptr": 13, + "__main__.main.result": 12 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 20, + "input_file": { + "filename": "cairo0/Builtins/poseidon_builtin.cairo" + }, + "start_col": 5, + "start_line": 20 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.PoseidonBuiltin": { + "destination": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin", + "type": "alias" + }, + "__main__.PoseidonBuiltinState": { + "destination": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "type": "alias" + }, + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "poseidon_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp1": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp1", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp10": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp10", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 11 + }, + "pc": 32, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp11": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp11", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 35, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp2": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp2", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp3": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp3", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp4": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp4", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp5": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp5", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp6": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp6", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp7": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp7", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 23, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp8": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp8", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 26, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.__temp9": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp9", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 10 + }, + "pc": 29, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.poseidon_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin*", + "full_name": "__main__.main.poseidon_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.PoseidonBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 9, + "value": "cast([fp + (-3)] + 6, starkware.cairo.common.cairo_builtins.PoseidonBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 27, + "value": "cast([fp + (-3)] + 12, starkware.cairo.common.cairo_builtins.PoseidonBuiltin*)" + } + ], + "type": "reference" + }, + "__main__.main.result": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "full_name": "__main__.main.result", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 9, + "value": "[cast([fp + (-3)] + 3, starkware.cairo.common.poseidon_state.PoseidonBuiltinState*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 27, + "value": "[cast([fp + (-3)] + 9, starkware.cairo.common.poseidon_state.PoseidonBuiltinState*)]" + } + ], + "type": "reference" + }, + "starkware.cairo.common.cairo_builtins.BitwiseBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.BitwiseBuiltin", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "x_and_y": { + "cairo_type": "felt", + "offset": 2 + }, + "x_or_y": { + "cairo_type": "felt", + "offset": 4 + }, + "x_xor_y": { + "cairo_type": "felt", + "offset": 3 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 5, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcOpBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.EcOpBuiltin", + "members": { + "m": { + "cairo_type": "felt", + "offset": 4 + }, + "p": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 0 + }, + "q": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 2 + }, + "r": { + "cairo_type": "starkware.cairo.common.ec_point.EcPoint", + "offset": 5 + } + }, + "size": 7, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.EcPoint": { + "destination": "starkware.cairo.common.ec_point.EcPoint", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.HashBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "members": { + "result": { + "cairo_type": "felt", + "offset": 2 + }, + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 3, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.KeccakBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "offset": 8 + } + }, + "size": 16, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.KeccakBuiltinState": { + "destination": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.PoseidonBuiltin", + "members": { + "input": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 0 + }, + "output": { + "cairo_type": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "offset": 3 + } + }, + "size": 6, + "type": "struct" + }, + "starkware.cairo.common.cairo_builtins.PoseidonBuiltinState": { + "destination": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "type": "alias" + }, + "starkware.cairo.common.cairo_builtins.SignatureBuiltin": { + "full_name": "starkware.cairo.common.cairo_builtins.SignatureBuiltin", + "members": { + "message": { + "cairo_type": "felt", + "offset": 1 + }, + "pub_key": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.ec_point.EcPoint": { + "full_name": "starkware.cairo.common.ec_point.EcPoint", + "members": { + "x": { + "cairo_type": "felt", + "offset": 0 + }, + "y": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.cairo.common.keccak_state.KeccakBuiltinState": { + "full_name": "starkware.cairo.common.keccak_state.KeccakBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + }, + "s3": { + "cairo_type": "felt", + "offset": 3 + }, + "s4": { + "cairo_type": "felt", + "offset": 4 + }, + "s5": { + "cairo_type": "felt", + "offset": 5 + }, + "s6": { + "cairo_type": "felt", + "offset": 6 + }, + "s7": { + "cairo_type": "felt", + "offset": 7 + } + }, + "size": 8, + "type": "struct" + }, + "starkware.cairo.common.poseidon_state.PoseidonBuiltinState": { + "full_name": "starkware.cairo.common.poseidon_state.PoseidonBuiltinState", + "members": { + "s0": { + "cairo_type": "felt", + "offset": 0 + }, + "s1": { + "cairo_type": "felt", + "offset": 1 + }, + "s2": { + "cairo_type": "felt", + "offset": 2 + } + }, + "size": 3, + "type": "struct" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), starkware.cairo.common.cairo_builtins.PoseidonBuiltin**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 2 + }, + "pc": 5, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 8, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 9, + "value": "[cast([fp + (-3)] + 3, starkware.cairo.common.poseidon_state.PoseidonBuiltinState*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 3 + }, + "pc": 9, + "value": "cast([fp + (-3)] + 6, starkware.cairo.common.cairo_builtins.PoseidonBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 4 + }, + "pc": 11, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 5 + }, + "pc": 14, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 6 + }, + "pc": 17, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 7 + }, + "pc": 20, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 8 + }, + "pc": 23, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 26, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 27, + "value": "[cast([fp + (-3)] + 9, starkware.cairo.common.poseidon_state.PoseidonBuiltinState*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 9 + }, + "pc": 27, + "value": "cast([fp + (-3)] + 12, starkware.cairo.common.cairo_builtins.PoseidonBuiltin*)" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 10 + }, + "pc": 29, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 11 + }, + "pc": 32, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 12 + }, + "pc": 35, + "value": "[cast(ap + (-1), felt*)]" + } + ] + } +} diff --git a/cairo0/builtins/range_check96_builtin.cairo b/cairo0/builtins/range_check96_builtin.cairo new file mode 100644 index 0000000..55842f8 --- /dev/null +++ b/cairo0/builtins/range_check96_builtin.cairo @@ -0,0 +1,7 @@ +%builtins range_check96 + +func main{range_check96_ptr: felt*}() { + assert [range_check96_ptr] = 2 ** 96 - 1; + let range_check96_ptr = range_check96_ptr + 1; + return (); +} diff --git a/cairo0/builtins/range_check96_buitlin.json b/cairo0/builtins/range_check96_buitlin.json new file mode 100644 index 0000000..b90741a --- /dev/null +++ b/cairo0/builtins/range_check96_buitlin.json @@ -0,0 +1,234 @@ +{ + "attributes": [], + "builtins": ["range_check96"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0xffffffffffffffffffffffff", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.range_check96_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 45, + "end_line": 4, + "input_file": { + "filename": "cairo0/Builtins/range_check96_builtin.cairo" + }, + "start_col": 34, + "start_line": 4 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.range_check96_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 46, + "end_line": 4, + "input_file": { + "filename": "cairo0/Builtins/range_check96_builtin.cairo" + }, + "start_col": 5, + "start_line": 4 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.range_check96_ptr": 2 + } + }, + "hints": [], + "inst": { + "end_col": 50, + "end_line": 5, + "input_file": { + "filename": "cairo0/Builtins/range_check96_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 35, + "end_line": 3, + "input_file": { + "filename": "cairo0/Builtins/range_check96_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/range_check96_builtin.cairo" + }, + "start_col": 5, + "start_line": 6 + }, + "While trying to retrieve the implicit argument 'range_check96_ptr' in:" + ], + "start_col": 11, + "start_line": 3 + }, + "While expanding the reference 'range_check96_ptr' in:" + ], + "start_col": 29, + "start_line": 5 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.range_check96_ptr": 2 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/range_check96_builtin.cairo" + }, + "start_col": 5, + "start_line": 6 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "range_check96_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.range_check96_ptr": { + "cairo_type": "felt*", + "full_name": "__main__.main.range_check96_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 3, + "value": "cast([fp + (-3)] + 1, felt*)" + } + ], + "type": "reference" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 3, + "value": "cast([fp + (-3)] + 1, felt*)" + } + ] + } +} diff --git a/cairo0/builtins/range_check_builtin.cairo b/cairo0/builtins/range_check_builtin.cairo new file mode 100644 index 0000000..e00511b --- /dev/null +++ b/cairo0/builtins/range_check_builtin.cairo @@ -0,0 +1,7 @@ +%builtins range_check + +func main{range_check_ptr: felt*}() { + assert [range_check_ptr] = 2 ** 128 - 1; + let range_check_ptr = range_check_ptr + 1; + return (); +} diff --git a/cairo0/builtins/range_check_builtin.json b/cairo0/builtins/range_check_builtin.json new file mode 100644 index 0000000..d6a1b33 --- /dev/null +++ b/cairo0/builtins/range_check_builtin.json @@ -0,0 +1,234 @@ +{ + "attributes": [], + "builtins": ["range_check"], + "compiler_version": "0.13.1", + "data": [ + "0x480680017fff8000", + "0xffffffffffffffffffffffffffffffff", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x1", + "0x208b7fff7fff7ffe" + ], + "debug_info": { + "file_contents": {}, + "instruction_locations": { + "0": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 0 + }, + "reference_ids": { + "__main__.main.range_check_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 44, + "end_line": 4, + "input_file": { + "filename": "cairo0/Builtins/range_check_builtin.cairo" + }, + "start_col": 32, + "start_line": 4 + } + }, + "2": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.range_check_ptr": 0 + } + }, + "hints": [], + "inst": { + "end_col": 45, + "end_line": 4, + "input_file": { + "filename": "cairo0/Builtins/range_check_builtin.cairo" + }, + "start_col": 5, + "start_line": 4 + } + }, + "3": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 1 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.range_check_ptr": 2 + } + }, + "hints": [], + "inst": { + "end_col": 46, + "end_line": 5, + "input_file": { + "filename": "cairo0/Builtins/range_check_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 33, + "end_line": 3, + "input_file": { + "filename": "cairo0/Builtins/range_check_builtin.cairo" + }, + "parent_location": [ + { + "end_col": 15, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/range_check_builtin.cairo" + }, + "start_col": 5, + "start_line": 6 + }, + "While trying to retrieve the implicit argument 'range_check_ptr' in:" + ], + "start_col": 11, + "start_line": 3 + }, + "While expanding the reference 'range_check_ptr' in:" + ], + "start_col": 27, + "start_line": 5 + } + }, + "5": { + "accessible_scopes": ["__main__", "__main__.main"], + "flow_tracking_data": { + "ap_tracking": { + "group": 0, + "offset": 2 + }, + "reference_ids": { + "__main__.main.__temp0": 1, + "__main__.main.range_check_ptr": 2 + } + }, + "hints": [], + "inst": { + "end_col": 15, + "end_line": 6, + "input_file": { + "filename": "cairo0/Builtins/range_check_builtin.cairo" + }, + "start_col": 5, + "start_line": 6 + } + } + } + }, + "hints": {}, + "identifiers": { + "__main__.main": { + "decorators": [], + "pc": 0, + "type": "function" + }, + "__main__.main.Args": { + "full_name": "__main__.main.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.main.ImplicitArgs": { + "full_name": "__main__.main.ImplicitArgs", + "members": { + "range_check_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.main.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.main.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.main.__temp0": { + "cairo_type": "felt", + "full_name": "__main__.main.__temp0", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + } + ], + "type": "reference" + }, + "__main__.main.range_check_ptr": { + "cairo_type": "felt*", + "full_name": "__main__.main.range_check_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 3, + "value": "cast([fp + (-3)] + 1, felt*)" + } + ], + "type": "reference" + } + }, + "main_scope": "__main__", + "prime": "0x800000000000011000000000000000000000000000000000000000000000001", + "reference_manager": { + "references": [ + { + "ap_tracking_data": { + "group": 0, + "offset": 0 + }, + "pc": 0, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 2, + "value": "[cast(ap + (-1), felt*)]" + }, + { + "ap_tracking_data": { + "group": 0, + "offset": 1 + }, + "pc": 3, + "value": "cast([fp + (-3)] + 1, felt*)" + } + ] + } +} diff --git a/src/builtins/ec_op/ec_op.ts b/src/builtins/ec_op/ec_op.ts index ebb3e3c..75f2d4a 100644 --- a/src/builtins/ec_op/ec_op.ts +++ b/src/builtins/ec_op/ec_op.ts @@ -51,5 +51,5 @@ function ecMul(m: bigint, p: AffinePoint): AffinePoint { } function ecOp(m: bigint, p: AffinePoint, q: AffinePoint): AffinePoint { - return ecAdd(ecMul(m, p), q); + return ecAdd(p, ecMul(m, q)); } diff --git a/src/builtins/keccak/keccak.ts b/src/builtins/keccak/keccak.ts deleted file mode 100644 index 0879fde..0000000 --- a/src/builtins/keccak/keccak.ts +++ /dev/null @@ -1,137 +0,0 @@ -//This is the typescript version of the compact python implementation by the Keccak team : -//https://github.com/XKCP/XKCP/blob/master/Standalone/CompactFIPS202/Python/CompactFIPS202.py - -function ROL64(a: bigint, n: number): bigint { - return ( - ((a >> (BigInt(64) - BigInt(n % 64))) + (a << BigInt(n % 64))) % - (BigInt(1) << BigInt(64)) - ); -} - -function keccakF1600onLanes(lanes: bigint[][]): bigint[][] { - let R = 1; - for (let round = 0; round < 24; round++) { - const C = new Array(5) - .fill(BigInt(0)) - .map( - (_, x) => - lanes[x][0] ^ lanes[x][1] ^ lanes[x][2] ^ lanes[x][3] ^ lanes[x][4], - ); - const D = new Array(5) - .fill(BigInt(0)) - .map((_, x) => C[(x + 4) % 5] ^ ROL64(C[(x + 1) % 5], 1)); - lanes = lanes.map((row, x) => row.map((lane, y) => lane ^ D[x])); - - let x = 1, - y = 0; - let current = lanes[x][y]; - for (let t = 0; t < 24; t++) { - [x, y] = [y, (2 * x + 3 * y) % 5]; - [current, lanes[x][y]] = [ - lanes[x][y], - ROL64(current, ((t + 1) * (t + 2)) / 2), - ]; - } - - for (let y = 0; y < 5; y++) { - const T = lanes.map((row) => row[y]); - for (let x = 0; x < 5; x++) { - lanes[x][y] = T[x] ^ (~T[(x + 1) % 5] & T[(x + 2) % 5]); - } - } - - for (let j = 0; j < 7; j++) { - R = ((R << 1) ^ ((R >> 7) * 0x71)) % 256; - if (R & 2) { - lanes[0][0] ^= BigInt(1) << BigInt((1 << j) - 1); - } - } - } - return lanes; -} - -function load64(b: Uint8Array): bigint { - return b.reduce( - (acc, byte, i) => acc + (BigInt(byte) << BigInt(8 * i)), - BigInt(0), - ); -} - -function store64(a: bigint): Uint8Array { - const b = new Uint8Array(8); - for (let i = 0; i < 8; i++) { - b[i] = Number((a >> BigInt(8 * i)) % BigInt(256)); - } - return b; -} - -function keccakF1600(state: Uint8Array): Uint8Array { - let lanes = new Array(5) - .fill(0) - .map((_, x) => - new Array(5) - .fill(BigInt(0)) - .map((_, y) => - load64(state.slice(8 * (x + 5 * y), 8 * (x + 5 * y) + 8)), - ), - ); - lanes = keccakF1600onLanes(lanes); - const newState = new Uint8Array(200); - for (let x = 0; x < 5; x++) { - for (let y = 0; y < 5; y++) { - newState.set(store64(lanes[x][y]), 8 * (x + 5 * y)); - } - } - return newState; -} - -function keccak( - rate: number, - capacity: number, - inputBytes: Uint8Array, - delimitedSuffix: number, - outputByteLen: number, -): Uint8Array | undefined { - let outputBytes = new Uint8Array(); - let state = new Uint8Array(200); - const rateInBytes = rate / 8; - let blockSize = 0; - - if (rate + capacity !== 1600 || rate % 8 !== 0) { - return; - } - - let inputOffset = 0; - while (inputOffset < inputBytes.length) { - blockSize = Math.min(inputBytes.length - inputOffset, rateInBytes); - for (let i = 0; i < blockSize; i++) { - state[i] ^= inputBytes[i + inputOffset]; - } - inputOffset += blockSize; - if (blockSize === rateInBytes) { - state = keccakF1600(state); - blockSize = 0; - } - } - - state[blockSize] ^= delimitedSuffix; - if ((delimitedSuffix & 0x80) !== 0 && blockSize === rateInBytes - 1) { - state = keccakF1600(state); - } - state[rateInBytes - 1] ^= 0x80; - state = keccakF1600(state); - - while (outputByteLen > 0) { - blockSize = Math.min(outputByteLen, rateInBytes); - outputBytes = Uint8Array.from([ - ...outputBytes, - ...state.slice(0, blockSize), - ]); - outputByteLen -= blockSize; - if (outputByteLen > 0) { - state = keccakF1600(state); - } - } - - return outputBytes; -} diff --git a/src/builtins/keccak/keccak_f1600.ts b/src/builtins/keccak/keccak_f1600.ts new file mode 100644 index 0000000..0fb2f63 --- /dev/null +++ b/src/builtins/keccak/keccak_f1600.ts @@ -0,0 +1,110 @@ +// Keccak implementation from https://github.com/paulmillr/noble-hashes + +const U32_MASK64 = BigInt(2 ** 32 - 1); +const _32n = BigInt(32); + +function fromBig(n: bigint, le = false) { + if (le) + return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) }; + return { + h: Number((n >> _32n) & U32_MASK64) | 0, + l: Number(n & U32_MASK64) | 0, + }; +} + +function split(lst: bigint[], le = false) { + let Ah = new Uint32Array(lst.length); + let Al = new Uint32Array(lst.length); + for (let i = 0; i < lst.length; i++) { + const { h, l } = fromBig(lst[i], le); + [Ah[i], Al[i]] = [h, l]; + } + return [Ah, Al]; +} + +// Left rotate for Shift in [1, 32) +const rotlSH = (h: number, l: number, s: number) => (h << s) | (l >>> (32 - s)); +const rotlSL = (h: number, l: number, s: number) => (l << s) | (h >>> (32 - s)); +// Left rotate for Shift in (32, 64), NOTE: 32 is special case. +const rotlBH = (h: number, l: number, s: number) => + (l << (s - 32)) | (h >>> (64 - s)); +const rotlBL = (h: number, l: number, s: number) => + (h << (s - 32)) | (l >>> (64 - s)); + +// Various per round constants calculations +const SHA3_PI: number[] = []; +const SHA3_ROTL: number[] = []; +const _SHA3_IOTA: bigint[] = []; +const _0n = BigInt(0); +const _1n = BigInt(1); +const _2n = BigInt(2); +const _7n = BigInt(7); +const _256n = BigInt(256); +const _0x71n = BigInt(0x71); +for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) { + // Pi + [x, y] = [y, (2 * x + 3 * y) % 5]; + SHA3_PI.push(2 * (5 * y + x)); + // Rotational + SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64); + // Iota + let t = _0n; + for (let j = 0; j < 7; j++) { + R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n; + if (R & _2n) t ^= _1n << ((_1n << BigInt(j)) - _1n); + } + _SHA3_IOTA.push(t); +} +const [SHA3_IOTA_H, SHA3_IOTA_L] = split(_SHA3_IOTA, true); + +// Left rotation (without 0, 32, 64) +const rotlH = (h: number, l: number, s: number) => + s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s); +const rotlL = (h: number, l: number, s: number) => + s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s); + +// Same as keccakf1600, but allows to skip some rounds +function keccakP(s: Uint32Array, rounds: number = 24) { + const B = new Uint32Array(5 * 2); + // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js) + for (let round = 24 - rounds; round < 24; round++) { + // Theta θ + for (let x = 0; x < 10; x++) + B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; + for (let x = 0; x < 10; x += 2) { + const idx1 = (x + 8) % 10; + const idx0 = (x + 2) % 10; + const B0 = B[idx0]; + const B1 = B[idx0 + 1]; + const Th = rotlH(B0, B1, 1) ^ B[idx1]; + const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; + for (let y = 0; y < 50; y += 10) { + s[x + y] ^= Th; + s[x + y + 1] ^= Tl; + } + } + // Rho (ρ) and Pi (π) + let curH = s[2]; + let curL = s[3]; + for (let t = 0; t < 24; t++) { + const shift = SHA3_ROTL[t]; + const Th = rotlH(curH, curL, shift); + const Tl = rotlL(curH, curL, shift); + const PI = SHA3_PI[t]; + curH = s[PI]; + curL = s[PI + 1]; + s[PI] = Th; + s[PI + 1] = Tl; + } + // Chi (χ) + for (let y = 0; y < 50; y += 10) { + for (let x = 0; x < 10; x++) B[x] = s[y + x]; + for (let x = 0; x < 10; x++) + s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; + } + // Iota (ι) + s[0] ^= SHA3_IOTA_H[round]; + s[1] ^= SHA3_IOTA_L[round]; + } + B.fill(0); +} diff --git a/src/builtins/keccak/keccak_utils.ts b/src/builtins/keccak/keccak_utils.ts new file mode 100644 index 0000000..fca7384 --- /dev/null +++ b/src/builtins/keccak/keccak_utils.ts @@ -0,0 +1,89 @@ +// Utils for keccak come from paulmillr's repo : +// https://github.com/paulmillr/noble-curves and https://github.com/paulmillr/noble-hashes + +type TypedArray = + | Int8Array + | Uint8ClampedArray + | Uint8Array + | Uint16Array + | Int16Array + | Uint32Array + | Int32Array; +const u8 = (arr: TypedArray) => + new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength); +const u32 = (arr: TypedArray) => + new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); + +function concatBytes(...arrays: Uint8Array[]): Uint8Array { + let sum = 0; + for (let i = 0; i < arrays.length; i++) { + const a = arrays[i]; + sum += a.length; + } + const res = new Uint8Array(sum); + for (let i = 0, pad = 0; i < arrays.length; i++) { + const a = arrays[i]; + res.set(a, pad); + pad += a.length; + } + return res; +} + +const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const; +function asciiToBase16(ch: number): number | undefined { + if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48 + if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10) + if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10) + return; +} + +const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => + i.toString(16).padStart(2, "0"), +); +function bytesToHex(bytes: Uint8Array): string { + // pre-caching improves the speed 6x + let hex = ""; + for (let i = 0; i < bytes.length; i++) { + hex += hexes[bytes[i]]; + } + return hex; +} + +function hexToBytes(hex: string): Uint8Array { + if (typeof hex !== "string") + throw new Error("hex string expected, got " + typeof hex); + const hl = hex.length; + const al = hl / 2; + if (hl % 2) + throw new Error("hex string expected, got unpadded hex of length " + hl); + const array = new Uint8Array(al); + for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) { + const n1 = asciiToBase16(hex.charCodeAt(hi)); + const n2 = asciiToBase16(hex.charCodeAt(hi + 1)); + if (n1 === undefined || n2 === undefined) { + const char = hex[hi] + hex[hi + 1]; + throw new Error( + 'hex string expected, got non-hex character "' + + char + + '" at index ' + + hi, + ); + } + array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163 + } + return array; +} + +function hexToNumber(hex: string): bigint { + return hex === "" ? _0n : BigInt("0x" + hex); // Big Endian +} + +function bytesToNumberLE(bytes: Uint8Array): bigint { + return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse())); +} +function numberToBytesBE(n: number | bigint, len: number): Uint8Array { + return hexToBytes(n.toString(16).padStart(len * 2, "0")); +} +function numberToBytesLE(n: number | bigint, len: number): Uint8Array { + return numberToBytesBE(n, len).reverse(); +} diff --git a/src/builtins/poseidon/poseidon.ts b/src/builtins/poseidon/poseidon.ts index ac697cc..eebcf6e 100644 --- a/src/builtins/poseidon/poseidon.ts +++ b/src/builtins/poseidon/poseidon.ts @@ -37,7 +37,7 @@ function hadesRound( return values; } -function poseidon(x: bigint, y: bigint): bigint { +function poseidon(x: bigint, y: bigint, z: bigint): bigint[] { const params: HadesParamsType = { r: 2, c: 1, @@ -49,8 +49,8 @@ function poseidon(x: bigint, y: bigint): bigint { ark: roundKeys, mds: matrix, }; - var values: bigint[] = [x, y, BigInt(2)]; - return hadesPermutation(values, params)[0]; + var values: bigint[] = [x, y, z]; + return hadesPermutation(values, params); } function modAddVectors(A: bigint[], B: bigint[]): bigint[] { diff --git a/src/tests.ts b/src/tests.ts index a8a717b..b07f47a 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -108,31 +108,5 @@ function testRunner() { ); }); - test("poseidon hash", (t) => { - //This test comes from : https://github.com/paulmillr/noble-curves/blob/main/test/poseidon.test.js#L88 - t.equal( - poseidon( - BigInt( - "4379311784651118086770398084575492314150568148003994287303975907890254409956", - ), - BigInt( - "5329163686893598957822497554130545759427567507701132391649270915797304266381", - ), - ), - BigInt( - "2457757238178986673695038558497063891521456354791980183317105434323761563347", - ), - ); - }); - - test("keccak", (t) => { - t.equal( - BigInt(KECCAK("hello")), - BigInt( - "0x8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8", - ), - ); //test value comes from https://github.com/paulmillr/scure-starknet - }); - test.finish(); } diff --git a/src/ui/Code.ts b/src/ui/Code.ts index 4c56dc2..3e64fc6 100644 --- a/src/ui/Code.ts +++ b/src/ui/Code.ts @@ -58,125 +58,97 @@ function DECODE_INSTRUCTION(encodedInstruction: string): [any[]] { } } -function TO_SIGNED_INTEGER(encodedInstruction: string): [any[]] { - return [["", "", toSignedInteger(BigInt(encodedInstruction)).toString(10)]]; +function TO_UNSIGNED_INTEGER(encodedInstruction: string): [any[]] { + return [["", "", toUnsignedInteger(BigInt(encodedInstruction)).toString(10)]]; } -/** - * Provides custom function for bitwise 'and' for given two inputs. - * - * @param {number} x - one of the input for 'and' operation - * @param {number} y - the other input for 'and' operation - * @return The bitwise 'and' of two given inputs in bigint form. - * @customfunction - */ -function BITWISE_AND(x: number | string, y: number | string): string { - return x == "" || y == "" - ? "" - : bitwiseAnd(BigInt(x), BigInt(y)).toString(10); -} - -/** - * Provides custom function for bitwise 'xor' for given two inputs. - * - * @param {number} x - one of the input for 'xor' operation - * @param {number} y - the other input for 'xor' operation - * @return The bitwise 'xor' of two given inputs in bigint form. - * @customfunction - */ -function BITWISE_XOR(x: number | string, y: number | string): string { - return x == "" || y == "" - ? "" - : bitwiseXor(BigInt(x), BigInt(y)).toString(10); -} - -/** - * Provides custom function for bitwise 'or' for given two inputs. - * - * @param {number} x - one of the input for 'or' operation - * @param {number} y - the other input for 'or' operation - * @return The bitwise 'or' of two given inputs in bigint form. - * @customfunction - */ -function BITWISE_OR(x: number | string, y: number | string): string { - return x == "" || y == "" ? "" : bitwiseOr(BigInt(x), BigInt(y)).toString(10); -} - -function EC_OP( - m: number | string, - p: AffinePoint, - q: AffinePoint, -): AffinePoint { - return ecOp(BigInt(m), p, q); -} - -function SIGN_ECDSA( - message: number | string, - private_key: number | string, -): SignatureType { - return signMessage(BigInt(message), BigInt(private_key)); -} - -function CHECK_ECDSA_SIGNATURE( - r: number | string, - s: number | string, - message: number | string, - x: number | string, - y: number | string, -): boolean { - var signature: SignatureType = { r: BigInt(r), s: BigInt(s) }; - var public_key = new AffinePoint(String(x), String(y)); - return verifySignature(signature, BigInt(message), public_key); -} - -/** - * Provides custom function for range checking a given input. - * - * @param {number} num - The number which is to be validated. - * @return The number itself in bigint form if it is in range, else throws InvalidRangeError. - * @customfunction - */ -function RANGE_CHECK(num: number | string): string { - return num == "" ? "" : rangeCheck(BigInt(num)).toString(10); -} - -function PEDERSEN(x: number | string, y: number | string): number | string { - return x == "" || y == "" ? "" : pedersen(BigInt(x), BigInt(y)).toString(10); -} - -function KECCAK(message: string): string { - if (message == "") { - return ""; +function BITWISE(inputs: string[][]): string[] { + if (hasEmptyCell(inputs)) { + return [""]; } - const utf8Bytes = encodeUTF8(message.toString()); - const bytearrayOutput = keccak(1088, 512, utf8Bytes, 0x01, 256 / 8); - - const bitOutput = Array.from(bytearrayOutput) - .map((byte) => byte.toString(2).padStart(8, "0")) - .join(""); - - // trim the first 6 bits as Starknet keccak is keccak % 2**250 - const bitStringSlice = bitOutput.slice(6); - const bitBigInt = BigInt("0b" + bitStringSlice); - - const decOutput = bitBigInt.toString(10); - return decOutput; + const [x, y] = inputs.flat(); + return [ + bitwiseAnd(BigInt(x), BigInt(y)).toString(10), + bitwiseXor(BigInt(x), BigInt(y)).toString(10), + bitwiseOr(BigInt(x), BigInt(y)).toString(10), + ]; } -function POSEIDON(x: number | string, y: number | string): number | string { - return x == "" || y == "" ? "" : poseidon(BigInt(x), BigInt(y)).toString(10); +function EC_OP(inputs: string[][]): string[] { + if (hasEmptyCell(inputs)) { + return [""]; + } + const [px, py, qx, qy, m] = inputs.flat(); + let p = new AffinePoint(px, py); + let q = new AffinePoint(qx, qy); + let ecOpResult: AffinePoint = ecOp(BigInt(m), p, q); + return [ecOpResult.x.toString(10), ecOpResult.y.toString(10)]; +} + +// function SIGN_ECDSA( +// message: number | string, +// private_key: number | string, +// ): SignatureType { +// return signMessage(BigInt(message), BigInt(private_key)); +// } + +// function CHECK_ECDSA_SIGNATURE(inputs: string[][]): string[] { +// if (hasEmptyCell(inputs)) { +// return [""]; +// } +// const [r, s, message, x, y] = inputs.flat(); +// var signature: SignatureType = { r: BigInt(r), s: BigInt(s) }; +// var public_key = new AffinePoint(String(x), String(y)); +// return [verifySignature(signature, BigInt(message), public_key)]; +// } + +function PEDERSEN(inputs: string[][]): string[] { + if (hasEmptyCell(inputs)) { + return [""]; + } + const [x, y] = inputs.flat(); + return [pedersen(BigInt(x), BigInt(y)).toString(10)]; } -function RANGE_CHECK96(num: number | string): string { - return num == "" ? "" : rangeCheck96(BigInt(num)).toString(10); +function KECCAK(inputs: string[][]): string[] { + if (hasEmptyCell(inputs)) { + return [""]; + } + let inputsFlattened: string[] = inputs.flat(); + const inputHash = concatBytes( + ...inputsFlattened.map((value) => { + return numberToBytesLE(BigInt(value), 25); + }), + ); + const state = u32(inputHash); + keccakP(state); + const finalState = u8(state); + const KECCAK_BYTES = 25; + const outputs = Array.from({ length: 8 }, (_, i) => + finalState.slice(i * KECCAK_BYTES, (i + 1) * KECCAK_BYTES), + ).map(bytesToNumberLE); + return outputs.map((output) => output.toString(10)); +} + +function POSEIDON(inputs: string[][]): string[] { + if (hasEmptyCell(inputs)) { + return [""]; + } + const [x, y, z] = inputs.flat(); + let poseidonResult: bigint[] = poseidon(BigInt(x), BigInt(y), BigInt(z)); + return [ + poseidonResult[0].toString(10), + poseidonResult[1].toString(10), + poseidonResult[2].toString(10), + ]; } -function ADD_FELT(a: number | string, b: number | string): number | string { - return modAdd(BigInt(a), BigInt(b)).toString(10); +function RANGE_CHECK(inputs: string): string[] { + return [rangeCheck(BigInt(inputs)).toString(10)]; } -function MUL_FELT(a: number | string, b: number | string): number | string { - return modMul(BigInt(a), BigInt(b)).toString(10); +function RANGE_CHECK96(inputs: string): string[] { + return [rangeCheck96(BigInt(inputs)).toString(10)]; } function GET_FLAGS_AND_OFFSETS(encodedInstruction: string): number[][] { diff --git a/src/ui/ui.ts b/src/ui/ui.ts index b4bca8f..8c4e17d 100644 --- a/src/ui/ui.ts +++ b/src/ui/ui.ts @@ -148,7 +148,7 @@ function loadProgram( [ bytecode[i], isConstant - ? `=TO_SIGNED_INTEGER(${progBytecodeColumn}${i + 2})` + ? `=TO_UNSIGNED_INTEGER(${progBytecodeColumn}${i + 2})` : `=DECODE_INSTRUCTION(${progBytecodeColumn}${i + 2})`, ], ]); diff --git a/src/utils.ts b/src/utils.ts index 7940a87..5273773 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -218,3 +218,6 @@ function isProofMode(): boolean { function nextPowerOfTwo(n: number): number { return 1 << Math.ceil(Math.log2(n)); } +function hasEmptyCell(array): boolean { + return array.flat().includes(""); +} diff --git a/src/vm/constants.ts b/src/vm/constants.ts index e115e62..f16d3bd 100644 --- a/src/vm/constants.ts +++ b/src/vm/constants.ts @@ -64,8 +64,9 @@ interface HadesParamsType { interface BuitlinType { freeCellsPerBuiltin: number; + numOutputCells: number; column: string; - functionName: string[]; + functionName: string; } type Layout = { diff --git a/src/vm/instructions.ts b/src/vm/instructions.ts index 1003b87..af8922c 100644 --- a/src/vm/instructions.ts +++ b/src/vm/instructions.ts @@ -29,6 +29,11 @@ function toSignedInteger(encodedInstruction): bigint { return number > BigInt(2 ** 128) ? number - PRIME : number; } +function toUnsignedInteger(encodedInstruction): bigint { + const number: bigint = BigInt(encodedInstruction); + return number < 0 ? number + PRIME : number; +} + function size(instruction): number { return instruction.Op1Register === Registers.PC ? 2 : 1; } diff --git a/src/vm/vm.ts b/src/vm/vm.ts index 05743c5..e870ad9 100644 --- a/src/vm/vm.ts +++ b/src/vm/vm.ts @@ -88,48 +88,57 @@ type Builtins = { let builtins: Builtins = { output: { freeCellsPerBuiltin: 0, + numOutputCells: 0, column: "", - functionName: ["OUTPUT"], + functionName: "OUTPUT", }, pedersen: { freeCellsPerBuiltin: 2, + numOutputCells: 1, column: "", - functionName: ["PEDERSEN"], + functionName: "PEDERSEN", }, range_check: { freeCellsPerBuiltin: 0, + numOutputCells: 1, column: "", - functionName: ["RANGE_CHECK"], + functionName: "RANGE_CHECK", }, range_check96: { freeCellsPerBuiltin: 0, + numOutputCells: 1, column: "", - functionName: ["RANGE_CHECK96"], + functionName: "RANGE_CHECK96", }, ecdsa: { freeCellsPerBuiltin: 3, + numOutputCells: 1, column: "", - functionName: ["CHECK_ECDSA_SIGNATURE"], + functionName: "CHECK_ECDSA_SIGNATURE", }, bitwise: { freeCellsPerBuiltin: 2, + numOutputCells: 3, column: "", - functionName: ["BITWISE_AND", "BITWISE_XOR", "BITWISE_OR"], + functionName: "BITWISE", }, ec_op: { - freeCellsPerBuiltin: 3, + freeCellsPerBuiltin: 5, + numOutputCells: 2, column: "", - functionName: ["EC_OP"], + functionName: "EC_OP", }, keccak: { - freeCellsPerBuiltin: 1, + freeCellsPerBuiltin: 8, + numOutputCells: 8, column: "", - functionName: ["KECCAK"], + functionName: "KECCAK", }, poseidon: { - freeCellsPerBuiltin: 2, + freeCellsPerBuiltin: 3, + numOutputCells: 3, column: "", - functionName: ["POSEIDON"], + functionName: "POSEIDON", }, }; @@ -291,8 +300,7 @@ function step(n: number = 0): void { if (Object.keys(builtinsColumns).includes(op1Column)) { const builtin = builtinsColumns[op1Column]; if (builtin.freeCellsPerBuiltin > 0) { - const builtinSize = - builtin.freeCellsPerBuiltin + builtin.functionName.length; + const builtinSize = builtin.freeCellsPerBuiltin + builtin.numOutputCells; const requiredInstances = op1Offset > 0 ? Math.ceil(op1Offset / builtinSize) : 1; @@ -306,18 +314,51 @@ function step(n: number = 0): void { for (let j = 1; j <= builtin.freeCellsPerBuiltin; j++) { inputCells.push(`${op1Column}${lastInstance + j + 1}`); } + runSheet + .getRange( + `${builtin.column}${lastInstance + 1 + builtin.freeCellsPerBuiltin + 1}`, + ) + .setFormula( + `=${builtin.functionName}(${inputCells[0]}:${inputCells[inputCells.length - 1]})`, + ); + } + } + } - for (let k = 0; k < builtin.functionName.length; k++) { - runSheet - .getRange( - `${builtin.column}${lastInstance + 1 + builtin.freeCellsPerBuiltin + 1}:${builtin.column}${lastBuiltinCell + 1}`, - ) - .setFormulas( - builtin.functionName.map((functionName) => [ - `=${functionName}(${inputCells.join(";")})`, - ]), - ); - } + if (builtins["range_check"].column != "") { + for ( + let j = 2; + j <= + getLastActiveFormulaRowNumber(builtins["range_check"].column, runSheet); + j++ + ) { + let currentCell: string = `${builtins["range_check"].column}${j}`; + let currentCellFormula: string = runSheet + .getRange(currentCell) + .getFormula(); + if (currentCellFormula[1] != "R") { + runSheet + .getRange(currentCell) + .setFormula(`=RANGE_CHECK(${currentCellFormula.substring(1)})`); + } + } + } + + if (builtins["range_check96"].column != "") { + for ( + let j = 2; + j <= + getLastActiveFormulaRowNumber(builtins["range_check96"].column, runSheet); + j++ + ) { + let currentCell: string = `${builtins["range_check96"].column}${j}`; + let currentCellFormula: string = runSheet + .getRange(currentCell) + .getFormula(); + if (currentCellFormula[1] != "R") { + runSheet + .getRange(currentCell) + .setFormula(`=RANGE_CHECK96(${currentCellFormula.substring(1)})`); } } } @@ -356,23 +397,11 @@ function step(n: number = 0): void { ); let validCallDstValue: string = registers[Registers.FP].toString(10); if (op0Value == "") { - runSheet - .getRange(op0Addr) - .setFormula( - op0Addr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${validCallOp0Value})` - : `="${validCallOp0Value}"`, - ); + runSheet.getRange(op0Addr).setFormula(`="${validCallOp0Value}"`); op0Value = runSheet.getRange(op0Addr).getValue(); } if (dstValue == "") { - runSheet - .getRange(dstAddr) - .setFormula( - dstAddr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${validCallDstValue})` - : `="${validCallDstValue}"`, - ); + runSheet.getRange(dstAddr).setFormula(`="${validCallDstValue}"`); dstValue = runSheet.getRange(dstAddr).getValue(); } @@ -387,30 +416,20 @@ function step(n: number = 0): void { if (op0Value === "") { runSheet .getRange(op0Addr) - .setFormula( - op0Addr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${addSegmentValues(dstValue, `-${op1Value}`)})` - : `="${addSegmentValues(dstValue, `-${op1Value}"`)}`, - ); + .setFormula(`="${addSegmentValues(dstValue, `-${op1Value}"`)}`); op0Value = runSheet.getRange(op0Addr).getValue(); } if (op1Value === "") { runSheet .getRange(op1Addr) - .setFormula( - op1Addr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${addSegmentValues(dstValue, `-${op0Value}`)})` - : `="${addSegmentValues(dstValue, `-${op0Value}"`)}`, - ); + .setFormula(`="${addSegmentValues(dstValue, `-${op0Value}"`)}`); op1Value = runSheet.getRange(op1Addr).getValue(); } if (dstValue === "") { runSheet .getRange(dstAddr) .setFormula( - dstAddr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${addSegmentValues(`${op0Value}`, `${op1Value}`)})` - : `="${addSegmentValues(`${op0Value}`, `${op1Value}`)}"`, + `="${addSegmentValues(`${op0Value}`, `${op1Value}`)}"`, ); } validAssertEqDstValue = addSegmentValues(op0Value, op1Value); @@ -419,31 +438,19 @@ function step(n: number = 0): void { if (op0Value === "") { runSheet .getRange(op0Addr) - .setFormula( - op0Addr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${BigInt(dstValue) / BigInt(op1Value)})` - : `="${BigInt(dstValue) / BigInt(op1Value)}"`, - ); + .setFormula(`="${BigInt(dstValue) / BigInt(op1Value)}"`); op0Value = runSheet.getRange(op0Addr).getValue(); } if (op1Value === "") { runSheet .getRange(op1Addr) - .setFormula( - op1Addr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${BigInt(dstValue) / BigInt(op0Value)})` - : `="${BigInt(dstValue) / BigInt(op0Value)}"`, - ); + .setFormula(`="${BigInt(dstValue) / BigInt(op0Value)}"`); op1Value = runSheet.getRange(op1Addr).getValue(); } if (dstValue === "") { runSheet .getRange(dstAddr) - .setFormula( - dstAddr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${BigInt(op0Value) * BigInt(op1Value)})` - : `="${BigInt(op0Value) * BigInt(op1Value)}"`, - ); + .setFormula(`="${BigInt(op0Value) * BigInt(op1Value)}"`); } validAssertEqDstValue = Number( BigInt(op0Value) * BigInt(op1Value), @@ -451,23 +458,11 @@ function step(n: number = 0): void { break; case ResLogics.Op1: if (op1Value === "") { - runSheet - .getRange(op1Addr) - .setFormula( - op1Addr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${dstValue})` - : `="${dstValue}"`, - ); + runSheet.getRange(op1Addr).setFormula(`="${dstValue}"`); op1Value = runSheet.getRange(op1Addr).getValue(); } if (dstValue === "") { - runSheet - .getRange(dstAddr) - .setFormula( - dstAddr[0] == builtins["range_check"].column - ? `=RANGE_CHECK(${op1Value})` - : `="${op1Value}"`, - ); + runSheet.getRange(dstAddr).setFormula(`="${op1Value}"`); } validAssertEqDstValue = op1Value; break;