Skip to content
Get startedGetting started →

createEd25519SigningSession

Creates a signing session from an Ed25519 private key.

import {
function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession

Creates a signing session from an Ed25519 private key.

@paramoptions - Signing session inputs.

@returnsA live Ed25519 signing session.

@throwsMeraError with code INPUT_INVALID when privateKey is not 32 bytes.

createEd25519SigningSession
} from "@category-labs/mera";
import {
function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession

Creates a signing session from an Ed25519 private key.

@paramoptions - Signing session inputs.

@returnsA live Ed25519 signing session.

@throwsMeraError with code INPUT_INVALID when privateKey is not 32 bytes.

createEd25519SigningSession
,
function getSolanaAddress(publicKey: Uint8Array): SolanaAddress

Derives the base58-encoded Solana address for an Ed25519 public key.

@parampublicKey - A 32-byte Ed25519 public key.

@returnsThe base58-encoded Solana address.

@throwsMeraError with code INPUT_INVALID when publicKey is not 32 bytes.

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.

MDN Reference

getRandomValues
(new
var Uint8Array: Uint8ArrayConstructor
new (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.

MDN Reference

TextEncoder class is a global reference for import { TextEncoder } from 'node:util' https://nodejs.org/api/globals.html#textencoder

@sincev11.0.0

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.

MDN Reference

encode
("hello mera");
const
const session: Ed25519SigningSession
session
=
function createEd25519SigningSession({ privateKey, }: CreateSigningSessionOptions): Ed25519SigningSession

Creates a signing session from an Ed25519 private key.

@paramoptions - Signing session inputs.

@returnsA live Ed25519 signing session.

@throwsMeraError with code INPUT_INVALID when privateKey is not 32 bytes.

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.

@parampublicKey - A 32-byte Ed25519 public key.

@returnsThe base58-encoded Solana address.

@throwsMeraError with code INPUT_INVALID when publicKey is not 32 bytes.

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.

@parammessage - The message to sign; hashing happens inside Ed25519 itself.

@returnsA 64-byte Ed25519 signature (R || s).

@throwsMeraError with code SESSION_ENDED after end has been called.

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
();

options is a CreateSigningSessionOptions.

  • Type: Uint8Array
  • Required

Ed25519 private key (the 32-byte seed).

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.