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
 
SecretKeyoperator= (const SecretKey &)=delete
 
 SecretKey (SecretKey &&) noexcept=default
 
SecretKeyoperator= (SecretKey &&) noexcept=default
 
 ~SecretKey ()=default
 
Result< SecretKeyclone () const
 Creates a second owned copy of this secret key.
 
const UInt512packed () 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< SecretKeyfrom_packed (const UInt512 &packed)
 Constructs a validated secret key from packed Purify secret bytes.
 
static Result< SecretKeyfrom_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

Referenced by from_packed().

◆ SecretKey() [2/3]

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

◆ SecretKey() [3/3]

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

◆ ~SecretKey()

purify::SecretKey::~SecretKey ( )
default

Member Function Documentation

◆ clone()

Result< SecretKey > purify::SecretKey::clone ( ) const
inline
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_plusplus::KeyPair::from_secret(), and purify::puresign::KeyPair::from_secret().

◆ from_hex()

static Result< SecretKey > purify::SecretKey::from_hex ( std::string_view  hex)
inlinestatic
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()

static Result< SecretKey > purify::SecretKey::from_packed ( const UInt512 packed)
inlinestatic
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 packed(), PURIFY_RETURN_IF_ERROR, SecretKey(), and purify::validate_secret_key().

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator==()

bool purify::SecretKey::operator== ( const SecretKey other) const
inlinenoexcept
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().

◆ packed()

const UInt512 & purify::SecretKey::packed ( ) const
inlinenoexcept
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: