Chain API

Defines API for calculating and checking hashes.

Variables

Functions

Variables Documentation

variable type

unsigned_int eosio::public_key::type;

Type of the public key.

Type of the public key, could be either K1 or R1

variable data

std::array<char,33> eosio::public_key::data;

Bytes of the public key.

Bytes of the public key

variable type

unsigned_int eosio::signature::type;

Type of the signature.

Type of the signature, could be either K1 or R1

variable data

std::array<char,65> eosio::signature::data;

Bytes of the signature.

Bytes of the signature

Functions Documentation

function assert_sha256

void eosio::assert_sha256(
    const char * data,
    uint32_t length,
    const eosio::checksum256 & hash
)

Tests if the sha256 hash generated from data matches the provided digest.

Tests if the SHA256 hash generated from data matches the provided digest. This method is optimized to a NO-OP when in fast evaluation mode.

Parameters:

  • data - Data you want to hash
  • length - Data length
  • hash - digest to compare to

function assert_sha1

void eosio::assert_sha1(
    const char * data,
    uint32_t length,
    const eosio::checksum160 & hash
)

Tests if the sha1 hash generated from data matches the provided digest.

Tests if the SHA1 hash generated from data matches the provided digest. This method is optimized to a NO-OP when in fast evaluation mode.

Parameters:

  • data - Data you want to hash
  • length - Data length
  • hash - digest to compare to

function assert_sha512

void eosio::assert_sha512(
    const char * data,
    uint32_t length,
    const eosio::checksum512 & hash
)

Tests if the sha512 hash generated from data matches the provided digest.

Tests if the SHA512 hash generated from data matches the provided digest. This method is optimized to a NO-OP when in fast evaluation mode.

Parameters:

  • data - Data you want to hash
  • length - Data length
  • hash - digest to compare to

function assert_ripemd160

void eosio::assert_ripemd160(
    const char * data,
    uint32_t length,
    const eosio::checksum160 & hash
)

Tests if the ripemd160 hash generated from data matches the provided digest.

Tests if the RIPEMD160 hash generated from data matches the provided digest.

Parameters:

  • data - Data you want to hash
  • length - Data length
  • hash - digest to compare to

function sha256

eosio::checksum256 eosio::sha256(
    const char * data,
    uint32_t length
)

Hashes data using SHA256.

Hashes data using SHA256.

Parameters:

  • data - Data you want to hash
  • length - Data length

Returns:

eosio::checksum256 - Computed digest

function sha1

eosio::checksum160 eosio::sha1(
    const char * data,
    uint32_t length
)

Hashes data using SHA1.

Hashes data using SHA1.

Parameters:

  • data - Data you want to hash
  • length - Data length

Returns:

eosio::checksum160 - Computed digest

function sha512

eosio::checksum512 eosio::sha512(
    const char * data,
    uint32_t length
)

Hashes data using SHA512.

Hashes data using SHA512.

Parameters:

  • data - Data you want to hash
  • length - Data length

Returns:

eosio::checksum512 - Computed digest

function ripemd160

eosio::checksum160 eosio::ripemd160(
    const char * data,
    uint32_t length
)

Hashes data using RIPEMD160.

Hashes data using RIPEMD160.

Parameters:

  • data - Data you want to hash
  • length - Data length

Returns:

eosio::checksum160 - Computed digest

function recover_key

eosio::public_key eosio::recover_key(
    const eosio::checksum256 & digest,
    const eosio::signature & sig
)

Calculates the public key used for a given signature on a given digest.

Calculates the public key used for a given signature on a given digest.

Parameters:

  • digest - Digest of the message that was signed
  • sig - Signature

Returns:

eosio::public_key - Recovered public key

function assert_recover_key

void eosio::assert_recover_key(
    const eosio::checksum256 & digest,
    const eosio::signature & sig,
    const eosio::public_key & pubkey
)

Tests a given public key with the recovered public key from digest and signature.

Tests a given public key with the recovered public key from digest and signature.

Parameters:

  • digest - Digest of the message that was signed
  • sig - Signature
  • pubkey - Public key