Serializes a Serializable value to its BCS representation.
This function is the TypeScript SDK equivalent of bcs::to_bytes in Move.
the BCS representation of the Serializable instance as a byte buffer.
Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.
A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.
Create a new PrivateKey instance from a Uint8Array or String.
HexInput (string or Uint8Array)
Optionalstrict: booleanIf true, private key must AIP-80 compliant.
Static ReadonlyLENGTHLength of an Ed25519 private key
Static ReadonlySLIP_The Ed25519 key seed to use for BIP-32 compatibility See more https://github.com/satoshilabs/slips/blob/master/slip-0010.md
Overwrites the underlying private-key byte buffer with random bytes and then zeros. After calling this method the key can no longer sign or derive a public key.
SECURITY: This is a best-effort window-narrowing tool, NOT a true
zeroization guarantee. In JavaScript, four classes of copies cannot be
reached from user code and so survive clear():
toString(),
toHexString(), or bcsToHex().toString() is an immutable string
in the heap. The language provides no API to overwrite string
memory; it is reclaimed only when GC collects it.@noble/curves
expands the private key into scalar BigInt field elements, which
are also immutable in V8/JSC/Hermes. Even if noble explicitly zeroed
its own byte copies after use, the BigInt intermediates persist.Uint8Array we zeroed may have stale copies sitting in survivor
space until the next cycle reclaims them.This method zeros the SDK's own Uint8Array (the most reachable
copy), but downstream consumers should treat it as a hardening signal,
not a guarantee. If you need real key-material hygiene, prefer
non-extractable crypto.subtle keys (where the underlying algorithm
is supported by the host runtime), a WASM-backed crypto library, or
hardware-backed keys (passkeys / secure enclave / HSM).
To minimize the size of the unreachable-copy set, avoid calling
toString() / toHexString() on private keys at all in long-lived
processes — the byte form is what gets cleared.
Returns whether the private key has been cleared from memory.
true if the key has been cleared, false otherwise
Derive the Ed25519PublicKey for this private key.
Ed25519PublicKey - The derived public key corresponding to the private key.
Sign the given message with the private key. This function generates a digital signature for the specified message, ensuring its authenticity and integrity.
A message as a string or Uint8Array in HexInput format.
A digital signature for the provided message.
The polymorphic message: HexInput input is ambiguous — a
bare even-length string of hex characters (e.g., "cafe") is signed
as the 2 bytes [0xCA, 0xFE], not as 4 UTF-8 text bytes. Use
signBytes for Uint8Array input or signText for
string input; both are unambiguous. See
convertSigningMessage for the full legacy rule.
Sign exactly the bytes of message. The input is interpreted as raw
bytes regardless of what they encode. Pair with
Ed25519PublicKey.verifyBytes.
The exact bytes to sign.
A digital signature for the provided bytes.
Sign the UTF-8 encoding of message. The input is always treated as
text — there is no hex/text heuristic. Pair with
Ed25519PublicKey.verifyText.
The text to sign.
A digital signature for the UTF-8 bytes of the provided text.
Get the private key as a hex string with the 0x prefix.
SECURITY: This produces an immutable JS string containing the key
material in hex. Strings cannot be zeroed by clear() (see the
clear() JSDoc for the four classes of unreachable copies). Avoid
calling this method on long-lived Ed25519PrivateKey instances in
processes where memory hygiene matters; prefer toUint8Array(),
which returns a clearable Uint8Array.
string representation of the private key.
StaticfromDerives a private key from a mnemonic seed phrase using a specified BIP44 path. To derive multiple keys from the same phrase, change the path
IMPORTANT: Ed25519 supports hardened derivation only, as it lacks a key homomorphism, making non-hardened derivation impossible.
The BIP44 path used for key derivation.
The mnemonic seed phrase from which the key will be derived.
StaticgenerateGenerate a new random private key.
Ed25519PrivateKey A newly generated Ed25519 private key.
StaticisDetermines if the provided private key is an instance of Ed25519PrivateKey.
The private key to check.
A boolean indicating whether the private key is an Ed25519PrivateKey.
Get the private key as a AIP-80 compliant hex string.
SECURITY: Same caveat as toString() — produces an immutable JS string
containing the key material; cannot be zeroed by clear().
AIP-80 compliant string representation of the private key.
Returns the hex string representation of the Serializable value without the 0x prefix.
the hex format as a string without 0x prefix.
Staticdeserialize
Represents the private key of an Ed25519 key pair.