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

Represents a Polyseed type. More...

#include <ots.hpp>

Inheritance diagram for ots::Polyseed:
Collaboration diagram for ots::Polyseed:

Public Member Functions

const WipeableString phrase (const SeedLanguage &language, const std::string &password="") const override
 Generates the seed phrase in a specified language.
 
const SeedIndices indices (const std::string &password="") const override
 Gets the raw numeric values representing the seed (indices)
 
MoneroSeed moneroSeed () const
 Gets the Monero seed from the Polyseed.
 
- 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 Polyseed create (const std::array< unsigned char, 19 > &random, Network network=Network::MAIN, uint64_t time=0, const std::string &passphrase="")
 Creates a Polyseed with specific parameters.
 
static Polyseed create (const std::array< unsigned char, 32 > &random, Network network=Network::MAIN, uint64_t time=0, const std::string &passphrase="")
 Convinience function to create a Polyseed from random 32 bytes like sha256 or pbkdf2.
 
static Polyseed generate (Network network=Network::MAIN, uint64_t time=0, const std::string &passphrase="")
 Generates a Polyseed with specific parameters.
 
static Polyseed decode (const std::string &phrase, const Network network=Network::MAIN, const std::string &password="", const std::string &passphrase="")
 Decodes a Polyseed from a phrase.
 
static Polyseed decode (const std::string &phrase, const SeedLanguage &language, const Network network=Network::MAIN, const std::string &password="", const std::string &passphrase="")
 Decodes a Polyseed from a phrase.
 
static Polyseed decode (const SeedIndices &indices, const Network network=Network::MAIN, const std::string &password="", const std::string &passphrase="")
 Decodes a Polyseed from indexes of the words.
 
static Polyseed decode (const std::vector< uint16_t > &values, const Network network=Network::MAIN, const std::string &password="", const std::string &passphrase="")
 Decodes a Polyseed from indexes of the words.
 
- 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

 Polyseed ()
 
- Protected Member Functions inherited from ots::Seed
 Seed ()
 

Protected Attributes

std::unique_ptr< PolyseedKeyStore, PolyseedKeyStoreDeleterm_seed
 
- 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 Polyseed type.

Provides Polyseed generation, encoding, and management

Note
Password and Passphrase is somehow unfortunate.
  • Password encrypts and decrypts a polyseed, so you can call Polyseed::phrase(lang, "password") or Polyseed::indices("password") to encrypt the seed with a password. And later you provide the same seed phrase and the same password to decrypt it.
  • Passphrase is used to offset the seed, and works a bit different. The seed offset passphrase is used after the data from the seed, for that the passphrase is set on creation time and need to be provided always on decoding. So, while you can change your seed phrase with a password, the passphrase will be always the same! With a monero seed you can change the passphrase because the secret key is encoded by the seed phrase while with polyseed the secret key is derived from the seed phrase data and not reversible.
if you provide to the user seed offset by passphrase, or encryption by password I suggest asking the user for the fingerprint of the seed and compare it with the fingerprint of the Seeed and if not it doesn't match the passphrase or password are wrong.

Constructor & Destructor Documentation

◆ Polyseed()

ots::Polyseed::Polyseed ( )
protected

Member Function Documentation

◆ create() [1/2]

Polyseed ots::Polyseed::create ( const std::array< unsigned char, 19 > &  random,
Network  network = Network::MAIN,
uint64_t  time_ = 0,
const std::string &  passphrase = "" 
)
static

Creates a Polyseed with specific parameters.

Parameters
random19-byte random input
networkNetwork type (default: MAIN)
timeTimestamp for seed creation, default 0, what translates to now (current system time)
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Created seed
Note
Unfortunately the birthday in polyseed is set with the dependency injection what makes it necessary to inject every time or use a global/static variable to be flexible with the timestamp. So for now polyseed_create is not used, but re-implemented in a way the timestamp can be set on a by case base without writing ugly code.
Todo:
Maybe a PR with a refactoring of tevador/polyseed in the future and if accepted refactor here again, too.

◆ create() [2/2]

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

Convinience function to create a Polyseed from random 32 bytes like sha256 or pbkdf2.

Parameters
random32-byte random input, but only first 19 bytes are used!
networkNetwork type (default: MAIN)
timeTimestamp for seed creation, default 0, what translates to now (current system time)
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Created seed

◆ decode() [1/4]

Polyseed ots::Polyseed::decode ( const SeedIndices indices,
const Network  network = Network::MAIN,
const std::string &  password = "",
const std::string &  passphrase = "" 
)
static

Decodes a Polyseed from indexes of the words.

Parameters
indicesSeedIndices to decode
networkNetwork type (default: MAIN)
passwordDecryption password, if different from empty string
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails
ots::exception::polyseed::NoPasswordProvidedIf a password is needed but not provided
Note
Language not needed because the index is the same in all languages

◆ decode() [2/4]

Polyseed ots::Polyseed::decode ( const std::string &  phrase,
const Network  network = Network::MAIN,
const std::string &  password = "",
const std::string &  passphrase = "" 
)
static

Decodes a Polyseed from a phrase.

Parameters
phraseSeed phrase
networkNetwork type (default: MAIN)
passwordDecryption password, if different from empty string
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails
ots::exception::polyseed::NoPasswordProvidedIf a password is needed but not provided
Note
autodetect language

◆ decode() [3/4]

Polyseed ots::Polyseed::decode ( const std::string &  phrase,
const SeedLanguage language,
const Network  network = Network::MAIN,
const std::string &  password = "",
const std::string &  passphrase = "" 
)
static

Decodes a Polyseed from a phrase.

Parameters
phraseSeed phrase
languagethe language of the wordlist to use
networkNetwork type (default: MAIN)
passwordDecryption password, if different from empty string
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails
ots::exception::polyseed::NoPasswordProvidedIf a password is needed but not provided

◆ decode() [4/4]

Polyseed ots::Polyseed::decode ( const std::vector< uint16_t > &  values,
const Network  network = Network::MAIN,
const std::string &  password = "",
const std::string &  passphrase = "" 
)
static

Decodes a Polyseed from indexes of the words.

Parameters
valuesSeed phrase as index representation
networkNetwork type (default: MAIN)
passwordDecryption password, if different from empty string
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Decoded seed
Exceptions
ots::exception::seed::SeedDecodingFailedIf decoding fails
ots::exception::polyseed::NoPasswordProvidedIf a password is needed but not provided
Note
Language not needed because the index is the same in all languages

◆ generate()

Polyseed ots::Polyseed::generate ( Network  network = Network::MAIN,
uint64_t  time = 0,
const std::string &  passphrase = "" 
)
static

Generates a Polyseed with specific parameters.

Parameters
networkNetwork type (default: MAIN)
timeTimestamp for seed creation, default 0, what translates to now (current system time)
passphrasefor seed offset (like in monero seed), default empty string
Returns
Polyseed Created seed

◆ indices()

const SeedIndices ots::Polyseed::indices ( const std::string &  password = "") const
overridevirtual

Gets the raw numeric values representing the seed (indices)

Returns
Seed numeric representation

Implements ots::Seed.

◆ moneroSeed()

MoneroSeed ots::Polyseed::moneroSeed ( ) const

Gets the Monero seed from the Polyseed.

Returns
MoneroSeed Monero seed

◆ phrase()

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

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

Implements ots::Seed.

Member Data Documentation

◆ m_seed

std::unique_ptr<PolyseedKeyStore, PolyseedKeyStoreDeleter> ots::Polyseed::m_seed
protected

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