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

Namespaces

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

Data Structures

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

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 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 WitnessAssignments = std::vector< std::optional< FieldElement > >
 Partial witness assignment vector indexed by transcript witness id.
 
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 = std::unique_ptr< purify_bulletproof_backend_resources, BulletproofBackendResourceDeleter >
 

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< GeneratedKeyderive_key (const SecretKey &secret)
 Derives the packed public key corresponding to a packed secret.
 
Result< GeneratedKeyderive_key (SecretKey &&secret)
 Derives the packed public key corresponding to a packed secret.
 
Result< Bip340Keyderive_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< UInt512random_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< UInt512random_below (const UInt512 &range, FillRandom &&fill_random)
 Samples a uniformly random packed secret below a range using a no-fail byte-fill source.
 
Result< UInt512random_below (const UInt512 &range)
 Samples a uniformly random packed secret below a range using the built-in OS RNG.
 
Result< GeneratedKeygenerate_key ()
 Generates a random Purify keypair using the built-in OS RNG.
 
Result< GeneratedKeygenerate_key (KeySeed seed)
 Deterministically derives a Purify keypair from seed material.
 
Result< GeneratedKeygenerate_key (std::span< const unsigned char > seed)
 Deterministically derives a Purify keypair from seed material.
 
template<typename FillRandom >
requires (NoexceptByteFill<FillRandom> || NoexceptCheckedByteFill<FillRandom>)
Result< GeneratedKeygenerate_key (FillRandom &&fill_random)
 Generates a random Purify keypair using a caller-supplied byte-fill routine.
 
Result< FieldElementeval (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< NativeBulletproofCircuitverifier_circuit (const Bytes &message, const UInt512 &pubkey)
 Builds the native verifier circuit for a message and public key.
 
Result< BulletproofWitnessDataprove_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< Bytesprove_assignment (const Bytes &message, const SecretKey &secret)
 Serializes the witness assignment produced for a message and secret.
 
Result< ExperimentalBulletproofProofprove_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::optional< BulletproofScalarBytes > blind=std::nullopt, ExperimentalBulletproofBackendCache *backend_cache=nullptr)
 Proves a native circuit with the experimental imported Bulletproof circuit backend.
 
Result< ExperimentalBulletproofProofprove_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::optional< BulletproofScalarBytes > blind=std::nullopt, 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 one-commitment native circuit.
 
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< NativeBulletproofCircuitTemplateverifier_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.
 
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< CircuitMainResultcircuit_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 UInt256order_n1 ()
 Returns the subgroup order for the first curve.
 
const UInt256order_n2 ()
 Returns the subgroup order for the second curve.
 
const UInt256half_n1 ()
 Returns floor(order_n1 / 2).
 
const UInt256half_n2 ()
 Returns floor(order_n2 / 2).
 
const UInt512packed_secret_key_space_size ()
 Returns the size of the packed secret-key encoding space.
 
const UInt512packed_public_key_space_size ()
 Returns the size of the packed public-key encoding space.
 
const UInt320two_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 EllipticCurvecurve1 ()
 Returns the first Purify curve instance.
 
const EllipticCurvecurve2 ()
 Returns the second Purify curve instance.
 
Result< JacobianPointhash_to_curve (const Bytes &data, const EllipticCurve &curve)
 Hashes arbitrary data onto the supplied curve by rejection sampling x-coordinates.
 
const JacobianPointgenerator1 ()
 Returns the fixed generator for the first curve.
 
const JacobianPointgenerator2 ()
 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< std::pair< UInt256, UInt256 > > unpack_public (const UInt512 &packed)
 Splits a packed public key into its two x-coordinates.
 
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< Errorunexpected_error (ErrorCode code, const char *context=nullptr)
 Constructs an unexpected Error value from a machine-readable code.
 
constexpr Unexpected< Errorunexpected_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)
 
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 UInt256prime_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< ExperimentalBulletproofProofprove_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::optional< BulletproofScalarBytes > blind, ExperimentalBulletproofBackendCache *backend_cache)
 
Result< Bytesexperimental_circuit_binding_digest (const NativeBulletproofCircuit &circuit, std::span< const unsigned char > statement_binding)
 
Result< Bytesexperimental_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< Bytesbytes_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

◆ BulletproofGeneratorBytes

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

Definition at line 33 of file bulletproof.hpp.

◆ BulletproofPointBytes

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

Definition at line 32 of file bulletproof.hpp.

◆ BulletproofScalarBytes

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

Definition at line 31 of file bulletproof.hpp.

◆ Bytes

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

Definition at line 99 of file common.hpp.

◆ ExprPoint

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

Definition at line 492 of file bulletproof.hpp.

◆ KeySeed

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

Definition at line 30 of file api.hpp.

◆ Result

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

Definition at line 99 of file error.hpp.

◆ SecpContextPtr

Definition at line 50 of file common.hpp.

◆ Status

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

Definition at line 102 of file error.hpp.

◆ UInt256

using purify::UInt256 = typedef BigUInt<4>

Definition at line 798 of file numeric.hpp.

◆ UInt320

using purify::UInt320 = typedef BigUInt<5>

Definition at line 800 of file numeric.hpp.

◆ UInt512

using purify::UInt512 = typedef BigUInt<8>

Definition at line 802 of file numeric.hpp.

◆ WitnessAssignments

using purify::WitnessAssignments = typedef std::vector<std::optional<FieldElement> >

Definition at line 63 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().

◆ 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 best_effort_reserve_mul(), and checked_mul_size().

Referenced by best_effort_reserve_mul().

◆ bytes_from_ascii()

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

Definition at line 163 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 172 of file curve.cpp.

Referenced by hkdf().

◆ checked_add_size()

◆ checked_mul_size()

bool purify::checked_mul_size ( std::size_t  lhs,
std::size_t  rhs,
std::size_t &  out 
)
inlinenoexcept

◆ 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 2147 of file bulletproof.cpp.

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

Referenced by circuit_ec_multiply_x().

◆ 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 2156 of file bulletproof.cpp.

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

Referenced by circuit_ec_multiply_x().

◆ 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 2165 of file bulletproof.cpp.

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

Referenced by circuit_ec_multiply_x().

◆ circuit_combine()

◆ circuit_ec_add()

◆ circuit_ec_add_x()

◆ circuit_ec_multiply_x()

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

◆ circuit_main()

◆ circuit_optionally_negate_ec()

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

Definition at line 2181 of file bulletproof.cpp.

References purify::Transcript::mul().

Referenced by circuit_ec_multiply_x().

◆ combine()

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

Definition at line 345 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 142 of file api.cpp.

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

Referenced by derive_key(), purify::puresign_plusplus::api_impl::derive_public_key(), purify::puresign::api_impl::derive_public_key(), generate_key(), 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 147 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 769 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 177 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 282 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 288 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 2338 of file bulletproof.cpp.

◆ field_a()

FieldElement purify::field_a ( )

Definition at line 239 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 243 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 247 of file curve.cpp.

References purify_curve_field_d().

Referenced by curve2().

◆ field_di()

FieldElement purify::field_di ( )

Definition at line 251 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 103 of file api.cpp.

References purify_fill_secure_random().

Referenced by 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 213 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 201 of file api.hpp.

References generate_key(), PURIFY_ASSIGN_OR_RETURN, and purify::SpanAtLeast< MinSize, T >::try_from().

◆ generator1()

◆ generator2()

◆ half_n1()

const UInt256 & purify::half_n1 ( )

Definition at line 214 of file curve.cpp.

References purify_curve_half_n1().

Referenced by circuit_main().

◆ half_n2()

const UInt256 & purify::half_n2 ( )

Definition at line 219 of file curve.cpp.

References purify_curve_half_n2().

Referenced by circuit_main().

◆ 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.

◆ 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 182 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 176 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 303 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)

Definition at line 299 of file curve.cpp.

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

Referenced by validate_secret_key().

◆ key_space_size()

UInt512 purify::key_space_size ( )
inline

Definition at line 101 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 721 of file numeric.hpp.

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

◆ narrow_size_to_u64()

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

Definition at line 87 of file common.hpp.

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

Referenced by narrow_size_to_u64().

◆ 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 311 of file expr.cpp.

◆ operator*() [2/5]

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

Definition at line 327 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 323 of file expr.cpp.

◆ operator*() [5/5]

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

Definition at line 331 of file expr.cpp.

◆ operator+() [1/5]

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

Definition at line 167 of file curve.cpp.

◆ operator+() [2/5]

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

Definition at line 265 of file expr.cpp.

◆ operator+() [3/5]

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

Definition at line 287 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 291 of file expr.cpp.

◆ operator-() [1/5]

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

Definition at line 295 of file expr.cpp.

◆ operator-() [2/5]

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

Definition at line 299 of file expr.cpp.

◆ operator-() [3/5]

Expr purify::operator- ( const Expr value)

Definition at line 307 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 303 of file expr.cpp.

◆ operator<() [1/2]

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

Definition at line 369 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 373 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 335 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 ( )

Definition at line 204 of file curve.cpp.

References purify_curve_order_n1().

Referenced by curve1(), and generator1().

◆ order_n2()

const UInt256 & purify::order_n2 ( )

Definition at line 209 of file curve.cpp.

References purify_curve_order_n2().

Referenced by curve2(), and generator2().

◆ pack_public()

UInt512 purify::pack_public ( const UInt256 x1,
const UInt256 x2 
)

◆ packed_public_key_space_size()

const UInt512 & purify::packed_public_key_space_size ( )

Definition at line 229 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 224 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 199 of file curve.cpp.

References purify_curve_prime_p().

◆ 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 294 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::optional< BulletproofScalarBytes blind = std::nullopt,
ExperimentalBulletproofBackendCache backend_cache = nullptr 
)

This wrapper only supports circuits with exactly one committed scalar. Providing blind = std::nullopt yields the exact public point commitment assignment.commitments[0] * value_generator, which is the form needed for R = rG style statements.

Definition at line 1533 of file bulletproof.cpp.

References nonce.

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::optional< BulletproofScalarBytes blind = std::nullopt,
ExperimentalBulletproofBackendCache backend_cache = nullptr 
)

Definition at line 1553 of file bulletproof.cpp.

References nonce.

◆ 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::optional< BulletproofScalarBytes blind,
ExperimentalBulletproofBackendCache backend_cache 
)

Definition at line 1573 of file bulletproof.cpp.

References nonce.

◆ 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 108 of file api.cpp.

References fill_secure_random(), and random_below().

◆ random_below() [2/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 132 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().

◆ random_below() [3/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 158 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().

◆ require_secp_context()

◆ run_cli()

◆ size_fits_u32()

bool purify::size_fits_u32 ( std::size_t  value)
inlinenoexcept

Definition at line 79 of file common.hpp.

References size_fits_u32().

Referenced by purify::BulletproofAssignmentData::serialize(), and size_fits_u32().

◆ size_fits_u64()

bool purify::size_fits_u64 ( std::size_t  value)
inlinenoexcept

◆ 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.

◆ to_string() [1/2]

constexpr std::string_view purify::to_string ( ErrorCategory  category)
constexprnoexcept

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 234 of file curve.cpp.

References purify_curve_two_p().

◆ unexpected_error() [1/2]

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

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

Definition at line 302 of file error.hpp.

◆ unexpected_error() [2/2]

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

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(), array_from_hex(), purify::puresign_plusplus::TopicProofCache::build(), purify::puresign::api_impl::build_topic_proof_cache(), bytes_from_hex(), circuit_main(), purify::ExperimentalBulletproofBackendCache::clone_for_thread(), purify::bppp::ExperimentalCircuitCache::clone_line_for_thread(), purify::bppp::commit_norm_arg_with_cache(), purify::bppp::create_generators(), derive_bip340_key(), derive_key(), purify::ExperimentalBulletproofProof::deserialize(), purify::puresign_plusplus::PublicKey::deserialize(), purify::puresign_plusplus::Nonce::deserialize(), purify::puresign_plusplus::Signature::deserialize(), purify::puresign_plusplus::NonceProof::deserialize(), purify::puresign_plusplus::ProvenSignature::deserialize(), purify::puresign::PublicKey::deserialize(), purify::puresign::Nonce::deserialize(), purify::puresign::Signature::deserialize(), purify::puresign::NonceProof::deserialize(), purify::puresign::ProvenSignature::deserialize(), eval(), purify::NativeBulletproofCircuitTemplate::final_evaluate(), purify::NativeBulletproofCircuit::PackedWithSlack::from_circuit(), purify::BulletproofTranscript::from_transcript(), generate_key(), generate_key(), hash_to_curve(), purify::NativeBulletproofCircuitTemplate::instantiate(), purify::NativeBulletproofCircuitTemplate::instantiate_packed(), purify::NativeBulletproofCircuitTemplate::integrity_digest(), key_to_bits(), purify::EllipticCurve::mul_secret_affine(), narrow_size_to_u64(), purify::capi_detail::parse_public_key(), purify::capi_detail::parse_secret_key(), purify::NativeBulletproofCircuitTemplate::partial_evaluate(), purify::bppp::pedersen_commit_char(), 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_with_cache(), random_below(), require_secp_context(), purify::BulletproofAssignmentData::serialize(), purify::ExperimentalBulletproofProof::serialize(), purify::puresign_plusplus::NonceProof::serialize(), purify::puresign_plusplus::ProvenSignature::serialize(), purify::puresign::NonceProof::serialize(), purify::puresign::ProvenSignature::serialize(), purify::BulletproofTranscript::serialize_assignment(), purify::puresign_plusplus::PreparedNonce::sign_message(), purify::puresign::PreparedNonce::sign_message(), purify::puresign_plusplus::PreparedNonceWithProof::sign_message(), purify::puresign::PreparedNonceWithProof::sign_message(), purify::puresign_plusplus::PreparedNonce::sign_topic_message(), purify::puresign::PreparedNonce::sign_topic_message(), purify::puresign_plusplus::PreparedNonceWithProof::sign_topic_message(), purify::puresign::PreparedNonceWithProof::sign_topic_message(), try_divmod_same(), purify::SpanAtLeast< MinSize, T >::try_from(), purify::FieldElement::try_from_bytes32(), purify::BigUInt< Words >::try_from_hex(), try_narrow(), purify::NativeBulletproofCircuit::PackedWithSlack::unpack(), unpack_public(), 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(), verify_experimental_circuit(), verify_experimental_circuit(), purify::bppp::verify_experimental_circuit_norm_arg(), purify::bppp::verify_experimental_circuit_zk_norm_arg_impl(), purify::puresign_plusplus::api_impl::verify_signature(), purify::puresign::api_impl::verify_signature(), purify::puresign_plusplus::api_impl::verify_topic_nonce_proof(), purify::puresign::api_impl::verify_topic_nonce_proof(), and write_file().

◆ unpack_public()

◆ unpack_secret()

◆ validate_public_key()

◆ validate_secret_key()

Status purify::validate_secret_key ( const UInt512 z)

Definition at line 307 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 
)
Parameters
messageMessage bytes baked into the verifier.
pubkeyPacked public key.
Returns
Serialized verifier program, or ErrorCode::HashToCurveExhausted.

Definition at line 190 of file api.cpp.

References purify::BulletproofTranscript::add_pubkey_and_out(), circuit_main(), curve1(), curve2(), purify::BulletproofTranscript::from_transcript(), hash_to_curve(), PURIFY_ASSIGN_OR_RETURN, PURIFY_RETURN_IF_ERROR, and purify::BulletproofTranscript::to_string().

Referenced by run_cli().

◆ verifier_circuit()

Result< NativeBulletproofCircuit > purify::verifier_circuit ( const Bytes message,
const UInt512 pubkey 
)

◆ 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

constexpr unexpect_t purify::unexpect {}
inlineconstexpr

Definition at line 26 of file expected.hpp.