EDDSAPrivateKey constructor
EDDSAPrivateKey(
- EDPoint generator,
- List<
int> privateKey, - SerializableHash hashMethod()
Creates an EdDSA private key from a random value using a provided hash method.
The private key is generated from the provided hash method and the provided random value. It prunes the key for improved security.
Parameters:
- generator: The Edwards curve generator point.
- privateKey: The private key bytes.
- hashMethod: A serializable hash function for key generation.
Throws:
- ArgumentException: If the private key size is invalid.
Implementation
EDDSAPrivateKey(
this.generator,
List<int> privateKey,
SerializableHash Function() hashMethod,
) : baselen = (generator.curve.p.bitLength + 1 + 7) ~/ 8,
isKhalow = false {
if (privateKey.length != baselen) {
throw ArgumentException(
'Incorrect size of private key, expected: $baselen bytes');
}
_privateKey = List<int>.from(privateKey);
_h = hashMethod().update(privateKey).digest();
final a = _h.sublist(0, baselen);
final prunedKey = _keyPrune(List<int>.from(a));
_s = BigintUtils.fromBytes(prunedKey, byteOrder: Endian.little);
}