SchnorrkelSecretKey constructor
Creates a SchnorrkelSecretKey instance from provided secret key and nonce components.
Parameters:
key: A byte array representing the secret key.nonce: A byte array representing the nonce.
Returns:
A SchnorrkelSecretKey instance if the input components are valid and in canonical form.
Throws:
- An
CryptoExceptionif the input components are invalid or not in canonical form.
Implementation
factory SchnorrkelSecretKey(List<int> key, List<int> nonce) {
_KeyUtils._checkKeysBytes(
key, SchnorrkelKeyCost.miniSecretLength, "mini secret key");
_KeyUtils._checkKeysBytes(nonce, SchnorrkelKeyCost.nonceLength, "nonce");
final canonicalKey = _KeyUtils.toCanonical(key);
if (canonicalKey != null) {
return SchnorrkelSecretKey._(canonicalKey, nonce);
}
throw const CryptoException("invalid sr25519 private key.");
}