sign method
Returns a Future that resolves to the result of signing data with the
private key held internally by a given instance.
Implementation
Future<Signature> sign(Iterable<int> data) async {
// DartEd25519 expects SimpleKeyPairData as a keypair, but it's sealed, so
// we cannot make this class a subclass of SimpleKeyPairData, so we sign it
// with the instance of SimpleKeyPairData and then create a new Signature
// with our public key.
final keypair = SimpleKeyPairData(
_privateKey,
publicKey: SimplePublicKey(
publicKey.bytes,
type: KeyPairType.ed25519,
),
type: KeyPairType.ed25519,
);
final signature = await _ed25519.sign(
data.toList(growable: false),
keyPair: keypair,
);
return Signature(signature.bytes, publicKey: publicKey);
}