Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
libsnark::variable_or_identity< ppT, groupT, groupVariableT > Class Template Reference

#include <scalar_multiplication.hpp>

Inheritance diagram for libsnark::variable_or_identity< ppT, groupT, groupVariableT >:
Inheritance graph
[legend]
Collaboration diagram for libsnark::variable_or_identity< ppT, groupT, groupVariableT >:
Collaboration graph
[legend]

Public Types

using FieldT = libff::Fr< ppT >
 

Public Member Functions

 variable_or_identity (protoboard< FieldT > &pb, const std::string &annotation_prefix)
 
 variable_or_identity (protoboard< FieldT > &pb, const groupT &P, const std::string &annotation_prefix)
 
void generate_r1cs_constraints ()
 
void generate_r1cs_witness (const groupT &elt)
 
void generate_r1cs_witness (bool is_identity)
 
groupT get_element () const
 
- Public Member Functions inherited from libsnark::gadget< libff::Fr< ppT > >
 gadget (protoboard< libff::Fr< ppT > > &pb, const std::string &annotation_prefix)
 

Public Attributes

groupVariableT value
 
pb_linear_combination< FieldTis_identity
 

Protected Attributes

pb_variable< FieldTis_identity_var
 
- Protected Attributes inherited from libsnark::gadget< libff::Fr< ppT > >
protoboard< libff::Fr< ppT > > & pb
 
const std::string annotation_prefix
 

Detailed Description

template<typename ppT, typename groupT, typename groupVariableT>
class libsnark::variable_or_identity< ppT, groupT, groupVariableT >

Wrapper for group variable, adding a flag that indicates whether the variable is the identity.

For use in 2 possible configurations:

1) Construct with variable_or_identity(pb, annotation_prefix), which internally allocates variables for the group element and flag. Values can later be set via generate_r1cs_witness() calls.

2) Construct using a group element value, which defines values as linear combinations (no variable allocation). generate_r1cs_witness() calls should NOT be made to such objects.

Definition at line 35 of file scalar_multiplication.hpp.

Member Typedef Documentation

◆ FieldT

template<typename ppT , typename groupT , typename groupVariableT >
using libsnark::variable_or_identity< ppT, groupT, groupVariableT >::FieldT = libff::Fr<ppT>

Definition at line 38 of file scalar_multiplication.hpp.

Constructor & Destructor Documentation

◆ variable_or_identity() [1/2]

template<typename ppT , typename groupT , typename groupVariableT >
libsnark::variable_or_identity< ppT, groupT, groupVariableT >::variable_or_identity ( protoboard< FieldT > &  pb,
const std::string &  annotation_prefix 
)

◆ variable_or_identity() [2/2]

template<typename ppT , typename groupT , typename groupVariableT >
libsnark::variable_or_identity< ppT, groupT, groupVariableT >::variable_or_identity ( protoboard< FieldT > &  pb,
const groupT &  P,
const std::string &  annotation_prefix 
)

Member Function Documentation

◆ generate_r1cs_constraints()

template<typename ppT , typename groupT , typename groupVariableT >
void libsnark::variable_or_identity< ppT, groupT, groupVariableT >::generate_r1cs_constraints ( )

Constrains the is_identity flag to be boolean. Do not call this if the setter can guarantee boolean-ness in some other way.

◆ generate_r1cs_witness() [1/2]

template<typename ppT , typename groupT , typename groupVariableT >
void libsnark::variable_or_identity< ppT, groupT, groupVariableT >::generate_r1cs_witness ( bool  is_identity)

For the case where value has been set by other gadgets, and we simply wish to set whether this variable should be considered the identity.

◆ generate_r1cs_witness() [2/2]

template<typename ppT , typename groupT , typename groupVariableT >
void libsnark::variable_or_identity< ppT, groupT, groupVariableT >::generate_r1cs_witness ( const groupT &  elt)

If elt == 0, this sets value to 1 and is_identity to true, otherwise it sets value to elt and is_identity to false.

◆ get_element()

template<typename ppT , typename groupT , typename groupVariableT >
groupT libsnark::variable_or_identity< ppT, groupT, groupVariableT >::get_element ( ) const

Member Data Documentation

◆ is_identity

template<typename ppT , typename groupT , typename groupVariableT >
pb_linear_combination<FieldT> libsnark::variable_or_identity< ppT, groupT, groupVariableT >::is_identity

Definition at line 41 of file scalar_multiplication.hpp.

◆ is_identity_var

template<typename ppT , typename groupT , typename groupVariableT >
pb_variable<FieldT> libsnark::variable_or_identity< ppT, groupT, groupVariableT >::is_identity_var
protected

Definition at line 72 of file scalar_multiplication.hpp.

◆ value

template<typename ppT , typename groupT , typename groupVariableT >
groupVariableT libsnark::variable_or_identity< ppT, groupT, groupVariableT >::value

Definition at line 40 of file scalar_multiplication.hpp.


The documentation for this class was generated from the following file: