EDDSAPrivateKey.fromKhalow constructor

EDDSAPrivateKey.fromKhalow(
  1. EDPoint generator,
  2. List<int> privateKey
)

Creates an EdDSA private key from a private key value for Khalow curves.

This constructor is specifically used for Khalow curves where the private key is not pruned. It creates the private key from the provided private key value.

Parameters:

  • generator: The Edwards curve generator point.
  • privateKey: The private key bytes for Khalow curves.

Throws:

  • ArgumentException: If the private key size is invalid.

Implementation

factory EDDSAPrivateKey.fromKhalow(EDPoint generator, List<int> privateKey) {
  final baselen = (generator.curve.p.bitLength + 1 + 7) ~/ 8;
  if (privateKey.length < baselen) {
    throw ArgumentException(
        'Incorrect size of private key, expected: ${baselen * 2} bytes');
  }
  final List<int> privateKeyPart = privateKey.sublist(0, baselen);
  final List<int> extendedKey = privateKey.sublist(baselen);
  final secret =
      BigintUtils.fromBytes(privateKeyPart, byteOrder: Endian.little);
  return EDDSAPrivateKey._(
      generator, baselen, privateKeyPart, secret, extendedKey);
}