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

Move-only packed Purify secret stored in dedicated heap memory. More...

#include <secret.hpp>

Public Member Functions

 SecretKey ()=delete
 SecretKey (const SecretKey &)=delete
SecretKey & operator= (const SecretKey &)=delete
 SecretKey (SecretKey &&) noexcept=default
SecretKey & operator= (SecretKey &&) noexcept=default
 ~SecretKey ()=default
Result< SecretKey > clone () const
 Creates a second owned copy of this secret key.
const UInt512 & packed () const noexcept
 Exposes the packed secret for lower-level cryptographic operations.
bool operator== (const SecretKey &other) const noexcept
 Compares two owned secrets by their packed values.

Static Public Member Functions

static Result< SecretKey > from_packed (const UInt512 &packed)
 Constructs a validated secret key from packed Purify secret bytes.
static Result< SecretKey > from_hex (std::string_view hex)
 Parses and validates a packed Purify secret from hexadecimal text.

Detailed Description

The packed secret is validated on construction, zeroized on destruction, and never copied implicitly. Call clone() when an additional owned copy is intentionally required.

Definition at line 52 of file secret.hpp.

Constructor & Destructor Documentation

◆ SecretKey() [1/3]

purify::SecretKey::SecretKey ( )
delete

◆ SecretKey() [2/3]

purify::SecretKey::SecretKey ( const SecretKey & )
delete

References SecretKey().

◆ SecretKey() [3/3]

purify::SecretKey::SecretKey ( SecretKey && )
defaultnoexcept

References SecretKey().

◆ ~SecretKey()

purify::SecretKey::~SecretKey ( )
default

References SecretKey().

Member Function Documentation

◆ clone()

Result< SecretKey > purify::SecretKey::clone ( ) const
inlinenodiscard
Returns
Independent owned secret key with the same packed value.

Definition at line 85 of file secret.hpp.

References from_packed(), and packed().

Referenced by purify::derive_key(), purify::puresign::KeyPair::from_secret(), and purify::puresign_plusplus::KeyPair::from_secret().

◆ from_hex()

Result< SecretKey > purify::SecretKey::from_hex ( std::string_view hex)
inlinestaticnodiscard
Parameters
hexHex string containing exactly one packed secret.
Returns
Owned secret key on success, or a parsing/validation error.

Definition at line 76 of file secret.hpp.

References from_packed(), packed(), PURIFY_ASSIGN_OR_RETURN, and purify::BigUInt< 8 >::try_from_hex().

Referenced by purify::run_cli().

◆ from_packed()

Result< SecretKey > purify::SecretKey::from_packed ( const UInt512 & packed)
inlinestaticnodiscard
Parameters
packedPacked secret scalar pair.
Returns
Owned secret key on success, or ErrorCode::RangeViolation if packed is invalid.

Definition at line 66 of file secret.hpp.

References from_packed(), packed(), PURIFY_RETURN_IF_ERROR, SecretKey(), and purify::validate_secret_key().

Referenced by clone(), from_hex(), from_packed(), and purify::generate_key().

◆ operator=() [1/2]

SecretKey & purify::SecretKey::operator= ( const SecretKey & )
delete

References SecretKey().

◆ operator=() [2/2]

SecretKey & purify::SecretKey::operator= ( SecretKey && )
defaultnoexcept

References SecretKey().

◆ operator==()

bool purify::SecretKey::operator== ( const SecretKey & other) const
inlinenodiscardnoexcept
Parameters
otherSecret to compare against.
Returns
true when both secrets encode the same packed value.

Definition at line 102 of file secret.hpp.

References packed(), and SecretKey().

◆ packed()

const UInt512 & purify::SecretKey::packed ( ) const
inlinenodiscardnoexcept
Returns
Reference to the validated packed Purify secret.

Definition at line 93 of file secret.hpp.

Referenced by clone(), purify::derive_bip340_key(), purify::eval(), from_hex(), from_packed(), operator==(), and purify::prove_assignment_data().


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