Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
alu_gadget.tcc
Go to the documentation of this file.
1 /** @file
2  *****************************************************************************
3 
4  Implementation of interfaces for the TinyRAM ALU gadget.
5 
6  See alu.hpp .
7 
8  *****************************************************************************
9  * @author This file is part of libsnark, developed by SCIPR Lab
10  * and contributors (see AUTHORS).
11  * @copyright MIT license (see LICENSE file)
12  *****************************************************************************/
13 
14 #ifndef ALU_GADGET_TCC_
15 #define ALU_GADGET_TCC_
16 
17 namespace libsnark
18 {
19 
20 template<typename FieldT> void ALU_gadget<FieldT>::generate_r1cs_constraints()
21 {
22  for (size_t i = 0; i < 1ul << this->pb.ap.opcode_width(); ++i) {
23  if (components[i]) {
24  components[i]->generate_r1cs_constraints();
25  }
26  }
27 }
28 
29 template<typename FieldT> void ALU_gadget<FieldT>::generate_r1cs_witness()
30 {
31  for (size_t i = 0; i < 1ul << this->pb.ap.opcode_width(); ++i) {
32  if (components[i]) {
33  components[i]->generate_r1cs_witness();
34  }
35  }
36 }
37 
38 } // namespace libsnark
39 
40 #endif // ALU_GADGET_TCC_