Ring Daemon 16.0.0
Loading...
Searching...
No Matches
dev Namespace Reference

Namespaces

namespace  crypto
 
namespace  keccak
 

Classes

class  FixedHash
 Fixed-size raw-byte array container type, with an API optimised for storing hashes. More...
 
class  KeyPair
 Simple class that represents a "key pair". More...
 
class  ScopeGuard
 RAII utility class whose destructor calls a given function. More...
 
class  SecureFixedHash
 
struct  SignatureStruct
 
struct  StaticLog2
 Compile-time calculation of Log2 of constant values. More...
 
struct  StaticLog2< 1 >
 
class  vector_ref
 A modifiable reference to an existing object or vector in memory. More...
 

Typedefs

using Address = h160
 An Ethereum address: 20 bytes.
 
using Addresses = h160s
 A vector of Ethereum addresses.
 
using AddressHash = std::unordered_set< h160 >
 A hash set of Ethereum addresses.
 
using bytes = std::vector< uint8_t >
 
using bytesConstRef = vector_ref< uint8_t const >
 
using BytesMap = std::map< bytes, bytes >
 
using bytesRef = vector_ref< uint8_t >
 
using h1024 = FixedHash< 128 >
 
using h128 = FixedHash< 16 >
 
using h160 = FixedHash< 20 >
 
using h160Hash = std::unordered_set< h160 >
 
using h160s = std::vector< h160 >
 
using h160Set = std::set< h160 >
 
using h2048 = FixedHash< 256 >
 
using h256 = FixedHash< 32 >
 
using h256Hash = std::unordered_set< h256 >
 
using h256s = std::vector< h256 >
 
using h256Set = std::set< h256 >
 
using h512 = FixedHash< 64 >
 
using h512s = std::vector< h512 >
 
using h520 = FixedHash< 65 >
 
using h64 = FixedHash< 8 >
 
using HexMap = std::map< bytes, bytes >
 
using Public = h512
 A public key: 64 bytes.
 
using Secret = SecureFixedHash< 32 >
 
using Secrets = std::vector< Secret >
 A vector of secrets.
 
using Signature = h520
 A signature: 65 bytes: r: [0, 32), s: [32, 64), v: 64.
 
using string32 = std::array< char, 32 >
 
using StringHashMap = std::unordered_map< std::string, std::string >
 
using StringMap = std::map< std::string, std::string >
 
using strings = std::vector< std::string >
 

Enumerations

enum class  WhenError { DontThrow = 0 , Throw = 1 }
 
enum class  WithExisting : int { Trust = 0 , Verify , Rescue , Kill }
 

Functions

bytes asBytes (std::string const &_b)
 Converts a string to a byte array containing the string's (byte) data.
 
bytes asNibbles (bytesConstRef const &_s)
 
std::string asString (bytes const &_b)
 Converts byte array to a string containing the same (binary) data.
 
std::string asString (bytesConstRef _b)
 Converts byte array ref to a string containing the same (binary) data.
 
template<class T , class _U >
unsigned commonPrefix (T const &_t, _U const &_u)
 
template<class T , class V >
bool contains (T const &_t, V const &_v)
 
template<class N >
diff (N const &_a, N const &_b)
 
template<class T , class _In >
fromBigEndian (_In const &_bytes)
 Converts a big-endian byte-stream represented on a templated collection to a templated integer value.
 
bytes fromHex (std::string const &_s, WhenError _throw=WhenError::DontThrow)
 
template<class T >
static bool isHash (std::string const &_hash)
 
bool isHex (std::string const &_s) noexcept
 
template<class T , class U >
std::vector< T > keysOf (std::map< T, U > const &_m)
 
template<class T , class U >
std::vector< T > keysOf (std::unordered_map< T, U > const &_m)
 
template<class T , class U >
std::set< T > operator+ (std::set< T > _a, U const &_b)
 Insert the contents of a container into a set.
 
template<class T , class U >
std::unordered_set< T > operator+ (std::unordered_set< T > _a, U const &_b)
 Insert the contents of a container into an unordered_set.
 
template<class T , class U >
std::vector< T > operator+ (std::vector< T > _a, U const &_b)
 Concatenate the contents of a container onto a vector.
 
template<class T >
std::vector< T > operator+ (std::vector< T > const &_a, std::vector< T > const &_b)
 Concatenate two vectors of elements.
 
template<class T , class U >
std::set< T > & operator+= (std::set< T > &_a, U const &_b)
 Insert the contents of a container into a set.
 
template<class T , class U >
std::unordered_set< T > & operator+= (std::unordered_set< T > &_a, U const &_b)
 Insert the contents of a container into an unordered_set.
 
template<class T , class U >
std::vector< T > & operator+= (std::vector< T > &_a, U const &_b)
 Concatenate the contents of a container onto a vector.
 
template<class T >
std::vector< T > & operator+= (std::vector< typename std::enable_if< std::is_pod< T >::value, T >::type > &_a, std::vector< T > const &_b)
 Concatenate two vectors of elements of POD types.
 
template<class T >
std::vector< T > & operator+= (std::vector< typename std::enable_if<!std::is_pod< T >::value, T >::type > &_a, std::vector< T > const &_b)
 Concatenate two vectors of elements.
 
template<class T , class _U >
void pushFront (T &_t, _U _e)
 Pushes an element on to the front of a collection.
 
template<class _T >
vector_ref< _T > ref (_T &_t)
 
template<class _T >
vector_ref< _T const > ref (_T const &_t)
 
template<class _T >
vector_ref< _T > ref (std::vector< _T > &_t)
 
template<class _T >
vector_ref< _T const > ref (std::vector< _T > const &_t)
 
h160 right160 (h256 const &_t)
 Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes.
 
h256 sha3 (bytes const &_input)
 Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.
 
h256 sha3 (bytesConstRef _input)
 Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.
 
bool sha3 (bytesConstRef _input, bytesRef o_output)
 Calculate SHA3-256 hash of the given input and load it into the given output.
 
template<unsigned N>
h256 sha3 (FixedHash< N > const &_input)
 Calculate SHA3-256 hash of the given input (presented as a FixedHash), returns a 256-bit hash.
 
h256 sha3 (std::string const &_input)
 Calculate SHA3-256 hash of the given input (presented as a binary-filled string), returning as a 256-bit hash.
 
std::string sha3 (std::string const &_input, bool _isNibbles)
 Calculate SHA3-256 hash of the given input, possibly interpreting it as nibbles, and return the hash as a string filled with binary data.
 
Address toAddress (Public const &_public)
 Convert a public key to address.
 
Address toAddress (Secret const &_secret)
 Convert a secret key into address of public key equivalent.
 
bytes toCompactBigEndian (uint8_t _val, unsigned _min=0)
 
template<class Iterator >
std::string toHex (Iterator _it, Iterator _end, std::string _prefix)
 
template<class T >
std::string toHex (T const &_data)
 
template<class T >
std::string toHexPrefixed (T const &_data)
 
Public toPublic (Secret const &_secret)
 Convert a secret key into the public key equivalent.
 
template<class T >
void trimFront (T &_t, unsigned _elements)
 Trims a given number of elements from the front of a collection.
 
template<class T , class U >
std::vector< U > valuesOf (std::map< T, U > const &_m)
 
template<class T , class U >
std::vector< U > valuesOf (std::unordered_map< T, U > const &_m)
 

Variables

h256 EmptySHA3 = sha3(bytesConstRef())
 
std::string const EmptyString
 
char const * Version
 

Typedef Documentation

◆ Address

typedef h160 dev::Address

An Ethereum address: 20 bytes.

@NOTE This is not endian-specific; it's just a bunch of bytes.

Definition at line 29 of file Address.h.

◆ Addresses

using dev::Addresses = typedef h160s

A vector of Ethereum addresses.

Definition at line 32 of file Address.h.

◆ AddressHash

using dev::AddressHash = typedef std::unordered_set<h160>

A hash set of Ethereum addresses.

Definition at line 35 of file Address.h.

◆ bytes

using dev::bytes = typedef std::vector<uint8_t>

Definition at line 72 of file libdevcore/Common.h.

◆ bytesConstRef

using dev::bytesConstRef = typedef vector_ref<uint8_t const>

Definition at line 74 of file libdevcore/Common.h.

◆ BytesMap

using dev::BytesMap = typedef std::map<bytes, bytes>

Definition at line 78 of file libdevcore/Common.h.

◆ bytesRef

using dev::bytesRef = typedef vector_ref<uint8_t>

Definition at line 73 of file libdevcore/Common.h.

◆ h1024

using dev::h1024 = typedef FixedHash<128>

Definition at line 490 of file FixedHash.h.

◆ h128

using dev::h128 = typedef FixedHash<16>

Definition at line 495 of file FixedHash.h.

◆ h160

typedef FixedHash< 20 > dev::h160

Definition at line 494 of file FixedHash.h.

◆ h160Hash

using dev::h160Hash = typedef std::unordered_set<h160>

Definition at line 503 of file FixedHash.h.

◆ h160s

using dev::h160s = typedef std::vector<h160>

Definition at line 499 of file FixedHash.h.

◆ h160Set

using dev::h160Set = typedef std::set<h160>

Definition at line 501 of file FixedHash.h.

◆ h2048

using dev::h2048 = typedef FixedHash<256>

Definition at line 489 of file FixedHash.h.

◆ h256

using dev::h256 = typedef FixedHash<32>

Definition at line 493 of file FixedHash.h.

◆ h256Hash

using dev::h256Hash = typedef std::unordered_set<h256>

Definition at line 502 of file FixedHash.h.

◆ h256s

using dev::h256s = typedef std::vector<h256>

Definition at line 498 of file FixedHash.h.

◆ h256Set

using dev::h256Set = typedef std::set<h256>

Definition at line 500 of file FixedHash.h.

◆ h512

using dev::h512 = typedef FixedHash<64>

Definition at line 492 of file FixedHash.h.

◆ h512s

using dev::h512s = typedef std::vector<h512>

Definition at line 497 of file FixedHash.h.

◆ h520

using dev::h520 = typedef FixedHash<65>

Definition at line 491 of file FixedHash.h.

◆ h64

using dev::h64 = typedef FixedHash<8>

Definition at line 496 of file FixedHash.h.

◆ HexMap

using dev::HexMap = typedef std::map<bytes, bytes>

Definition at line 79 of file libdevcore/Common.h.

◆ Public

using dev::Public = typedef h512

A public key: 64 bytes.

@NOTE This is not endian-specific; it's just a bunch of bytes.

Definition at line 38 of file libdevcrypto/Common.h.

◆ Secret

using dev::Secret = typedef SecureFixedHash<32>

Definition at line 34 of file libdevcrypto/Common.h.

◆ Secrets

using dev::Secrets = typedef std::vector<Secret>

A vector of secrets.

Definition at line 64 of file libdevcrypto/Common.h.

◆ Signature

using dev::Signature = typedef h520

A signature: 65 bytes: r: [0, 32), s: [32, 64), v: 64.

@NOTE This is not endian-specific; it's just a bunch of bytes.

Definition at line 42 of file libdevcrypto/Common.h.

◆ string32

using dev::string32 = typedef std::array<char, 32>

Definition at line 88 of file libdevcore/Common.h.

◆ StringHashMap

using dev::StringHashMap = typedef std::unordered_map<std::string, std::string>

Definition at line 82 of file libdevcore/Common.h.

◆ StringMap

using dev::StringMap = typedef std::map<std::string, std::string>

Definition at line 77 of file libdevcore/Common.h.

◆ strings

using dev::strings = typedef std::vector<std::string>

Definition at line 85 of file libdevcore/Common.h.

Enumeration Type Documentation

◆ WhenError

enum class dev::WhenError
strong
Enumerator
DontThrow 
Throw 

Definition at line 38 of file CommonData.h.

◆ WithExisting

enum class dev::WithExisting : int
strong
Enumerator
Trust 
Verify 
Rescue 
Kill 

Definition at line 118 of file libdevcore/Common.h.

Function Documentation

◆ asBytes()

bytes dev::asBytes ( std::string const &  _b)
inline

Converts a string to a byte array containing the string's (byte) data.

Definition at line 116 of file CommonData.h.

Referenced by sha3().

◆ asNibbles()

bytes dev::asNibbles ( bytesConstRef const &  _s)

Definition at line 82 of file CommonData.cpp.

References dev::vector_ref< _T >::size().

Here is the call graph for this function:

◆ asString() [1/2]

std::string dev::asString ( bytes const &  _b)
inline

Converts byte array to a string containing the same (binary) data.

Unless the byte array happens to contain ASCII data, this won't be printable.

Definition at line 101 of file CommonData.h.

Referenced by sha3().

◆ asString() [2/2]

std::string dev::asString ( bytesConstRef  _b)
inline

Converts byte array ref to a string containing the same (binary) data.

Unless the byte array happens to contain ASCII data, this won't be printable.

Definition at line 109 of file CommonData.h.

References dev::vector_ref< _T >::data(), and dev::vector_ref< _T >::size().

Here is the call graph for this function:

◆ commonPrefix()

template<class T , class _U >
unsigned dev::commonPrefix ( T const &  _t,
_U const &  _u 
)

Definition at line 154 of file CommonData.h.

◆ contains()

template<class T , class V >
bool dev::contains ( T const &  _t,
V const &  _v 
)

Definition at line 317 of file CommonData.h.

◆ diff()

template<class N >
N dev::diff ( N const &  _a,
N const &  _b 
)
inline
Returns
the absolute distance between _a and _b.

Definition at line 93 of file libdevcore/Common.h.

◆ fromBigEndian()

template<class T , class _In >
T dev::fromBigEndian ( _In const &  _bytes)
inline

Converts a big-endian byte-stream represented on a templated collection to a templated integer value.

_In will typically be either std::string or bytes. T will typically by unsigned, u160, u256 or bigint.

Definition at line 133 of file CommonData.h.

◆ fromHex()

bytes dev::fromHex ( std::string const &  _s,
WhenError  _throw = WhenError::DontThrow 
)

Definition at line 53 of file CommonData.cpp.

Referenced by sha3().

◆ isHash()

template<class T >
static bool dev::isHash ( std::string const &  _hash)
static
Returns
true if _hash is a hash conforming to FixedHash type T.

Definition at line 91 of file CommonData.h.

References isHex().

Here is the call graph for this function:

◆ isHex()

bool dev::isHex ( std::string const &  _s)
noexcept
Returns
true if _s is a hex string.

Referenced by isHash().

◆ keysOf() [1/2]

template<class T , class U >
std::vector< T > dev::keysOf ( std::map< T, U > const &  _m)

Definition at line 275 of file CommonData.h.

◆ keysOf() [2/2]

template<class T , class U >
std::vector< T > dev::keysOf ( std::unordered_map< T, U > const &  _m)

Definition at line 285 of file CommonData.h.

◆ operator+() [1/4]

template<class T , class U >
std::set< T > dev::operator+ ( std::set< T >  _a,
U const &  _b 
)

Insert the contents of a container into a set.

Definition at line 243 of file CommonData.h.

◆ operator+() [2/4]

template<class T , class U >
std::unordered_set< T > dev::operator+ ( std::unordered_set< T >  _a,
U const &  _b 
)

Insert the contents of a container into an unordered_set.

Definition at line 251 of file CommonData.h.

◆ operator+() [3/4]

template<class T , class U >
std::vector< T > dev::operator+ ( std::vector< T >  _a,
U const &  _b 
)

Concatenate the contents of a container onto a vector.

Definition at line 259 of file CommonData.h.

◆ operator+() [4/4]

template<class T >
std::vector< T > dev::operator+ ( std::vector< T > const &  _a,
std::vector< T > const &  _b 
)
inline

Concatenate two vectors of elements.

Definition at line 267 of file CommonData.h.

◆ operator+=() [1/5]

template<class T , class U >
std::set< T > & dev::operator+= ( std::set< T > &  _a,
U const &  _b 
)

Insert the contents of a container into a set.

Definition at line 213 of file CommonData.h.

◆ operator+=() [2/5]

template<class T , class U >
std::unordered_set< T > & dev::operator+= ( std::unordered_set< T > &  _a,
U const &  _b 
)

Insert the contents of a container into an unordered_set.

Definition at line 223 of file CommonData.h.

◆ operator+=() [3/5]

template<class T , class U >
std::vector< T > & dev::operator+= ( std::vector< T > &  _a,
U const &  _b 
)

Concatenate the contents of a container onto a vector.

Definition at line 233 of file CommonData.h.

◆ operator+=() [4/5]

template<class T >
std::vector< T > & dev::operator+= ( std::vector< typename std::enable_if< std::is_pod< T >::value, T >::type > &  _a,
std::vector< T > const &  _b 
)
inline

Concatenate two vectors of elements of POD types.

Definition at line 189 of file CommonData.h.

◆ operator+=() [5/5]

template<class T >
std::vector< T > & dev::operator+= ( std::vector< typename std::enable_if<!std::is_pod< T >::value, T >::type > &  _a,
std::vector< T > const &  _b 
)
inline

Concatenate two vectors of elements.

Definition at line 201 of file CommonData.h.

◆ pushFront()

template<class T , class _U >
void dev::pushFront ( T &  _t,
_U  _e 
)

Pushes an element on to the front of a collection.

Only works for POD element types.

Definition at line 178 of file CommonData.h.

◆ ref() [1/4]

template<class _T >
vector_ref< _T > dev::ref ( _T &  _t)

Definition at line 198 of file vector_ref.h.

◆ ref() [2/4]

template<class _T >
vector_ref< _T const > dev::ref ( _T const &  _t)

Definition at line 192 of file vector_ref.h.

◆ ref() [3/4]

template<class _T >
vector_ref< _T > dev::ref ( std::vector< _T > &  _t)

Definition at line 210 of file vector_ref.h.

◆ ref() [4/4]

template<class _T >
vector_ref< _T const > dev::ref ( std::vector< _T > const &  _t)

Definition at line 204 of file vector_ref.h.

◆ right160()

h160 dev::right160 ( h256 const &  _t)
inline

Convert the given value into h160 (160-bit unsigned integer) using the right 20 bytes.

Definition at line 507 of file FixedHash.h.

References dev::FixedHash< N >::data().

Referenced by toAddress().

Here is the call graph for this function:

◆ sha3() [1/6]

h256 dev::sha3 ( bytes const &  _input)
inline

Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.

Definition at line 49 of file SHA3.h.

References sha3().

Here is the call graph for this function:

◆ sha3() [2/6]

h256 dev::sha3 ( bytesConstRef  _input)
inline

Calculate SHA3-256 hash of the given input, returning as a 256-bit hash.

Definition at line 40 of file SHA3.h.

References dev::FixedHash< N >::ref(), and sha3().

Here is the call graph for this function:

◆ sha3() [3/6]

bool dev::sha3 ( bytesConstRef  _input,
bytesRef  o_output 
)

Calculate SHA3-256 hash of the given input and load it into the given output.

Returns
false if o_output.size() != 32.

Definition at line 196 of file SHA3.cpp.

Referenced by sha3(), sha3(), sha3(), sha3(), sha3(), and toAddress().

◆ sha3() [4/6]

template<unsigned N>
h256 dev::sha3 ( FixedHash< N > const &  _input)
inline

Calculate SHA3-256 hash of the given input (presented as a FixedHash), returns a 256-bit hash.

Definition at line 65 of file SHA3.h.

References dev::FixedHash< N >::ref(), and sha3().

Here is the call graph for this function:

◆ sha3() [5/6]

h256 dev::sha3 ( std::string const &  _input)
inline

Calculate SHA3-256 hash of the given input (presented as a binary-filled string), returning as a 256-bit hash.

Definition at line 57 of file SHA3.h.

References sha3().

Here is the call graph for this function:

◆ sha3() [6/6]

std::string dev::sha3 ( std::string const &  _input,
bool  _isNibbles 
)
inline

Calculate SHA3-256 hash of the given input, possibly interpreting it as nibbles, and return the hash as a string filled with binary data.

Definition at line 73 of file SHA3.h.

References asBytes(), asString(), fromHex(), and sha3().

Here is the call graph for this function:

◆ toAddress() [1/2]

Address dev::toAddress ( Public const &  _public)

Convert a public key to address.

Definition at line 78 of file Common.cpp.

References dev::FixedHash< N >::ref(), right160(), and sha3().

Referenced by dev::KeyPair::KeyPair(), and toAddress().

Here is the call graph for this function:

◆ toAddress() [2/2]

Address dev::toAddress ( Secret const &  _secret)

Convert a secret key into address of public key equivalent.

Returns
0 if it's not a valid secret key.

Definition at line 84 of file Common.cpp.

References toAddress(), and toPublic().

Here is the call graph for this function:

◆ toCompactBigEndian()

bytes dev::toCompactBigEndian ( uint8_t  _val,
unsigned  _min = 0 
)
inline

Definition at line 142 of file CommonData.h.

◆ toHex() [1/2]

template<class Iterator >
std::string dev::toHex ( Iterator  _it,
Iterator  _end,
std::string  _prefix 
)

◆ toHex() [2/2]

template<class T >
std::string dev::toHex ( T const &  _data)

Definition at line 65 of file CommonData.h.

References toHex().

Here is the call graph for this function:

◆ toHexPrefixed()

template<class T >
std::string dev::toHexPrefixed ( T const &  _data)

Definition at line 74 of file CommonData.h.

References toHex().

Here is the call graph for this function:

◆ toPublic()

Public dev::toPublic ( Secret const &  _secret)

Convert a secret key into the public key equivalent.

Definition at line 56 of file Common.cpp.

References dev::FixedHash< N >::ConstructFromPointer, and dev::SecureFixedHash< T >::data().

Referenced by toAddress().

Here is the call graph for this function:

◆ trimFront()

template<class T >
void dev::trimFront ( T &  _t,
unsigned  _elements 
)

Trims a given number of elements from the front of a collection.

Only works for POD element types.

Definition at line 167 of file CommonData.h.

◆ valuesOf() [1/2]

template<class T , class U >
std::vector< U > dev::valuesOf ( std::map< T, U > const &  _m)

Definition at line 295 of file CommonData.h.

◆ valuesOf() [2/2]

template<class T , class U >
std::vector< U > dev::valuesOf ( std::unordered_map< T, U > const &  _m)

Definition at line 306 of file CommonData.h.

Variable Documentation

◆ EmptySHA3

h256 dev::EmptySHA3 = sha3(bytesConstRef())

Definition at line 32 of file SHA3.cpp.

◆ EmptyString

std::string const dev::EmptyString
extern

◆ Version

char const* dev::Version
extern