World all
- Imports:
- interface
hermes:binary/api
- interface
hermes:crypto/api
- interface
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
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
tuple b256
256 bit value
Tuple Fields
tuple b512
512 bit value
Tuple Fields
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
#### `type b256` [`b256`](#b256)
#### `type b512` [`b512`](#b512)
Errors that can occurs.
Enum Cases
-
The prefix is longer than the maximum allowed length, max is 3.
-
The mnemonic length is not a multiple of 3 or not in the range of 12 - 24.
-
A word in the mnemonic is not found in the word list.
-
The mnemonic is invalid.
-
The derivational path is invalid.
-
Failed to generate entropy.
type bip32-ed25519-private-key
bip32-ed25519 Private Key
type bip32-ed25519-extended-private-key
bip32-ed25519 Extended Private Key
type bip32-ed25519-public-key
bip32-ed25519 Public Key
type bip32-ed25519-signature
bip32-ed25519 Signature
type mnemonic-phrase
Mnemonic
type passphrase
Passphrase
type path
string
Derivation path
type prefix
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
- result<
mnemonic-phrase
,errno
>
[constructor]bip32-ed25519: func
Create a new BIP32-Ed25519 Crypto resource
Parameters
mnemonic-phrase
: BIP39 mnemonic.passphrase
: Optional BIP39 passphrase.
Params
mnemonic
:mnemonic-phrase
passphrase
: option<passphrase
>
Return values
- own<
bip32-ed25519
>
[method]bip32-ed25519.public-key: func
Get the public key for this private key.
Params
self
: borrow<bip32-ed25519
>
Return values
[method]bip32-ed25519.sign-data: func
Sign data with the Private key, and return it.
Parameters
data
: The data to sign.
Params
self
: borrow<bip32-ed25519
>data
:bstr
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
self
: borrow<bip32-ed25519
>data
:bstr
sig
:bip32-ed25519-signature
Return values
[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
self
: borrow<bip32-ed25519
>path
:path
Return values
- own<
bip32-ed25519
>