purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
api.cpp
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
9
10#include "purify/api.hpp"
11
12#include <algorithm>
13#include <cassert>
14
15#include "purify.h"
16#include "error_bridge.hpp"
17
18namespace purify {
19namespace {
20
21Status status_from_core(purify_error_code code, const char* context) {
22 if (code == PURIFY_ERROR_OK) {
23 return {};
24 }
26}
27
28void clear_core_generated_key(purify_generated_key& generated) noexcept {
29 detail::secure_clear_bytes(generated.secret_key, sizeof(generated.secret_key));
30 std::fill(std::begin(generated.public_key), std::end(generated.public_key), 0);
31}
32
33void clear_core_bip340_key(purify_bip340_key& key) noexcept {
34 detail::secure_clear_bytes(key.secret_key, sizeof(key.secret_key));
35 std::fill(std::begin(key.xonly_public_key), std::end(key.xonly_public_key), 0);
36}
37
38Result<GeneratedKey> generated_key_from_core(const purify_generated_key& generated) {
39 UInt512 packed_secret = UInt512::from_bytes_be(
40 generated.secret_key, sizeof(generated.secret_key));
41 Result<SecretKey> owned_secret = SecretKey::from_packed(packed_secret);
42 detail::secure_clear_bytes(&packed_secret, sizeof(packed_secret));
43 if (!owned_secret.has_value()) {
44 return unexpected_error(
45 owned_secret.error(), "generated_key_from_core:from_packed");
46 }
47 const UInt512 public_key = UInt512::from_bytes_be(generated.public_key, sizeof(generated.public_key));
48 return GeneratedKey{std::move(*owned_secret), public_key};
49}
50
51Bytes tagged_message(std::string_view prefix, const Bytes& message) {
52 Bytes out;
53 out.reserve(prefix.size() + message.size());
54 out.insert(out.end(), prefix.begin(), prefix.end());
55 out.insert(out.end(), message.begin(), message.end());
56 return out;
57}
58
59void add_expr_slack(NativeBulletproofCircuit::PackedSlackPlan& slack, const Expr& expr) {
60 for (const auto& term : expr.linear()) {
61 switch (term.first.kind) {
63 if (term.first.index < slack.wl.size()) {
64 ++slack.wl[term.first.index];
65 }
66 break;
68 if (term.first.index < slack.wr.size()) {
69 ++slack.wr[term.first.index];
70 }
71 break;
73 if (term.first.index < slack.wo.size()) {
74 ++slack.wo[term.first.index];
75 }
76 break;
78 if (term.first.index < slack.wv.size()) {
79 ++slack.wv[term.first.index];
80 }
81 break;
83 assert(false && "verifier_circuit_template should not pack raw witness symbols");
84 break;
85 }
86 }
87}
88
89NativeBulletproofCircuit::PackedSlackPlan build_template_slack(std::size_t n_gates, std::size_t n_commitments,
90 const Expr& p1x, const Expr& p2x, const Expr& out) {
92 slack.constraint_slack = 3;
93 slack.wl.assign(n_gates, 0);
94 slack.wr.assign(n_gates, 0);
95 slack.wo.assign(n_gates, 0);
96 slack.wv.assign(n_commitments, 0);
97 add_expr_slack(slack, p1x.split().second);
98 add_expr_slack(slack, p2x.split().second);
99 add_expr_slack(slack, out);
100 if (!slack.wv.empty()) {
101 ++slack.wv[0];
102 }
103 return slack;
104}
105
106} // namespace
107
108Status fill_secure_random(std::span<unsigned char> bytes) noexcept {
109 return status_from_core(purify_fill_secure_random(bytes.data(), bytes.size()),
110 "fill_secure_random:purify_fill_secure_random");
111}
112
114 return random_below(range, fill_secure_random);
115}
116
118 purify_generated_key generated{};
119 const purify_error_code code = purify_generate_key(&generated);
120 if (code != PURIFY_ERROR_OK) {
121 clear_core_generated_key(generated);
122 return unexpected_error(core_api_detail::from_core_error_code(code), "generate_key:purify_generate_key");
123 }
124 Result<GeneratedKey> out = generated_key_from_core(generated);
125 clear_core_generated_key(generated);
126 if (!out.has_value()) {
127 return unexpected_error(out.error(), "generate_key:generated_key_from_core");
128 }
129 return out;
130}
131
133 purify_generated_key generated{};
134 const purify_error_code code = purify_generate_key_from_seed(&generated, seed.data(), seed.size());
135 if (code != PURIFY_ERROR_OK) {
136 clear_core_generated_key(generated);
137 return unexpected_error(core_api_detail::from_core_error_code(code), "generate_key:purify_generate_key_from_seed");
138 }
139 Result<GeneratedKey> out = generated_key_from_core(generated);
140 clear_core_generated_key(generated);
141 if (!out.has_value()) {
142 return unexpected_error(out.error(), "generate_key:generated_key_from_core");
143 }
144 return out;
145}
146
148 PURIFY_ASSIGN_OR_RETURN(auto owned_secret, secret.clone(), "derive_key:clone");
149 return derive_key(std::move(owned_secret));
150}
151
153 std::array<unsigned char, PURIFY_SECRET_KEY_BYTES> secret_bytes = secret.packed().to_bytes_be();
154 std::array<unsigned char, PURIFY_PUBLIC_KEY_BYTES> public_key_bytes{};
155 const purify_error_code code = purify_derive_public_key(public_key_bytes.data(), secret_bytes.data());
156 detail::secure_clear_bytes(secret_bytes.data(), secret_bytes.size());
157 if (code != PURIFY_ERROR_OK) {
158 std::fill(public_key_bytes.begin(), public_key_bytes.end(), 0);
159 return unexpected_error(core_api_detail::from_core_error_code(code), "derive_key:purify_derive_public_key");
160 }
161 const UInt512 public_key = UInt512::from_bytes_be(public_key_bytes.data(), public_key_bytes.size());
162 std::fill(public_key_bytes.begin(), public_key_bytes.end(), 0);
163 return GeneratedKey{std::move(secret), public_key};
164}
165
167 std::array<unsigned char, PURIFY_SECRET_KEY_BYTES> secret_bytes = secret.packed().to_bytes_be();
168 purify_bip340_key key{};
169 const purify_error_code code = purify_derive_bip340_key(&key, secret_bytes.data(), secp_context);
170 detail::secure_clear_bytes(secret_bytes.data(), secret_bytes.size());
171 if (code != PURIFY_ERROR_OK) {
172 clear_core_bip340_key(key);
173 return unexpected_error(core_api_detail::from_core_error_code(code), "derive_bip340_key:purify_derive_bip340_key");
174 }
175 Bip340Key out{};
176 std::copy(std::begin(key.secret_key), std::end(key.secret_key), out.seckey.begin());
177 std::copy(std::begin(key.xonly_public_key), std::end(key.xonly_public_key), out.xonly_pubkey.begin());
178 clear_core_bip340_key(key);
179 return out;
180}
181
182Result<FieldElement> eval(const SecretKey& secret, const Bytes& message) {
183 std::array<unsigned char, PURIFY_SECRET_KEY_BYTES> secret_bytes = secret.packed().to_bytes_be();
184 std::array<unsigned char, PURIFY_FIELD_ELEMENT_BYTES> output_bytes{};
185 const purify_error_code code =
186 purify_eval(output_bytes.data(), secret_bytes.data(), message.data(), message.size());
187 detail::secure_clear_bytes(secret_bytes.data(), secret_bytes.size());
188 if (code != PURIFY_ERROR_OK) {
189 detail::secure_clear_bytes(output_bytes.data(), output_bytes.size());
190 return unexpected_error(core_api_detail::from_core_error_code(code), "eval:purify_eval");
191 }
192 auto output = FieldElement::try_from_bytes32(output_bytes);
193 detail::secure_clear_bytes(output_bytes.data(), output_bytes.size());
194 return output;
195}
196
197Result<std::string> verifier(const Bytes& message, const UInt512& pubkey) {
198 PURIFY_ASSIGN_OR_RETURN(const auto& m1, hash_to_curve(tagged_message("Eval/1/", message), curve1()),
199 "verifier:hash_to_curve_m1");
200 PURIFY_ASSIGN_OR_RETURN(const auto& m2, hash_to_curve(tagged_message("Eval/2/", message), curve2()),
201 "verifier:hash_to_curve_m2");
202 Transcript transcript;
203 PURIFY_ASSIGN_OR_RETURN(const auto& result, circuit_main(transcript, m1, m2), "verifier:circuit_main");
205 PURIFY_RETURN_IF_ERROR(bp.from_transcript(transcript, result.n_bits), "verifier:from_transcript");
206 PURIFY_RETURN_IF_ERROR(bp.add_pubkey_and_out(pubkey, result.p1x, result.p2x, result.out),
207 "verifier:add_pubkey_and_out");
208 return bp.to_string();
209}
210
212 PURIFY_ASSIGN_OR_RETURN(const auto& template_circuit, verifier_circuit_template(message),
213 "verifier_circuit:verifier_circuit_template");
214 return template_circuit.instantiate(pubkey);
215}
216
218 PURIFY_ASSIGN_OR_RETURN(const auto& m1, hash_to_curve(tagged_message("Eval/1/", message), curve1()),
219 "verifier_circuit_template:hash_to_curve_m1");
220 PURIFY_ASSIGN_OR_RETURN(const auto& m2, hash_to_curve(tagged_message("Eval/2/", message), curve2()),
221 "verifier_circuit_template:hash_to_curve_m2");
222 Transcript transcript;
223 PURIFY_ASSIGN_OR_RETURN(const auto& result, circuit_main(transcript, m1, m2),
224 "verifier_circuit_template:circuit_main");
226 PURIFY_RETURN_IF_ERROR(bp.from_transcript(transcript, result.n_bits), "verifier_circuit_template:from_transcript");
227 Expr p1x = result.p1x;
228 Expr p2x = result.p2x;
229 Expr out = result.out;
233
234 NativeBulletproofCircuit base_circuit = bp.native_circuit();
236 auto packed,
237 base_circuit.pack_with_slack(build_template_slack(base_circuit.n_gates, base_circuit.n_commitments, p1x, p2x, out)),
238 "verifier_circuit_template:pack_with_slack");
239 return NativeBulletproofCircuitTemplate::from_parts(std::move(packed), std::move(p1x), std::move(p2x),
240 std::move(out));
241}
242
244 PURIFY_ASSIGN_OR_RETURN(const auto& unpacked, unpack_secret(secret.packed()), "prove_assignment_data:unpack_secret");
245 PURIFY_ASSIGN_OR_RETURN(const auto& m1, hash_to_curve(tagged_message("Eval/1/", message), curve1()),
246 "prove_assignment_data:hash_to_curve_m1");
247 PURIFY_ASSIGN_OR_RETURN(const auto& m2, hash_to_curve(tagged_message("Eval/2/", message), curve2()),
248 "prove_assignment_data:hash_to_curve_m2");
249 PURIFY_ASSIGN_OR_RETURN(const auto& p1, curve1().mul_secret_affine(generator1(), unpacked.first),
250 "prove_assignment_data:mul_secret_affine_p1");
251 PURIFY_ASSIGN_OR_RETURN(const auto& p2, curve2().mul_secret_affine(generator2(), unpacked.second),
252 "prove_assignment_data:mul_secret_affine_p2");
253 PURIFY_ASSIGN_OR_RETURN(const auto& q1, curve1().mul_secret_affine(m1, unpacked.first),
254 "prove_assignment_data:mul_secret_affine_q1");
255 PURIFY_ASSIGN_OR_RETURN(const auto& q2, curve2().mul_secret_affine(m2, unpacked.second),
256 "prove_assignment_data:mul_secret_affine_q2");
257 FieldElement native_out = combine(q1.x, q2.x);
258
259 Transcript transcript;
260 PURIFY_ASSIGN_OR_RETURN(const auto& result, circuit_main(transcript, m1, m2, unpacked.first, unpacked.second),
261 "prove_assignment_data:circuit_main");
262 if (transcript.evaluate(result.p1x) != std::optional<FieldElement>(p1.x)) {
263 return unexpected_error(ErrorCode::InternalMismatch, "prove_assignment_data:p1x_mismatch");
264 }
265 if (transcript.evaluate(result.p2x) != std::optional<FieldElement>(p2.x)) {
266 return unexpected_error(ErrorCode::InternalMismatch, "prove_assignment_data:p2x_mismatch");
267 }
268 if (transcript.evaluate(result.out) != std::optional<FieldElement>(native_out)) {
269 return unexpected_error(ErrorCode::InternalMismatch, "prove_assignment_data:output_mismatch");
270 }
271
272 UInt512 pubkey = pack_public(p1.x.to_uint256(), p2.x.to_uint256());
274 PURIFY_RETURN_IF_ERROR(bp.from_transcript(transcript, result.n_bits), "prove_assignment_data:from_transcript");
275 PURIFY_RETURN_IF_ERROR(bp.add_pubkey_and_out(pubkey, result.p1x, result.p2x, result.out),
276 "prove_assignment_data:add_pubkey_and_out");
277 if (!bp.evaluate(transcript.varmap(), native_out)) {
278 return unexpected_error(ErrorCode::TranscriptCheckFailed, "prove_assignment_data:transcript_check");
279 }
280
281 Result<BulletproofAssignmentData> assignment = bp.assignment_data(transcript.varmap(), native_out);
282 assert(assignment.has_value() && "prove_assignment_data() should materialize a complete assignment");
283 if (!assignment.has_value()) {
284 return unexpected_error(ErrorCode::InternalMismatch, "prove_assignment_data:assignment_data");
285 }
286 return BulletproofWitnessData{pubkey, native_out, std::move(*assignment)};
287}
288
290 PURIFY_ASSIGN_OR_RETURN(const auto& circuit, verifier_circuit(message, witness.public_key),
291 "evaluate_verifier_circuit:verifier_circuit");
292 return circuit.evaluate(witness.assignment);
293}
294
296 PURIFY_ASSIGN_OR_RETURN(const auto& witness, prove_assignment_data(message, secret),
297 "evaluate_verifier_circuit:prove_assignment_data");
298 return evaluate_verifier_circuit(message, witness);
299}
300
301Result<Bytes> prove_assignment(const Bytes& message, const SecretKey& secret) {
302 PURIFY_ASSIGN_OR_RETURN(const auto& witness, prove_assignment_data(message, secret), "prove_assignment:prove_assignment_data");
303 Result<Bytes> serialized = witness.assignment.serialize();
304 assert(serialized.has_value() && "prove_assignment() should serialize a well-formed assignment");
305 if (!serialized.has_value()) {
306 return unexpected_error(ErrorCode::InternalMismatch, "prove_assignment:serialize_assignment");
307 }
308 return serialized;
309}
310
311} // namespace purify
High-level Purify key generation, evaluation, witness generation, and circuit helpers.
Lowering helper that converts a symbolic transcript into native Bulletproof witness and circuit forms...
Status from_transcript(const Transcript &transcript, std::size_t n_bits, std::size_t minimum_gate_count=1)
Imports a symbolic transcript with a fixed power-of-two gate floor.
bool evaluate(const WitnessAssignments &vars, const FieldElement &commitment) const
Evaluates the lowered symbolic constraints with a concrete commitment value.
std::string to_string() const
Renders the lowered circuit in the legacy textual verifier format.
void replace_expr_v_with_bp_var(Expr &expr)
Rewrites transcript variable names to their eventual Bulletproof wire aliases.
Status add_pubkey_and_out(const UInt512 &pubkey, Expr p1x, Expr p2x, Expr out)
Binds packed public-key coordinates and the output commitment into explicit constraints.
NativeBulletproofCircuit native_circuit() const
Builds the native sparse circuit object from the lowered assignments and constraints.
Result< BulletproofAssignmentData > assignment_data(const WitnessAssignments &vars) const
Materializes the witness columns expected by the native circuit representation.
bool has_value() const noexcept
Definition expected.hpp:170
Symbolic affine expression over indexed variables and field coefficients.
Definition expr.hpp:73
Field element modulo the backend scalar field used by this implementation.
Definition numeric.hpp:834
static Result< FieldElement > try_from_bytes32(const std::array< unsigned char, 32 > &bytes)
Decodes a canonical 32-byte big-endian field element.
Definition numeric.cpp:53
static NativeBulletproofCircuitTemplate from_parts(NativeBulletproofCircuit::PackedWithSlack base_packed, Expr p1x, Expr p2x, Expr out)
Builds a template from a lowered base circuit plus late-bound public expressions.
Move-only packed Purify secret stored in dedicated heap memory.
Definition secret.hpp:95
const UInt512 & packed() const noexcept
Exposes the packed secret for lower-level cryptographic operations.
Definition secret.hpp:136
static Result< SecretKey > from_packed(const UInt512 &packed)
Constructs a validated secret key from packed Purify secret bytes.
Definition secret.hpp:109
Result< SecretKey > clone() const
Creates a second owned copy of this secret key.
Definition secret.hpp:128
constexpr std::size_t size() const noexcept
Definition common.hpp:153
constexpr const T * data() const noexcept
Definition common.hpp:149
Mutable transcript used to record symbolic multiplication, division, and boolean constraints.
Definition expr.hpp:215
std::optional< FieldElement > evaluate(const Expr &expr) const
Evaluates an expression against the transcript's current witness vector.
Definition expr.cpp:479
const WitnessAssignments & varmap() const
Returns the underlying witness assignment vector.
Definition expr.hpp:243
#define PURIFY_RETURN_IF_ERROR(expr, context)
Evaluates an expected-like expression and returns the wrapped error on failure.
Definition error.hpp:329
#define PURIFY_ASSIGN_OR_RETURN(lhs, expr, context)
Evaluates an expected-like expression, binds the value to lhs, and propagates errors.
Definition error.hpp:338
Bytes tagged_message(std::string_view prefix, const Bytes &message)
Definition c_api.cpp:105
constexpr ErrorCode from_core_error_code(purify_error_code code) noexcept
void secure_clear_bytes(void *data, std::size_t size) noexcept
Definition secret.hpp:22
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
Result< std::string > verifier(const Bytes &message, const UInt512 &pubkey)
Builds the legacy serialized verifier description for a message and public key.
Definition api.cpp:197
BigUInt< 8 > UInt512
512-bit unsigned integer used for private and packed public keys.
Definition numeric.hpp:821
Result< NativeBulletproofCircuitTemplate > verifier_circuit_template(const Bytes &message)
Builds a reusable public-key-agnostic verifier-circuit template for a message.
Definition api.cpp:217
Result< BulletproofWitnessData > prove_assignment_data(const Bytes &message, const SecretKey &secret)
Computes the native Purify witness for a message and secret.
Definition api.cpp:243
Result< GeneratedKey > generate_key()
Generates a random Purify keypair using the built-in OS RNG.
Definition api.cpp:117
Result< NativeBulletproofCircuit > verifier_circuit(const Bytes &message, const UInt512 &pubkey)
Builds the native verifier circuit for a message and public key.
Definition api.cpp:211
Result< Bip340Key > derive_bip340_key(const SecretKey &secret, purify_secp_context *secp_context)
Derives a canonical BIP340 signing keypair from an owned Purify secret.
Definition api.cpp:166
Result< Bytes > prove_assignment(const Bytes &message, const SecretKey &secret)
Serializes the witness assignment produced for a message and secret.
Definition api.cpp:301
Result< GeneratedKey > derive_key(const SecretKey &secret)
Derives the packed public key corresponding to a packed secret.
Definition api.cpp:147
const EllipticCurve & curve1()
Returns the first Purify curve instance.
Definition curve.cpp:261
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.
Expected< T, Error > Result
Expected-returning convenience alias for Purify value-producing APIs.
Definition error.hpp:99
const JacobianPoint & generator1()
Returns the fixed generator for the first curve.
Definition curve.cpp:282
UInt512 pack_public(const UInt256 &x1, const UInt256 &x2)
Packs two x-coordinates into the reference 512-bit public-key encoding.
Definition curve.cpp:399
Result< FieldElement > eval(const SecretKey &secret, const Bytes &message)
Evaluates the Purify PRF for an owned secret key and message.
Definition api.cpp:182
Result< bool > evaluate_verifier_circuit(const Bytes &message, const BulletproofWitnessData &witness)
Evaluates the generated verifier circuit against an explicit witness.
Definition api.cpp:289
Result< std::pair< UInt256, UInt256 > > unpack_secret(const UInt512 &z)
Splits a packed private key into its two per-curve secret scalars.
Definition curve.cpp:326
Expected< void, Error > Status
Expected-returning convenience alias for Purify status-only APIs.
Definition error.hpp:102
Result< JacobianPoint > hash_to_curve(const Bytes &data, const EllipticCurve &curve)
Hashes arbitrary data onto the supplied curve by rejection sampling x-coordinates.
Definition curve.cpp:273
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.
Definition api.hpp:162
std::vector< unsigned char > Bytes
Dynamically sized byte string used for messages, serialized witnesses, and proofs.
Definition common.hpp:99
const EllipticCurve & curve2()
Returns the second Purify curve instance.
Definition curve.cpp:266
const JacobianPoint & generator2()
Returns the fixed generator for the second curve.
Definition curve.cpp:293
FieldElement combine(const FieldElement &x1, const FieldElement &x2)
Applies the Purify curve-combination map to two x-coordinates.
Definition curve.cpp:405
Status fill_secure_random(std::span< unsigned char > bytes) noexcept
Fills a buffer with operating-system randomness.
Definition api.cpp:108
SpanAtLeast< 16, const unsigned char > KeySeed
Minimum-length checked wrapper for deterministic key-generation seed material.
Definition api.hpp:30
Public C core for Purify key validation, key derivation, key generation, and evaluation.
struct purify_generated_key purify_generated_key
Seed/public-key bundle returned by the C core key-generation entry points.
purify_error_code purify_generate_key(purify_generated_key *out)
Generates one random Purify keypair.
Definition c_api.cpp:171
purify_error_code purify_fill_secure_random(unsigned char *bytes, size_t bytes_len)
Fills a caller-owned buffer with secure operating-system randomness.
Definition core.c:266
purify_error_code
Machine-readable status code returned by the Purify C core.
Definition purify.h:28
@ PURIFY_ERROR_OK
Definition purify.h:29
purify_error_code purify_generate_key_from_seed(purify_generated_key *out, const unsigned char *seed, size_t seed_len)
Deterministically derives one Purify keypair from seed material.
Definition c_api.cpp:200
purify_error_code purify_eval(unsigned char out_field_element[PURIFY_FIELD_ELEMENT_BYTES], const unsigned char secret_key[PURIFY_SECRET_KEY_BYTES], const unsigned char *message, size_t message_len)
Evaluates the Purify PRF for one packed secret and message.
Definition c_api.cpp:309
purify_error_code purify_derive_public_key(unsigned char out_public_key[PURIFY_PUBLIC_KEY_BYTES], const unsigned char secret_key[PURIFY_SECRET_KEY_BYTES])
Derives the packed public key corresponding to one packed Purify secret.
Definition c_api.cpp:237
struct purify_bip340_key purify_bip340_key
Canonical BIP340 keypair derived from one packed Purify secret.
purify_error_code purify_derive_bip340_key(purify_bip340_key *out, const unsigned char secret_key[PURIFY_SECRET_KEY_BYTES], purify_secp_context *secp_context)
Derives one canonical BIP340 keypair from one packed Purify secret.
Definition c_api.cpp:262
static BigUInt from_bytes_be(const unsigned char *data, std::size_t size)
Definition numeric.hpp:238
std::array< unsigned char, Words *8 > to_bytes_be() const
Serializes the value to a fixed-width big-endian byte array.
Definition numeric.hpp:640
Canonical BIP340 keypair derived deterministically from a packed Purify secret.
Definition api.hpp:38
std::array< unsigned char, 32 > seckey
Definition api.hpp:62
std::array< unsigned char, 32 > xonly_pubkey
Definition api.hpp:63
Complete witness bundle for evaluating and proving a Purify instance.
Definition api.hpp:73
BulletproofAssignmentData assignment
Definition api.hpp:106
Derived Purify keypair bundle with an owned packed secret and its matching public key.
Definition api.hpp:24
Native in-memory representation of a Bulletproof-style arithmetic circuit.
Result< PackedWithSlack > pack_with_slack() const
Packs the circuit into one aligned slab with no additional row or constraint slack.
Canonical BIP340 keypair derived from one packed Purify secret.
Definition purify.h:68
unsigned char secret_key[PURIFY_BIP340_SECRET_KEY_BYTES]
Definition purify.h:69
unsigned char xonly_public_key[PURIFY_BIP340_XONLY_PUBKEY_BYTES]
Definition purify.h:70
Seed/public-key bundle returned by the C core key-generation entry points.
Definition purify.h:62
unsigned char secret_key[PURIFY_SECRET_KEY_BYTES]
Definition purify.h:63
unsigned char public_key[PURIFY_PUBLIC_KEY_BYTES]
Definition purify.h:64