X25519 function

Uint8List X25519(
  1. List<int> scalar,
  2. List<int> point
)

X25519 returns the result of the scalar multiplication (scalar * point), according to RFC 7748, Section 5. scalar, point and the return value are slices of 32 bytes.

scalar can be generated at random, for example with crypto/rand. point should be either Basepoint or the output of another X25519 call.

If point is Basepoint (but not if it's a different slice with the same contents) a precomputed implementation might be used for performance.

Implementation

Uint8List X25519(List<int> scalar, List<int> point) {
  /// Outline the body of function, to let the allocation be inlined in the
  /// caller, and possibly avoid escaping to the heap.
  var dst = List<int>.filled(32, 0);
  return x25519(dst, scalar, point);
}