createSecp256k1SigningSession
Creates a signing session from a secp256k1 private key.
Import
Section titled “Import”import { createSecp256k1SigningSession } from "@category-labs/mera";import { createSecp256k1SigningSession, getEvmAddress,} from "@category-labs/mera";
const privateKey = crypto.getRandomValues(new Uint8Array(32));const digest32 = new Uint8Array(32);
const session = createSecp256k1SigningSession({ privateKey });
const address = getEvmAddress(session.publicKey);const { compact, recovery } = await session.signDigest(digest32);
session.end();Parameters
Section titled “Parameters”options is a CreateSigningSessionOptions.
options.privateKey
Section titled “options.privateKey”- Type:
Uint8Array - Required
secp256k1 private key. Must be exactly 32 bytes and a valid scalar, an integer inside the curve’s private-key range.
Returns
Section titled “Returns”A live Secp256k1SigningSession.
Errors
Section titled “Errors”INPUT_INVALID:privateKeyis not 32 bytes or not a valid secp256k1 scalar.
See also
Section titled “See also”- getEvmAddress: the address for
session.publicKey. - toViemAccount: a viem account backed by the session.
- Signing sessions: how a session owns the key, and the lifecycle.