Secp256k1SigningSession
A live signing session holding a secp256k1 private key. createSecp256k1SigningSession returns it.
Import
Section titled “Import”import type { Secp256k1SigningSession } from "@category-labs/mera";Members
Section titled “Members”publicKey
Section titled “publicKey”Uint8Array, 65 bytes, the uncompressed secp256k1 public key with the 0x04 prefix.
signDigest(digest32)
Section titled “signDigest(digest32)”Signs a 32-byte digest without prehashing it and resolves to a Secp256k1Signature: compact (64 bytes, r || s, low-S: s lies in the lower half of the curve order) plus recovery (0 or 1).
Zeroes the session-owned private-key copy and permanently ends the session; later signing throws SESSION_ENDED.
[Symbol.dispose]()
Section titled “[Symbol.dispose]()”Calls end, so a using declaration ends the session when its scope exits:
import { createSecp256k1SigningSession } from "@category-labs/mera";
const privateKey = crypto.getRandomValues(new Uint8Array(32));const digest32 = new Uint8Array(32);
{ using session = createSecp256k1SigningSession({ privateKey }); await session.signDigest(digest32);} // ended hereErrors
Section titled “Errors”INPUT_INVALID:digest32is not 32 bytes.SESSION_ENDED:signDigestwas called afterend.
See also
Section titled “See also”- createSecp256k1SigningSession: creates the session from a private key.
- getEvmAddress: the address for
publicKey. - toViemAccount: a viem account backed by the session.
- Signing sessions: how a session owns the key, and the lifecycle.