scalarMult static method
Perform scalar multiplication with an arbitrary public key (u-coordinate). Returns the shared secret.
Implementation
static List<int> scalarMult(List<int> scalar, List<int> uBytes) {
if (scalar.length != X25519KeyConst.privateKeyLength) {
throw CryptoException('invalid scalar bytes length');
}
if (uBytes.length != X25519KeyConst.publickKeyLength) {
throw CryptoException('invalid u bytes length');
}
final clamped = _clampScalar(scalar);
final u = BigintUtils.fromBytes(uBytes, byteOrder: Endian.little);
if (u >= X25519KeyConst.p) {
throw CryptoException('uBytes is not a canonical field element');
}
return _montgomeryLadder(clamped, u);
}