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

Move-only prepared nonce bound to either a message or a topic. More...

#include <legacy.hpp>

Public Types

enum class  Scope : std::uint8_t { Message , Topic }
 

Public Member Functions

 PreparedNonce (const PreparedNonce &)=delete
 
PreparedNonceoperator= (const PreparedNonce &)=delete
 
 PreparedNonce (PreparedNonce &&other) noexcept
 
PreparedNonceoperator= (PreparedNonce &&other) noexcept
 
 ~PreparedNonce ()
 
const Noncepublic_nonce () const noexcept
 Returns the public nonce corresponding to this prepared secret nonce scalar.
 
Scalar32 scalar () const
 Explicitly exports the secret nonce scalar.
 
Result< Signaturesign_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.
 
Result< Signaturesign_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.
 

Static Public Member Functions

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.
 

Detailed Description

The public nonce is safe to send over the wire. The secret scalar is intentionally not serializable and is wiped on destruction and after moves.

Definition at line 292 of file legacy.hpp.

Member Enumeration Documentation

◆ Scope

enum class purify::puresign::PreparedNonce::Scope : std::uint8_t
strong
Enumerator
Message 
Topic 

Definition at line 294 of file legacy.hpp.

Constructor & Destructor Documentation

◆ PreparedNonce() [1/2]

purify::puresign::PreparedNonce::PreparedNonce ( const PreparedNonce )
delete

◆ PreparedNonce() [2/2]

purify::puresign::PreparedNonce::PreparedNonce ( PreparedNonce &&  other)
noexcept

Definition at line 273 of file legacy.cpp.

◆ ~PreparedNonce()

purify::puresign::PreparedNonce::~PreparedNonce ( )

Definition at line 292 of file legacy.cpp.

Member Function Documentation

◆ from_parts()

PreparedNonce purify::puresign::PreparedNonce::from_parts ( Scope  scope,
const Scalar32 scalar,
const Nonce nonce,
const XOnly32 signer_pubkey,
const XOnly32 binding_digest 
)
static
Parameters
scopeWhether the nonce is message-bound or topic-bound.
scalarThe secret nonce scalar to store.
nonceThe public x-only nonce corresponding to scalar.
signer_pubkeyThe signer's BIP340 x-only public key.
binding_digestThe binding digest that this nonce must later match.
Returns
The constructed move-only prepared nonce.

Definition at line 268 of file legacy.cpp.

References binding_digest, nonce, scalar, scope, and signer_pubkey.

◆ operator=() [1/2]

PreparedNonce & purify::puresign::PreparedNonce::operator= ( const PreparedNonce )
delete

◆ operator=() [2/2]

PreparedNonce & purify::puresign::PreparedNonce::operator= ( PreparedNonce &&  other)
noexcept

Definition at line 279 of file legacy.cpp.

◆ public_nonce()

const Nonce & purify::puresign::PreparedNonce::public_nonce ( ) const
inlinenoexcept
Returns
The x-only public nonce that is safe to share with a verifier.

Definition at line 310 of file legacy.hpp.

Referenced by purify::puresign::PreparedNonceWithProof::public_nonce().

◆ scalar()

Scalar32 purify::puresign::PreparedNonce::scalar ( ) const
inline

This is intentionally a copy-returning accessor so callers have to opt in to handling the secret value.

Definition at line 320 of file legacy.hpp.

Referenced by purify::puresign::PreparedNonceWithProof::scalar().

◆ sign_message()

Result< Signature > purify::puresign::PreparedNonce::sign_message ( const Bip340Key signer,
std::span< const unsigned char >  message,
purify_secp_context secp_context 
) &&
Parameters
signerThe BIP340 signer derived from the same secret as this prepared nonce.
messageThe message that must match the nonce binding.
Returns
The resulting BIP340 signature.

Definition at line 300 of file legacy.cpp.

References binding_digest, purify_bip340_sign_with_fixed_nonce(), purify_bip340_verify(), PURIFY_RETURN_IF_ERROR, purify::require_secp_context(), and purify::unexpected_error().

◆ sign_topic_message()

Result< Signature > purify::puresign::PreparedNonce::sign_topic_message ( const Bip340Key signer,
std::span< const unsigned char >  message,
purify_secp_context secp_context 
) &&
Parameters
signerThe BIP340 signer derived from the same secret as this prepared nonce.
messageThe message to sign.
Returns
The resulting BIP340 signature.

Definition at line 330 of file legacy.cpp.

References purify_bip340_sign_with_fixed_nonce(), purify_bip340_verify(), PURIFY_RETURN_IF_ERROR, purify::require_secp_context(), and purify::unexpected_error().


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