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

Public key bundle pairing a Purify packed public key with its derived BIP340 x-only key. More...

#include <legacy.hpp>

Public Member Functions

Bytes serialize () const
 Serializes this 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, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
 Verifies a message-bound nonce proof against this public key.
 
Result< bool > verify_message_nonce_proof (const MessageProofCache &cache, const NonceProof &nonce_proof, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
 Verifies a message-bound nonce proof using a reusable message proof cache.
 
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.
 
Result< bool > verify_topic_nonce_proof (const TopicProofCache &cache, const NonceProof &nonce_proof, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
 Verifies a topic-bound nonce proof using a reusable topic proof cache.
 
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_signature_with_proof (const MessageProofCache &cache, const ProvenSignature &signature, purify_secp_context *secp_context, ExperimentalBulletproofBackendCache *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, ExperimentalBulletproofBackendCache *circuit_cache=nullptr) const
 Verifies a topic-bound signature bundled with its 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, ExperimentalBulletproofBackendCache *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 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

This bundle is convenient for applications that need both identities. Third parties can verify signatures against bip340_pubkey, but this convenience type does not by itself prove that the bundled Purify and BIP340 keys came from the same secret.

Definition at line 42 of file legacy.hpp.

Member Function Documentation

◆ deserialize()

Result< PublicKey > purify::puresign::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 48 of file legacy.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::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 706 of file legacy.cpp.

◆ serialize()

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

Definition at line 39 of file legacy.cpp.

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

◆ verify_message_nonce_proof() [1/2]

Result< bool > purify::puresign::PublicKey::verify_message_nonce_proof ( const MessageProofCache cache,
const NonceProof nonce_proof,
purify_secp_context secp_context,
ExperimentalBulletproofBackendCache 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 backend verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and cached message template.

Definition at line 722 of file legacy.cpp.

◆ verify_message_nonce_proof() [2/2]

Result< bool > purify::puresign::PublicKey::verify_message_nonce_proof ( std::span< const unsigned char >  message,
const NonceProof nonce_proof,
purify_secp_context secp_context,
ExperimentalBulletproofBackendCache circuit_cache = nullptr 
) const
Parameters
messageThe message that defines the nonce binding.
nonce_proofThe public nonce proof to verify.
circuit_cacheOptional backend verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and message.

Definition at line 715 of file legacy.cpp.

◆ verify_message_signature_with_proof() [1/2]

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

Definition at line 748 of file legacy.cpp.

◆ verify_message_signature_with_proof() [2/2]

Result< bool > purify::puresign::PublicKey::verify_message_signature_with_proof ( std::span< const unsigned char >  message,
const ProvenSignature signature,
purify_secp_context secp_context,
ExperimentalBulletproofBackendCache circuit_cache = nullptr 
) const
Parameters
messageThe signed message.
signatureThe bundled signature and nonce proof to verify.
circuit_cacheOptional backend verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and the nonce proof verify.

Definition at line 741 of file legacy.cpp.

◆ verify_signature()

Result< bool > purify::puresign::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 710 of file legacy.cpp.

◆ verify_topic_nonce_proof() [1/2]

Result< bool > purify::puresign::PublicKey::verify_topic_nonce_proof ( const TopicProofCache cache,
const NonceProof nonce_proof,
purify_secp_context secp_context,
ExperimentalBulletproofBackendCache 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 backend verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and cached topic template.

Definition at line 735 of file legacy.cpp.

◆ verify_topic_nonce_proof() [2/2]

Result< bool > purify::puresign::PublicKey::verify_topic_nonce_proof ( std::span< const unsigned char >  topic,
const NonceProof nonce_proof,
purify_secp_context secp_context,
ExperimentalBulletproofBackendCache circuit_cache = nullptr 
) const
Parameters
topicThe topic that defines the nonce binding.
nonce_proofThe public nonce proof to verify.
circuit_cacheOptional backend verifier cache to reuse across calls.
Returns
true when the proof is valid for this public key and topic.

Definition at line 728 of file legacy.cpp.

◆ verify_topic_signature_with_proof() [1/2]

Result< bool > purify::puresign::PublicKey::verify_topic_signature_with_proof ( const TopicProofCache cache,
std::span< const unsigned char >  message,
const ProvenSignature signature,
purify_secp_context secp_context,
ExperimentalBulletproofBackendCache 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 backend verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and cached topic-bound nonce proof verify.

Definition at line 763 of file legacy.cpp.

◆ verify_topic_signature_with_proof() [2/2]

Result< bool > purify::puresign::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,
ExperimentalBulletproofBackendCache 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 backend verifier cache to reuse across calls.
Returns
true when both the BIP340 signature and topic-bound nonce proof verify.

Definition at line 755 of file legacy.cpp.

Field Documentation

◆ bip340_pubkey

XOnly32 purify::puresign::PublicKey::bip340_pubkey {}

Definition at line 46 of file legacy.hpp.

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

◆ kSerializedSize

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

Definition at line 43 of file legacy.hpp.

Referenced by deserialize(), and serialize().

◆ purify_pubkey


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