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.
A HexInput (string or Uint8Array)
Optionalstrict: boolean
If true, private key must AIP-80 compliant.
Static ReadonlyLENGTHLength of SLH-DSA-SHA2-128s private key (48 bytes: SK seed + PRF seed + PK seed)
Overwrites the 48-byte seed and the expanded 64-byte noble secret key with random bytes and then zeros. After calling this method the key can no longer sign, derive a public key, or be serialized.
SECURITY: This is a best-effort window-narrowing tool, NOT a true
zeroization guarantee. It has the same limits as
Ed25519PrivateKey.clear(): strings already produced by
toString() / toHexString() / toAIP80String(), intermediates inside
@noble/post-quantum, JIT register/stack residue and GC-relocated copies
cannot be reached from JavaScript and survive clear().
Returns whether the private key has been cleared from memory.
true if the key has been cleared, false otherwise
Derive the SlhDsaSha2128sPublicKey from this private key.
PERFORMANCE: the first call (or first sign()) derives PK.root, which takes ~0.5 s; the
result is cached for later calls.
SlhDsaSha2128sPublicKey The derived public key.
Sign the given message with the private key. This function generates a cryptographic signature for the provided message.
Produces a FIPS 205 pure SLH-DSA-SHA2-128s signature with an empty context, using the
deterministic variant (opt_rand = PK.seed) like the Aptos node and the other Aptos SDKs.
PERFORMANCE: blocks the calling thread for ~3 s (plus ~0.5 s on the first call to derive PK.root). See the class documentation for running it in a worker.
A message in HexInput format to be signed.
Signature - The generated signature for the provided message.
Redacted JSON representation, so JSON.stringify of this key (or of an
account holding it) does not dump the secret seed bytes. Use
toAIP80String() or bcsToBytes() to export the key deliberately.
Get the private key as a string representation.
SECURITY: This returns the AIP-80 encoded private key, i.e. the secret
itself, as an immutable JS string that clear() cannot zero. Avoid
calling it on long-lived keys and never log it. JSON.stringify and Node's
util.inspect (console.log) are redacted, but template literals and
string concatenation call toString() and are not.
string representation of the private key
StaticgenerateGenerate a new random private key. The private key contains the 48-byte three seeds (SK seed + PRF seed + PK seed). The public key can be derived from these seeds using the publicKey() method.
SlhDsaSha2128sPrivateKey - A newly generated SLH-DSA-SHA2-128s private key.
StaticisDetermines if the provided private key is an instance of SlhDsaSha2128sPrivateKey.
The private key to be checked.
Get the private key as a AIP-80 compliant hex string.
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 a SLH-DSA-SHA2-128s private key, providing functionality to create, sign messages, derive public keys, and serialize/deserialize the key.
PERFORMANCE: SLH-DSA is slow in pure JavaScript and every operation below runs synchronously on the calling thread. Rough single-core timings with
@noble/post-quantum:generate(),deserialize(): cheap; only the 48-byte seed is stored.publicKey()orsign(): ~0.5 s to derive PK.root (a full top-layer XMSS tree). The result is cached, so later calls skip it. Creating aSingleKeyAccountcallspublicKey().sign(): ~3 s.SlhDsaSha2128sPublicKey.verifySignature(): a few ms.In a browser or a latency-sensitive server, run signing in a Web Worker /
worker_threadsworker (pass the AIP-80 string or the 48 bytes fromtoUint8Array(), and send backsignature.toUint8Array()) instead of on the main thread.Signing is deterministic (FIPS 205
opt_rand = PK.seed), matching the Aptos node and the other Aptos SDKs: the same key and message always produce the same signature.