23using XOnly32 = std::array<unsigned char, 32>;
80 std::span<const unsigned char> message,
106 std::span<const unsigned char> topic,
132 std::span<const unsigned char> message,
159 std::span<const unsigned char> message,
160 std::span<const unsigned char> topic,
175 std::span<const unsigned char> message,
335 std::span<const unsigned char> message,
345 std::span<const unsigned char> message,
352 void clear() noexcept;
391 return prepared_.
scalar();
409 std::span<const unsigned char> message,
419 std::span<const unsigned char> message,
424 : prepared_(std::move(prepared)), proof_(std::move(
proof)) {}
426 PreparedNonce prepared_;
477 std::span<const unsigned char> message,
507 std::span<const unsigned char> topic,
547 std::span<const unsigned char> message,
558 std::span<const unsigned char> topic,
577 std::span<const unsigned char> message,
588 std::span<const unsigned char> message,
611 std::span<const unsigned char> message,
612 std::span<const unsigned char> topic,
624 std::span<const unsigned char> message,
631 : secret_(std::move(secret)), public_key_(std::move(
public_key)) {}
634 PublicKey public_key_{};
High-level Purify key generation, evaluation, witness generation, and circuit helpers.
C++ wrappers for the BPPP functionality used by Purify.
Purify result carrier that either holds a value or an error.
Public-key-agnostic native verifier-circuit template.
Move-only packed Purify secret stored in dedicated heap memory.
Common interface for reusable experimental BPPP backend state.
Caller-owned cache for reusable experimental circuit reduction and BPPP backend data.
Result< PreparedNonce > prepare_message_nonce(std::span< const unsigned char > message, purify_secp_context *secp_context) const
Deterministically prepares a message-bound nonce.
Result< PreparedNonce > prepare_topic_nonce(std::span< const unsigned char > topic, purify_secp_context *secp_context) const
Deterministically prepares a topic-bound nonce.
Result< ProvenSignature > sign_message_with_proof(std::span< const unsigned char > message, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Signs a message and returns the signature bundled with its BPPP nonce proof.
const PublicKey & public_key() const noexcept
Returns the public key bundle associated with this signer.
Result< Signature > sign_with_prepared_topic(std::span< const unsigned char > message, PreparedNonce &&prepared, purify_secp_context *secp_context) const
Signs a message using an already prepared topic-bound nonce.
KeyPair & operator=(KeyPair &&other) noexcept=default
KeyPair & operator=(const KeyPair &)=delete
static Result< KeyPair > from_secret(const SecretKey &secret, purify_secp_context *secp_context)
Derives a PureSign++ signing key pair from one packed Purify secret.
Result< PreparedNonceWithProof > prepare_message_nonce_with_proof(std::span< const unsigned char > message, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Deterministically prepares a message-bound nonce together with its BPPP proof.
Result< ProvenSignature > sign_with_prepared_topic_proof(std::span< const unsigned char > message, PreparedNonceWithProof &&prepared, purify_secp_context *secp_context) const
Signs a message using an already prepared topic-bound nonce proof bundle.
Result< Signature > sign_message_with_prepared(std::span< const unsigned char > message, PreparedNonce &&prepared, purify_secp_context *secp_context) const
Signs a message using an already prepared message-bound nonce.
Result< ProvenSignature > sign_with_topic_proof(std::span< const unsigned char > message, std::span< const unsigned char > topic, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Signs a message with a topic-bound nonce proof.
Result< Signature > sign_message(std::span< const unsigned char > message, purify_secp_context *secp_context) const
Signs a message with a deterministically derived message-bound nonce.
Result< PreparedNonceWithProof > prepare_topic_nonce_with_proof(std::span< const unsigned char > topic, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Deterministically prepares a topic-bound nonce together with its BPPP proof.
KeyPair(const KeyPair &)=delete
Result< Signature > sign_with_topic(std::span< const unsigned char > message, std::span< const unsigned char > topic, purify_secp_context *secp_context) const
Signs a message using a topic-bound deterministic nonce.
KeyPair(KeyPair &&other) noexcept=default
Result< ProvenSignature > sign_message_with_prepared_proof(std::span< const unsigned char > message, PreparedNonceWithProof &&prepared, purify_secp_context *secp_context) const
Signs a message using an already prepared message-bound nonce proof bundle.
PreparedNonceWithProof(const PreparedNonceWithProof &)=delete
const NonceProof & proof() const noexcept
Returns the public nonce proof carried by this bundle.
Result< ProvenSignature > sign_message(const SecretKey &secret, std::span< const unsigned char > message, purify_secp_context *secp_context) &&
Consumes this message-bound prepared proof bundle and signs the message.
static PreparedNonceWithProof from_parts(PreparedNonce prepared, NonceProof proof)
Bundles a prepared nonce with its matching BPPP-backed public nonce proof.
PreparedNonceWithProof & operator=(PreparedNonceWithProof &&other) noexcept=default
Scalar32 scalar() const
Explicitly exports the secret nonce scalar from the wrapped prepared nonce.
~PreparedNonceWithProof()=default
PreparedNonceWithProof(PreparedNonceWithProof &&other) noexcept=default
Result< ProvenSignature > sign_topic_message(const SecretKey &secret, std::span< const unsigned char > message, purify_secp_context *secp_context) &&
Consumes this topic-bound prepared proof bundle and signs the message.
const Nonce & public_nonce() const noexcept
Returns the public nonce proved by this bundle.
PreparedNonceWithProof & operator=(const PreparedNonceWithProof &)=delete
Move-only prepared nonce bound to either a message or a topic.
Result< Signature > sign_message(const Bip340Key &signer, std::span< const unsigned char > message, purify_secp_context *secp_context) &&
Consumes this message-bound nonce and signs the matching message.
const Nonce & public_nonce() const noexcept
Returns the public nonce corresponding to this prepared secret nonce scalar.
PreparedNonce & operator=(const PreparedNonce &)=delete
PreparedNonce(const PreparedNonce &)=delete
Result< Signature > sign_topic_message(const Bip340Key &signer, std::span< const unsigned char > message, purify_secp_context *secp_context) &&
Consumes this topic-bound nonce and signs a message under that topic binding.
Scalar32 scalar() const
Explicitly exports the secret nonce scalar.
static PreparedNonce from_parts(Scope scope, const Scalar32 &scalar, const Nonce &nonce, const XOnly32 &signer_pubkey, const XOnly32 &binding_digest)
Builds a prepared nonce from already-derived nonce components.
std::array< unsigned char, 33 > PointBytes
Compressed 33-byte curve-point encoding.
std::array< unsigned char, 64 > Signature64
std::array< unsigned char, 32 > Scalar32
std::array< unsigned char, 32 > XOnly32
std::vector< unsigned char > Bytes
Dynamically sized byte string used for messages, serialized witnesses, and proofs.
Canonical BIP340 keypair derived deterministically from a packed Purify secret.
Experimental masked circuit proof that hides the reduced witness before the final BPPP argument.
Cacheable message-bound nonce-proof template for the BPPP-backed PureSign++ proof(R) flow.
bppp::ExperimentalCircuitCache backend_cache
NativeBulletproofCircuitTemplate circuit_template
static Result< MessageProofCache > build(std::span< const unsigned char > message)
Builds a reusable verifier template for one exact message.
bppp::PointBytes commitment_point
static Result< NonceProof > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Result< Bytes > serialize(purify_secp_context *secp_context) const
bppp::ExperimentalCircuitZkNormArgProof proof
static constexpr unsigned char kSerializationVersion
Public BIP340 nonce point in x-only form.
static Result< Nonce > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Parses a serialized x-only nonce.
Bytes serialize() const
Serializes this x-only nonce into its fixed-size wire format.
static constexpr std::size_t kSerializedSize
Result< Bytes > serialize(purify_secp_context *secp_context) const
static constexpr unsigned char kSerializationVersion
static Result< ProvenSignature > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
static Result< PublicKey > from_secret(const SecretKey &secret, purify_secp_context *secp_context)
Derives both public identities from one packed Purify secret.
Result< bool > verify_message_nonce_proof(std::span< const unsigned char > message, const NonceProof &nonce_proof, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Verifies a message-bound BPPP nonce proof against this public key.
static Result< PublicKey > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Parses a serialized PureSign++ public-key bundle.
Result< bool > verify_topic_nonce_proof(std::span< const unsigned char > topic, const NonceProof &nonce_proof, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Verifies a topic-bound BPPP nonce proof against this public key.
Result< bool > verify_signature(std::span< const unsigned char > message, const Signature &signature, purify_secp_context *secp_context) const
Verifies a plain BIP340 signature against this bundle's x-only public key.
Bytes serialize() const
Serializes this PureSign++ public-key bundle into its fixed-size wire format.
Result< bool > verify_message_signature_with_proof(std::span< const unsigned char > message, const ProvenSignature &signature, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Verifies a message signature bundled with its BPPP nonce proof.
static constexpr std::size_t kSerializedSize
Result< bool > verify_topic_signature_with_proof(std::span< const unsigned char > message, std::span< const unsigned char > topic, const ProvenSignature &signature, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
Verifies a topic-bound signature bundled with its BPPP nonce proof.
Standard 64-byte BIP340 signature.
Bytes serialize() const
Serializes this signature into its fixed-size wire format.
static constexpr std::size_t kSerializedSize
Scalar32 s() const
Returns the 32-byte Schnorr s scalar encoded in the last 32 signature bytes.
Nonce nonce() const
Returns the x-only public nonce encoded in the first 32 signature bytes.
static Result< Signature > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Parses a serialized BIP340 signature.
Cacheable topic-bound nonce-proof template for the BPPP-backed PureSign++ proof(R) flow.
bppp::ExperimentalCircuitCache backend_cache
NativeBulletproofCircuitTemplate circuit_template
static Result< TopicProofCache > build(std::span< const unsigned char > topic)
Builds a reusable verifier template for one exact topic.