Search proof
Maru search proof via zk-STARKs enables efficient verification of any transaction data(hashes, ... etc) that included in Patricia Merkle Trie. Using this approach we can ensure that volume values, contract address, method signature, hashes are included in RLP encoding.
For example, we have to ensure that BranchNode hashes consist of previous hash of RLP BranchNode , LeafNode or receipts_root in RLP of block header. To implement this calculation, we got the idea to search 32 bytes in array of 136 + 32 bytes (block_size + postfix bytes of previous block) to ensure that searched bytes not will be between start of one and end of the next block. Using right cyclic shifts we create one row per shift until the first 32 bytes of HAYSTACK_REGISTER will be equal to 32 bytes in NEEDLE_REGISTER, where the searched bytes. As input we get from trusted setup we use start indexes of each data array (value, contract address, ... etc).
Circuit
Private inputs include data fields about each value:
inputincludes one block of 136 bytes and 32 bytes of previous blocksub_stringincludes searched 32 bytesoffsetincludes the index of first sub_string elementidincludes the number of search operation
In execution trace we use such fields:
IS_INwill be set to 1 in rows where the initial sub-array is present.IS_OUTwill be set to 1 where the first 32 bytes ofHAYSTACK_REGISTERare equal toNEEDLE_REGISTER.DUMMY_ROWindicates padding rows.OFFSETis a number of offsets in block, after using cyclic shifts will reduced to one per shift operation .IS_SHIFTwill be set to 1 in rows where we used a right cyclic shift.HAYSTACK_REGISTERregister of array.NEEDLE_REGISTERregister of subarrayIDnumber of search operation
Constraints
The Search Stark aims to constrain the following aspects:
Verify that the first 32 elements in
HAYSTACK_REGISTERare equal to the first 32 elements inNEEDLE_REGISTER.IS_INandIS_OUTcan have values in the range of {0, 1}.Confirm that the last element of the haystack’s first row of each search operation equals the first element in the next row of the cyclic shift when
IS_IN= 1, andIS_INin the next row equals to 0.Ensure that the previous element in the row of the cyclic shift equals the next element of the next row when
IS_IN= 0, and the rows are not dummy.Check that the offset in the row equalst to 0, when
IS_OUT= 0.Verify that the offset of the previous row is greater than one corresponding to the next row
The main idea of the proof relies on CTL, where we build two functions for CTL proofing:
ctl_substr_in_haystack()guarantees that the concatenated columns oftyped_datawithzero_shift_num(always zero) in the Data table, using a row filter wherechild_hash_found,transfer_value_found,method_signature_found,contract_address found,receipts_root_found,external_child_hash_found,sold_token_id_found, ortotal_sum= 1, equal to the concatenated columns ofNEEDLE_REGISTERwithOFFSETandIDin the Search table using a filter whereIS_OUTequals 1.ctl_haystack_equal_data()guarantees that the concatenated columns ofprefix,block_bytes, andshift_numin the Data table, using a filter wherechild_hash_found,transfer_value_found,method_signature_found,contract_address_found,receipts_root_found,external_child_hash_found,sold_token_id_found, ortotal_sum= 1, have the exact values ofHAYSTACK_REGISTERin the Search table.
Last updated