|
purify
C++ Purify implementation with native circuit and BPP support
|
Lowering helper that converts a symbolic transcript into native Bulletproof witness and circuit forms. More...
#include <bulletproof.hpp>
Public Member Functions | |
| void | replace_expr_v_with_bp_var (Expr &expr) |
| Rewrites transcript variable names to their eventual Bulletproof wire aliases. | |
| bool | replace_and_insert (Expr &expr, Symbol symbol) |
| Detects simple witness aliases and records them for later assignment lowering. | |
| void | add_assignment (Symbol symbol, Expr expr) |
| Adds one symbolic wire assignment to the lowering state. | |
| Status | from_transcript (const Transcript &transcript, std::size_t n_bits, std::size_t minimum_gate_count=1) |
| Imports a symbolic transcript with a fixed power-of-two gate floor. | |
| Status | bind_output_to_commitment (Expr output) |
| Binds a scalar expression to public commitment slot zero. | |
| Status | add_pubkey_and_out (const UInt512 &pubkey, Expr p1x, Expr p2x, Expr out) |
| Binds packed public-key coordinates and the output commitment into explicit constraints. | |
| std::string | to_string () const |
| Renders the lowered circuit in the legacy textual verifier format. | |
| bool | evaluate (const WitnessAssignments &vars, const FieldElement &commitment) const |
| Evaluates the lowered symbolic constraints with a concrete commitment value. | |
| NativeBulletproofCircuit | native_circuit () const |
| Builds the native sparse circuit object from the lowered assignments and constraints. | |
| Result< BulletproofAssignmentData > | assignment_data (const WitnessAssignments &vars) const |
| Materializes the witness columns expected by the native circuit representation. | |
| Result< BulletproofAssignmentData > | assignment_data (const WitnessAssignments &vars, const FieldElement &commitment) const |
| Materializes the witness columns with an explicit output commitment value. | |
| Result< Bytes > | serialize_assignment (const WitnessAssignments &vars) const |
| Serializes the derived witness assignment using the legacy blob format. | |
Definition at line 448 of file bulletproof.hpp.
Definition at line 1837 of file bulletproof.cpp.
References replace_and_insert().
Referenced by from_transcript().
| Status purify::BulletproofTranscript::add_pubkey_and_out | ( | const UInt512 & | pubkey, |
| Expr | p1x, | ||
| Expr | p2x, | ||
| Expr | out ) |
Definition at line 1971 of file bulletproof.cpp.
References purify::NativeBulletproofCircuit::add_constraint(), bind_output_to_commitment(), purify::Expected< T, E >::error(), purify::Expected< T, E >::has_value(), replace_expr_v_with_bp_var(), purify::FieldElement::try_from_uint256(), purify::unexpected_error(), and purify::unpack_public().
Referenced by purify::prove_assignment_data(), and purify::verifier().
| Result< BulletproofAssignmentData > purify::BulletproofTranscript::assignment_data | ( | const WitnessAssignments & | vars | ) | const |
Definition at line 2339 of file bulletproof.cpp.
Referenced by purify::prove_assignment_data(), and serialize_assignment().
| Result< BulletproofAssignmentData > purify::BulletproofTranscript::assignment_data | ( | const WitnessAssignments & | vars, |
| const FieldElement & | commitment ) const |
Definition at line 2343 of file bulletproof.cpp.
The expression may contain transcript witnesses already assigned to Bulletproof wires by from_transcript. Unmapped witnesses, public commitment symbols, and wire indices outside the lowered circuit are rejected.
Definition at line 1936 of file bulletproof.cpp.
References purify::Commitment, purify::Symbol::commitment(), purify::Symbol::index, purify::IndexOutOfRange, purify::InvalidSymbol, purify::Symbol::kind, purify::Left, purify::Expr::linear(), purify::Output, replace_expr_v_with_bp_var(), purify::Right, purify::unexpected_error(), purify::UninitializedState, purify::UnsupportedSymbol, purify::Expr::variable(), and purify::Witness.
Referenced by add_pubkey_and_out(), and purify::accountable::anchor_escrow_circuit_shape_for_testing().
| bool purify::BulletproofTranscript::evaluate | ( | const WitnessAssignments & | vars, |
| const FieldElement & | commitment ) const |
Definition at line 2034 of file bulletproof.cpp.
References purify::Symbol::commitment(), and purify::Expected< T, E >::has_value().
Referenced by purify::prove_assignment_data().
| Status purify::BulletproofTranscript::from_transcript | ( | const Transcript & | transcript, |
| std::size_t | n_bits, | ||
| std::size_t | minimum_gate_count = 1 ) |
The natural circuit size still wins when it exceeds minimum_gate_count. The floor must be a non-zero power of two that fits the circuit's 32-bit wire-index space.
Definition at line 1842 of file bulletproof.cpp.
References add_assignment(), purify::checked_add_size(), purify::Transcript::eqs(), purify::InvalidDimensions, purify::is_power_of_two_size(), purify::Symbol::left(), purify::Transcript::muls(), purify::NativeBulletproofCircuit::n_bits, purify::Symbol::output(), purify::Overflow, replace_expr_v_with_bp_var(), purify::Symbol::right(), purify::unexpected_error(), purify::UnsupportedSymbol, purify::Expr::variable(), purify::Transcript::varmap(), and purify::Symbol::witness().
Referenced by purify::accountable::anchor_escrow_circuit_shape_for_testing(), purify::prove_assignment_data(), purify::verifier(), and purify::verifier_circuit_template().
| NativeBulletproofCircuit purify::BulletproofTranscript::native_circuit | ( | ) | const |
Definition at line 2077 of file bulletproof.cpp.
References purify::NativeBulletproofCircuit::c, purify::NativeBulletproofCircuit::n_bits, purify::NativeBulletproofCircuit::n_commitments, purify::NativeBulletproofCircuit::n_gates, purify::Expr::variable(), purify::NativeBulletproofCircuit::wl, purify::NativeBulletproofCircuit::wo, purify::NativeBulletproofCircuit::wr, and purify::NativeBulletproofCircuit::wv.
Referenced by purify::accountable::anchor_escrow_circuit_shape_for_testing(), and purify::verifier_circuit_template().
Definition at line 1819 of file bulletproof.cpp.
References purify::Expr::constant(), purify::FieldElement::is_zero(), purify::Expr::linear(), purify::FieldElement::one(), replace_expr_v_with_bp_var(), and purify::Witness.
Referenced by add_assignment().
| void purify::BulletproofTranscript::replace_expr_v_with_bp_var | ( | Expr & | expr | ) |
Definition at line 1809 of file bulletproof.cpp.
References purify::Expr::linear(), and purify::Witness.
Referenced by add_pubkey_and_out(), bind_output_to_commitment(), from_transcript(), replace_and_insert(), and purify::verifier_circuit_template().
| Result< Bytes > purify::BulletproofTranscript::serialize_assignment | ( | const WitnessAssignments & | vars | ) | const |
Definition at line 2411 of file bulletproof.cpp.
References assignment_data(), purify::Expected< T, E >::error(), purify::Expected< T, E >::has_value(), and purify::unexpected_error().
| std::string purify::BulletproofTranscript::to_string | ( | ) | const |
Definition at line 2003 of file bulletproof.cpp.
References purify::to_string().
Referenced by purify::verifier().