createEd25519SigningSession
Creates a signing session from an Ed25519 private key.
Import
Section titled “Import”import { function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession
Creates a signing session from an Ed25519 private key.
createEd25519SigningSession } from "@category-labs/mera";import { function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession
Creates a signing session from an Ed25519 private key.
createEd25519SigningSession, function getSolanaAddress(publicKey: Uint8Array): SolanaAddress
Derives the base58-encoded Solana address for an Ed25519 public key.
getSolanaAddress,} 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");
const const 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 });
const const address: SolanaAddress
address = function getSolanaAddress(publicKey: Uint8Array): SolanaAddress
Derives the base58-encoded Solana address for an Ed25519 public key.
getSolanaAddress(const session: Ed25519SigningSession
session.publicKey: Uint8Array<ArrayBuffer>
32-byte Ed25519 public key for the session.
publicKey);const const signature: Uint8Array<ArrayBuffer>
signature = await const session: Ed25519SigningSession
session.function signMessage(message: Uint8Array): Promise<Uint8Array<ArrayBuffer>>
Signs an arbitrary-length message.
signMessage(const message: Uint8Array<ArrayBuffer>
message);
const session: Ed25519SigningSession
session.function end(): void
Zeroes the session-owned private-key copy; later signing throws
SESSION_ENDED.
end();Parameters
Section titled “Parameters”options is a CreateSigningSessionOptions.
options.privateKey
Section titled “options.privateKey”- Type:
Uint8Array - Required
Ed25519 private key (the 32-byte seed).
Returns
Section titled “Returns”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";
type type ReturnType = SigningSession & { readonly publicKey: Uint8Array<ArrayBuffer>; signMessage(message: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;}
ReturnType = 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;A live Ed25519SigningSession.
Errors
Section titled “Errors”INPUT_INVALID:privateKeyis not 32 bytes.
See also
Section titled “See also”- getSolanaAddress: the address for
session.publicKey. - Signing sessions: how a session owns the key, and the lifecycle.