createInstructionWithPrivateKey static method
/ Create an ed25519 instruction with a private key. The private key must be a buffer that is 64 bytes long.
Implementation
static TransactionInstruction createInstructionWithPrivateKey({
required final Uint8List privateKey,
required final Uint8List message,
required final int? instructionIndex,
}) {
check(
privateKey.length == nacl.seckeyLength,
'The private key must be ${nacl.seckeyLength} bytes but received ${privateKey.length} bytes.'
);
try {
final keypair = Keypair.fromSeckeySync(privateKey);
final pubkey = keypair.pubkey.toBytes();
final signature = nacl.sign.detached.sync(message, keypair.seckey);
return createInstructionWithPubkey(
pubkey: pubkey,
message: message,
signature: signature,
instructionIndex: instructionIndex,
);
} catch (error) {
throw Exception('Error creating ED25519 instruction: $error');
}
}