Offline Transaction Signing (OTS) 0.1.0
Loading...
Searching...
No Matches
ots::Seed Class Referenceabstract

Abstract base class for cryptographic seed management. More...

#include <ots.hpp>

Inheritance diagram for ots::Seed:
Collaboration diagram for ots::Seed:

Public Member Functions

virtual ~Seed ()=default
 Virtual destructor to ensure proper cleanup of derived classes.
 
virtual const WipeableString phrase (const SeedLanguage &language, const std::string &password="") const =0
 Generates the seed phrase in a specified language.
 
virtual const SeedIndices indices (const std::string &password="") const =0
 Gets the raw numeric values representing the seed (indices)
 
virtual const std::string & fingerprint () const noexcept
 Provides a unique fingerprint for the seed.
 
virtual const Addressaddress () const noexcept
 Address of the seed.
 
virtual const uint64_t timestamp () const noexcept
 Gets the seed's creation timestamp.
 
virtual const uint64_t height () const noexcept
 Gets the blockchain height associated with the seed.
 
virtual const Networknetwork () const noexcept
 Gets the network associated with the seed.
 
virtual std::shared_ptr< Walletwallet () noexcept
 Creates a wallet from the seed.
 
 Seed (const Seed &)=delete
 
Seedoperator= (const Seed &)=delete
 
 Seed (Seed &&) noexcept=default
 
Seedoperator= (Seed &&) noexcept=default
 

Static Public Member Functions

static std::vector< uint16_t > mergeValues (const std::vector< uint16_t > &values1, const std::vector< uint16_t > &values2)
 Merges two seed values, so you can join multiple SeedQRs to one seed.
 
static std::vector< uint16_t > mergeValues (const std::vector< std::vector< uint16_t > > &values)
 Merges multiple seed values, so you can join multiple SeedQRs to one seed.
 
static std::vector< uint16_t > mergeAndZeorizeValues (std::vector< uint16_t > &values1, std::vector< uint16_t > &values2, bool del=true)
 Merges two seed values, so you can join multiple SeedQRs to one seed.
 
static std::vector< uint16_t > mergeAndZeorizeValues (std::vector< std::vector< uint16_t > > &values, bool del=true)
 Merges multiple seed values, so you can join multiple SeedQRs to one seed.
 
static std::vector< uint16_t > mergeWithPassword (const std::string &password, const std::vector< uint16_t > &values)
 Merge password with seed values.
 
static std::vector< uint16_t > mergeWithPasswordAndZeorize (std::string &password, std::vector< uint16_t > &values, bool del=true)
 Merge password with seed values and zeroize password.
 
static std::vector< uint16_t > mergeWithPassword (const WipeableString &password, const std::vector< uint16_t > &values)
 Merge password with seed values.
 
static std::vector< uint16_t > mergeWithPasswordAndZeorize (const WipeableString &password, std::vector< uint16_t > &values, bool del=true)
 Merge password with seed values and zeroize values.
 

Protected Member Functions

 Seed ()
 

Protected Attributes

std::unique_ptr< Addressm_address
 
std::shared_ptr< Walletm_wallet
 
uint64_t m_timestamp = 0
 
uint64_t m_height = 0
 
std::unique_ptr< KeyStore, KeyStoreDeleterm_key
 
Network m_network
 

Detailed Description

Abstract base class for cryptographic seed management.

Provides core functionality for managing seeds

Constructor & Destructor Documentation

◆ ~Seed()

virtual ots::Seed::~Seed ( )
virtualdefault

Virtual destructor to ensure proper cleanup of derived classes.

◆ Seed() [1/3]

ots::Seed::Seed ( const Seed )
delete

◆ Seed() [2/3]

ots::Seed::Seed ( Seed &&  )
defaultnoexcept

◆ Seed() [3/3]

ots::Seed::Seed ( )
protected

Member Function Documentation

◆ address()

const Address & ots::Seed::address ( ) const
virtualnoexcept

Address of the seed.

Returns
reference to the address of the seed
Note
Can't thow exception, because on constructing a seed address must be valid or throw and exception.

◆ fingerprint()

const std::string & ots::Seed::fingerprint ( ) const
virtualnoexcept

Provides a unique fingerprint for the seed.

Returns
std::string Seed fingerprint
Note
Fingerprint is the last 6 digits of sha256(address) as uppercase hex
Can't thow exception, because on constructing a seed address must be valid or throw and exception. And with valid address the fingerprint is also valid.

◆ height()

const uint64_t ots::Seed::height ( ) const
virtualnoexcept

Gets the blockchain height associated with the seed.

Returns
uint64_t Blockchain height

For Polyseed this is an estimation minus a security time span of 30 days in the past For Monero seeds it will be the same if the user provided a date, otherwise it will be the height the user provided, can be 0 also.

◆ indices()

virtual const SeedIndices ots::Seed::indices ( const std::string &  password = "") const
pure virtual

Gets the raw numeric values representing the seed (indices)

Returns
Seed numeric representation

Implemented in ots::MoneroSeed, ots::LegacySeed, and ots::Polyseed.

◆ mergeAndZeorizeValues() [1/2]

std::vector< uint16_t > ots::Seed::mergeAndZeorizeValues ( std::vector< std::vector< uint16_t > > &  values,
bool  del = true 
)
static

Merges multiple seed values, so you can join multiple SeedQRs to one seed.

Parameters
valuesthe collection of seed values to merge
delwill delete all values after merging and zeroize them, default is true
Returns
std::vector<uint16_t> Merged seed values
Exceptions
ots::exception::seed::LengthMismatchIf the seeds are not of the same size
ots::exception::seed::TooFewValuesif not at least two values are provided
Note
The vectors need to have the same size, and at least two values need to be provided

◆ mergeAndZeorizeValues() [2/2]

std::vector< uint16_t > ots::Seed::mergeAndZeorizeValues ( std::vector< uint16_t > &  values1,
std::vector< uint16_t > &  values2,
bool  del = true 
)
static

Merges two seed values, so you can join multiple SeedQRs to one seed.

Parameters
values1First seed values to merge
values2Second seed values to merge
delwill delete both values after merging and zeroize them, default is true
Returns
std::vector<uint16_t> Merged seed values
Exceptions
ots::exception::seed::LengthMismatchIf the seeds are not of the same size
Note
The vectors need to have the same size

◆ mergeValues() [1/2]

std::vector< uint16_t > ots::Seed::mergeValues ( const std::vector< std::vector< uint16_t > > &  values)
static

Merges multiple seed values, so you can join multiple SeedQRs to one seed.

Parameters
valuesthe collection of seed values to merge
Returns
std::vector<uint16_t> Merged seed values
Exceptions
ots::exception::seed::LengthMismatchIf the seeds are not of the same size
ots::exception::seed::TooFewValuesif not at least two values are provided
Note
The vectors need to have the same size, and at least two values need to be provided

◆ mergeValues() [2/2]

std::vector< uint16_t > ots::Seed::mergeValues ( const std::vector< uint16_t > &  values1,
const std::vector< uint16_t > &  values2 
)
static

Merges two seed values, so you can join multiple SeedQRs to one seed.

Parameters
values1First seed values to merge
values2Second seed values to merge
Returns
std::vector<uint16_t> Merged seed values
Exceptions
ots::exception::seed::LengthMismatchIf the seeds are not of the same size
Note
The vectors need to have the same size

◆ mergeWithPassword() [1/2]

std::vector< uint16_t > ots::Seed::mergeWithPassword ( const std::string &  password,
const std::vector< uint16_t > &  values 
)
static

Merge password with seed values.

Parameters
passwordfor the seed ^ PBKDF2_SHA256(password) operation
valuesseed values to merge
Returns
Merged values
Exceptions
ots::exception::seed::MergeErrorOn failures

◆ mergeWithPassword() [2/2]

std::vector< uint16_t > ots::Seed::mergeWithPassword ( const WipeableString password,
const std::vector< uint16_t > &  values 
)
static

Merge password with seed values.

Parameters
passwordfor the seed ^ PBKDF2
valuesseed values to merge
Returns
Merged values
Exceptions
ots::exception::seed::MergeErrorOn failures

◆ mergeWithPasswordAndZeorize() [1/2]

std::vector< uint16_t > ots::Seed::mergeWithPasswordAndZeorize ( const WipeableString password,
std::vector< uint16_t > &  values,
bool  del = true 
)
static

Merge password with seed values and zeroize values.

Parameters
passwordfor the seed ^ PBKDF2
valuesseed values to merge and zeroize
Returns
Merged values
Exceptions
ots::exception::seed::MergeErrorOn failures

◆ mergeWithPasswordAndZeorize() [2/2]

std::vector< uint16_t > ots::Seed::mergeWithPasswordAndZeorize ( std::string &  password,
std::vector< uint16_t > &  values,
bool  del = true 
)
static

Merge password with seed values and zeroize password.

Parameters
passwordfor the seed ^ PBKDF2_SHA256(password) operation
valuesseed values to merge
delwill delete password and values after merging and zeroize it, default is true
Returns
Merged values
Exceptions
ots::exception::seed::MergeErrorOn failures

◆ network()

virtual const Network & ots::Seed::network ( ) const
inlinevirtualnoexcept

Gets the network associated with the seed.

Returns
Network Cryptocurrency network

Main importance is that the addresses are based on the key and the network - other network different keys

◆ operator=() [1/2]

Seed & ots::Seed::operator= ( const Seed )
delete

◆ operator=() [2/2]

Seed & ots::Seed::operator= ( Seed &&  )
defaultnoexcept

◆ phrase()

virtual const WipeableString ots::Seed::phrase ( const SeedLanguage language,
const std::string &  password = "" 
) const
pure virtual

Generates the seed phrase in a specified language.

Parameters
languageSeedLanguage to generate phrase in
Returns
Seed phrase
Exceptions
ots::exception::seed::UnsupportedLanguageIf the language is not supported

Implemented in ots::MoneroSeed, ots::LegacySeed, and ots::Polyseed.

◆ timestamp()

const uint64_t ots::Seed::timestamp ( ) const
virtualnoexcept

Gets the seed's creation timestamp.

Returns
uint64_t Seed creation timestamp

For Polyseed this is more exact as height() For Monero seeds it depends what was provided by the user, if there date was provided it will be more accurate, in case the block height on creation was provide this is also only a rough estimation

◆ wallet()

std::shared_ptr< Wallet > ots::Seed::wallet ( )
virtualnoexcept

Creates a wallet from the seed.

Returns
std::shared_ptr<Wallet> Wallet created from the seed

will return always the same wallet, wallet is created only once.

Member Data Documentation

◆ m_address

std::unique_ptr<Address> ots::Seed::m_address
protected

◆ m_height

uint64_t ots::Seed::m_height = 0
protected

◆ m_key

std::unique_ptr<KeyStore, KeyStoreDeleter> ots::Seed::m_key
protected

◆ m_network

Network ots::Seed::m_network
protected

◆ m_timestamp

uint64_t ots::Seed::m_timestamp = 0
protected

◆ m_wallet

std::shared_ptr<Wallet> ots::Seed::m_wallet
protected

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