26using XOnly32 = std::array<unsigned char, 32>;
88 std::span<const unsigned char> message,
114 std::span<const unsigned char> topic,
140 std::span<const unsigned char> message,
167 std::span<const unsigned char> message,
168 std::span<const unsigned char> topic,
183 std::span<const unsigned char> message,
343 std::span<const unsigned char> message,
353 std::span<const unsigned char> message,
360 void clear() noexcept;
406 return prepared_.
scalar();
424 std::span<const unsigned char> message,
434 std::span<const unsigned char> message,
439 : prepared_(std::move(prepared)), proof_(std::move(
proof)) {}
441 PreparedNonce prepared_;
491 std::span<const unsigned char> message,
517 std::span<const unsigned char> topic,
554 std::span<const unsigned char> message,
565 std::span<const unsigned char> topic,
585 std::span<const unsigned char> message,
595 std::span<const unsigned char> message,
614 std::span<const unsigned char> message,
615 std::span<const unsigned char> topic,
625 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.
Purify result carrier that either holds a value or an error.
Caller-owned cache for reusable legacy Bulletproof backend resources keyed by gate count.
Public-key-agnostic native verifier-circuit template.
Move-only packed Purify secret stored in dedicated heap memory.
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.
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.
static Result< KeyPair > from_secret(const SecretKey &secret, purify_secp_context *secp_context)
Derives a signing key pair from one packed Purify secret.
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.
Result< PreparedNonce > prepare_message_nonce(std::span< const unsigned char > message, purify_secp_context *secp_context) const
Deterministically prepares a message-bound nonce.
Result< PreparedNonceWithProof > prepare_message_nonce_with_proof(std::span< const unsigned char > message, purify_secp_context *secp_context) const
Deterministically prepares a message-bound nonce together with its proof.
Result< PreparedNonce > prepare_topic_nonce(std::span< const unsigned char > topic, purify_secp_context *secp_context) const
Deterministically prepares a topic-bound nonce.
KeyPair & operator=(const KeyPair &)=delete
KeyPair & operator=(KeyPair &&other) noexcept=default
Result< PreparedNonceWithProof > prepare_topic_nonce_with_proof(std::span< const unsigned char > topic, purify_secp_context *secp_context) const
Deterministically prepares a topic-bound nonce together with its proof.
KeyPair(const KeyPair &)=delete
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.
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.
Result< ProvenSignature > sign_with_topic_proof(std::span< const unsigned char > message, std::span< const unsigned char > topic, purify_secp_context *secp_context) const
Signs a message with a topic-bound nonce proof.
const PublicKey & public_key() const noexcept
Returns the public key bundle associated with this signer.
Result< ProvenSignature > sign_message_with_proof(std::span< const unsigned char > message, purify_secp_context *secp_context) const
Signs a message and returns the signature bundled with its nonce 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.
Move-only prepared nonce bundled with its public statement proof.
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.
Scalar32 scalar() const
Explicitly exports the secret nonce scalar from the wrapped prepared nonce.
const Nonce & public_nonce() const noexcept
Returns the public nonce proved 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.
const NonceProof & proof() const noexcept
Returns the public nonce proof carried by this bundle.
static PreparedNonceWithProof from_parts(PreparedNonce prepared, NonceProof proof)
Bundles a prepared nonce with its matching public nonce proof.
~PreparedNonceWithProof()=default
PreparedNonceWithProof(const PreparedNonceWithProof &)=delete
PreparedNonceWithProof & operator=(PreparedNonceWithProof &&other) noexcept=default
PreparedNonceWithProof & operator=(const PreparedNonceWithProof &)=delete
PreparedNonceWithProof(PreparedNonceWithProof &&other) noexcept=default
Move-only prepared nonce bound to either a message or a topic.
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.
Scalar32 scalar() const
Explicitly exports the secret nonce scalar.
const Nonce & public_nonce() const noexcept
Returns the public nonce corresponding to this prepared secret nonce scalar.
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.
PreparedNonce & operator=(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.
PreparedNonce(const PreparedNonce &)=delete
std::array< unsigned char, 32 > Scalar32
std::array< unsigned char, 32 > XOnly32
std::array< unsigned char, 64 > Signature64
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 single-proof wrapper over the imported legacy Bulletproof circuit backend.
Cacheable message-bound nonce-proof template.
NativeBulletproofCircuitTemplate circuit_template
static Result< MessageProofCache > build(std::span< const unsigned char > message)
Builds a reusable verifier template for one exact message.
ExperimentalBulletproofBackendCache backend_cache
Public nonce together with its experimental Purify statement proof.
ExperimentalBulletproofProof proof
static Result< NonceProof > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Result< Bytes > serialize(purify_secp_context *secp_context) const
Public BIP340 nonce point in x-only form.
static Result< Nonce > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
static constexpr std::size_t kSerializedSize
Standard signature bundled with the public nonce proof it relied on.
static Result< ProvenSignature > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Result< Bytes > serialize(purify_secp_context *secp_context) const
Public key bundle pairing a Purify packed public key with its derived BIP340 x-only key.
static constexpr std::size_t kSerializedSize
Result< bool > verify_message_signature_with_proof(std::span< const unsigned char > message, const ProvenSignature &signature, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
Verifies a message signature bundled with its nonce proof.
Result< bool > verify_message_nonce_proof(std::span< const unsigned char > message, const NonceProof &nonce_proof, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
Verifies a message-bound 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 public-key bundle into its fixed-size wire format.
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_topic_signature_with_proof(std::span< const unsigned char > message, std::span< const unsigned char > topic, const ProvenSignature &signature, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
Verifies a topic-bound signature bundled with its nonce proof.
Result< bool > verify_topic_nonce_proof(std::span< const unsigned char > topic, const NonceProof &nonce_proof, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
Verifies a topic-bound nonce proof against this public key.
static Result< PublicKey > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Parses a serialized public-key bundle.
Standard 64-byte BIP340 signature.
static constexpr std::size_t kSerializedSize
static Result< Signature > deserialize(std::span< const unsigned char > serialized, purify_secp_context *secp_context)
Cacheable topic-bound nonce-proof template.
NativeBulletproofCircuitTemplate circuit_template
ExperimentalBulletproofBackendCache backend_cache
static Result< TopicProofCache > build(std::span< const unsigned char > topic)
Builds a reusable verifier template for one exact topic.