purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
bppp_internal.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Judica, Inc.
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or https://opensource.org/license/mit/.
4
5#pragma once
6
7#include <optional>
8
9#include "purify/bppp.hpp"
10
11namespace purify::bppp::detail {
12
15{
16 std::optional<FieldElement> root = FieldElement::one().negate().sqrt();
17 if (!root.has_value()) {
19 "bppp:canonical_sqrt_minus_one");
20 }
21 if ((root->to_bytes_be().back() & 1U) != 0U) {
22 *root = root->negate();
23 }
24 return *root;
25}
26
41
44 const NativeBulletproofCircuit& circuit,
46 purify_secp_context* secp_context,
47 std::span<const unsigned char> statement_binding,
49
52 const NativeBulletproofCircuit& circuit,
54 std::span<const PointBytes> public_commitments,
55 purify_secp_context* secp_context,
56 std::span<const unsigned char> statement_binding,
58
59} // namespace purify::bppp::detail
C++ wrappers for the BPPP functionality used by Purify.
Field element modulo the backend scalar field used by this implementation.
Definition numeric.hpp:834
std::optional< FieldElement > sqrt() const
Computes a square root when one exists, otherwise returns std::nullopt.
Definition numeric.cpp:143
static FieldElement one()
Returns the multiplicative identity of the scalar field.
Definition numeric.cpp:36
FieldElement negate() const
Returns the additive inverse modulo the field prime.
Definition numeric.cpp:121
static FieldElement zero()
Returns the additive identity of the scalar field.
Definition numeric.cpp:32
Common interface for reusable experimental BPPP backend state.
Definition bppp.hpp:129
Internal access helpers for experimental BPPP backend implementations.
Definition bppp.hpp:25
Result< std::optional< PreparedExperimentalCircuitZkNormArg > > prepare_experimental_circuit_zk_norm_arg(const NativeBulletproofCircuit &circuit, const ExperimentalCircuitZkNormArgProof &proof, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding, ExperimentalCircuitBackend *cache)
Definition bppp.cpp:2676
Result< std::optional< PreparedExperimentalCircuitZkNormArg > > prepare_experimental_circuit_zk_norm_arg_with_public_commitments(const NativeBulletproofCircuit &circuit, const ExperimentalCircuitZkNormArgProof &proof, std::span< const PointBytes > public_commitments, purify_secp_context *secp_context, std::span< const unsigned char > statement_binding, ExperimentalCircuitBackend *cache)
Definition bppp.cpp:2621
Result< FieldElement > canonical_sqrt_minus_one()
constexpr Unexpected< Error > unexpected_error(ErrorCode code, const char *context=nullptr)
Constructs an unexpected Error value from a machine-readable code.
Definition error.hpp:293
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
Definition error.hpp:99
Native in-memory representation of a Bulletproof-style arithmetic circuit.
Masked circuit proof with a pre-challenge raw-coordinate commitment.
Definition bppp.hpp:268
Standalone BPPP norm-argument proof bundle with all verifier-side inputs.
Definition bppp.hpp:118