Skip to main content
@tevm/voltaire
@tevm/voltaire / crypto/Bip39

crypto/Bip39

Classes

Bip39Error

Defined in: src/crypto/Bip39/errors.js:21 Base error for BIP-39 operations

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Extends

Extended by

Constructors

Constructor
new Bip39Error(message?, options?): Bip39Error
Defined in: src/crypto/Bip39/errors.js:26
Parameters
message?
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
Bip39Error
Overrides
CryptoError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
CryptoError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
CryptoError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
CryptoError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
CryptoError.docsPath
name
name: string
Defined in: src/crypto/Bip39/errors.js:33
Inherited from
CryptoError.name

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
CryptoError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
CryptoError.toJSON

InvalidEntropyError

Defined in: src/crypto/Bip39/errors.js:87 Error thrown when entropy is invalid

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Extends

Constructors

Constructor
new InvalidEntropyError(message?, options?): InvalidEntropyError
Defined in: src/crypto/Bip39/errors.js:92
Parameters
message?
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidEntropyError
Overrides
Bip39Error.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
Bip39Error.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
Bip39Error.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
Bip39Error.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
Bip39Error.docsPath
name
name: string
Defined in: src/crypto/Bip39/errors.js:99
Inherited from
Bip39Error.name

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
Bip39Error.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
Bip39Error.toJSON

InvalidMnemonicError

Defined in: src/crypto/Bip39/errors.js:53 Error thrown when mnemonic is invalid

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Extends

Constructors

Constructor
new InvalidMnemonicError(message?, options?): InvalidMnemonicError
Defined in: src/crypto/Bip39/errors.js:58
Parameters
message?
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
InvalidMnemonicError
Overrides
InvalidFormatError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidFormatError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
Inherited from
InvalidFormatError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
Inherited from
InvalidFormatError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
Inherited from
InvalidFormatError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidFormatError.expected
name
name: string
Defined in: src/crypto/Bip39/errors.js:67
Inherited from
InvalidFormatError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidFormatError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidFormatError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidFormatError.toJSON

Type Aliases

Entropy

Entropy = Uint8Array
Defined in: src/crypto/Bip39/EntropyType.ts:13 Entropy bytes for BIP-39 mnemonic generation

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


Mnemonic

Mnemonic = string
Defined in: src/crypto/Bip39/MnemonicType.ts:13 BIP-39 mnemonic phrase (12-24 words)

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


Seed

Seed = Uint8Array
Defined in: src/crypto/Bip39/SeedType.ts:13 BIP-39 seed (64 bytes / 512 bits)

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Variables

Bip39

const Bip39: object
Defined in: src/crypto/Bip39/Bip39.js:59 BIP-39 Mnemonic Implementation Provides mnemonic generation, validation, and seed derivation following the BIP-39 standard for deterministic key generation.

Type Declaration

assertValidMnemonic()
assertValidMnemonic: (mnemonic, wl?) => void
Validate mnemonic or throw error
Parameters
mnemonic
string Mnemonic phrase to validate
wl?
string[] = wordlist Optional wordlist (defaults to English)
Returns
void
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If mnemonic is invalid
Example
ENTROPY_128
ENTROPY_128: number
128 bits entropy = 12 words
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
ENTROPY_160
ENTROPY_160: number
160 bits entropy = 15 words
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
ENTROPY_192
ENTROPY_192: number
192 bits entropy = 18 words
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
ENTROPY_224
ENTROPY_224: number
224 bits entropy = 21 words
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
ENTROPY_256
ENTROPY_256: number
256 bits entropy = 24 words
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
entropyToMnemonic()
entropyToMnemonic: (entropy, wl?) => string
Generate mnemonic from custom entropy
Parameters
entropy
Entropy Entropy bytes (16, 20, 24, 28, or 32 bytes)
wl?
string[] = wordlist Optional wordlist (defaults to English)
Returns
string Mnemonic phrase
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If entropy size is invalid
Throws
If conversion fails
Example
generateMnemonic()
generateMnemonic: (strength?, wl?) => string
Generate a BIP-39 mnemonic phrase
Parameters
strength?
Entropy strength in bits (128=12 words, 256=24 words) 128 | 160 | 192 | 224 | 256
wl?
string[] = wordlist Optional wordlist (defaults to English)
Returns
string Mnemonic phrase
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If mnemonic generation fails
Example
getEntropyBits()
getEntropyBits: (wordCount) => number
Get entropy bits from word count
Parameters
wordCount
number Number of words
Returns
number Entropy in bits
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If word count is invalid
Example
getWordCount()
getWordCount: (entropyBits) => number
Get word count from entropy bits
Parameters
entropyBits
number Entropy in bits
Returns
number Number of words in mnemonic
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If entropy bits value is invalid
Example
mnemonicToSeed()
mnemonicToSeed: (mnemonic, passphrase?) => Promise<Seed>
Convert mnemonic to seed (async)
Parameters
mnemonic
string BIP-39 mnemonic phrase
passphrase?
string = "" Optional passphrase for additional security
Returns
Promise<Seed> 64-byte seed
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If mnemonic is invalid
Throws
If seed derivation fails
Example
mnemonicToSeedSync()
mnemonicToSeedSync: (mnemonic, passphrase?) => Seed
Convert mnemonic to seed (sync)
Parameters
mnemonic
string BIP-39 mnemonic phrase
passphrase?
string = "" Optional passphrase for additional security
Returns
Seed 64-byte seed
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
If mnemonic is invalid
Throws
If seed derivation fails
Example
SEED_LENGTH
SEED_LENGTH: number
BIP-39 seed length (512 bits / 64 bytes)
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example
validateMnemonic()
validateMnemonic: (mnemonic, wl?) => boolean
Validate a BIP-39 mnemonic phrase
Parameters
mnemonic
string Mnemonic phrase to validate
wl?
string[] = wordlist Optional wordlist (defaults to English)
Returns
boolean True if valid, false otherwise
See
https://voltaire.tevm.sh/crypto for crypto documentation
Since
0.0.0
Throws
Example

Example


ENTROPY_128

const ENTROPY_128: 128 = 128
Defined in: src/crypto/Bip39/constants.js:13 128 bits entropy = 12 words

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


ENTROPY_160

const ENTROPY_160: 160 = 160
Defined in: src/crypto/Bip39/constants.js:27 160 bits entropy = 15 words

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


ENTROPY_192

const ENTROPY_192: 192 = 192
Defined in: src/crypto/Bip39/constants.js:41 192 bits entropy = 18 words

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


ENTROPY_224

const ENTROPY_224: 224 = 224
Defined in: src/crypto/Bip39/constants.js:55 224 bits entropy = 21 words

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


ENTROPY_256

const ENTROPY_256: 256 = 256
Defined in: src/crypto/Bip39/constants.js:69 256 bits entropy = 24 words

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example


SEED_LENGTH

const SEED_LENGTH: 64 = 64
Defined in: src/crypto/Bip39/constants.js:84 BIP-39 seed length (512 bits / 64 bytes)

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example

Functions

assertValidMnemonic()

assertValidMnemonic(mnemonic, wl?): void
Defined in: src/crypto/Bip39/assertValidMnemonic.js:24 Validate mnemonic or throw error

Parameters

mnemonic
string Mnemonic phrase to validate
wl?
string[] = wordlist Optional wordlist (defaults to English)

Returns

void

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If mnemonic is invalid

Example


entropyToMnemonic()

entropyToMnemonic(entropy, wl?): string
Defined in: src/crypto/Bip39/entropyToMnemonic.js:22 Generate mnemonic from custom entropy

Parameters

entropy
Entropy Entropy bytes (16, 20, 24, 28, or 32 bytes)
wl?
string[] = wordlist Optional wordlist (defaults to English)

Returns

string Mnemonic phrase

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If entropy size is invalid

Throws

If conversion fails

Example


generateMnemonic()

generateMnemonic(strength?, wl?): string
Defined in: src/crypto/Bip39/generateMnemonic.js:23 Generate a BIP-39 mnemonic phrase

Parameters

strength?
Entropy strength in bits (128=12 words, 256=24 words) 128 | 160 | 192 | 224 | 256
wl?
string[] = wordlist Optional wordlist (defaults to English)

Returns

string Mnemonic phrase

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If mnemonic generation fails

Example


getEntropyBits()

getEntropyBits(wordCount): number
Defined in: src/crypto/Bip39/getEntropyBits.js:18 Get entropy bits from word count

Parameters

wordCount
number Number of words

Returns

number Entropy in bits

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If word count is invalid

Example


getWordCount()

getWordCount(entropyBits): number
Defined in: src/crypto/Bip39/getWordCount.js:18 Get word count from entropy bits

Parameters

entropyBits
number Entropy in bits

Returns

number Number of words in mnemonic

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If entropy bits value is invalid

Example


mnemonicToSeed()

mnemonicToSeed(mnemonic, passphrase?): Promise<Seed>
Defined in: src/crypto/Bip39/mnemonicToSeed.js:21 Convert mnemonic to seed (async)

Parameters

mnemonic
string BIP-39 mnemonic phrase
passphrase?
string = "" Optional passphrase for additional security

Returns

Promise<Seed> 64-byte seed

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If mnemonic is invalid

Throws

If seed derivation fails

Example


mnemonicToSeedSync()

mnemonicToSeedSync(mnemonic, passphrase?): Seed
Defined in: src/crypto/Bip39/mnemonicToSeedSync.js:21 Convert mnemonic to seed (sync)

Parameters

mnemonic
string BIP-39 mnemonic phrase
passphrase?
string = "" Optional passphrase for additional security

Returns

Seed 64-byte seed

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

If mnemonic is invalid

Throws

If seed derivation fails

Example


validateMnemonic()

validateMnemonic(mnemonic, wl?): boolean
Defined in: src/crypto/Bip39/validateMnemonic.js:22 Validate a BIP-39 mnemonic phrase

Parameters

mnemonic
string Mnemonic phrase to validate
wl?
string[] = wordlist Optional wordlist (defaults to English)

Returns

boolean True if valid, false otherwise

See

https://voltaire.tevm.sh/crypto for crypto documentation

Since

0.0.0

Throws

Example