SchnorrkelSecretKey.fromEd25519 constructor
Creates a SchnorrkelSecretKey
instance from a byte representation of an Ed25519 secret key.
Parameters:
secretKeyBytes
: A byte array representing an Ed25519 secret key.
Returns:
A SchnorrkelSecretKey
instance derived from the provided Ed25519 secret key representation.
Throws:
- An
ArgumentException
if the byte array does not have the correct length for a secret key.
Implementation
factory SchnorrkelSecretKey.fromEd25519(List<int> secretKeyBytes) {
_KeyUtils._checkKeysBytes(
secretKeyBytes, SchnorrkelKeyCost.secretKeyLength, "secret key");
final newKey = List<int>.from(
secretKeyBytes.sublist(0, SchnorrkelKeyCost.miniSecretLength));
_KeyUtils.divideScalarByCofactor(newKey);
return SchnorrkelSecretKey(
BytesUtils.toBytes(newKey, unmodifiable: true),
BytesUtils.toBytes(
secretKeyBytes.sublist(SchnorrkelKeyCost.miniSecretLength,
SchnorrkelKeyCost.secretKeyLength),
unmodifiable: true));
}