Entropies

class index.ENTROPIES()

A class containing all supported entropy types.

exported from entropies.index

index.ENTROPIES.dictionary

type: Record<string, typeof Entropy>

Dictionary of all entropy classes by name.

static index.ENTROPIES.getClasses()

Return all entropy classes.

Returns:

typeof Entropy[] – Array of entropy classes

static index.ENTROPIES.getEntropyClass(name)

Get a specific entropy class by name.

Arguments:
  • name (string) – The entropy name

Returns:

any – The entropy class

static index.ENTROPIES.getNames()

Return all entropy names.

Returns:

string[] – Array of entropy names

static index.ENTROPIES.isEntropy(name)

Check if a name is a valid entropy.

Arguments:
  • name (string) – The entropy name

Returns:

boolean – True if the entropy exists, false otherwise

class entropy.Entropy(entropy)

Base class for entropy types.

exported from entropies.entropy

Construct an entropy instance.

Arguments:
  • entropy (string) – Entropy hex string

entropy.Entropy.entropy

type: string

entropy.Entropy.strength

type: number

entropy.Entropy.strengths

type: number[]

entropy.Entropy.getEntropy()

Get the entropy value as hex.

Returns:

string – Hex string of entropy

entropy.Entropy.getName()

Get the name of this entropy instance.

Returns:

string

entropy.Entropy.getStrength()

Get the entropy strength in bits.

Returns:

number – Strength in bits

static entropy.Entropy.areEntropyBitsEnough(entropy)

Check if entropy bits are enough (override in subclasses).

Arguments:
  • entropy (number | Uint8Array<ArrayBufferLike>) – Entropy bytes

Returns:

boolean

static entropy.Entropy.generate(strength)

Generate a new entropy string.

Arguments:
  • strength (number) – Strength in bits

Returns:

string – Generated entropy as hex

static entropy.Entropy.getName()

Get the class name (to be overridden in subclasses)

Returns:

string

static entropy.Entropy.isValid(entropy)

Check if a string is a valid entropy.

Arguments:
  • entropy (string) – Entropy hex string

Returns:

boolean – True if valid, false otherwise

static entropy.Entropy.isValidBytesStrength(bytesStrength)

Check if a byte-length strength is valid.

Arguments:
  • bytesStrength (number) – Strength in bytes

Returns:

boolean – True if valid, false otherwise

static entropy.Entropy.isValidStrength(strength)

Check if a strength in bits is valid.

Arguments:
  • strength (number) – Strength in bits

Returns:

boolean – True if valid, false otherwise

class algorand.AlgorandEntropy()

AlgorandEntropy class.

Uses entropy to generate a mnemonic phrase specific to Algorand, ensuring secure account creation with a unique checksum.

This class extends Entropy, so all base functionality is available.

exported from entropies.algorand

Extends:
  • Entropy

algorand.AlgorandEntropy.strengths

type: 256[]

List of supported entropy strengths for Algorand.

static algorand.AlgorandEntropy.getName()

Get the name of this entropy class.

Returns:

string – The name of the entropy class.

const { ENTROPIES, AlgorandEntropy, ALGORAND_ENTROPY_STRENGTHS } = await import('./src/entropies/index.js');
ENTROPIES.names()
console.log(ENTROPIES.getNames());
// Output: [ 'Algorand', 'BIP39', 'Electrum-V1', 'Electrum-V2', 'Monero' ]
ENTROPIES.classes()
console.log(ENTROPIES.getClasses());
// Output: [ [class AlgorandEntropy], [class BIP39Entropy], ... ]
ENTROPIES.getEntropyClass("Algorand")
console.log(ENTROPIES.getEntropyClass("Algorand"));
// Output: [class AlgorandEntropy]
ENTROPIES.getEntropyClass("Algorand") === AlgorandEntropy
console.log(ENTROPIES.getEntropyClass("Algorand") === AlgorandEntropy);
// Output: true
ENTROPIES.isEntropy("Algorand")
console.log(ENTROPIES.isEntropy("Algorand"));
// Output: true
ALGORAND_ENTROPY_STRENGTHS.TWO_HUNDRED_FIFTY_SIX
console.log(ALGORAND_ENTROPY_STRENGTHS.TWO_HUNDRED_FIFTY_SIX);
// Output: 256
class bip39.BIP39Entropy()

BIP39Entropy class for generating mnemonic phrases according to the BIP39 standard.

Uses entropy to generate a mnemonic phrase specific to BIP39, ensuring secure wallet creation with a checksum.

This class inherits from the Entropy base class, so all base functionality (entropy validation, generation, etc.) is available.

exported from entropies.bip39

Extends:
  • Entropy

bip39.BIP39Entropy.strengths

type: (128 | 160 | 192 | 224 | 256)[]

Supported entropy strengths for BIP39.

static bip39.BIP39Entropy.getName()

Returns the name of this entropy class.

Returns:

string – - The name of the entropy type.

const { ENTROPIES, BIP39Entropy } = await import('./src/entropies/index.js');
ENTROPIES.names()
console.log(ENTROPIES.getNames());
Output: [ 'Algorand', 'BIP39', 'Electrum-V1', 'Electrum-V2', 'Monero' ]
ENTROPIES.classes()
console.log(ENTROPIES.getClasses());
// Output: [ [class AlgorandEntropy], [class BIP39Entropy], ... ]
ENTROPIES.getEntropyClass("BIP39")
console.log(ENTROPIES.getEntropyClass("BIP39"));
Output: [class BIP39Entropy]
ENTROPIES.getEntropyClass("BIP39") === BIP39Entropy
console.log(ENTROPIES.getEntropyClass("BIP39") === BIP39Entropy);
Output: true
ENTROPIES.isEntropy("Electrum-V2")
console.log(ENTROPIES.isEntropy("Electrum-V2"));
Output: true
class monero.MoneroEntropy()

MoneroEntropy class.

Uses entropy to generate a mnemonic phrase specific to Monero, ensuring secure account creation with a unique checksum.

This class extends Entropy, so all base functionality is available.

exported from entropies.monero

Extends:
  • Entropy

monero.MoneroEntropy.strengths

type: (128 | 256)[]

List of supported entropy strengths for Monero.

static monero.MoneroEntropy.getName()

Get the name of this entropy class.

Returns:

string – The name of the entropy class.

const { ENTROPIES, MoneroEntropy, MONERO_ENTROPY_STRENGTHS } = await import('./src/entropies/index.js');
ENTROPIES.names()
console.log(ENTROPIES.getNames());
// Output: [ 'Algorand', 'BIP39', 'Electrum-V1', 'Electrum-V2', 'Monero'
ENTROPIES.classes()
console.log(ENTROPIES.getClasses());
// Output: [ [class AlgorandEntropy], [class BIP39Entropy], ..., [class MoneroEntropy] ]
ENTROPIES.getEntropyClass("Monero")
console.log(ENTROPIES.getEntropyClass("Monero"));
// Output: [class MoneroEntropy]
ENTROPIES.getEntropyClass("Monero") === MoneroEntropy
console.log(ENTROPIES.getEntropyClass("Monero") === MoneroEntropy);
// Output: true
ENTROPIES.isEntropy("Monero")
console.log(ENTROPIES.isEntropy("Monero"));
// Output: true
MONERO_ENTROPY_STRENGTHS.ONE_HUNDRED_TWENTY_EIGHT
console.log(MONERO_ENTROPY_STRENGTHS.ONE_HUNDRED_TWENTY_EIGHT);
// Output: 128
MONERO_ENTROPY_STRENGTHS.TWO_HUNDRED_FIFTY_SIX
console.log(MONERO_ENTROPY_STRENGTHS.TWO_HUNDRED_FIFTY_SIX);
// Output: 256
MoneroEntropy.strengths
console.log(MoneroEntropy.strengths);
// Output: [128, 256]
MoneroEntropy.getName()
console.log(MoneroEntropy.getName());
// Output: 'Monero'
class electrum.v1.ElectrumV1Entropy()

ElectrumV1Entropy class for generating mnemonic phrases according to the Electrum V1 standard.

Uses 128-bit entropy to generate mnemonic phrases specific to Electrum V1.

This class inherits from the Entropy base class, so all base functionality (entropy validation, generation, etc.) is available.

exported from entropies.electrum.v1

Extends:
  • Entropy

electrum.v1.ElectrumV1Entropy.strengths

type: 128[]

Supported entropy strengths for Electrum V1.

static electrum.v1.ElectrumV1Entropy.getName()

Returns the name of this entropy class.

Returns:

string – - The name of the entropy type.

const { ENTROPIES, ElectrumV1Entropy, ELECTRUM_V1_ENTROPY_STRENGTHS } = await import('./src/entropies/index.js');
ENTROPIES.names()
console.log(ENTROPIES.getNames());
// Output: [ 'Algorand', 'BIP39', 'Electrum-V1', 'Electrum-V2', 'Monero' ]
ENTROPIES.classes()
console.log(ENTROPIES.getClasses());
// Output: [ [class AlgorandEntropy], [class BIP39Entropy], [class ElectrumV1Entropy], ... ]
ENTROPIES.getEntropyClass("Electrum-V1")
console.log(ENTROPIES.getEntropyClass("Electrum-V1"));
// Output: [class ElectrumV1Entropy]
ENTROPIES.getEntropyClass("Electrum-V1") === ElectrumV1Entropy
console.log(ENTROPIES.getEntropyClass("Electrum-V1") === ElectrumV1Entropy);
// Output: true
ENTROPIES.isEntropy("Electrum-V1")
console.log(ENTROPIES.isEntropy("Electrum-V1"));
// Output: true
ELECTRUM_V1_ENTROPY_STRENGTHS.ONE_HUNDRED_TWENTY_EIGHT
console.log(ELECTRUM_V1_ENTROPY_STRENGTHS.ONE_HUNDRED_TWENTY_EIGHT);
// Output: 128
ElectrumV1Entropy.strengths
console.log(ElectrumV1Entropy.strengths);
// Output: [128]
ElectrumV1Entropy.getName()
console.log(ElectrumV1Entropy.getName());
// Output: 'Electrum-V1'
class electrum.v2.ElectrumV2Entropy()

ElectrumV2Entropy class for handling entropy used in Electrum V2 wallets.

Electrum V2 supports variable entropy sizes (132 or 264 bits), unlike V1. This ensures compatibility with the Electrum V2 mnemonic scheme.

Inherits core functionality such as entropy validation and generation from the Entropy base class.

exported from entropies.electrum.v2

Extends:
  • Entropy

electrum.v2.ElectrumV2Entropy.strengths

type: number[]

Supported entropy strengths for Electrum V2.

static electrum.v2.ElectrumV2Entropy.areEntropyBitsEnough(entropy)

Verify if the provided entropy contains enough bits for Electrum V2.

Arguments:
  • entropy (number | Uint8Array<ArrayBufferLike>) – Entropy bytes or integer value.

Returns:

boolean – True if enough entropy bits, false otherwise.

static electrum.v2.ElectrumV2Entropy.generate(strength)

Generate a random Electrum V2 entropy value.

Arguments:
  • strength (number) – Entropy strength in bits (132 or 264).

Returns:

string – Hex-encoded entropy string.

static electrum.v2.ElectrumV2Entropy.getName()

Returns the name of this entropy class.

Returns:

string – - The name of the entropy type.

static electrum.v2.ElectrumV2Entropy.isValid(entropy)

Validate whether the given entropy string is valid for Electrum V2.

Arguments:
  • entropy (string) – The entropy value in hex.

Returns:

boolean – True if valid, false otherwise.

static electrum.v2.ElectrumV2Entropy.isValidStrength(strength)

Check if a given entropy strength is valid for Electrum V2.

Arguments:
  • strength (number) – The entropy strength in bits.

Returns:

boolean – True if the strength is valid, false otherwise.

const { ENTROPIES, ElectrumV2Entropy, ELECTRUM_V2_ENTROPY_STRENGTHS } = await import('./src/entropies/index.js');
ENTROPIES.names()
console.log(ENTROPIES.getNames());
// Output: [ 'Algorand', 'BIP39', 'Electrum-V1', 'Electrum-V2', 'Monero' ]
ENTROPIES.classes()
console.log(ENTROPIES.getClasses());
// Output: [ [class AlgorandEntropy], [class BIP39Entropy], [class ElectrumV1Entropy], [class ElectrumV2Entropy], ... ]
ENTROPIES.getEntropyClass("Electrum-V2")
console.log(ENTROPIES.getEntropyClass("Electrum-V2"));
// Output: [class ElectrumV2Entropy]
ENTROPIES.getEntropyClass("Electrum-V2") === ElectrumV2Entropy
console.log(ENTROPIES.getEntropyClass("Electrum-V2") === ElectrumV2Entropy);
// Output: true
ENTROPIES.isEntropy("Electrum-V2")
console.log(ENTROPIES.isEntropy("Electrum-V2"));
// Output: true
ELECTRUM_V2_ENTROPY_STRENGTHS.ONE_HUNDRED_THIRTY_TWO
console.log(ELECTRUM_V2_ENTROPY_STRENGTHS.ONE_HUNDRED_THIRTY_TWO);
// Output: 132
ELECTRUM_V2_ENTROPY_STRENGTHS.TWO_HUNDRED_SIXTY_FOUR
console.log(ELECTRUM_V2_ENTROPY_STRENGTHS.TWO_HUNDRED_SIXTY_FOUR);
// Output: 264
ElectrumV2Entropy.strengths
console.log(ElectrumV2Entropy.strengths);
// Output: [132, 264]
ElectrumV2Entropy.getName()
console.log(ElectrumV2Entropy.getName());
// Output: 'Electrum-V2'