purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
purify Namespace Reference

Namespaces

namespace  accountable
namespace  bppp
namespace  detail
namespace  puresign_plusplus
namespace  puresign
namespace  capi_detail
namespace  core_api_detail

Data Structures

struct  GeneratedKey
 Derived Purify keypair bundle with an owned packed secret and its matching public key. More...
struct  Bip340Key
 Canonical BIP340 keypair derived deterministically from a packed Purify secret. More...
struct  BulletproofWitnessData
 Complete witness bundle for evaluating and proving a Purify instance. More...
struct  BulletproofAssignmentData
 Columnar witness assignment compatible with the native Bulletproof circuit layout. More...
struct  NativeBulletproofCircuitTerm
 One sparse matrix entry in a native circuit row. More...
struct  NativeBulletproofCircuitRow
 One sparse row of circuit coefficients. More...
struct  NativeBulletproofCircuit
 Native in-memory representation of a Bulletproof-style arithmetic circuit. More...
struct  ExperimentalBulletproofProof
 Experimental single-proof wrapper over the imported legacy Bulletproof circuit backend. More...
class  ExperimentalBulletproofBackendCache
 Caller-owned cache for reusable legacy Bulletproof backend resources keyed by gate count. More...
class  NativeBulletproofCircuitTemplate
 Public-key-agnostic native verifier-circuit template. More...
class  BulletproofTranscript
 Lowering helper that converts a symbolic transcript into native Bulletproof witness and circuit forms. More...
struct  CircuitMainResult
 Result bundle returned by the main symbolic Purify circuit construction. More...
struct  SecpContextDeleter
class  SpanAtLeast
 Checked span wrapper that guarantees a minimum runtime length. More...
struct  JacobianPoint
 Jacobian point representation used for curve arithmetic. More...
struct  AffinePoint
 Affine point representation used for serialization and lookup tables. More...
struct  CompleteProjectivePoint
 Projective point used by the hardened secret-scalar multiplication path. More...
class  EllipticCurve
 Minimal elliptic-curve arithmetic over the Purify base field. More...
class  TaggedHash
 Reusable BIP340-style tagged SHA-256 helper. More...
struct  Error
 Compact error object returned by checked APIs. More...
struct  unexpect_t
class  bad_expected_access
class  Unexpected
class  Expected
 Purify result carrier that either holds a value or an error. More...
class  Expected< void, E >
struct  Symbol
 Compact symbolic variable identifier used inside expressions and transcripts. More...
struct  SymbolLess
class  Expr
 Symbolic affine expression over indexed variables and field coefficients. More...
struct  ExprLess
struct  ExprPairLess
class  ExprBuilder
 Small runtime builder that flattens affine combinations into one expression. More...
class  Transcript
 Mutable transcript used to record symbolic multiplication, division, and boolean constraints. More...
struct  NonceBatchGroup
 One ordered coalition/topic relation with its own summed nonce output. More...
struct  BigUInt
 Little-endian fixed-width unsigned integer with simple arithmetic utilities. More...
class  FieldElement
 Field element modulo the backend scalar field used by this implementation. More...
class  SecretKey
 Move-only packed Purify secret stored in dedicated heap memory. More...
struct  BulletproofBackendResourceDeleter
class  WipeOnDestruction

Concepts

concept  NoexceptByteFill
 Callable concept for byte-fill RNG adapters that cannot fail.
concept  NoexceptCheckedByteFill
 Callable concept for byte-fill RNG adapters that report failure via Status.

Typedefs

using KeySeed = SpanAtLeast<16, const unsigned char>
 Minimum-length checked wrapper for deterministic key-generation seed material.
using BulletproofScalarBytes = std::array<unsigned char, 32>
using BulletproofPointBytes = std::array<unsigned char, 33>
using BulletproofGeneratorBytes = std::array<unsigned char, 33>
using BulletproofWitnessColumn
using ExprPoint = std::pair<Expr, Expr>
 Symbolic affine point represented as independent x and y expressions.
using SecpContextPtr = std::unique_ptr<purify_secp_context, SecpContextDeleter>
using Bytes = std::vector<unsigned char>
 Dynamically sized byte string used for messages, serialized witnesses, and proofs.
template<typename T>
using Result = Expected<T, Error>
 Expected-returning convenience alias for Purify value-producing APIs.
using Status = Expected<void, Error>
 Expected-returning convenience alias for Purify status-only APIs.
using WitnessAssignment = std::optional<FieldElement>
 Partial witness assignment vector indexed by transcript witness id.
using WitnessAssignments
using UInt256 = BigUInt<4>
 256-bit unsigned integer used for field elements and curve orders.
using UInt320 = BigUInt<5>
 320-bit unsigned integer used during hash-to-curve sampling.
using UInt512 = BigUInt<8>
 512-bit unsigned integer used for private and packed public keys.
using BulletproofBackendResourcePtr

Enumerations

enum class  ErrorCategory : std::uint8_t { Natural , Usage , Internal }
 High-level classification for all recoverable Purify errors. More...
enum class  ErrorCode : std::uint16_t {
  InvalidHex , InvalidHexLength , InvalidFixedSize , Overflow ,
  Underflow , NarrowingOverflow , DivisionByZero , BitIndexOutOfRange ,
  RangeViolation , EmptyInput , SizeMismatch , MissingValue ,
  InvalidSymbol , UnsupportedSymbol , UninitializedState , IndexOutOfRange ,
  InvalidDimensions , NonBooleanValue , EquationMismatch , BindingMismatch ,
  IoOpenFailed , IoWriteFailed , EntropyUnavailable , BackendRejectedInput ,
  HashToCurveExhausted , UnexpectedSize , GeneratorOrderCheckFailed , InternalMismatch ,
  TranscriptCheckFailed
}
 Machine-readable error codes shared across the library. More...
enum class  SymbolKind : std::uint8_t {
  Witness = 0 , Left = 1 , Right = 2 , Output = 3 ,
  Commitment = 4
}
 Symbol classes used while deriving witness and Bulletproof wire relations. More...

Functions

Result< GeneratedKey > derive_key (const SecretKey &secret)
 Derives the packed public key corresponding to a packed secret.
Result< GeneratedKey > derive_key (SecretKey &&secret)
 Derives the packed public key corresponding to a packed secret.
Result< Bip340Key > derive_bip340_key (const SecretKey &secret, purify_secp_context *secp_context)
 Derives a canonical BIP340 signing keypair from an owned Purify secret.
UInt512 key_space_size ()
 Returns the size of the packed Purify secret-key space.
Status fill_secure_random (std::span< unsigned char > bytes) noexcept
 Fills a buffer with operating-system randomness.
template<typename FillRandom>
requires NoexceptCheckedByteFill<FillRandom>
Result< UInt512 > random_below (const UInt512 &range, FillRandom &&fill_random)
 Samples a uniformly random packed secret below a range using a checked byte-fill source.
template<typename FillRandom>
requires NoexceptByteFill<FillRandom>
Result< UInt512 > random_below (const UInt512 &range, FillRandom &&fill_random)
 Samples a uniformly random packed secret below a range using a no-fail byte-fill source.
Result< UInt512 > random_below (const UInt512 &range)
 Samples a uniformly random packed secret below a range using the built-in OS RNG.
Result< GeneratedKey > generate_key ()
 Generates a random Purify keypair using the built-in OS RNG.
Result< GeneratedKey > generate_key (KeySeed seed)
 Deterministically derives a Purify keypair from seed material.
Result< GeneratedKey > generate_key (std::span< const unsigned char > seed)
 Deterministically derives a Purify keypair from seed material.
template<typename FillRandom>
requires (NoexceptByteFill<FillRandom> || NoexceptCheckedByteFill<FillRandom>)
Result< GeneratedKey > generate_key (FillRandom &&fill_random)
 Generates a random Purify keypair using a caller-supplied byte-fill routine.
Result< FieldElement > eval (const SecretKey &secret, const Bytes &message)
 Evaluates the Purify PRF for an owned secret key and message.
Result< std::string > verifier (const Bytes &message, const UInt512 &pubkey)
 Builds the legacy serialized verifier description for a message and public key.
Result< NativeBulletproofCircuit > verifier_circuit (const Bytes &message, const UInt512 &pubkey)
 Builds the native verifier circuit for a message and public key.
Result< BulletproofWitnessData > prove_assignment_data (const Bytes &message, const SecretKey &secret)
 Computes the native Purify witness for a message and secret.
Result< bool > evaluate_verifier_circuit (const Bytes &message, const BulletproofWitnessData &witness)
 Evaluates the generated verifier circuit against an explicit witness.
Result< bool > evaluate_verifier_circuit (const Bytes &message, const SecretKey &secret)
 Evaluates the generated verifier circuit using a witness derived from a secret.
Result< Bytes > prove_assignment (const Bytes &message, const SecretKey &secret)
 Serializes the witness assignment produced for a message and secret.
Result< ExperimentalBulletproofProof > prove_experimental_circuit (const NativeBulletproofCircuit &circuit, const BulletproofAssignmentData &assignment, const BulletproofScalarBytes &nonce, const BulletproofGeneratorBytes &value_generator, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding={}, std::span< const BulletproofScalarBytes > blinds={}, ExperimentalBulletproofBackendCache *backend_cache=nullptr)
 Proves a native circuit with the experimental imported Bulletproof circuit backend.
Result< ExperimentalBulletproofProof > prove_experimental_circuit (const NativeBulletproofCircuit::PackedWithSlack &circuit, const BulletproofAssignmentData &assignment, const BulletproofScalarBytes &nonce, const BulletproofGeneratorBytes &value_generator, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding={}, std::span< const BulletproofScalarBytes > blinds={}, ExperimentalBulletproofBackendCache *backend_cache=nullptr)
Result< bool > verify_experimental_circuit (const NativeBulletproofCircuit &circuit, const ExperimentalBulletproofProof &proof, const BulletproofGeneratorBytes &value_generator, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding={}, ExperimentalBulletproofBackendCache *backend_cache=nullptr)
 Verifies a proof produced by prove_experimental_circuit against the same native circuit and ordered output commitments.
Result< bool > verify_experimental_circuit (const NativeBulletproofCircuit::PackedWithSlack &circuit, const ExperimentalBulletproofProof &proof, const BulletproofGeneratorBytes &value_generator, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding={}, ExperimentalBulletproofBackendCache *backend_cache=nullptr)
Result< NativeBulletproofCircuitTemplate > verifier_circuit_template (const Bytes &message)
 Builds a reusable public-key-agnostic verifier-circuit template for a message.
Expr circuit_1bit (const std::array< FieldElement, 2 > &values, Transcript &transcript, const Expr &x)
 Selects one of two field constants using a single boolean expression bit.
Expr circuit_2bit (const std::array< FieldElement, 4 > &values, Transcript &transcript, const Expr &x, const Expr &y)
 Selects one of four field constants using two boolean expression bits.
Expr circuit_3bit (const std::array< FieldElement, 8 > &values, Transcript &transcript, const Expr &x, const Expr &y, const Expr &z)
 Selects one of eight field constants using three boolean expression bits.
ExprPoint circuit_1bit_point (const EllipticCurve &curve, const std::array< JacobianPoint, 2 > &points, Transcript &transcript, const Expr &b0)
 Selects between two affine point constants using one boolean expression bit.
ExprPoint circuit_2bit_point (const EllipticCurve &curve, const std::array< JacobianPoint, 4 > &points, Transcript &transcript, const Expr &b0, const Expr &b1)
 Selects between four affine point constants using two boolean expression bits.
ExprPoint circuit_3bit_point (const EllipticCurve &curve, const std::array< JacobianPoint, 8 > &points, Transcript &transcript, const Expr &b0, const Expr &b1, const Expr &b2)
 Selects between eight affine point constants using three boolean expression bits.
ExprPoint circuit_optionally_negate_ec (const ExprPoint &point, Transcript &transcript, const Expr &negate_bit)
 Conditionally negates an elliptic-curve point encoded as symbolic affine expressions.
ExprPoint circuit_ec_add (Transcript &transcript, const ExprPoint &p1, const ExprPoint &p2)
 Symbolically adds two affine elliptic-curve points.
Expr circuit_ec_add_x (Transcript &transcript, const ExprPoint &p1, const ExprPoint &p2)
 Symbolically adds two affine points and returns only the resulting x-coordinate.
ExprPoint circuit_ec_multiply_point (const EllipticCurve &curve, Transcript &transcript, const JacobianPoint &point, const std::vector< Expr > &bits)
 Builds the symbolic affine-point multiplication gadget for one curve point.
Expr circuit_ec_multiply_x (const EllipticCurve &curve, Transcript &transcript, const JacobianPoint &point, const std::vector< Expr > &bits)
 Builds the symbolic x-coordinate multiplication gadget for one curve point.
Expr circuit_combine (Transcript &transcript, const Expr &x1, const Expr &x2)
 Builds the symbolic Purify output combiner over two x-coordinates.
Result< CircuitMainResult > circuit_main (Transcript &transcript, const JacobianPoint &m1, const JacobianPoint &m2, const std::optional< UInt256 > &z1=std::nullopt, const std::optional< UInt256 > &z2=std::nullopt)
 Builds the full symbolic Purify circuit from message points and optional witness scalars.
SecpContextPtr make_secp_context () noexcept
Status require_secp_context (const purify_secp_context *context, const char *error_context)
bool checked_add_size (std::size_t lhs, std::size_t rhs, std::size_t &out) noexcept
bool checked_mul_size (std::size_t lhs, std::size_t rhs, std::size_t &out) noexcept
bool size_fits_u32 (std::size_t value) noexcept
bool size_fits_u64 (std::size_t value) noexcept
Result< std::uint64_t > narrow_size_to_u64 (std::size_t value, const char *context)
bool is_power_of_two_size (std::size_t value) noexcept
template<typename T>
void best_effort_reserve_add (std::vector< T > &out, std::size_t lhs, std::size_t rhs)
 Reserve capacity when the size arithmetic fits, otherwise skip the hint.
template<typename T>
void best_effort_reserve_mul (std::vector< T > &out, std::size_t lhs, std::size_t rhs)
Bytes bytes_from_ascii (std::string_view input)
 Encodes an ASCII string as a byte vector.
Bytes operator+ (Bytes lhs, const Bytes &rhs)
 Concatenates two byte vectors.
std::uint64_t ceil_div (std::uint64_t lhs, std::uint64_t rhs)
 Computes ceiling division for unsigned 64-bit values.
Bytes hmac_sha256 (const Bytes &key, const Bytes &data)
 Computes an HMAC-SHA256 digest using the secp bridge implementation.
Bytes hkdf (std::size_t length, const Bytes &ikm, const Bytes &salt={}, const Bytes &info={})
 Expands input key material using HKDF-SHA256.
template<std::size_t Words>
std::optional< BigUInt< Words > > hash_to_int (const Bytes &data, const BigUInt< Words > &range, const Bytes &info={})
 Rejection-samples a uniformly distributed integer below range.
template<std::size_t Words>
std::optional< BigUInt< Words > > tagged_hash_to_int (std::span< const unsigned char > data, const BigUInt< Words > &range, const TaggedHash &tag, std::span< const unsigned char > info={})
 Rejection-samples a uniformly distributed integer below range using repeated tagged hashes.
const UInt256 & order_n1 ()
 Returns the subgroup order for the first curve.
const UInt256 & order_n2 ()
 Returns the subgroup order for the second curve.
const UInt256 & half_n1 ()
 Returns floor(order_n1 / 2).
const UInt256 & half_n2 ()
 Returns floor(order_n2 / 2).
const UInt512 & packed_secret_key_space_size ()
 Returns the size of the packed secret-key encoding space.
const UInt512 & packed_public_key_space_size ()
 Returns the size of the packed public-key encoding space.
const UInt320 & two_p ()
 Returns 2 * prime_p() as a widened integer for hash-to-curve sampling.
FieldElement field_a ()
 Returns the shared Weierstrass a coefficient used by Purify.
FieldElement field_b ()
 Returns the shared Weierstrass b coefficient used by Purify.
FieldElement field_d ()
 Returns the twist factor used to derive the second curve.
FieldElement field_di ()
 Returns the inverse of the twist factor in the field.
const EllipticCurve & curve1 ()
 Returns the first Purify curve instance.
const EllipticCurve & curve2 ()
 Returns the second Purify curve instance.
Result< JacobianPoint > hash_to_curve (const Bytes &data, const EllipticCurve &curve)
 Hashes arbitrary data onto the supplied curve by rejection sampling x-coordinates.
const JacobianPoint & generator1 ()
 Returns the fixed generator for the first curve.
const JacobianPoint & generator2 ()
 Returns the fixed generator for the second curve.
bool is_valid_secret_key (const UInt512 &z)
 Returns true when a packed secret is encoded canonically.
bool is_valid_public_key (const UInt512 &packed)
 Returns true when a packed public key is encoded canonically.
Status validate_secret_key (const UInt512 &z)
 Validates the packed secret-key encoding range.
Status validate_public_key (const UInt512 &packed)
 Validates the packed public-key encoding range.
Result< std::pair< UInt256, UInt256 > > unpack_secret (const UInt512 &z)
 Splits a packed private key into its two per-curve secret scalars.
Result< UInt512 > pack_secret (const UInt256 &first, const UInt256 &second)
 Packs scalars in [1, half_n1] and [1, half_n2].
Result< std::pair< UInt256, UInt256 > > unpack_public (const UInt512 &packed)
 Splits a packed public key into its two x-coordinates.
Result< std::pair< JacobianPoint, JacobianPoint > > unpack_public_points (const UInt512 &packed)
 Decodes and validates both curve points in a packed public key.
Status validate_public_points (const UInt512 &packed)
 Validates both curve points in a packed public key.
UInt512 pack_public (const UInt256 &x1, const UInt256 &x2)
 Packs two x-coordinates into the reference 512-bit public-key encoding.
FieldElement combine (const FieldElement &x1, const FieldElement &x2)
 Applies the Purify curve-combination map to two x-coordinates.
Result< std::vector< int > > key_to_bits (UInt256 n, const UInt256 &max_value)
 Encodes a scalar into the signed 3-bit window bit schedule used by the circuit.
constexpr ErrorCategory error_category (ErrorCode code) noexcept
 Returns the high-level category for a concrete error code.
constexpr std::string_view to_string (ErrorCategory category) noexcept
 Returns a stable programmatic name for an error category.
constexpr std::string_view to_string (ErrorCode code) noexcept
 Returns a stable programmatic name for an error code.
constexpr std::string_view error_message (ErrorCode code) noexcept
 Returns the human-facing description for an error code.
constexpr Unexpected< Error > unexpected_error (ErrorCode code, const char *context=nullptr)
 Constructs an unexpected Error value from a machine-readable code.
constexpr Unexpected< Error > unexpected_error (Error error, const char *context=nullptr)
 Re-wraps an existing Error value for propagation through another Result.
bool operator< (const Symbol &lhs, const Symbol &rhs) noexcept
std::ostream & operator<< (std::ostream &out, const Expr &expr)
 Streams the human-readable expression form to an output stream.
Expr operator+ (const Expr &lhs, const Expr &rhs)
Expr operator+ (const Expr &lhs, std::int64_t rhs)
Expr operator+ (std::int64_t lhs, const Expr &rhs)
Expr operator- (const Expr &lhs, const Expr &rhs)
Expr operator- (const Expr &lhs, std::int64_t rhs)
Expr operator- (std::int64_t lhs, const Expr &rhs)
Expr operator- (const Expr &value)
Expr operator* (const Expr &expr, const FieldElement &scalar)
Expr operator* (const FieldElement &scalar, const Expr &expr)
Expr operator* (const Expr &expr, std::int64_t scalar)
Expr operator* (std::int64_t scalar, const Expr &expr)
bool operator== (const Expr &lhs, const Expr &rhs)
bool operator< (const Expr &lhs, const Expr &rhs)
Result< NativeBulletproofCircuit > nonce_batch_circuit (std::span< const NonceBatchGroup > groups)
 Builds a public verifier circuit with one output commitment per group.
Result< BulletproofAssignmentData > nonce_batch_assignments (std::span< const NonceBatchGroup > groups, std::span< const std::vector< BulletproofAssignmentData > > assignments)
 Validates and combines member assignments for nonce_batch_circuit.
template<std::size_t OutWords, std::size_t InWords>
BigUInt< OutWords > widen (const BigUInt< InWords > &value)
 Widens an integer to a larger limb count by zero-extending high limbs.
template<std::size_t OutWords, std::size_t InWords>
Result< BigUInt< OutWords > > try_narrow (const BigUInt< InWords > &value)
 Narrows an integer to a smaller limb count, rejecting truncated high bits.
template<std::size_t OutWords, std::size_t InWords>
BigUInt< OutWords > narrow (const BigUInt< InWords > &value)
 Narrows an integer to a smaller limb count, requiring that no high bits are lost.
template<std::size_t Words>
Result< std::pair< BigUInt< Words >, BigUInt< Words > > > try_divmod_same (const BigUInt< Words > &numerator, const BigUInt< Words > &denominator)
 Performs long division where numerator and denominator have the same width.
template<std::size_t Words>
std::pair< BigUInt< Words >, BigUInt< Words > > divmod_same (const BigUInt< Words > &numerator, const BigUInt< Words > &denominator)
 Performs long division where numerator and denominator have the same width.
template<std::size_t LeftWords, std::size_t RightWords>
BigUInt< LeftWords+RightWords > multiply (const BigUInt< LeftWords > &lhs, const BigUInt< RightWords > &rhs)
 Multiplies two fixed-width integers and returns the full-width product.
const UInt256 & prime_p ()
 Returns the Purify base-field modulus.
FieldElement square (const FieldElement &value)
 Squares a field element.
int legendre_symbol (const FieldElement &value)
 Returns 0 for zero, 1 for quadratic residues, and -1 for non-residues.
Result< ExperimentalBulletproofProof > prove_experimental_circuit_assume_valid (const NativeBulletproofCircuit::PackedWithSlack &circuit, const BulletproofAssignmentData &assignment, const BulletproofScalarBytes &nonce, const BulletproofGeneratorBytes &value_generator, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding, std::span< const BulletproofScalarBytes > blinds, ExperimentalBulletproofBackendCache *backend_cache)
Result< Bytes > experimental_circuit_binding_digest (const NativeBulletproofCircuit &circuit, std::span< const unsigned char > statement_binding)
Result< Bytes > experimental_circuit_binding_digest (const NativeBulletproofCircuit::PackedWithSlack &circuit, std::span< const unsigned char > statement_binding)
bool operator== (const FieldElement &lhs, const FieldElement &rhs)
bool operator!= (const FieldElement &lhs, const FieldElement &rhs)
FieldElement operator+ (const FieldElement &lhs, const FieldElement &rhs)
FieldElement operator- (const FieldElement &lhs, const FieldElement &rhs)
FieldElement operator* (const FieldElement &lhs, const FieldElement &rhs)
Result< Bytes > bytes_from_hex (std::string_view hex)
 Parses a hexadecimal string into raw bytes.
template<std::size_t N>
Result< std::array< unsigned char, N > > array_from_hex (std::string_view hex)
 Parses a fixed-size hexadecimal string into an array.
template<typename ByteContainer>
std::string hex_from_bytes (const ByteContainer &bytes)
 Encodes a byte container as lowercase hexadecimal.
Status write_file (const std::string &path, const Bytes &bytes)
 Writes a byte buffer to disk.
Status prove (const Bytes &message, const SecretKey &secret, const std::string &output_path="prove.assn")
 Writes a serialized witness assignment for a message and secret.
int run_cli (int argc, char **argv)
 Dispatches the purify_cpp command-line interface.

Variables

constexpr unexpect_t unexpect {}

Typedef Documentation

◆ BulletproofBackendResourcePtr

Initial value:
std::unique_ptr<purify_bulletproof_backend_resources, BulletproofBackendResourceDeleter>

Definition at line 38 of file bulletproof.cpp.

◆ BulletproofGeneratorBytes

using purify::BulletproofGeneratorBytes = std::array<unsigned char, 33>

Definition at line 33 of file bulletproof.hpp.

◆ BulletproofPointBytes

using purify::BulletproofPointBytes = std::array<unsigned char, 33>

Definition at line 32 of file bulletproof.hpp.

◆ BulletproofScalarBytes

using purify::BulletproofScalarBytes = std::array<unsigned char, 32>

Definition at line 31 of file bulletproof.hpp.

◆ BulletproofWitnessColumn

Initial value:
std::vector<FieldElement, detail::SecureAllocator<FieldElement>>

Definition at line 34 of file bulletproof.hpp.

◆ Bytes

using purify::Bytes = std::vector<unsigned char>

Definition at line 99 of file common.hpp.

◆ ExprPoint

using purify::ExprPoint = std::pair<Expr, Expr>

Definition at line 532 of file bulletproof.hpp.

◆ KeySeed

using purify::KeySeed = SpanAtLeast<16, const unsigned char>

Definition at line 30 of file api.hpp.

◆ Result

template<typename T>
using purify::Result = Expected<T, Error>

Definition at line 99 of file error.hpp.

◆ SecpContextPtr

Definition at line 50 of file common.hpp.

◆ Status

using purify::Status = Expected<void, Error>

Definition at line 102 of file error.hpp.

◆ UInt256

Definition at line 817 of file numeric.hpp.

◆ UInt320

Definition at line 819 of file numeric.hpp.

◆ UInt512

Definition at line 821 of file numeric.hpp.

◆ WitnessAssignment

using purify::WitnessAssignment = std::optional<FieldElement>

Definition at line 63 of file expr.hpp.

◆ WitnessAssignments

Initial value:
std::vector<WitnessAssignment, detail::SecureAllocator<WitnessAssignment>>

Definition at line 64 of file expr.hpp.

Enumeration Type Documentation

◆ ErrorCategory

enum class purify::ErrorCategory : std::uint8_t
strong

Natural errors can happen in valid operation and should be surfaced in checked APIs. Usage errors mean the caller supplied malformed input or violated a documented contract. Internal errors indicate a broken library invariant and should generally map to debug assertions or unchecked fast-fail paths instead of normal error returns.

Enumerator
Natural 
Usage 
Internal 

Definition at line 29 of file error.hpp.

◆ ErrorCode

enum class purify::ErrorCode : std::uint16_t
strong

The intent is that checked APIs list the exact ErrorCode values they may return, while the category helpers below make it obvious whether each error is a normal runtime condition, caller misuse, or a library defect.

Enumerator
InvalidHex 
InvalidHexLength 
InvalidFixedSize 
Overflow 
Underflow 
NarrowingOverflow 
DivisionByZero 
BitIndexOutOfRange 
RangeViolation 
EmptyInput 
SizeMismatch 
MissingValue 
InvalidSymbol 
UnsupportedSymbol 
UninitializedState 
IndexOutOfRange 
InvalidDimensions 
NonBooleanValue 
EquationMismatch 
BindingMismatch 
IoOpenFailed 
IoWriteFailed 
EntropyUnavailable 
BackendRejectedInput 
HashToCurveExhausted 
UnexpectedSize 
GeneratorOrderCheckFailed 
InternalMismatch 
TranscriptCheckFailed 

Definition at line 42 of file error.hpp.

◆ SymbolKind

enum class purify::SymbolKind : std::uint8_t
strong
Enumerator
Witness 
Left 
Right 
Output 
Commitment 

Definition at line 26 of file expr.hpp.

Function Documentation

◆ array_from_hex()

template<std::size_t N>
Result< std::array< unsigned char, N > > purify::array_from_hex ( std::string_view hex)
inline
Template Parameters
NRequired byte length.
Parameters
hexInput hex string.
Returns
Parsed byte array.

Definition at line 73 of file purify_runtime.hpp.

References bytes_from_hex(), purify::Expected< T, E >::error(), purify::Expected< T, E >::has_value(), InvalidFixedSize, and unexpected_error().

Referenced by run_cli().

◆ best_effort_reserve_add()

template<typename T>
void purify::best_effort_reserve_add ( std::vector< T > & out,
std::size_t lhs,
std::size_t rhs )
inline

Reserve is only a performance hint. Callers use this when overflow should not change semantics.

Definition at line 107 of file common.hpp.

References checked_add_size().

Referenced by purify::detail::tagged_eval_input().

◆ best_effort_reserve_mul()

template<typename T>
void purify::best_effort_reserve_mul ( std::vector< T > & out,
std::size_t lhs,
std::size_t rhs )
inline

Definition at line 115 of file common.hpp.

References checked_mul_size().

◆ bytes_from_ascii()

Bytes purify::bytes_from_ascii ( std::string_view input)

Definition at line 168 of file curve.cpp.

Referenced by generator1(), generator2(), main(), and purify_derive_bip340_key().

◆ bytes_from_hex()

Result< Bytes > purify::bytes_from_hex ( std::string_view hex)
inline
Parameters
hexInput hex string; ASCII whitespace is ignored.
Returns
Parsed bytes.

Definition at line 31 of file purify_runtime.hpp.

References InvalidHex, InvalidHexLength, and unexpected_error().

Referenced by array_from_hex(), and run_cli().

◆ ceil_div()

std::uint64_t purify::ceil_div ( std::uint64_t lhs,
std::uint64_t rhs )

Definition at line 177 of file curve.cpp.

Referenced by hkdf().

◆ checked_add_size()

◆ checked_mul_size()

◆ circuit_1bit()

Expr purify::circuit_1bit ( const std::array< FieldElement, 2 > & values,
Transcript & transcript,
const Expr & x )

◆ circuit_1bit_point()

ExprPoint purify::circuit_1bit_point ( const EllipticCurve & curve,
const std::array< JacobianPoint, 2 > & points,
Transcript & transcript,
const Expr & b0 )

Definition at line 2463 of file bulletproof.cpp.

References purify::EllipticCurve::affine(), and circuit_1bit().

◆ circuit_2bit()

Expr purify::circuit_2bit ( const std::array< FieldElement, 4 > & values,
Transcript & transcript,
const Expr & x,
const Expr & y )

◆ circuit_2bit_point()

ExprPoint purify::circuit_2bit_point ( const EllipticCurve & curve,
const std::array< JacobianPoint, 4 > & points,
Transcript & transcript,
const Expr & b0,
const Expr & b1 )

Definition at line 2472 of file bulletproof.cpp.

References purify::EllipticCurve::affine(), and circuit_2bit().

◆ circuit_3bit()

Expr purify::circuit_3bit ( const std::array< FieldElement, 8 > & values,
Transcript & transcript,
const Expr & x,
const Expr & y,
const Expr & z )

◆ circuit_3bit_point()

ExprPoint purify::circuit_3bit_point ( const EllipticCurve & curve,
const std::array< JacobianPoint, 8 > & points,
Transcript & transcript,
const Expr & b0,
const Expr & b1,
const Expr & b2 )

Definition at line 2481 of file bulletproof.cpp.

References purify::EllipticCurve::affine(), and circuit_3bit().

◆ circuit_combine()

◆ circuit_ec_add()

◆ circuit_ec_add_x()

◆ circuit_ec_multiply_point()

ExprPoint purify::circuit_ec_multiply_point ( const EllipticCurve & curve,
Transcript & transcript,
const JacobianPoint & point,
const std::vector< Expr > & bits )

Definition at line 2598 of file bulletproof.cpp.

◆ circuit_ec_multiply_x()

Expr purify::circuit_ec_multiply_x ( const EllipticCurve & curve,
Transcript & transcript,
const JacobianPoint & point,
const std::vector< Expr > & bits )

Definition at line 2604 of file bulletproof.cpp.

Referenced by circuit_main().

◆ circuit_main()

◆ circuit_optionally_negate_ec()

ExprPoint purify::circuit_optionally_negate_ec ( const ExprPoint & point,
Transcript & transcript,
const Expr & negate_bit )

Definition at line 2497 of file bulletproof.cpp.

References purify::Transcript::mul().

◆ combine()

FieldElement purify::combine ( const FieldElement & x1,
const FieldElement & x2 )

Definition at line 405 of file curve.cpp.

References purify_curve_combine().

Referenced by prove_assignment_data(), and purify_eval().

◆ curve1()

◆ curve2()

◆ derive_bip340_key()

◆ derive_key() [1/2]

Result< GeneratedKey > purify::derive_key ( const SecretKey & secret)
Parameters
secretOwned secret to clone into the returned key bundle.
Returns
Derived key bundle containing a fresh owned copy of secret.

Definition at line 147 of file api.cpp.

References purify::SecretKey::clone(), derive_key(), and PURIFY_ASSIGN_OR_RETURN.

Referenced by derive_key(), purify::puresign::api_impl::derive_public_key(), purify::puresign_plusplus::api_impl::derive_public_key(), purify::accountable::derive_recovery_root(), generate_key(), purify::accountable::recover_aggregated_recovery_root(), and run_cli().

◆ derive_key() [2/2]

Result< GeneratedKey > purify::derive_key ( SecretKey && secret)
Parameters
secretOwned secret to move into the returned key bundle.
Returns
Derived key bundle consuming secret.

Definition at line 152 of file api.cpp.

References purify::BigUInt< 8 >::from_bytes_be(), purify::core_api_detail::from_core_error_code(), purify_derive_public_key(), PURIFY_ERROR_OK, purify::detail::secure_clear_bytes(), and unexpected_error().

◆ divmod_same()

template<std::size_t Words>
std::pair< BigUInt< Words >, BigUInt< Words > > purify::divmod_same ( const BigUInt< Words > & numerator,
const BigUInt< Words > & denominator )

Definition at line 788 of file numeric.hpp.

References purify::Expected< T, E >::has_value(), and try_divmod_same().

◆ error_category()

◆ error_message()

◆ eval()

Result< FieldElement > purify::eval ( const SecretKey & secret,
const Bytes & message )
Parameters
secretOwned secret key.
messageMessage bytes to evaluate.
Returns
Purify output as a field element, or ErrorCode::HashToCurveExhausted.

Definition at line 182 of file api.cpp.

References purify::core_api_detail::from_core_error_code(), purify::SecretKey::packed(), PURIFY_ERROR_OK, purify_eval(), purify::detail::secure_clear_bytes(), purify::BigUInt< Words >::to_bytes_be(), purify::FieldElement::try_from_bytes32(), and unexpected_error().

Referenced by run_cli().

◆ evaluate_verifier_circuit() [1/2]

Result< bool > purify::evaluate_verifier_circuit ( const Bytes & message,
const BulletproofWitnessData & witness )
Parameters
messageMessage baked into the verifier circuit.
witnessWitness bundle to validate.
Returns
True when the witness satisfies the circuit, or ErrorCode::HashToCurveExhausted.

Definition at line 289 of file api.cpp.

References purify::BulletproofWitnessData::assignment, purify::BulletproofWitnessData::public_key, PURIFY_ASSIGN_OR_RETURN, and verifier_circuit().

Referenced by evaluate_verifier_circuit().

◆ evaluate_verifier_circuit() [2/2]

Result< bool > purify::evaluate_verifier_circuit ( const Bytes & message,
const SecretKey & secret )
Parameters
messageMessage baked into the verifier circuit.
secretOwned secret key.
Returns
True when the derived witness satisfies the circuit, or ErrorCode::HashToCurveExhausted.

Definition at line 295 of file api.cpp.

References evaluate_verifier_circuit(), prove_assignment_data(), and PURIFY_ASSIGN_OR_RETURN.

◆ experimental_circuit_binding_digest() [1/2]

Result< Bytes > purify::experimental_circuit_binding_digest ( const NativeBulletproofCircuit & circuit,
std::span< const unsigned char > statement_binding )

◆ experimental_circuit_binding_digest() [2/2]

Result< Bytes > purify::experimental_circuit_binding_digest ( const NativeBulletproofCircuit::PackedWithSlack & circuit,
std::span< const unsigned char > statement_binding )

Definition at line 2683 of file bulletproof.cpp.

◆ field_a()

FieldElement purify::field_a ( )

Definition at line 244 of file curve.cpp.

References purify_curve_field_a().

Referenced by circuit_combine(), curve1(), and curve2().

◆ field_b()

FieldElement purify::field_b ( )

Definition at line 248 of file curve.cpp.

References purify_curve_field_b().

Referenced by circuit_combine(), curve1(), and curve2().

◆ field_d()

FieldElement purify::field_d ( )

Definition at line 252 of file curve.cpp.

References purify_curve_field_d().

Referenced by curve2().

◆ field_di()

FieldElement purify::field_di ( )

Definition at line 256 of file curve.cpp.

References purify_curve_field_di().

Referenced by circuit_combine().

◆ fill_secure_random()

Status purify::fill_secure_random ( std::span< unsigned char > bytes)
noexcept
Parameters
bytesBuffer to fill.
Returns
Success or ErrorCode::EntropyUnavailable.

Definition at line 108 of file api.cpp.

References purify_fill_secure_random().

Referenced by purify::accountable::AnchorEscrowRecord::create_anchor_escrow, and random_below().

◆ generate_key() [1/4]

◆ generate_key() [2/4]

template<typename FillRandom>
requires (NoexceptByteFill<FillRandom> || NoexceptCheckedByteFill<FillRandom>)
Result< GeneratedKey > purify::generate_key ( FillRandom && fill_random)
Parameters
fill_randomCallable that fills the supplied byte span.
Returns
Generated keypair bundle.

Definition at line 243 of file api.hpp.

References derive_key(), purify::SecretKey::from_packed(), key_space_size(), PURIFY_ASSIGN_OR_RETURN, and random_below().

◆ generate_key() [3/4]

Result< GeneratedKey > purify::generate_key ( KeySeed seed)

◆ generate_key() [4/4]

Result< GeneratedKey > purify::generate_key ( std::span< const unsigned char > seed)
inline
Parameters
seedSeed bytes. Inputs shorter than 16 bytes are rejected.
Returns
Generated keypair bundle.

Definition at line 231 of file api.hpp.

References generate_key(), PURIFY_ASSIGN_OR_RETURN, and purify::SpanAtLeast< 16, const unsigned char >::try_from().

◆ generator1()

◆ generator2()

◆ half_n1()

const UInt256 & purify::half_n1 ( )

◆ half_n2()

◆ hash_to_curve()

◆ hash_to_int()

template<std::size_t Words>
std::optional< BigUInt< Words > > purify::hash_to_int ( const Bytes & data,
const BigUInt< Words > & range,
const Bytes & info = {} )

Definition at line 150 of file curve.hpp.

Referenced by purify_derive_bip340_key().

◆ hex_from_bytes()

template<typename ByteContainer>
std::string purify::hex_from_bytes ( const ByteContainer & bytes)
inline
Template Parameters
ByteContainerContainer with byte-like values.
Parameters
bytesInput bytes.
Returns
Hexadecimal string.

Definition at line 93 of file purify_runtime.hpp.

Referenced by run_cli().

◆ hkdf()

Bytes purify::hkdf ( std::size_t length,
const Bytes & ikm,
const Bytes & salt = {},
const Bytes & info = {} )

Definition at line 187 of file curve.cpp.

References ceil_div(), and hmac_sha256().

◆ hmac_sha256()

Bytes purify::hmac_sha256 ( const Bytes & key,
const Bytes & data )

Definition at line 181 of file curve.cpp.

References purify_hmac_sha256().

Referenced by hkdf().

◆ is_power_of_two_size()

◆ is_valid_public_key()

bool purify::is_valid_public_key ( const UInt512 & packed)

Definition at line 308 of file curve.cpp.

References purify::BigUInt< Words >::limbs, and purify_curve_is_valid_public_key().

Referenced by validate_public_key().

◆ is_valid_secret_key()

bool purify::is_valid_secret_key ( const UInt512 & z)

◆ key_space_size()

UInt512 purify::key_space_size ( )
inline

Definition at line 131 of file api.hpp.

References packed_secret_key_space_size().

Referenced by generate_key().

◆ key_to_bits()

Result< std::vector< int > > purify::key_to_bits ( UInt256 n,
const UInt256 & max_value )

◆ legendre_symbol()

int purify::legendre_symbol ( const FieldElement & value)

Definition at line 190 of file numeric.cpp.

References purify_fe_legendre_symbol().

◆ make_secp_context()

SecpContextPtr purify::make_secp_context ( )
inlinenoexcept

Definition at line 52 of file common.hpp.

References purify_secp_context_create().

Referenced by run_cli().

◆ multiply()

template<std::size_t LeftWords, std::size_t RightWords>
BigUInt< LeftWords+RightWords > purify::multiply ( const BigUInt< LeftWords > & lhs,
const BigUInt< RightWords > & rhs )

◆ narrow()

template<std::size_t OutWords, std::size_t InWords>
BigUInt< OutWords > purify::narrow ( const BigUInt< InWords > & value)

Definition at line 740 of file numeric.hpp.

References purify::Expected< T, E >::has_value(), and try_narrow().

◆ narrow_size_to_u64()

Result< std::uint64_t > purify::narrow_size_to_u64 ( std::size_t value,
const char * context )
inlinenodiscard

Definition at line 87 of file common.hpp.

References size_fits_u64(), unexpected_error(), and UnexpectedSize.

◆ nonce_batch_assignments()

Result< BulletproofAssignmentData > purify::nonce_batch_assignments ( std::span< const NonceBatchGroup > groups,
std::span< const std::vector< BulletproofAssignmentData > > assignments )

assignments[g][i] belongs to groups[g].hosts[i] for that group's exact evaluation input. The caller receives all private witnesses and summed output scalars; this is a centralized prover helper, not an MPC interface or an operation for a public certificate assembler.

Definition at line 81 of file nonce_batch.cpp.

References purify::BulletproofAssignmentData::commitments, InvalidDimensions, purify::BulletproofAssignmentData::left, purify::BulletproofAssignmentData::output, PURIFY_ASSIGN_OR_RETURN, PURIFY_RETURN_IF_ERROR, purify::BulletproofAssignmentData::right, SizeMismatch, unexpected_error(), verifier_circuit_template(), and purify::FieldElement::zero().

◆ nonce_batch_circuit()

Result< NativeBulletproofCircuit > purify::nonce_batch_circuit ( std::span< const NonceBatchGroup > groups)

Group and host order are retained. Each group uses the existing summed-host relation, including its padding; the combined circuit is padded once more to a power of two. No witnesses or completed proofs are needed here. This builds a relation, not a public compression of completed group proofs.

Definition at line 43 of file nonce_batch.cpp.

References purify::NativeBulletproofCircuit::c, InvalidDimensions, purify::NativeBulletproofCircuit::n_gates, PURIFY_ASSIGN_OR_RETURN, PURIFY_RETURN_IF_ERROR, unexpected_error(), verifier_circuit_template(), purify::NativeBulletproofCircuit::wl, purify::NativeBulletproofCircuit::wo, purify::NativeBulletproofCircuit::wr, and purify::NativeBulletproofCircuit::wv.

◆ operator!=()

bool purify::operator!= ( const FieldElement & lhs,
const FieldElement & rhs )

Definition at line 163 of file numeric.cpp.

◆ operator*() [1/5]

Expr purify::operator* ( const Expr & expr,
const FieldElement & scalar )

Definition at line 323 of file expr.cpp.

◆ operator*() [2/5]

Expr purify::operator* ( const Expr & expr,
std::int64_t scalar )

Definition at line 339 of file expr.cpp.

◆ operator*() [3/5]

FieldElement purify::operator* ( const FieldElement & lhs,
const FieldElement & rhs )

Definition at line 177 of file numeric.cpp.

◆ operator*() [4/5]

Expr purify::operator* ( const FieldElement & scalar,
const Expr & expr )

Definition at line 335 of file expr.cpp.

◆ operator*() [5/5]

Expr purify::operator* ( std::int64_t scalar,
const Expr & expr )

Definition at line 343 of file expr.cpp.

◆ operator+() [1/5]

Bytes purify::operator+ ( Bytes lhs,
const Bytes & rhs )

Definition at line 172 of file curve.cpp.

◆ operator+() [2/5]

Expr purify::operator+ ( const Expr & lhs,
const Expr & rhs )

Definition at line 277 of file expr.cpp.

◆ operator+() [3/5]

Expr purify::operator+ ( const Expr & lhs,
std::int64_t rhs )

Definition at line 299 of file expr.cpp.

◆ operator+() [4/5]

FieldElement purify::operator+ ( const FieldElement & lhs,
const FieldElement & rhs )

Definition at line 167 of file numeric.cpp.

◆ operator+() [5/5]

Expr purify::operator+ ( std::int64_t lhs,
const Expr & rhs )

Definition at line 303 of file expr.cpp.

◆ operator-() [1/5]

Expr purify::operator- ( const Expr & lhs,
const Expr & rhs )

Definition at line 307 of file expr.cpp.

◆ operator-() [2/5]

Expr purify::operator- ( const Expr & lhs,
std::int64_t rhs )

Definition at line 311 of file expr.cpp.

◆ operator-() [3/5]

Expr purify::operator- ( const Expr & value)

Definition at line 319 of file expr.cpp.

◆ operator-() [4/5]

FieldElement purify::operator- ( const FieldElement & lhs,
const FieldElement & rhs )

Definition at line 173 of file numeric.cpp.

◆ operator-() [5/5]

Expr purify::operator- ( std::int64_t lhs,
const Expr & rhs )

Definition at line 315 of file expr.cpp.

◆ operator<() [1/2]

bool purify::operator< ( const Expr & lhs,
const Expr & rhs )

Definition at line 381 of file expr.cpp.

◆ operator<() [2/2]

bool purify::operator< ( const Symbol & lhs,
const Symbol & rhs )
inlinenoexcept

Definition at line 58 of file expr.hpp.

◆ operator<<()

std::ostream & purify::operator<< ( std::ostream & out,
const Expr & expr )

Definition at line 385 of file expr.cpp.

References operator<<(), and purify::Expr::to_string().

Referenced by operator<<().

◆ operator==() [1/2]

bool purify::operator== ( const Expr & lhs,
const Expr & rhs )

Definition at line 347 of file expr.cpp.

◆ operator==() [2/2]

bool purify::operator== ( const FieldElement & lhs,
const FieldElement & rhs )

Definition at line 159 of file numeric.cpp.

◆ order_n1()

const UInt256 & purify::order_n1 ( )

◆ order_n2()

◆ pack_public()

◆ pack_secret()

◆ packed_public_key_space_size()

const UInt512 & purify::packed_public_key_space_size ( )

Definition at line 234 of file curve.cpp.

References purify_curve_packed_public_key_space_size().

◆ packed_secret_key_space_size()

const UInt512 & purify::packed_secret_key_space_size ( )

Definition at line 229 of file curve.cpp.

References purify_curve_packed_secret_key_space_size().

Referenced by key_space_size().

◆ prime_p()

const UInt256 & purify::prime_p ( )

Definition at line 204 of file curve.cpp.

References purify_curve_prime_p().

Referenced by purify::accountable::recover_aggregated_recovery_root().

◆ prove()

Status purify::prove ( const Bytes & message,
const SecretKey & secret,
const std::string & output_path = "prove.assn" )
inline
Parameters
messageMessage bytes to evaluate.
secretOwned secret key.
output_pathDestination path for the witness blob.

Definition at line 125 of file purify_runtime.hpp.

References purify::Expected< T, E >::error(), purify::Expected< T, E >::has_value(), prove_assignment(), unexpected_error(), and write_file().

Referenced by run_cli().

◆ prove_assignment()

Result< Bytes > purify::prove_assignment ( const Bytes & message,
const SecretKey & secret )
Parameters
messageMessage bytes to evaluate.
secretOwned secret key.
Returns
Serialized witness blob compatible with the legacy assignment format, or ErrorCode::HashToCurveExhausted.

Definition at line 301 of file api.cpp.

References purify::Expected< T, E >::has_value(), InternalMismatch, prove_assignment_data(), PURIFY_ASSIGN_OR_RETURN, and unexpected_error().

Referenced by prove().

◆ prove_assignment_data()

◆ prove_experimental_circuit() [1/2]

Result< ExperimentalBulletproofProof > purify::prove_experimental_circuit ( const NativeBulletproofCircuit & circuit,
const BulletproofAssignmentData & assignment,
const BulletproofScalarBytes & nonce,
const BulletproofGeneratorBytes & value_generator,
purify_secp_context * secp_context,
std::span< const unsigned char > statement_binding = {},
std::span< const BulletproofScalarBytes > blinds = {},
ExperimentalBulletproofBackendCache * backend_cache = nullptr )

Circuits must have at least one committed scalar. An empty blinds span uses zero blinding for every output, yielding assignment.commitments[i] * value_generator. Otherwise supply exactly one blind per committed scalar, in circuit order.

Definition at line 1661 of file bulletproof.cpp.

Referenced by main().

◆ prove_experimental_circuit() [2/2]

Result< ExperimentalBulletproofProof > purify::prove_experimental_circuit ( const NativeBulletproofCircuit::PackedWithSlack & circuit,
const BulletproofAssignmentData & assignment,
const BulletproofScalarBytes & nonce,
const BulletproofGeneratorBytes & value_generator,
purify_secp_context * secp_context,
std::span< const unsigned char > statement_binding = {},
std::span< const BulletproofScalarBytes > blinds = {},
ExperimentalBulletproofBackendCache * backend_cache = nullptr )

Definition at line 1681 of file bulletproof.cpp.

◆ prove_experimental_circuit_assume_valid()

Result< ExperimentalBulletproofProof > purify::prove_experimental_circuit_assume_valid ( const NativeBulletproofCircuit::PackedWithSlack & circuit,
const BulletproofAssignmentData & assignment,
const BulletproofScalarBytes & nonce,
const BulletproofGeneratorBytes & value_generator,
purify_secp_context * secp_context,
std::span< const unsigned char > statement_binding,
std::span< const BulletproofScalarBytes > blinds,
ExperimentalBulletproofBackendCache * backend_cache )

Definition at line 1701 of file bulletproof.cpp.

◆ random_below() [1/3]

Result< UInt512 > purify::random_below ( const UInt512 & range)
Parameters
rangeExclusive upper bound.
Returns
Random integer in [0, range).

Definition at line 113 of file api.cpp.

References fill_secure_random(), and random_below().

◆ random_below() [2/3]

template<typename FillRandom>
requires NoexceptByteFill<FillRandom>
Result< UInt512 > purify::random_below ( const UInt512 & range,
FillRandom && fill_random )
Parameters
rangeExclusive upper bound.
fill_randomCallable with signature void(std::span<unsigned char>) noexcept.
Returns
Random integer in [0, range).

Definition at line 188 of file api.hpp.

References purify::BigUInt< Words >::bit_length(), purify::BigUInt< Words >::compare(), purify::BigUInt< 8 >::from_bytes_be(), purify::BigUInt< Words >::is_zero(), purify::BigUInt< Words >::mask_bits(), RangeViolation, and unexpected_error().

◆ random_below() [3/3]

template<typename FillRandom>
requires NoexceptCheckedByteFill<FillRandom>
Result< UInt512 > purify::random_below ( const UInt512 & range,
FillRandom && fill_random )
Parameters
rangeExclusive upper bound.
fill_randomCallable with signature Status(std::span<unsigned char>) noexcept.
Returns
Random integer in [0, range).

Definition at line 162 of file api.hpp.

References purify::BigUInt< Words >::bit_length(), purify::BigUInt< Words >::compare(), purify::BigUInt< 8 >::from_bytes_be(), purify::BigUInt< Words >::is_zero(), purify::BigUInt< Words >::mask_bits(), PURIFY_RETURN_IF_ERROR, RangeViolation, and unexpected_error().

Referenced by generate_key(), and random_below().

◆ require_secp_context()

Status purify::require_secp_context ( const purify_secp_context * context,
const char * error_context )
inline

Definition at line 56 of file common.hpp.

References MissingValue, and unexpected_error().

Referenced by purify::accountable::SigningRoster::aggregate(), purify::bppp::commit_norm_arg_with_cache(), purify::accountable::AnchorPunishmentPublicKey::create(), purify::bppp::accumulation::Basis::create(), purify::accountable::AnchorEscrowRecord::create_anchor_escrow, purify::accountable::AnchorEscrowRecord::create_anchor_escrow_with_aux_randomness, purify::bppp::create_generators(), purify::bppp::accumulation::decide(), purify::bppp::candidate::derive_circuit_precommitment_v4(), purify::bppp::candidate::derive_circuit_proof_transcript_v4(), purify::accountable::ConstructionLeafAccumulator::derive_parent_constants(), purify::accountable::ConstructionLeafAccumulator::derive_pending_anchor_parent_constants(), purify::accountable::RecoveryRootShare::derive_recovery_root_share, purify::puresign::Nonce::deserialize(), purify::puresign::PublicKey::deserialize(), purify::puresign::Signature::deserialize(), purify::puresign_plusplus::Nonce::deserialize(), purify::puresign_plusplus::NonceProof::deserialize(), purify::puresign_plusplus::PublicKey::deserialize(), purify::puresign_plusplus::Signature::deserialize(), purify::accountable::AnchorPunishmentKey::from_secret(), purify::bppp::accumulation::parse_algebraic_norm_reduction(), purify::bppp::accumulation::parse_algebraic_step(), purify::puresign_plusplus::parse_certificate_nonce_native_receipt(), purify::bppp::accumulation::parse_norm_reduction(), purify::bppp::accumulation::parse_step(), purify::bppp::pedersen_commit_char(), purify::accountable::ConstructionLeafAccumulator::prepare(), purify::accountable::ConstructionLeafAccumulator::prepare(), purify::accountable::RecoveryRootSetupAccumulator::prepare(), purify::bppp::accumulation::PreparedNorm::prepare_experimental_circuit_zk_norm_arg, purify::bppp::accumulation::PreparedNorm::prepare_experimental_circuit_zk_norm_arg_with_public_commitments, purify::bppp::accumulation::PreparedNorm::prepare_norm, purify::bppp::accumulation::AlgebraicPreparedNorm::prepare_v4_circuit_norm_for_algebraic_reduction, purify::bppp::accumulation::prove_algebraic_norm_reduction(), purify::puresign_plusplus::CertificateNonceParentAccumulator::prove_linear_receipt(), purify::bppp::prove_norm_arg_to_commitment_with_cache(), purify::bppp::accumulation::prove_norm_reduction(), purify::accountable::RecoveryRootShare::prove_recovery_root_contribution, purify::accountable::RecoveryRootSetupProof::prove_recovery_root_setup, purify::accountable::recover_aggregated_recovery_root(), purify::accountable::recover_registered_root(), purify::puresign_plusplus::serialize_accepted_certificate_nonce_parent_witness(), purify::accountable::serialize_accepted_construction_parent_witness(), purify::puresign_plusplus::serialize_accepted_linear_certificate_nonce_parent_witness(), purify::puresign_plusplus::serialize_certificate_nonce_native_receipt(), purify::puresign::PreparedNonce::sign_message(), purify::puresign_plusplus::PreparedNonce::sign_message(), purify::puresign::PreparedNonce::sign_topic_message(), purify::puresign_plusplus::PreparedNonce::sign_topic_message(), purify::accountable::AnchorEscrowRecord::verify_anchor_escrow, verify_experimental_circuit(), verify_experimental_circuit(), purify::puresign_plusplus::CertificateNonceParentAccumulator::verify_linear_receipt(), purify::accountable::RecoveryRootContribution::verify_recovery_root_contribution, purify::accountable::RecoveryBoundSigningRoster::verify_recovery_root_setup, purify::puresign::api_impl::verify_signature(), and purify::puresign_plusplus::api_impl::verify_signature().

◆ run_cli()

◆ size_fits_u32()

◆ size_fits_u64()

◆ square()

FieldElement purify::square ( const FieldElement & value)

Definition at line 183 of file numeric.cpp.

References purify_fe_square().

◆ tagged_hash_to_int()

template<std::size_t Words>
std::optional< BigUInt< Words > > purify::tagged_hash_to_int ( std::span< const unsigned char > data,
const BigUInt< Words > & range,
const TaggedHash & tag,
std::span< const unsigned char > info = {} )

Definition at line 166 of file curve.hpp.

Referenced by purify_derive_bip340_key().

◆ to_string() [1/2]

std::string_view purify::to_string ( ErrorCategory category)
nodiscardconstexprnoexcept

Definition at line 146 of file error.hpp.

References Internal, Natural, and Usage.

Referenced by purify::Error::name(), and purify::BulletproofTranscript::to_string().

◆ to_string() [2/2]

◆ try_divmod_same()

◆ try_narrow()

template<std::size_t OutWords, std::size_t InWords>
Result< BigUInt< OutWords > > purify::try_narrow ( const BigUInt< InWords > & value)

◆ two_p()

const UInt320 & purify::two_p ( )

Definition at line 239 of file curve.cpp.

References purify_curve_two_p().

◆ unexpected_error() [1/2]

Unexpected< Error > purify::unexpected_error ( Error error,
const char * context = nullptr )
nodiscardconstexpr

context is reserved for future diagnostic plumbing and must have static lifetime.

Definition at line 302 of file error.hpp.

◆ unexpected_error() [2/2]

Unexpected< Error > purify::unexpected_error ( ErrorCode code,
const char * context = nullptr )
nodiscardconstexpr

context is reserved for future diagnostic plumbing and must have static lifetime.

Definition at line 293 of file error.hpp.

Referenced by purify::BulletproofTranscript::add_pubkey_and_out(), purify::accountable::SigningRoster::aggregate(), purify::accountable::RecoveryRootShareAggregate::aggregate_recovery_root_shares, purify::accountable::VerifiedCoalitionNonceSet::aggregate_responses, purify::bppp::candidate::CircuitProofTranscriptV4::append_anchored_commitments(), purify::bppp::candidate::Sha256Transcript::append_bytes(), purify::bppp::candidate::CircuitProofTranscriptV4::append_combined_commitment(), purify::bppp::candidate::CircuitProofTranscriptV4::append_dlog_response(), purify::bppp::candidate::CircuitProofTranscriptV4::append_mask(), purify::bppp::candidate::Sha256Transcript::append_point(), purify::bppp::candidate::Sha256Transcript::append_point_pair(), purify::bppp::candidate::CircuitProofTranscriptV4::append_public_opening(), purify::bppp::candidate::CircuitProofTranscriptV4::append_round(), array_from_hex(), purify::BulletproofTranscript::bind_output_to_commitment(), purify::puresign_plusplus::TopicProofCache::build(), purify::puresign::api_impl::build_topic_proof_cache(), bytes_from_hex(), purify::bppp::detail::canonical_sqrt_minus_one(), purify::puresign_plusplus::certificate_nonce_authorization_manifest(), purify::puresign_plusplus::certificate_nonce_authorization_manifest_seed(), purify::puresign_plusplus::certificate_nonce_authorization_manifest_step(), purify::puresign_plusplus::certificate_nonce_native_receipt_size(), purify::puresign_plusplus::CertificateNonceRecursiveManifestResolution::certificate_nonce_recursive_manifest, purify::puresign_plusplus::CertificateNonceRecursiveManifest::certificate_nonce_recursive_manifest_seed, purify::puresign_plusplus::CertificateNonceRecursiveManifest::certificate_nonce_recursive_manifest_step, purify::puresign_plusplus::certificate_nonce_recursive_member_digest(), purify::puresign_plusplus::certificate_nonce_recursive_step_digest(), circuit_main(), purify::ExperimentalBulletproofBackendCache::clone_for_thread(), purify::bppp::ExperimentalCircuitCache::clone_line_for_thread(), purify::bppp::commit_norm_arg_with_cache(), purify::accountable::construction_receipt_statement_digest(), purify::accountable::AnchorPunishmentPublicKey::create(), purify::accountable::CoalitionFormation::create(), purify::accountable::ConstructionReceiptEnvelope::create(), purify::accountable::ResolvedConstructionSetup::create(), purify::accountable::ResolvedConstructionSetupDigest::create(), purify::bppp::accumulation::Basis::create(), purify::bppp::candidate::CircuitTranscriptShapeV4::create(), purify::puresign_plusplus::CertificateNonceNativeResponse::create(), purify::puresign_plusplus::CertificateNonceParentPublicInputs::create(), purify::bppp::create_generators(), purify::bppp::accumulation::decide(), purify::puresign_plusplus::CertificateNonceParentAccumulator::decide_root(), derive_bip340_key(), purify::bppp::candidate::derive_circuit_proof_transcript_v4(), derive_key(), purify::puresign_plusplus::CertificateNonceLeafAccumulator::derive_parent_constants(), purify::capi_detail::derive_public_key_from_secret(), purify::accountable::derive_recovery_root(), purify::accountable::RecoveryRootShare::derive_recovery_root_share, purify::accountable::AnchorEscrowRecord::deserialize(), purify::accountable::ConstructionReceiptEnvelope::deserialize(), purify::accountable::ConstructionReceiptPayload::deserialize(), purify::accountable::RecoveryRootContribution::deserialize(), purify::accountable::RecoveryRootSetupProof::deserialize(), purify::accountable::RecoveryRootShare::deserialize(), purify::accountable::ScalarSignature::deserialize(), purify::ExperimentalBulletproofProof::deserialize(), purify::puresign::Nonce::deserialize(), purify::puresign::NonceProof::deserialize(), purify::puresign::ProvenSignature::deserialize(), purify::puresign::PublicKey::deserialize(), purify::puresign::Signature::deserialize(), purify::puresign_plusplus::Nonce::deserialize(), purify::puresign_plusplus::NonceHost::deserialize(), purify::puresign_plusplus::NonceProof::deserialize(), purify::puresign_plusplus::ProvenSignature::deserialize(), purify::puresign_plusplus::PublicKey::deserialize(), purify::puresign_plusplus::Signature::deserialize(), eval(), purify::NativeBulletproofCircuitTemplate::final_evaluate(), purify::bppp::candidate::CircuitProofTranscriptV4::finish(), purify::accountable::AnchorEscrowAuxiliaryScalar::from_bytes(), purify::NativeBulletproofCircuit::PackedWithSlack::from_circuit(), purify::accountable::AnchorPunishmentKey::from_secret(), purify::BulletproofTranscript::from_transcript(), generate_key(), generate_key(), hash_to_curve(), purify::NativeBulletproofCircuitTemplate::instantiate(), purify::NativeBulletproofCircuitTemplate::instantiate_packed(), purify::NativeBulletproofCircuitTemplate::instantiate_sum(), purify::NativeBulletproofCircuitTemplate::integrity_digest(), key_to_bits(), purify::accountable::ConstructionParentVerifier::load(), purify::EllipticCurve::mul_secret_affine(), narrow_size_to_u64(), nonce_batch_assignments(), nonce_batch_circuit(), pack_secret(), purify::bppp::candidate::CircuitPrecommitmentDigestV4::parse(), purify::bppp::accumulation::parse_algebraic_norm_reduction(), purify::bppp::accumulation::parse_algebraic_step(), purify::puresign_plusplus::parse_certificate_nonce_native_receipt(), purify::bppp::accumulation::parse_norm_reduction(), purify::bppp::parse_norm_rounds_v4(), purify::capi_detail::parse_public_key(), purify::bppp::accumulation::PendingClaim::parse_root_claim, purify::capi_detail::parse_secret_key(), purify::bppp::accumulation::parse_step(), purify::NativeBulletproofCircuitTemplate::partial_evaluate(), purify::bppp::pedersen_commit_char(), purify::accountable::ConstructionLeafAccumulator::prepare(), purify::accountable::ConstructionLeafAccumulator::prepare(), purify::accountable::RecoveryRootSetupAccumulator::prepare(), purify::puresign_plusplus::CertificateNonceLeafAccumulator::prepare(), purify::bppp::candidate::prepare_circuit_zk_norm_arg_v4_impl(), purify::bppp::accumulation::PreparedNorm::prepare_experimental_circuit_zk_norm_arg, purify::bppp::accumulation::PreparedNorm::prepare_experimental_circuit_zk_norm_arg_with_public_commitments, purify::bppp::detail::prepare_experimental_circuit_zk_norm_arg_with_public_commitments(), purify::bppp::accumulation::PreparedNorm::prepare_norm, purify::bppp::prepare_norm_arg_v4(), purify::bppp::accumulation::AlgebraicPreparedNorm::prepare_v4_circuit_norm_for_algebraic_reduction, prove(), prove_assignment(), prove_assignment_data(), purify::bppp::prove_experimental_circuit_norm_arg_to_commitment(), purify::bppp::prove_experimental_circuit_zk_norm_arg_impl(), purify::bppp::prove_norm_arg_to_commitment_v4(), purify::bppp::prove_norm_arg_to_commitment_with_cache(), purify::accountable::RecoveryRootSetupProof::prove_recovery_root_setup, random_below(), purify::puresign_plusplus::PreparedNonceWithProof::raw_scalar(), purify::accountable::reconstruct_nonce(), purify::accountable::recover_aggregated_recovery_root(), purify::accountable::recover_distributed_escrowed_anchor(), purify::accountable::recover_escrowed_anchor(), purify::accountable::recover_registered_root(), purify::accountable::recover_same_slot_key(), purify::accountable::VerifiedScalarResponse::recover_verified_same_slot_key, require_secp_context(), purify::accountable::detail::resolve_construction_parent_public_inputs(), purify::puresign::PreparedNonce::scalar(), purify::puresign_plusplus::PreparedNonce::scalar(), purify::BulletproofAssignmentData::serialize(), purify::ExperimentalBulletproofProof::serialize(), purify::puresign::NonceProof::serialize(), purify::puresign::ProvenSignature::serialize(), purify::puresign_plusplus::NonceProof::serialize(), purify::puresign_plusplus::serialize_accepted_certificate_nonce_parent_witness(), purify::accountable::serialize_accepted_construction_parent_witness(), purify::puresign_plusplus::serialize_accepted_linear_certificate_nonce_parent_witness(), purify::BulletproofTranscript::serialize_assignment(), purify::puresign_plusplus::serialize_certificate_nonce_native_receipt(), purify::puresign_plusplus::serialize_certificate_parent_public_frame(), purify::puresign::PreparedNonce::sign_message(), purify::puresign::PreparedNonceWithProof::sign_message(), purify::puresign_plusplus::PreparedNonce::sign_message(), purify::puresign_plusplus::PreparedNonceWithProof::sign_message(), purify::puresign::PreparedNonce::sign_topic_message(), purify::puresign::PreparedNonceWithProof::sign_topic_message(), purify::puresign_plusplus::PreparedNonce::sign_topic_message(), purify::puresign_plusplus::PreparedNonceWithProof::sign_topic_message(), purify::accountable::signature_challenge(), purify::NativeBulletproofCircuitTemplate::sum_assignments(), try_divmod_same(), purify::SpanAtLeast< 16, const unsigned char >::try_from(), purify::FieldElement::try_from_bytes32(), purify::BigUInt< 4 >::try_from_hex(), try_narrow(), purify::NativeBulletproofCircuit::PackedWithSlack::unpack(), unpack_public(), unpack_public_points(), unpack_secret(), purify::detail::validate_message_proof_cache(), purify::detail::validate_proof_cache_circuit(), validate_public_key(), validate_secret_key(), purify::detail::validate_topic_proof_cache(), purify::accountable::ConstructionParentVerifier::verify(), purify::bppp::accumulation::PendingClaim::verify_algebraic_norm_reduction, purify::accountable::VerifiedCoalitionNonceSet::verify_coalition_nonce_set, purify::accountable::VerifiedDistributedRecoverySetup::verify_distributed_recovery_setup, verify_experimental_circuit(), verify_experimental_circuit(), purify::bppp::verify_experimental_circuit_norm_arg(), purify::puresign_plusplus::CertificateNonceParentAccumulator::verify_linear_receipt(), purify::puresign_plusplus::CertificateNonceParentAccumulator::verify_native_receipt(), purify::bppp::accumulation::PendingClaim::verify_norm_reduction, purify::accountable::VerifiedCoalitionNonceSet::verify_partial_response, purify::accountable::RecoveryBoundSigningRoster::verify_recovery_root_setup, purify::puresign_plusplus::CertificateNonceParentAccumulator::verify_response(), purify::accountable::VerifiedCoalitionNonceSet::verify_scalar_response, purify::puresign::api_impl::verify_signature(), purify::puresign_plusplus::api_impl::verify_signature(), purify::bppp::accumulation::PendingClaim::verify_step, purify::puresign::api_impl::verify_topic_nonce_proof(), purify::puresign_plusplus::api_impl::verify_topic_nonce_proof(), purify::puresign_plusplus::NonceHost::verify_topic_nonce_proof(), and write_file().

◆ unpack_public()

◆ unpack_public_points()

Result< std::pair< JacobianPoint, JacobianPoint > > purify::unpack_public_points ( const UInt512 & packed)

This rejects non-canonical encodings, coordinates outside the field, coordinates that do not lift to finite curve points, and points outside the respective prime-order subgroups.

Definition at line 370 of file curve.cpp.

References BackendRejectedInput, curve1(), curve2(), purify::EllipticCurve::lift_x(), order_n1(), order_n2(), PURIFY_ASSIGN_OR_RETURN, purify::FieldElement::try_from_uint256(), unexpected_error(), and unpack_public().

Referenced by validate_public_points().

◆ unpack_secret()

◆ validate_public_key()

◆ validate_public_points()

◆ validate_secret_key()

Status purify::validate_secret_key ( const UInt512 & z)

Definition at line 312 of file curve.cpp.

References is_valid_secret_key(), RangeViolation, and unexpected_error().

Referenced by purify::SecretKey::from_packed().

◆ verifier()

Result< std::string > purify::verifier ( const Bytes & message,
const UInt512 & pubkey )

◆ verifier_circuit()

◆ verifier_circuit_template()

◆ verify_experimental_circuit() [1/2]

◆ verify_experimental_circuit() [2/2]

◆ widen()

template<std::size_t OutWords, std::size_t InWords>
BigUInt< OutWords > purify::widen ( const BigUInt< InWords > & value)

◆ write_file()

Status purify::write_file ( const std::string & path,
const Bytes & bytes )
inline
Parameters
pathOutput file path.
bytesBytes to write.

Definition at line 107 of file purify_runtime.hpp.

References IoOpenFailed, IoWriteFailed, and unexpected_error().

Referenced by prove().

Variable Documentation

◆ unexpect

unexpect_t purify::unexpect {}
inlineconstexpr

Definition at line 26 of file expected.hpp.