Crypto API Reference

The Crypto API provides an abstraction layer with the cryptography implementation.

ED25519 Keypair

struct iota_keypair_t

Ed25519 Keypair.

Public Members

uint8_t pub[ED_PUBLIC_KEY_BYTES]

32 bytes public key

uint8_t priv[ED_PRIVATE_KEY_BYTES]

64 bytes private key

Random Bytes

void iota_crypto_randombytes(uint8_t *const buf, const size_t len)

fill-in random bytes into the given byte buffer.

Parameters
  • buf[out] A buffer holds random bytes

  • len[in] The length of byte buffer

ED25519 keypair

void iota_crypto_keypair(uint8_t const seed[], iota_keypair_t *keypair)

derives key pair from a given seed(IOTA_SEED_BYTES)

Parameters
  • seed[in] A given seed with length of IOTA_SEED_BYTES

  • keypair[out] A keypair derived from the seed

ED25519 Signature

int iota_crypto_sign(uint8_t const priv_key[], uint8_t msg[], size_t msg_len, uint8_t signature[])

signs message by the given private key

Parameters
  • priv_key[in] The private key

  • msg[in] A byte buffer holds the message data

  • msg_len[in] The length of the message

  • signature[out] The output signature

Returns

int 0 on successful

HMAC-SHA-256

int iota_crypto_hmacsha256(uint8_t const secret_key[], uint8_t msg[], size_t msg_len, uint8_t auth[])

HMAC-SHA-256 interface.

Parameters
  • secret_key[in] The private/secret key

  • msg[in] A buffer holds message data

  • msg_len[in] The length of message

  • auth[out] The output authentication

Returns

int 0 on successful

HMAC-SHA-512

int iota_crypto_hmacsha512(uint8_t const secret_key[], uint8_t msg[], size_t msg_len, uint8_t auth[])

HMAC-SHA-512 interface.

Parameters
  • secret_key[in] The private/secret key

  • msg[in] A buffer holds message data

  • msg_len[in] The length of message

  • auth[out] The output authentication

Returns

int 0 on successful

Blake2b Sum

int iota_blake2b_sum(uint8_t const msg[], size_t msg_len, uint8_t out[], size_t out_len)

Blake2b hash function.

Parameters
  • msg[in] The message to hash

  • msg_len[in] The length of message

  • out[out] An output hash

  • out_len[out] The length of output hash

Returns

int 0 on success