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

General functionality. More...

#include <ots.hpp>

Public Member Functions

 OTS ()
 

Static Public Member Functions

static const std::string version () noexcept
 
static std::array< int, 3 > versionComponents () noexcept
 
static uint64_t heightFromTimestamp (uint64_t timestamp, Network network=Network::MAIN)
 Estimates the block height of a given timestamp.
 
static uint64_t timestampFromHeight (uint64_t height, Network network=Network::MAIN)
 Estimates the timestamp for a given block height on a network.
 
static std::array< unsigned char, 32 > random ()
 Random 32 bytes.
 
static void random (size_t size, uint8_t *bytes)
 Random bytes.
 
static bool lowEntropy (size_t size, const uint8_t *data, double minEntropy=3.5) noexcept
 check for low entropy in data
 
static void enforceEntropy (bool enforce=true) noexcept
 switch enforcement of sufficient entropy
 
static void setMaxAccountDepth (uint32_t depth) noexcept
 set the maximum depth of the accounts to search through
 
static void setMaxIndexDepth (uint32_t depth) noexcept
 set the maximum depth of the indexes to search through
 
static void setMaxDepth (uint32_t account, uint32_t index) noexcept
 set the maximum depth of the accounts and indexes to search through
 
static void resetMaxDepth () noexcept
 reset the maximum depth of the accounts and indexes to search through
 
static uint32_t maxAccountDepth (uint32_t depth=0) noexcept
 get the maximum depth of the accounts to search through (lookahead, generate addresses to search)
 
static uint32_t maxIndexDepth (uint32_t depth=0) noexcept
 get the maximum depth of the indexes to search through (lookahead, generate addresses to search)
 
static bool verifyData (const std::string &data, const std::string &address, const std::string &signature, bool legacyFallback=false)
 Verify a signed message.
 

Static Protected Member Functions

static void ensureEntropy (size_t size, const uint8_t *data, double minEntropy=3.5)
 check for low entropy in data
 

Detailed Description

General functionality.

Constructor & Destructor Documentation

◆ OTS()

ots::OTS::OTS ( )
explicit

Member Function Documentation

◆ enforceEntropy()

void ots::OTS::enforceEntropy ( bool  enforce = true)
staticnoexcept

switch enforcement of sufficient entropy

Parameters
enforcetrue to enforce entropy check, default is true

◆ ensureEntropy()

void ots::OTS::ensureEntropy ( size_t  size,
const uint8_t *  data,
double  minEntropy = 3.5 
)
staticprotected

check for low entropy in data

Parameters
sizesize of data
datathe data to check
minEntropythe minimum entropy to accept
Exceptions
ots::exception::LowEntropyif the entropy is lower than minEntropy

◆ heightFromTimestamp()

uint64_t ots::OTS::heightFromTimestamp ( uint64_t  timestamp,
Network  network = Network::MAIN 
)
static

Estimates the block height of a given timestamp.

Parameters
timestampunix timestamp (epoch, seconds since 1970-01-01 00:00:00 UTC)
networkestimation is network related
Returns
monero blockchain block height
Note
The estimation automatically substracts 10 days, how test have show a difference up to 8 days with data until 2025-01-23

◆ lowEntropy()

bool ots::OTS::lowEntropy ( size_t  size,
const uint8_t *  data,
double  minEntropy = 3.5 
)
staticnoexcept

check for low entropy in data

Parameters
sizesize of data
datathe data to check
minEntropythe minimum entropy to accept
Returns
true if the entropy is lower than minEntropy

◆ maxAccountDepth()

uint32_t ots::OTS::maxAccountDepth ( uint32_t  depth = 0)
staticnoexcept

get the maximum depth of the accounts to search through (lookahead, generate addresses to search)

Parameters
depththe maximum depth of the account, default is 0 and returns the current value, or DEFAULT_MAX_ACCOUNT_DEPTH or the value set via
See also
setMaxAccountDepth or
setMaxDepth
Returns
the maximum depth of the account generation

◆ maxIndexDepth()

uint32_t ots::OTS::maxIndexDepth ( uint32_t  depth = 0)
staticnoexcept

get the maximum depth of the indexes to search through (lookahead, generate addresses to search)

Parameters
depththe maximum depth of the index, default is 0 and returns the current value, or DEFAULT_MAX_INDEX_DEPTH or the value set via
See also
setMaxIndexDepth or
setMaxDepth
Returns
the maximum depth of the index generation

◆ random() [1/2]

std::array< unsigned char, 32 > ots::OTS::random ( )
static

Random 32 bytes.

Returns
32 random bytes
Warning
Entropy is depending on your device, on low entropy devices don't use this for security related purpose!

◆ random() [2/2]

void ots::OTS::random ( size_t  size,
uint8_t *  bytes 
)
static

Random bytes.

Parameters
[IN]size size of bytes
[OUT]bytes where to write the random bytes
Warning
Entropy is depending on your device, on low entropy devices don't use this for security related purpose!

◆ resetMaxDepth()

void ots::OTS::resetMaxDepth ( )
staticnoexcept

reset the maximum depth of the accounts and indexes to search through

◆ setMaxAccountDepth()

void ots::OTS::setMaxAccountDepth ( uint32_t  depth)
staticnoexcept

set the maximum depth of the accounts to search through

Parameters
depththe maximum depth of the account, set this value to 0 will restrict to use only the main (wallet) account

◆ setMaxDepth()

void ots::OTS::setMaxDepth ( uint32_t  account,
uint32_t  index 
)
staticnoexcept

set the maximum depth of the accounts and indexes to search through

Parameters
accountthe maximum depth of the account, set this value to 0 will restrict to use only the main (wallet) account
indexthe maximum depth of the index, set this value to 0 will restrict to use only the first index of every account

◆ setMaxIndexDepth()

void ots::OTS::setMaxIndexDepth ( uint32_t  depth)
staticnoexcept

set the maximum depth of the indexes to search through

Parameters
depththe maximum depth of the index, set this value to 0 will restrict to use only the first index of every account

◆ timestampFromHeight()

uint64_t ots::OTS::timestampFromHeight ( uint64_t  height,
Network  network = Network::MAIN 
)
static

Estimates the timestamp for a given block height on a network.

Parameters
heightmonero blockchain block height
networkestimation is network related
Returns
timestamp unix timestamp (epoch, seconds since 1970-01-01 00:00:00 UTC)

◆ verifyData()

bool ots::OTS::verifyData ( const std::string &  data,
const std::string &  address,
const std::string &  signature,
bool  legacyFallback = false 
)
static

Verify a signed message.

Parameters
dataString of the message to sign
addresspublic Monero address as string
signaturefor the message
legacyFallbackif true, will try to verify with legacy signature
Returns
true if the signature is valid
Exceptions
ots::exception::address::Invalidif the address is not valid
Todo:
TODO: not sure if better in Wallet only or move here, or keep alias. How verification is not wallet dependent, maybe a user would search here. On the other hand, if he user uses Wallet to sign data, probably he would search in Wallet for the verification.
Note
is an alias for Wallet::verifyData(data, address, signature, false)

◆ version()

const std::string ots::OTS::version ( )
staticnoexcept
Returns
the version liker major.minor.patch

◆ versionComponents()

std::array< int, 3 > ots::OTS::versionComponents ( )
staticnoexcept
Returns
{major, minor, patch}

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