Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
Public Member Functions | Public Attributes | List of all members
libsnark::ALU_cmps_gadget< FieldT > Class Template Reference

#include <alu_arithmetic.hpp>

Inheritance diagram for libsnark::ALU_cmps_gadget< FieldT >:
Inheritance graph
[legend]
Collaboration diagram for libsnark::ALU_cmps_gadget< FieldT >:
Collaboration graph
[legend]

Public Member Functions

 ALU_cmps_gadget (tinyram_protoboard< FieldT > &pb, const pb_variable_array< FieldT > &opcode_indicators, const word_variable_gadget< FieldT > &desval, const word_variable_gadget< FieldT > &arg1val, const word_variable_gadget< FieldT > &arg2val, const pb_variable< FieldT > &flag, const pb_variable< FieldT > &cmpg_result, const pb_variable< FieldT > &cmpg_result_flag, const pb_variable< FieldT > &cmpge_result, const pb_variable< FieldT > &cmpge_result_flag, const std::string &annotation_prefix="")
 
void generate_r1cs_constraints ()
 
void generate_r1cs_witness ()
 
- Public Member Functions inherited from libsnark::ALU_arithmetic_gadget< FieldT >
 ALU_arithmetic_gadget (tinyram_protoboard< FieldT > &pb, const pb_variable_array< FieldT > &opcode_indicators, const word_variable_gadget< FieldT > &desval, const word_variable_gadget< FieldT > &arg1val, const word_variable_gadget< FieldT > &arg2val, const pb_variable< FieldT > &flag, const pb_variable< FieldT > &result, const pb_variable< FieldT > &result_flag, const std::string &annotation_prefix="")
 
- Public Member Functions inherited from libsnark::tinyram_standard_gadget< FieldT >
 tinyram_standard_gadget (tinyram_protoboard< FieldT > &pb, const std::string &annotation_prefix="")
 
- Public Member Functions inherited from libsnark::tinyram_gadget< FieldT >
 tinyram_gadget (tinyram_protoboard< FieldT > &pb, const std::string &annotation_prefix="")
 
- Public Member Functions inherited from libsnark::gadget< FieldT >
 gadget (protoboard< FieldT > &pb, const std::string &annotation_prefix)
 

Public Attributes

const pb_variable< FieldT > cmpg_result
 
const pb_variable< FieldT > cmpg_result_flag
 
const pb_variable< FieldT > cmpge_result
 
const pb_variable< FieldT > cmpge_result_flag
 
- Public Attributes inherited from libsnark::ALU_arithmetic_gadget< FieldT >
const pb_variable_array< FieldT > opcode_indicators
 
const word_variable_gadget< FieldT > desval
 
const word_variable_gadget< FieldT > arg1val
 
const word_variable_gadget< FieldT > arg2val
 
const pb_variable< FieldT > flag
 
const pb_variable< FieldT > result
 
const pb_variable< FieldT > result_flag
 

Additional Inherited Members

- Protected Attributes inherited from libsnark::tinyram_gadget< FieldT >
tinyram_protoboard< FieldT > & pb
 
- Protected Attributes inherited from libsnark::gadget< FieldT >
protoboard< FieldT > & pb
 
const std::string annotation_prefix
 

Detailed Description

template<typename FieldT>
class libsnark::ALU_cmps_gadget< FieldT >

Definition at line 526 of file alu_arithmetic.hpp.

Constructor & Destructor Documentation

◆ ALU_cmps_gadget()

template<typename FieldT >
libsnark::ALU_cmps_gadget< FieldT >::ALU_cmps_gadget ( tinyram_protoboard< FieldT > &  pb,
const pb_variable_array< FieldT > &  opcode_indicators,
const word_variable_gadget< FieldT > &  desval,
const word_variable_gadget< FieldT > &  arg1val,
const word_variable_gadget< FieldT > &  arg2val,
const pb_variable< FieldT > &  flag,
const pb_variable< FieldT > &  cmpg_result,
const pb_variable< FieldT > &  cmpg_result_flag,
const pb_variable< FieldT > &  cmpge_result,
const pb_variable< FieldT > &  cmpge_result_flag,
const std::string &  annotation_prefix = "" 
)
inline

Definition at line 545 of file alu_arithmetic.hpp.

557  : ALU_arithmetic_gadget<FieldT>(
558  pb,
560  desval,
561  arg1val,
562  arg2val,
563  flag,
564  cmpg_result,
571  {
572  negated_arg1val_sign.allocate(
573  pb, FMT(this->annotation_prefix, " negated_arg1val_sign"));
574  negated_arg2val_sign.allocate(
575  pb, FMT(this->annotation_prefix, " negated_arg2val_sign"));
576 
577  modified_arg1 = pb_variable_array<FieldT>(
578  arg1val.bits.begin(), --arg1val.bits.end());
579  modified_arg1.emplace_back(negated_arg1val_sign);
580 
581  modified_arg2 = pb_variable_array<FieldT>(
582  arg2val.bits.begin(), --arg2val.bits.end());
583  modified_arg2.emplace_back(negated_arg2val_sign);
584 
585  packed_modified_arg1.allocate(
586  pb, FMT(this->annotation_prefix, " packed_modified_arg1"));
587  packed_modified_arg2.allocate(
588  pb, FMT(this->annotation_prefix, " packed_modified_arg2"));
589 
590  pack_modified_arg1.reset(new packing_gadget<FieldT>(
591  pb,
592  modified_arg1,
593  packed_modified_arg1,
594  FMT(this->annotation_prefix, " pack_modified_arg1")));
595  pack_modified_arg2.reset(new packing_gadget<FieldT>(
596  pb,
597  modified_arg2,
598  packed_modified_arg2,
599  FMT(this->annotation_prefix, " pack_modified_arg2")));
600 
601  comparator.reset(new comparison_gadget<FieldT>(
602  pb,
603  pb.ap.w,
604  packed_modified_arg2,
605  packed_modified_arg1,
608  FMT(this->annotation_prefix, " comparator")));
609  }
Here is the call graph for this function:

Member Function Documentation

◆ generate_r1cs_constraints()

template<typename FieldT >
void libsnark::ALU_cmps_gadget< FieldT >::generate_r1cs_constraints ( )
virtual

◆ generate_r1cs_witness()

template<typename FieldT >
void libsnark::ALU_cmps_gadget< FieldT >::generate_r1cs_witness ( )
virtual

Member Data Documentation

◆ cmpg_result

template<typename FieldT >
const pb_variable<FieldT> libsnark::ALU_cmps_gadget< FieldT >::cmpg_result

Definition at line 540 of file alu_arithmetic.hpp.

◆ cmpg_result_flag

template<typename FieldT >
const pb_variable<FieldT> libsnark::ALU_cmps_gadget< FieldT >::cmpg_result_flag

Definition at line 541 of file alu_arithmetic.hpp.

◆ cmpge_result

template<typename FieldT >
const pb_variable<FieldT> libsnark::ALU_cmps_gadget< FieldT >::cmpge_result

Definition at line 542 of file alu_arithmetic.hpp.

◆ cmpge_result_flag

template<typename FieldT >
const pb_variable<FieldT> libsnark::ALU_cmps_gadget< FieldT >::cmpge_result_flag

Definition at line 543 of file alu_arithmetic.hpp.


The documentation for this class was generated from the following file:
libsnark::ALU_arithmetic_gadget::arg2val
const word_variable_gadget< FieldT > arg2val
Definition: alu_arithmetic.hpp:32
libsnark::gadget::annotation_prefix
const std::string annotation_prefix
Definition: gadget.hpp:20
libsnark::ALU_arithmetic_gadget::desval
const word_variable_gadget< FieldT > desval
Definition: alu_arithmetic.hpp:30
libsnark::ALU_arithmetic_gadget::opcode_indicators
const pb_variable_array< FieldT > opcode_indicators
Definition: alu_arithmetic.hpp:29
libsnark::ALU_cmps_gadget::cmpg_result
const pb_variable< FieldT > cmpg_result
Definition: alu_arithmetic.hpp:540
libsnark::ALU_cmps_gadget::cmpg_result_flag
const pb_variable< FieldT > cmpg_result_flag
Definition: alu_arithmetic.hpp:541
libsnark::ALU_cmps_gadget::cmpge_result
const pb_variable< FieldT > cmpge_result
Definition: alu_arithmetic.hpp:542
libsnark::tinyram_gadget::pb
tinyram_protoboard< FieldT > & pb
Definition: tinyram_protoboard.hpp:34
libsnark::ALU_arithmetic_gadget::arg1val
const word_variable_gadget< FieldT > arg1val
Definition: alu_arithmetic.hpp:31
libsnark::ALU_arithmetic_gadget::flag
const pb_variable< FieldT > flag
Definition: alu_arithmetic.hpp:33
libsnark::ALU_cmps_gadget::cmpge_result_flag
const pb_variable< FieldT > cmpge_result_flag
Definition: alu_arithmetic.hpp:543