CatapultServer  v0.5.0.1 (Elephant)
catapult::crypto Namespace Reference

Classes

class  KeccakBuilder
 Builder for building a hash. More...
 
struct  KeccakModeTag
 Use with KeccakBuilder to generate Keccak hashes. More...
 
class  KeyPair
 Represents a pair of private key with associated public key. More...
 
class  MerkleHashBuilder
 Builder for creating a merkle hash. More...
 
class  PrivateKey
 Represents a private key. More...
 
struct  Sha3ModeTag
 Use with KeccakBuilder to generate SHA3 hashes. More...
 

Typedefs

using Sha3_256_Builder = KeccakBuilder< Sha3ModeTag, Hash256_tag >
 Sha3_256_Builder. More...
 
using Sha3_512_Builder = KeccakBuilder< Sha3ModeTag, Hash512_tag >
 Sha3_512_Builder. More...
 
using Keccak_256_Builder = KeccakBuilder< KeccakModeTag, Hash256_tag >
 Keccak_256_Builder. More...
 
using Keccak_512_Builder = KeccakBuilder< KeccakModeTag, Hash512_tag >
 Keccak_512_Builder. More...
 
using GenerationHash_Builder = KeccakBuilder< Sha3ModeTag, GenerationHash_tag >
 GenerationHash_Builder. More...
 

Functions

void HashPrivateKey (const PrivateKey &privateKey, Hash512 &hash)
 Calculates hash of a privateKey. More...
 
void Ripemd160 (const RawBuffer &dataBuffer, Hash160 &hash) noexcept
 Calculates the ripemd160 hash of dataBuffer into hash. More...
 
void Bitcoin160 (const RawBuffer &dataBuffer, Hash160 &hash) noexcept
 Calculates bitcoin's hash 160 of dataBuffer into hash (sha256 + ripemd). More...
 
void Sha256Double (const RawBuffer &dataBuffer, Hash256 &hash) noexcept
 Calculates double sha256 hash of dataBuffer into hash. More...
 
void Sha3_256 (const RawBuffer &dataBuffer, Hash256 &hash) noexcept
 Calculates the 256-bit SHA3 hash of dataBuffer into hash. More...
 
void Sha3_512 (const RawBuffer &dataBuffer, Hash512 &hash) noexcept
 Calculates the 512-bit SHA3 hash of dataBuffer into hash. More...
 
void Keccak_256 (const RawBuffer &dataBuffer, Hash256 &hash) noexcept
 Calculates the 256-bit Keccak hash of dataBuffer into hash. More...
 
void Keccak_512 (const RawBuffer &dataBuffer, Hash512 &hash) noexcept
 Calculates the 512-bit Keccak hash of dataBuffer into hash. More...
 
void ExtractPublicKeyFromPrivateKey (const PrivateKey &privateKey, Key &publicKey)
 Extracts a public key (publicKey) from a private key () More...
 
utils::ContainerHexFormatter< Key::const_iteratorFormatKey (const Key &key)
 Formats a public key for printing. More...
 
utils::ContainerHexFormatter< Key::const_iteratorFormatKey (const PrivateKey &key)
 Formats a private key for printing. More...
 
Key ParseKey (const std::string &keyString)
 Parses a key from a string (keyString) and returns the result. More...
 
bool IsValidKeyString (const std::string &str)
 Returns true if str represents a valid public key, false otherwise. More...
 
void SecureZero (Key &key)
 Securely zeros out the memory backing the specified key. More...
 
void SecureZero (uint8_t *pData, size_t dataSize)
 Securely zeros out the memory backing the specified pData with size dataSize. More...
 
void Sign (const KeyPair &keyPair, const RawBuffer &dataBuffer, Signature &computedSignature)
 
void Sign (const KeyPair &keyPair, std::initializer_list< const RawBuffer > buffersList, Signature &computedSignature)
 
bool Verify (const Key &publicKey, const RawBuffer &dataBuffer, const Signature &signature)
 
bool Verify (const Key &publicKey, std::initializer_list< const RawBuffer > buffersList, const Signature &signature)
 

Typedef Documentation

◆ GenerationHash_Builder

◆ Keccak_256_Builder

◆ Keccak_512_Builder

◆ Sha3_256_Builder

◆ Sha3_512_Builder

Function Documentation

◆ Bitcoin160()

void catapult::crypto::Bitcoin160 ( const RawBuffer &  dataBuffer,
Hash160 hash 
)
noexcept

Calculates bitcoin's hash 160 of dataBuffer into hash (sha256 + ripemd).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtractPublicKeyFromPrivateKey()

void catapult::crypto::ExtractPublicKeyFromPrivateKey ( const PrivateKey privateKey,
Key publicKey 
)

Extracts a public key (publicKey) from a private key ()

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatKey() [1/2]

utils::ContainerHexFormatter< Key::const_iterator > catapult::crypto::FormatKey ( const Key key)

Formats a public key for printing.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FormatKey() [2/2]

utils::ContainerHexFormatter< Key::const_iterator > catapult::crypto::FormatKey ( const PrivateKey key)

Formats a private key for printing.

Here is the call graph for this function:

◆ HashPrivateKey()

void catapult::crypto::HashPrivateKey ( const PrivateKey privateKey,
Hash512 hash 
)

Calculates hash of a privateKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValidKeyString()

bool catapult::crypto::IsValidKeyString ( const std::string &  str)

Returns true if str represents a valid public key, false otherwise.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Keccak_256()

void catapult::crypto::Keccak_256 ( const RawBuffer &  dataBuffer,
Hash256 hash 
)
noexcept

Calculates the 256-bit Keccak hash of dataBuffer into hash.

Here is the caller graph for this function:

◆ Keccak_512()

void catapult::crypto::Keccak_512 ( const RawBuffer &  dataBuffer,
Hash512 hash 
)
noexcept

Calculates the 512-bit Keccak hash of dataBuffer into hash.

Here is the caller graph for this function:

◆ ParseKey()

Key catapult::crypto::ParseKey ( const std::string &  keyString)

Parses a key from a string (keyString) and returns the result.

◆ Ripemd160()

void catapult::crypto::Ripemd160 ( const RawBuffer &  dataBuffer,
Hash160 hash 
)
noexcept

Calculates the ripemd160 hash of dataBuffer into hash.

Here is the caller graph for this function:

◆ SecureZero() [1/2]

void catapult::crypto::SecureZero ( Key key)

Securely zeros out the memory backing the specified key.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SecureZero() [2/2]

void catapult::crypto::SecureZero ( uint8_t *  pData,
size_t  dataSize 
)

Securely zeros out the memory backing the specified pData with size dataSize.

◆ Sha256Double()

void catapult::crypto::Sha256Double ( const RawBuffer &  dataBuffer,
Hash256 hash 
)
noexcept

Calculates double sha256 hash of dataBuffer into hash.

Here is the caller graph for this function:

◆ Sha3_256()

void catapult::crypto::Sha3_256 ( const RawBuffer &  dataBuffer,
Hash256 hash 
)
noexcept

Calculates the 256-bit SHA3 hash of dataBuffer into hash.

Here is the caller graph for this function:

◆ Sha3_512()

void catapult::crypto::Sha3_512 ( const RawBuffer &  dataBuffer,
Hash512 hash 
)
noexcept

Calculates the 512-bit SHA3 hash of dataBuffer into hash.

Here is the caller graph for this function:

◆ Sign() [1/2]

void catapult::crypto::Sign ( const KeyPair keyPair,
const RawBuffer &  dataBuffer,
Signature computedSignature 
)

Signs data pointed by dataBuffer using keyPair, placing resulting signature in computedSignature.

Note
The function will throw if the generated S part of the signature is not less than the group order.
Here is the caller graph for this function:

◆ Sign() [2/2]

void catapult::crypto::Sign ( const KeyPair keyPair,
std::initializer_list< const RawBuffer >  buffersList,
Signature computedSignature 
)

Signs data in buffersList using keyPair, placing resulting signature in computedSignature.

Note
The function will throw if the generated S part of the signature is not less than the group order.
Here is the call graph for this function:

◆ Verify() [1/2]

bool catapult::crypto::Verify ( const Key publicKey,
const RawBuffer &  dataBuffer,
const Signature signature 
)

Verifies that signature of data pointed by dataBuffer is valid, using public key publicKey. Returns true if signature is valid.

Here is the caller graph for this function:

◆ Verify() [2/2]

bool catapult::crypto::Verify ( const Key publicKey,
std::initializer_list< const RawBuffer >  buffersList,
const Signature signature 
)

Verifies that signature of data in buffersList is valid, using public key publicKey. Returns true if signature is valid.

Here is the call graph for this function: