purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
purify::puresign_plusplus::PublicKey Struct Reference

#include <bppp.hpp>

Public Member Functions

Bytes serialize () const
 Serializes this PureSign++ public-key bundle into its fixed-size wire format.
 
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.
 
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.
 
Result< bool > verify_message_nonce_proof (const MessageProofCache &cache, const NonceProof &nonce_proof, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
 Verifies a message-bound BPPP nonce proof using a reusable message cache.
 
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_topic_nonce_proof (const TopicProofCache &cache, const NonceProof &nonce_proof, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
 Verifies a topic-bound BPPP nonce proof using a reusable topic cache.
 
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.
 
Result< bool > verify_message_signature_with_proof (const MessageProofCache &cache, const ProvenSignature &signature, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
 Verifies a message signature bundle using a reusable message proof cache.
 
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.
 
Result< bool > verify_topic_signature_with_proof (const TopicProofCache &cache, std::span< const unsigned char > message, const ProvenSignature &signature, purify_secp_context *secp_context, bppp::ExperimentalCircuitBackend *circuit_cache=nullptr) const
 Verifies a topic-bound signature bundle using a reusable topic proof cache.
 

Static Public Member Functions

static Result< PublicKeydeserialize (std::span< const unsigned char > serialized, purify_secp_context *secp_context)
 Parses a serialized PureSign++ public-key bundle.
 
static Result< PublicKeyfrom_secret (const SecretKey &secret, purify_secp_context *secp_context)
 Derives both public identities from one packed Purify secret.
 

Data Fields

UInt512 purify_pubkey
 
XOnly32 bip340_pubkey {}
 

Static Public Attributes

static constexpr std::size_t kSerializedSize = 96
 

Detailed Description

Definition at line 34 of file bppp.hpp.

Member Function Documentation

◆ deserialize()

Result< PublicKey > purify::puresign_plusplus::PublicKey::deserialize ( std::span< const unsigned char >  serialized,
purify_secp_context secp_context 
)
static
Parameters
serializedThe byte sequence previously produced by serialize().
Returns
The parsed public-key bundle on success, or an error if the payload is malformed.

Definition at line 49 of file bppp.cpp.

References purify::BackendRejectedInput, purify::BigUInt< 8 >::from_bytes_be(), purify::InvalidFixedSize, kSerializedSize, purify_bip340_validate_xonly_pubkey(), purify_pubkey, PURIFY_RETURN_IF_ERROR, purify::require_secp_context(), purify::unexpected_error(), and purify::validate_public_key().

◆ from_secret()

Result< PublicKey > purify::puresign_plusplus::PublicKey::from_secret ( const SecretKey secret,
purify_secp_context secp_context 
)
static
Parameters
secretThe owned secret used to derive the Purify and BIP340 public keys.
Returns
The derived public-key bundle.

Definition at line 733 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::derive_public_key().

Referenced by purify::puresign_plusplus::KeyPair::from_secret().

◆ serialize()

Bytes purify::puresign_plusplus::PublicKey::serialize ( ) const
Returns
The 96-byte serialization of (purify_pubkey, bip340_pubkey).

Definition at line 40 of file bppp.cpp.

References bip340_pubkey, kSerializedSize, purify_pubkey, and purify::BigUInt< Words >::to_bytes_be().

◆ verify_message_nonce_proof() [1/2]

Result< bool > purify::puresign_plusplus::PublicKey::verify_message_nonce_proof ( const MessageProofCache cache,
const NonceProof nonce_proof,
purify_secp_context secp_context,
bppp::ExperimentalCircuitBackend circuit_cache = nullptr 
) const
Parameters
cacheThe prebuilt cache for the exact message bound into the proof.
nonce_proofThe public nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and cached message template.

Definition at line 749 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_message_nonce_proof().

◆ verify_message_nonce_proof() [2/2]

Result< bool > purify::puresign_plusplus::PublicKey::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
Parameters
messageThe message that defines the nonce binding.
nonce_proofThe public nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and message.

Definition at line 742 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_message_nonce_proof().

◆ verify_message_signature_with_proof() [1/2]

Result< bool > purify::puresign_plusplus::PublicKey::verify_message_signature_with_proof ( const MessageProofCache cache,
const ProvenSignature signature,
purify_secp_context secp_context,
bppp::ExperimentalCircuitBackend circuit_cache = nullptr 
) const
Parameters
cacheThe prebuilt cache for the exact signed message.
signatureThe bundled signature and nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and cached nonce proof verify.

Definition at line 775 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_message_signature_with_proof().

◆ verify_message_signature_with_proof() [2/2]

Result< bool > purify::puresign_plusplus::PublicKey::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
Parameters
messageThe signed message.
signatureThe bundled signature and nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and the nonce proof verify.

Definition at line 768 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_message_signature_with_proof().

◆ verify_signature()

Result< bool > purify::puresign_plusplus::PublicKey::verify_signature ( std::span< const unsigned char >  message,
const Signature signature,
purify_secp_context secp_context 
) const
Parameters
messageThe message that was signed.
signatureThe signature to verify.
Returns
true when the signature is valid for (message, bip340_pubkey).

Definition at line 737 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_signature().

◆ verify_topic_nonce_proof() [1/2]

Result< bool > purify::puresign_plusplus::PublicKey::verify_topic_nonce_proof ( const TopicProofCache cache,
const NonceProof nonce_proof,
purify_secp_context secp_context,
bppp::ExperimentalCircuitBackend circuit_cache = nullptr 
) const
Parameters
cacheThe prebuilt cache for the exact topic bound into the proof.
nonce_proofThe public nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and cached topic template.

Definition at line 762 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_topic_nonce_proof().

◆ verify_topic_nonce_proof() [2/2]

Result< bool > purify::puresign_plusplus::PublicKey::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
Parameters
topicThe topic that defines the nonce binding.
nonce_proofThe public nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and topic.

Definition at line 755 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_topic_nonce_proof().

◆ verify_topic_signature_with_proof() [1/2]

Result< bool > purify::puresign_plusplus::PublicKey::verify_topic_signature_with_proof ( const TopicProofCache cache,
std::span< const unsigned char >  message,
const ProvenSignature signature,
purify_secp_context secp_context,
bppp::ExperimentalCircuitBackend circuit_cache = nullptr 
) const
Parameters
cacheThe prebuilt cache for the exact topic bound into the proof.
messageThe signed message.
signatureThe bundled signature and nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and cached topic-bound nonce proof verify.

Definition at line 790 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_topic_signature_with_proof().

◆ verify_topic_signature_with_proof() [2/2]

Result< bool > purify::puresign_plusplus::PublicKey::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
Parameters
messageThe signed message.
topicThe topic that defines the nonce binding.
signatureThe bundled signature and nonce proof to verify.
circuit_cacheOptional BPPP verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and topic-bound nonce proof verify.

Definition at line 782 of file bppp.cpp.

References purify::puresign_plusplus::api_impl::verify_topic_signature_with_proof().

Field Documentation

◆ bip340_pubkey

XOnly32 purify::puresign_plusplus::PublicKey::bip340_pubkey {}

Definition at line 38 of file bppp.hpp.

Referenced by serialize(), and purify::puresign_plusplus::api_impl::verify_signature().

◆ kSerializedSize

constexpr std::size_t purify::puresign_plusplus::PublicKey::kSerializedSize = 96
staticconstexpr

Definition at line 35 of file bppp.hpp.

Referenced by deserialize(), and serialize().

◆ purify_pubkey


The documentation for this struct was generated from the following files: