Offline Transaction Signing (OTS) 0.1.0
Loading...
Searching...
No Matches
ots::MoneroSeed Class Reference

Represents a Monero 25-words seed. More...

#include <ots.hpp>

Inheritance diagram for ots::MoneroSeed:
Collaboration diagram for ots::MoneroSeed:

Public Member Functions

const WipeableString phrase (const SeedLanguage &language, const std::string &passphrase="") const override
 Generates the seed phrase in a specified language.
 
const SeedIndices indices (const std::string &passphrase="") const override
 Gets the raw numeric values representing the seed (indices)
 
- Public Member Functions inherited from ots::Seed
virtual ~Seed ()=default
 Virtual destructor to ensure proper cleanup of derived classes.
 
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 MoneroSeed decode (const std::string &phrase, uint64_t height=0, uint64_t time=0, Network network=Network::MAIN, const std::string &passphrase="")
 Decodes a Monero seed from a phrase.
 
static MoneroSeed decode (const SeedIndices &indices, uint64_t height=0, uint64_t time=0, Network network=Network::MAIN, const std::string &passphrase="")
 Decodes a Monero seed from numeric values.
 
static MoneroSeed decode (const std::vector< uint16_t > &values, uint64_t height=0, uint64_t time=0, Network network=Network::MAIN, const std::string &password="")
 Decodes a Monero seed from numeric values.
 
static MoneroSeed create (const std::array< unsigned char, 32 > &random, uint64_t height=0, uint64_t time=0, const Network network=Network::MAIN)
 Creates a Monero seed from a random source.
 
static MoneroSeed generate (uint64_t height=0, uint64_t time=0, const Network network=Network::MAIN)
 Generates a new Monero seed.
 
- Static Public Member Functions inherited from ots::Seed
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

 MoneroSeed ()=default
 
- Protected Member Functions inherited from ots::Seed
 Seed ()
 

Additional Inherited Members

- Protected Attributes inherited from ots::Seed
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

Represents a Monero 25-words seed.

Note
if you provide to the user seed offset by passphrase I suggest asking the user for the fingerprint of the seed and compare it with the fingerprint of the Seed if not it doesn't match the passphrase is wrong.

Provides Monero seed generation and decoding

Constructor & Destructor Documentation

◆ MoneroSeed()

ots::MoneroSeed::MoneroSeed ( )
protecteddefault

Member Function Documentation

◆ create()

MoneroSeed ots::MoneroSeed::create ( const std::array< unsigned char, 32 > &  random,
uint64_t  height = 0,
uint64_t  time = 0,
const Network  network = Network::MAIN 
)
static

Creates a Monero seed from a random source.

Parameters
random32-byte random input
heightOptional blockchain height
timeOptional timestamp
networkNetwork type (default: MAIN)
Returns
MoneroSeed created seed

Can be used to:

  • recover a seed
  • generate from external entropy

◆ decode() [1/3]

MoneroSeed ots::MoneroSeed::decode ( const SeedIndices indices,
uint64_t  height = 0,
uint64_t  time = 0,
Network  network = Network::MAIN,
const std::string &  passphrase = "" 
)
static

Decodes a Monero seed from numeric values.

Parameters
indicesSeedIndices to decode
heightOptional blockchain height
timeOptional timestamp
networkNetwork type (default: MAIN)
passphraseDecryption passphrase, if different from empty string
Returns
MoneroSeed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails

◆ decode() [2/3]

MoneroSeed ots::MoneroSeed::decode ( const std::string &  phrase,
uint64_t  height = 0,
uint64_t  time = 0,
Network  network = Network::MAIN,
const std::string &  passphrase = "" 
)
static

Decodes a Monero seed from a phrase.

Parameters
phraseSeed phrase
heightOptional blockchain height
timeOptional timestamp
networkNetwork type (default: MAIN)
passphraseDecryption passphrase, if different from empty string
Returns
MoneroSeed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails
Note
autodetect Language
passphrase decrypts the seed with a seed before encrypted by that passphrase

◆ decode() [3/3]

MoneroSeed ots::MoneroSeed::decode ( const std::vector< uint16_t > &  values,
uint64_t  height = 0,
uint64_t  time = 0,
Network  network = Network::MAIN,
const std::string &  password = "" 
)
static

Decodes a Monero seed from numeric values.

Parameters
valuesNumeric representation of the seed
heightOptional blockchain height
timeOptional timestamp
networkNetwork type (default: MAIN)
passphraseDecryption passphrase, if different from empty string
Returns
MoneroSeed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails

◆ generate()

MoneroSeed ots::MoneroSeed::generate ( uint64_t  height = 0,
uint64_t  time = 0,
const Network  network = Network::MAIN 
)
static

Generates a new Monero seed.

Parameters
heightOptional blockchain height
timeOptional timestamp
networkNetwork type (default: MAIN)
Returns
MoneroSeed Generated seed
Warning
Generates a seed from the device provided entropy. Use with caution if the device can't provide good enough entropy!

◆ indices()

const SeedIndices ots::MoneroSeed::indices ( const std::string &  passphrase = "") const
overridevirtual

Gets the raw numeric values representing the seed (indices)

Parameters
passphraseEncryption passphrase, if different from empty string
Returns
Seed numeric representation
Note
The passphrase uses monero encryption to encrypt the secret spend key with this passphrase, on decoding the same passphrase needs to be provided. There is no feedback if the passphrase is wrong, you can only see it on the public address, if it is not the same as expected.

Implements ots::Seed.

◆ phrase()

const WipeableString ots::MoneroSeed::phrase ( const SeedLanguage language,
const std::string &  passphrase = "" 
) const
overridevirtual

Generates the seed phrase in a specified language.

Parameters
languageSeedLanguage to generate phrase in
passphraseEncryption passphrase, if different from empty string
Returns
Seed phrase
Note
The passphrase uses monero encryption to encrypt the secret spend key with this passphrase, on decoding the same passphrase needs to be provided. There is no feedback if the passphrase is wrong, you can only see it on the public address, if it is not the same as expected.

Implements ots::Seed.


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