StormByte C++ Library: Crypto module 1.0.0
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
Public Member Functions | List of all members
StormByte::Crypto::Secret Class Referencefinal

A class for managing shared secret operations. More...

#include <secret.hxx>

Public Member Functions

 Secret (const Algorithm::SecretShare &algorithm, const KeyPair &key_pair) noexcept
 Constructs a Secret instance with an algorithm and a key pair.
 
 Secret (const Algorithm::SecretShare &algorithm, KeyPair &&key_pair) noexcept
 Constructs a Secret instance with an algorithm and a key pair (move version).
 
 Secret (const Secret &secret)=default
 Copy constructor for the Secret class.
 
 Secret (Secret &&secret) noexcept=default
 Move constructor for the Secret class.
 
 ~Secret () noexcept=default
 Destructor for the Secret class.
 
Secretoperator= (const Secret &secret)=default
 Copy assignment operator for the Secret class.
 
Secretoperator= (Secret &&secret) noexcept=default
 Move assignment operator for the Secret class.
 
void PeerPublicKey (const std::string &peer_public_key) noexcept
 Sets the peer's public key for shared secret derivation.
 
Expected< std::string, ExceptionContent () const noexcept
 Derives the shared secret using the private key and the peer's public key.
 
const KeyPairKeyPair () const noexcept
 Returns the key pair associated with this Secret instance.
 

Detailed Description

A class for managing shared secret operations.

This class provides methods for generating key pairs and deriving shared secrets using various secret-sharing algorithms (e.g., ECDH).

Constructor & Destructor Documentation

◆ Secret() [1/4]

StormByte::Crypto::Secret::Secret ( const Algorithm::SecretShare &  algorithm,
const KeyPair key_pair 
)
explicitnoexcept

Constructs a Secret instance with an algorithm and a key pair.

This constructor initializes the Secret instance with the specified secret-sharing algorithm and a key pair. The key pair is used for deriving shared secrets.

Parameters
algorithmThe secret-sharing algorithm to use.
key_pairThe key pair to use for shared secret operations.

◆ Secret() [2/4]

StormByte::Crypto::Secret::Secret ( const Algorithm::SecretShare &  algorithm,
KeyPair &&  key_pair 
)
explicitnoexcept

Constructs a Secret instance with an algorithm and a key pair (move version).

This constructor initializes the Secret instance with the specified secret-sharing algorithm and a key pair. The key pair is moved into the instance to avoid unnecessary copying.

Parameters
algorithmThe secret-sharing algorithm to use.
key_pairThe key pair to use for shared secret operations (rvalue reference).

◆ Secret() [3/4]

StormByte::Crypto::Secret::Secret ( const Secret secret)
default

Copy constructor for the Secret class.

Creates a copy of the given Secret instance.

Parameters
secretThe Secret instance to copy.

◆ Secret() [4/4]

StormByte::Crypto::Secret::Secret ( Secret &&  secret)
defaultnoexcept

Move constructor for the Secret class.

Moves the given Secret instance into the current instance.

Parameters
secretThe Secret instance to move.

◆ ~Secret()

StormByte::Crypto::Secret::~Secret ( )
defaultnoexcept

Destructor for the Secret class.

Cleans up the Secret instance.

Member Function Documentation

◆ Content()

Expected< std::string, Exception > StormByte::Crypto::Secret::Content ( ) const
noexcept

Derives the shared secret using the private key and the peer's public key.

This method derives the shared secret by combining the private key of the local key pair with the public key of the peer. The derived shared secret can be used for secure communication.

Returns
An Expected containing the derived shared secret or an error.

◆ KeyPair()

const KeyPair & StormByte::Crypto::Secret::KeyPair ( ) const
noexcept

Returns the key pair associated with this Secret instance.

This method returns the key pair used by the Secret instance for shared secret operations.

Returns
The key pair.

◆ operator=() [1/2]

Secret & StormByte::Crypto::Secret::operator= ( const Secret secret)
default

Copy assignment operator for the Secret class.

Assigns the values from the given Secret instance to the current instance.

Parameters
secretThe Secret instance to copy.
Returns
A reference to the updated Secret instance.

◆ operator=() [2/2]

Secret & StormByte::Crypto::Secret::operator= ( Secret &&  secret)
defaultnoexcept

Move assignment operator for the Secret class.

Moves the values from the given Secret instance to the current instance.

Parameters
secretThe Secret instance to move.
Returns
A reference to the updated Secret instance.

◆ PeerPublicKey()

void StormByte::Crypto::Secret::PeerPublicKey ( const std::string &  peer_public_key)
noexcept

Sets the peer's public key for shared secret derivation.

This method sets the public key of the peer, which is required for deriving the shared secret.

Parameters
peer_public_keyThe public key of the peer.

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