solana_kit_keys library

Ed25519 key and signature primitives for the Solana Kit Dart SDK.

Exports key-pair generation, public/private key types, and Solana compatible signature byte wrappers.

Generate keys and verify signatures

Use the key primitives when you need raw Ed25519 key material or signature verification outside the higher-level signer abstractions.

import 'dart:typed_data';

import 'package:solana_kit_keys/solana_kit_keys.dart';

void main() {
  final keyPair = generateKeyPair();
  final message = Uint8List.fromList([1, 2, 3]);

  final signature = signBytes(keyPair.privateKey, message);
  final verified = verifySignature(keyPair.publicKey, signature, message);

  print(verified);
}

This package is the right layer when you need direct access to key bytes, public-key derivation, or low-level signature helpers.

Classes

KeyPair
An Ed25519 key pair consisting of a 32-byte private key and a 32-byte public key.

Extension Types

Signature
A base58-encoded 64-byte Ed25519 signature.
SignatureBytes
A raw 64-byte Ed25519 signature as bytes.

Functions

assertIsPrivateKey(Uint8List bytes) → void
Validates that bytes represents a valid Ed25519 private key.
assertIsSignature(String putativeSignature) → void
Asserts that putativeSignature is a valid base58-encoded Ed25519 signature.
assertIsSignatureBytes(Uint8List putativeSignatureBytes) → void
Asserts that putativeSignatureBytes is a valid Ed25519 signature (exactly 64 bytes).
constantTimeEqual(Uint8List a, Uint8List b) bool
Compares two byte arrays in constant time to prevent timing attacks.
createKeyPairFromBytes(Uint8List bytes) KeyPair
Creates a KeyPair from a 64-byte array where the first 32 bytes represent the private key and the last 32 bytes represent the public key.
createKeyPairFromPrivateKeyBytes(Uint8List bytes) KeyPair
Creates a KeyPair from a 32-byte private key, deriving the corresponding public key.
generateKeyPair() KeyPair
Generates a new random Ed25519 key pair.
getPublicKeyFromPrivateKey(Uint8List privateKeyBytes) Uint8List
Derives the Ed25519 public key bytes from the given privateKeyBytes.
isSignature(String putativeSignature) bool
Returns true if putativeSignature is a valid base58-encoded Ed25519 signature string, false otherwise.
isSignatureBytes(Uint8List putativeSignatureBytes) bool
Returns true if putativeSignatureBytes is a valid Ed25519 signature (exactly 64 bytes), false otherwise.
signature(String value) Signature
Asserts and coerces value to a Signature.
signatureBytes(Uint8List value) SignatureBytes
Asserts and coerces value to SignatureBytes.
signBytes(Uint8List privateKeyBytes, Uint8List data) SignatureBytes
Signs data using the provided 32-byte privateKeyBytes and returns the 64-byte Ed25519 signature.
verifySignature(Uint8List publicKeyBytes, SignatureBytes signature, Uint8List data) bool
Verifies that signature was produced by signing data with the private key corresponding to publicKeyBytes.