Clearmatics Libsnark
0.1
C++ library for zkSNARK proofs
|
#include <memory_masking_gadget.hpp>
Public Attributes | |
doubleword_variable_gadget< FieldT > | dw_contents_prev |
dual_variable_gadget< FieldT > | subaddress |
pb_linear_combination< FieldT > | subcontents |
pb_linear_combination< FieldT > | access_is_word |
pb_linear_combination< FieldT > | access_is_byte |
doubleword_variable_gadget< FieldT > | dw_contents_next |
Additional Inherited Members | |
![]() | |
tinyram_protoboard< FieldT > & | pb |
![]() | |
protoboard< FieldT > & | pb |
const std::string | annotation_prefix |
The memory masking gadget checks if a specified part of a double word is correctly modified. In TinyRAM CPU checker we use this to implement byte addressing and word addressing for the memory that consists of double words.
More precisely, memory masking gadgets takes the following arguments:
dw_contents_prev, dw_contents_next – the contents of the memory
double word before and after the access
access_is_word – a boolean indicating if access is word
access_is_byte – a boolean indicating if access is byte
subaddress – an integer specifying which byte (if access_is_byte=1) or word (if access_is_byte=1) this access is operating on
subcontents – contents of the byte, resp., word to be operated on
Memory masking gadget enforces that dw_contents_prev is equal to dw_contents_next everywhere, except subaddres-th byte (if access_is_byte = 1), or MSB(subaddress)-th word (if access_is_word = 1). The corresponding byte, resp., word in dw_contents_next is required to equal subcontents.
Note that indexing MSB(subaddress)-th word is the same as indexing the word specified by subaddress expressed in bytes and aligned to the word boundary by rounding the subaddress down.
Requirements: The caller is required to perform bounds checks on subcontents. The caller is also required to ensure that exactly one of access_is_word and access_is_byte is set to 1.
Definition at line 58 of file memory_masking_gadget.hpp.
libsnark::memory_masking_gadget< FieldT >::memory_masking_gadget | ( | tinyram_protoboard< FieldT > & | pb, |
const doubleword_variable_gadget< FieldT > & | dw_contents_prev, | ||
const dual_variable_gadget< FieldT > & | subaddress, | ||
const pb_linear_combination< FieldT > & | subcontents, | ||
const pb_linear_combination< FieldT > & | access_is_word, | ||
const pb_linear_combination< FieldT > & | access_is_byte, | ||
const doubleword_variable_gadget< FieldT > & | dw_contents_next, | ||
const std::string & | annotation_prefix = "" |
||
) |
|
virtual |
Implements libsnark::tinyram_standard_gadget< FieldT >.
|
virtual |
Implements libsnark::tinyram_standard_gadget< FieldT >.
pb_linear_combination<FieldT> libsnark::memory_masking_gadget< FieldT >::access_is_byte |
Definition at line 82 of file memory_masking_gadget.hpp.
pb_linear_combination<FieldT> libsnark::memory_masking_gadget< FieldT >::access_is_word |
Definition at line 81 of file memory_masking_gadget.hpp.
doubleword_variable_gadget<FieldT> libsnark::memory_masking_gadget< FieldT >::dw_contents_next |
Definition at line 83 of file memory_masking_gadget.hpp.
doubleword_variable_gadget<FieldT> libsnark::memory_masking_gadget< FieldT >::dw_contents_prev |
Definition at line 78 of file memory_masking_gadget.hpp.
dual_variable_gadget<FieldT> libsnark::memory_masking_gadget< FieldT >::subaddress |
Definition at line 79 of file memory_masking_gadget.hpp.
pb_linear_combination<FieldT> libsnark::memory_masking_gadget< FieldT >::subcontents |
Definition at line 80 of file memory_masking_gadget.hpp.