SchnorrkelSecretKey constructor

SchnorrkelSecretKey(
  1. List<int> key,
  2. List<int> nonce
)

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 ArgumentException if 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._(
        BytesUtils.toBytes(canonicalKey, unmodifiable: true),
        BytesUtils.toBytes(nonce, unmodifiable: true));
  }
  throw const ArgumentException("invalid key");
}