Ed25519SigningSession
A live signing session holding an Ed25519 private key. createEd25519SigningSession returns it.
Import
Section titled “Import”import type { type Ed25519SigningSession = SigningSession & { readonly publicKey: Uint8Array<ArrayBuffer>; signMessage(message: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;}
Ed25519 signing session that can sign messages until end is called.
Ed25519SigningSession } from "@category-labs/mera";Members
Section titled “Members”publicKey
Section titled “publicKey”Uint8Array, the 32-byte Ed25519 public key.
signMessage(message)
Section titled “signMessage(message)”Signs an arbitrary-length message and resolves to the 64-byte Ed25519 signature (R || s). Hashing happens inside Ed25519 itself.
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 { function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession
Creates a signing session from an Ed25519 private key.
createEd25519SigningSession } from "@category-labs/mera";
const const privateKey: Uint8Array<ArrayBuffer>
privateKey = var crypto: Crypto
crypto.Crypto.getRandomValues<Uint8Array<ArrayBuffer>>(array: Uint8Array<ArrayBuffer>): Uint8Array<ArrayBuffer>
The Crypto.getRandomValues() method lets you get cryptographically strong random values.
getRandomValues(new var Uint8Array: Uint8ArrayConstructornew (length: number) => Uint8Array<ArrayBuffer> (+6 overloads)
Uint8Array(32));const const message: Uint8Array<ArrayBuffer>
message = new var TextEncoder: new () => TextEncoder
The TextEncoder interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
TextEncoder class is a global reference for import { TextEncoder } from 'node:util'
https://nodejs.org/api/globals.html#textencoder
TextEncoder().TextEncoder.encode(input?: string): Uint8Array<ArrayBuffer>
The TextEncoder.encode() method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.
encode("hello mera");
{ using using session: Ed25519SigningSession
session = function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession
Creates a signing session from an Ed25519 private key.
createEd25519SigningSession({ privateKey: Uint8Array<ArrayBufferLike>
Curve private key. Must be exactly 32 bytes and, for secp256k1, a valid
scalar.
privateKey }); await using session: Ed25519SigningSession
session.function signMessage(message: Uint8Array): Promise<Uint8Array<ArrayBuffer>>
Signs an arbitrary-length message.
signMessage(const message: Uint8Array<ArrayBuffer>
message);} // ended hereErrors
Section titled “Errors”SESSION_ENDED:signMessagewas called afterend.
See also
Section titled “See also”- createEd25519SigningSession: creates the session from a private key.
- getSolanaAddress: the address for
publicKey. - Signing sessions: how a session owns the key, and the lifecycle.