IoTeX client
Public Member Functions | List of all members
iotex::Signer Class Reference

Public Member Functions

void getHash (const uint8_t *pData, size_t size, uint8_t hash[IOTEX_HASH_SIZE])
 Get the kekkac 256 hash. More...
 
void getEthereumMessageHash (const uint8_t *pMsg, size_t length, uint8_t hash[IOTEX_HASH_SIZE])
 Get the Ethereum Message hash. More...
 
void getPublicKey (const uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE], uint8_t publicKey[IOTEX_PUBLIC_KEY_SIZE])
 Get the public key from the private key. More...
 
ResultCode signHash (const uint8_t hash[IOTEX_HASH_SIZE], const uint8_t private_key[IOTEX_PRIVATE_KEY_SIZE], uint8_t signature[IOTEX_SIGNATURE_SIZE])
 Sign a hash. More...
 
void signMessage (const uint8_t *message, size_t size, const uint8_t privateKey[IOTEX_PRIVATE_KEY_SIZE], uint8_t signature[IOTEX_SIGNATURE_SIZE])
 Sign an ethereum message. More...
 
ResultCode hex2str (const uint8_t *hex, size_t hex_size, char *str, size_t str_size)
 Convert a byte array to a hex string. More...
 
ResultCode str2hex (const char *str, uint8_t *hex, size_t size, size_t strLength=0)
 Convert a hex string to a byte array. More...
 

Member Function Documentation

◆ getEthereumMessageHash()

void Signer::getEthereumMessageHash ( const uint8_t *  pMsg,
size_t  length,
uint8_t  hash[IOTEX_HASH_SIZE] 
)

Get the Ethereum Message hash.

Parameters
pMsgA pointer to a byte array containing the message to hash
lengthThe length of the message in bytes
hashThe generated hash

◆ getHash()

void Signer::getHash ( const uint8_t *  pData,
size_t  size,
uint8_t  hash[IOTEX_HASH_SIZE] 
)

Get the kekkac 256 hash.

Parameters
pDataA pointer to a byte array containing the data to hash
sizeThe size of the data in bytes
[out]hashThe generated hash

◆ getPublicKey()

void Signer::getPublicKey ( const uint8_t  privateKey[IOTEX_PRIVATE_KEY_SIZE],
uint8_t  publicKey[IOTEX_PUBLIC_KEY_SIZE] 
)

Get the public key from the private key.

Parameters
privateKey
[out]publicKey

◆ hex2str()

ResultCode Signer::hex2str ( const uint8_t *  hex,
size_t  hex_size,
char *  str,
size_t  str_size 
)

Convert a byte array to a hex string.

Parameters
hexA pointer to the array
hex_sizeThe array size
[out]strA pointer to a buffer where to store the hex string
str_sizeThe size of the hex string buffer
Returns
ResultCode Success or an error code

◆ signHash()

ResultCode Signer::signHash ( const uint8_t  hash[IOTEX_HASH_SIZE],
const uint8_t  private_key[IOTEX_PRIVATE_KEY_SIZE],
uint8_t  signature[IOTEX_SIGNATURE_SIZE] 
)

Sign a hash.

Parameters
hashThe hash to sign
private_keyThe private key to use for signing
[out]signatureThe signature produced
Returns
ResultCode Success or an error code

◆ signMessage()

void Signer::signMessage ( const uint8_t *  message,
size_t  size,
const uint8_t  privateKey[IOTEX_PRIVATE_KEY_SIZE],
uint8_t  signature[IOTEX_SIGNATURE_SIZE] 
)

Sign an ethereum message.

Parameters
messageA pointer to a byte array containing the message to sign
sizeThe size of the mesage
privateKeyThe private key to use for signing
[out]signatureThe signature produced

◆ str2hex()

ResultCode Signer::str2hex ( const char *  str,
uint8_t *  hex,
size_t  size,
size_t  strLength = 0 
)

Convert a hex string to a byte array.

Parameters
strThe hex string. Must be null terminated
[out]hexA pointer to a buffer where to store the bytes
sizeThe size of the buffer
strLength[opt]The string length, needs to be passed if str is not null terminated
Returns
ResultCode Success or an error code

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