World all

Import interface hermes:binary/api

Binary Data API

Binary Data types and functions.

Permissions

This API is ALWAYS available. cspell: words Binary API Interface - Imports ONLY


Types

type bstr

bstr

Binary String (bstr) is a list of bytes. This type is used to indicate the data is an arbitrary array of bytes.

tuple b128

128 bit value

Tuple Fields
  • 0: u64
  • 1: u64

tuple b256

256 bit value

Tuple Fields
  • 0: u64
  • 1: u64
  • 2: u64
  • 3: u64

tuple b512

512 bit value

Tuple Fields
  • 0: u64
  • 1: u64
  • 2: u64
  • 3: u64
  • 4: u64
  • 5: u64
  • 6: u64
  • 7: u64

Import interface hermes:crypto/api

Crypto API

Crypto API functionality exposed to the Hermes WASM Modules.

Permissions

This API is ALWAYS available. Crypto API Interface


Types

type bstr

bstr

#### `type b256` [`b256`](#b256)

#### `type b512` [`b512`](#b512)

#### `enum errno`

Errors that can occurs.

Enum Cases
  • prefix-too-long

  • invalid-mnemonic-length

    The prefix is longer than the maximum allowed length, max is 3.

  • word-not-found

    The mnemonic length is not a multiple of 3 or not in the range of 12 - 24.

  • invalid-mnemonic

    A word in the mnemonic is not found in the word list.

  • invalid-derivational-path

    The mnemonic is invalid.

  • generate-entropy-failed

    The derivational path is invalid.

  • unsupported-language

    Failed to generate entropy.

type bip32-ed25519-private-key

b256

bip32-ed25519 Private Key

type bip32-ed25519-extended-private-key

b512

bip32-ed25519 Extended Private Key

type bip32-ed25519-public-key

b256

bip32-ed25519 Public Key

type bip32-ed25519-signature

b512

bip32-ed25519 Signature

type mnemonic-phrase

mnemonic-phrase

Mnemonic

type passphrase

passphrase

Passphrase

type path

string

Derivation path

type prefix

prefix

#### `resource bip32-ed25519`


Functions

generate-mnemonic: func

Generate BIP39 Mnemonic Function

Generate a new BIP39 mnemonic phrase with the given size, prefix and language.

Parameters

size : The size of the mnemonic. Must be a multiple of 3 and in the range of 12 - 24. prefix : The prefix for the mnemonic. Must be a list of 1 - 3 words. language : Optional. The language to use for the mnemonic. If not provided, the default language is used.

Returns

  • Either a list of mnemonic words.
  • Or an error if the mnemonic could not be generated:
  • prefix-too-long : The prefix is longer than the maximum allowed length, max is 3.
  • invalid-mnemonic-length : The mnemonic length is not a multiple of 3 or not in the range of 12 - 24.
  • word-not-found : A word in the mnemonic is not found in the word list.
  • generate-entropy-failed : Failed to generate entropy.
Params
Return values

[constructor]bip32-ed25519: func

Create a new BIP32-Ed25519 Crypto resource

Parameters

Params
Return values

[method]bip32-ed25519.public-key: func

Get the public key for this private key.

Params
Return values

[method]bip32-ed25519.sign-data: func

Sign data with the Private key, and return it.

Parameters

  • data : The data to sign.
Params
Return values

[method]bip32-ed25519.check-sig: func

Check a signature on a set of data.

Parameters

  • data : The data to check.
  • sig : The signature to check.

Returns

  • true : Signature checked OK.
  • false : Signature check failed.
Params
Return values
  • bool

[method]bip32-ed25519.derive: func

Derive a new private key from the current private key.

Parameters

  • path : Derivation path.

Note: uses BIP32 HD key derivation.

Params
Return values