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
bytesrepresents a valid Ed25519 private key. -
assertIsSignature(
String putativeSignature) → void -
Asserts that
putativeSignatureis a valid base58-encoded Ed25519 signature. -
assertIsSignatureBytes(
Uint8List putativeSignatureBytes) → void -
Asserts that
putativeSignatureBytesis 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
trueifputativeSignatureis a valid base58-encoded Ed25519 signature string,falseotherwise. -
isSignatureBytes(
Uint8List putativeSignatureBytes) → bool -
Returns
trueifputativeSignatureBytesis a valid Ed25519 signature (exactly 64 bytes),falseotherwise. -
signature(
String value) → Signature -
Asserts and coerces
valueto a Signature. -
signatureBytes(
Uint8List value) → SignatureBytes -
Asserts and coerces
valueto SignatureBytes. -
signBytes(
Uint8List privateKeyBytes, Uint8List data) → SignatureBytes -
Signs
datausing the provided 32-byteprivateKeyBytesand returns the 64-byte Ed25519 signature. -
verifySignature(
Uint8List publicKeyBytes, SignatureBytes signature, Uint8List data) → bool -
Verifies that
signaturewas produced by signingdatawith the private key corresponding topublicKeyBytes.