|
purify
C++ Purify implementation with native circuit and BPP support
|
Symbolic affine expression over indexed variables and field coefficients. More...
#include <expr.hpp>
Public Types | |
| using | Term = std::pair<Symbol, FieldElement> |
Public Member Functions | |
| Expr () | |
| Constructs the zero expression. | |
| Expr (const FieldElement &value) | |
| Constructs a pure constant expression from a field element. | |
| Expr (std::int64_t value) | |
| Constructs a pure constant expression from a signed integer. | |
| const FieldElement & | constant () const |
| Returns the constant term of the affine expression. | |
| std::vector< Term > & | linear () |
| Returns mutable access to the sorted linear term list. | |
| const std::vector< Term > & | linear () const |
| Returns read-only access to the sorted linear term list. | |
| std::string | to_string () const |
| Formats the expression in a stable human-readable form used for debugging and serialization. | |
| std::optional< FieldElement > | evaluate (const WitnessAssignments &values) const |
| Evaluates the expression against a possibly partial transcript witness assignment. | |
| std::pair< Expr, Expr > | split () const |
| Splits the expression into a pure constant and a pure linear component. | |
Static Public Member Functions | |
| static Expr | variable (Symbol symbol) |
| Returns a single-variable expression with coefficient one. | |
Friends | |
| Expr | operator+ (const Expr &lhs, const Expr &rhs) |
| Adds two affine expressions and merges like terms. | |
| Expr | operator+ (const Expr &lhs, std::int64_t rhs) |
| Adds an integer constant to an affine expression. | |
| Expr | operator+ (std::int64_t lhs, const Expr &rhs) |
| Adds an affine expression to an integer constant. | |
| Expr | operator- (const Expr &lhs, const Expr &rhs) |
| Subtracts one affine expression from another. | |
| Expr | operator- (const Expr &lhs, std::int64_t rhs) |
| Subtracts an integer constant from an affine expression. | |
| Expr | operator- (std::int64_t lhs, const Expr &rhs) |
| Subtracts an affine expression from an integer constant. | |
| Expr | operator- (const Expr &value) |
| Negates every coefficient in the affine expression. | |
| Expr | operator* (const Expr &expr, const FieldElement &scalar) |
| Scales an affine expression by a field element. | |
| Expr | operator* (const FieldElement &scalar, const Expr &expr) |
| Scales an affine expression by a field element. | |
| Expr | operator* (const Expr &expr, std::int64_t scalar) |
| Scales an affine expression by an integer constant. | |
| Expr | operator* (std::int64_t scalar, const Expr &expr) |
| Scales an affine expression by an integer constant. | |
| bool | operator== (const Expr &lhs, const Expr &rhs) |
| Compares two affine expressions structurally. | |
| bool | operator< (const Expr &lhs, const Expr &rhs) |
| Orders affine expressions structurally for cache keys. | |
This type is used while deriving circuit relations before they are lowered into native multiplication gates and linear constraints.
| using purify::Expr::Term = std::pair<Symbol, FieldElement> |
| purify::Expr::Expr | ( | ) |
|
explicit |
|
inline |
Definition at line 86 of file expr.hpp.
Referenced by purify::ExprBuilder::add(), purify::ExprBuilder::add_scaled(), purify::ExprLess::operator()(), purify::BulletproofTranscript::replace_and_insert(), and purify::ExprBuilder::subtract().
| std::optional< FieldElement > purify::Expr::evaluate | ( | const WitnessAssignments & | values | ) | const |
Definition at line 125 of file expr.cpp.
References purify::Witness.
Referenced by purify::Transcript::boolean(), purify::Transcript::div(), purify::Transcript::equal(), purify::Transcript::evaluate(), and purify::Transcript::mul().
|
inline |
Definition at line 91 of file expr.hpp.
Referenced by purify::ExprBuilder::add(), purify::ExprBuilder::add_scaled(), purify::circuit_1bit(), purify::circuit_2bit(), purify::circuit_3bit(), purify::circuit_combine(), purify::circuit_ec_add(), purify::circuit_ec_add_x(), purify::ExprLess::operator()(), purify::BulletproofTranscript::replace_and_insert(), purify::BulletproofTranscript::replace_expr_v_with_bp_var(), and purify::ExprBuilder::subtract().
|
inline |
| std::string purify::Expr::to_string | ( | ) | const |
Definition at line 104 of file expr.cpp.
References purify::FieldElement::one().
Referenced by purify::operator<<().
Definition at line 98 of file expr.cpp.
References Expr(), and purify::FieldElement::one().
Referenced by purify::BulletproofTranscript::add_pubkey_and_out(), purify::BulletproofTranscript::from_transcript(), purify::NativeBulletproofCircuitTemplate::instantiate_packed(), purify::BulletproofTranscript::native_circuit(), and purify::Transcript::secret().
|
friend |
Definition at line 327 of file expr.cpp.
References Expr(), purify::FieldElement::from_int(), and operator*.
|
friend |
Definition at line 307 of file expr.cpp.
References Expr(), purify::FieldElement::from_int(), and operator-.
Definition at line 335 of file expr.cpp.
References Expr(), and operator==.
Referenced by operator==.