calculateAgreement static method
Implementation
static Uint8List calculateAgreement(
ECPublicKey? publicKey, ECPrivateKey? privateKey) {
if (publicKey == null) {
throw Exception('publicKey value is null');
}
if (privateKey == null) {
throw Exception('privateKey value is null');
}
if (publicKey.getType() != privateKey.getType()) {
throw Exception('Public and private keys must be of the same type!');
}
if (publicKey.getType() == djbType) {
final calculator = agreementCalculator;
if (calculator != null) {
return calculator(
(privateKey as DjbECPrivateKey).privateKey,
(publicKey as DjbECPublicKey).publicKey,
);
}
final secretKey = x25519.X25519(
List<int>.from((privateKey as DjbECPrivateKey).privateKey),
List<int>.from((publicKey as DjbECPublicKey).publicKey),
);
return secretKey;
} else {
throw Exception('Unknown type: ${publicKey.getType()}');
}
}