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
PreparedNonce & operator= (const PreparedNonce &)=delete
 PreparedNonce (PreparedNonce &&other) noexcept
PreparedNonce & operator= (PreparedNonce &&other) noexcept
 ~PreparedNonce ()
const Nonce & public_nonce () const noexcept
 Returns the public nonce corresponding to this prepared secret nonce scalar.
bool available () const noexcept
 Returns whether the secret nonce remains available to consume.
Result< Scalar32 > scalar () const
 Explicitly exports the 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.
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.

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 333 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 335 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 417 of file bppp.cpp.

References PreparedNonce().

◆ ~PreparedNonce()

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

Definition at line 438 of file bppp.cpp.

Member Function Documentation

◆ available()

bool purify::puresign_plusplus::PreparedNonce::available ( ) const
inlinenodiscardnoexcept

Definition at line 356 of file bppp.hpp.

◆ 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 )
staticnodiscard
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 412 of file bppp.cpp.

References PreparedNonce(), and scalar().

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

References PreparedNonce().

◆ operator=() [2/2]

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

Definition at line 424 of file bppp.cpp.

References PreparedNonce().

◆ public_nonce()

const Nonce & purify::puresign_plusplus::PreparedNonce::public_nonce ( ) const
inlinenodiscardnoexcept

◆ scalar()

Result< Scalar32 > purify::puresign_plusplus::PreparedNonce::scalar ( ) const
inlinenodiscard

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

Returns
A scalar copy, or UninitializedState after the nonce is consumed.

Definition at line 367 of file bppp.hpp.

References purify::unexpected_error(), and purify::UninitializedState.

Referenced by from_parts().

◆ sign_message()

Result< Signature > purify::puresign_plusplus::PreparedNonce::sign_message ( const Bip340Key & signer,
std::span< const unsigned char > message,
purify_secp_context * secp_context ) &&
nodiscard

◆ 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 ) &&
nodiscard

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