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

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

#include <bppp.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 284 of file bppp.hpp.

Member Enumeration Documentation

◆ Scope

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

Definition at line 286 of file bppp.hpp.

Constructor & Destructor Documentation

◆ PreparedNonce() [1/2]

purify::puresign_plusplus::PreparedNonce::PreparedNonce ( const PreparedNonce )
delete

◆ PreparedNonce() [2/2]

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

Definition at line 311 of file bppp.cpp.

◆ ~PreparedNonce()

purify::puresign_plusplus::PreparedNonce::~PreparedNonce ( )

Definition at line 330 of file bppp.cpp.

Member Function Documentation

◆ from_parts()

PreparedNonce purify::puresign_plusplus::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 306 of file bppp.cpp.

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

Referenced by purify::puresign_plusplus::api_impl::prepare_message_nonce(), purify::puresign_plusplus::api_impl::prepare_message_nonce_with_proof(), purify::puresign_plusplus::api_impl::prepare_message_nonce_with_proof(), purify::puresign_plusplus::api_impl::prepare_topic_nonce(), purify::puresign_plusplus::api_impl::prepare_topic_nonce_with_proof(), and purify::puresign_plusplus::api_impl::prepare_topic_nonce_with_proof().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

Definition at line 317 of file bppp.cpp.

◆ public_nonce()

◆ scalar()

Scalar32 purify::puresign_plusplus::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 312 of file bppp.hpp.

Referenced by from_parts(), and purify::puresign_plusplus::PreparedNonceWithProof::scalar().

◆ sign_message()

Result< Signature > purify::puresign_plusplus::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 338 of file bppp.cpp.

References purify::BackendRejectedInput, binding_digest, purify::BindingMismatch, purify::InternalMismatch, 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_plusplus::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 368 of file bppp.cpp.

References purify::BackendRejectedInput, purify::BindingMismatch, purify::InternalMismatch, 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: