EDDSAPublicKey.fromPoint constructor
Creates an EdDSA public key from a generator and an existing public point.
This constructor initializes an EdDSA public key using the provided generator and an existing public point. It calculates the length of the base data and ensures that the size of the encoded public key bytes extracted from the public point matches the expected size based on the generator's curve.
Parameters:
- generator: The generator point associated with this public key.
- publicPoint: An existing Edwards curve public point.
Throws:
- ArgumentException: If the size of the encoded public key extracted from the public point does not match the expected size based on the generator's curve.
Details:
- The constructor initializes the public key using an existing public point, and it calculates the base data length and validates the size of the encoded public key bytes.
Note: This constructor is used when you have an existing public point and want to create an EdDSA public key from it. It performs necessary validation and prepares the public key for cryptographic operations.
Implementation
factory EDDSAPublicKey.fromPoint(
EDPoint generator,
EDPoint publicPoint,
) {
final int baselen = (generator.curve.p.bitLength + 1 + 7) ~/ 8;
final pubkeyBytes = publicPoint.toBytes();
if (pubkeyBytes.length != baselen) {
throw ArgumentException(
'Incorrect size of the public key, expected: $baselen bytes');
}
return EDDSAPublicKey._(generator, pubkeyBytes, baselen, publicPoint);
}