Hashing to Elliptic Curves for Kotlin implements RFC 9380 algorithms for encoding or hashing an arbitrary byte array to a point on an elliptic curve.
Warning
This project has not been independently audited. Help is welcome to increase security or to make risks explicit. Also see the Security policy.
Run the tests. On POSIX:
./gradlew test
On Windows:
gradlew test
Instead of test
, use jar
to create a JAR in build/libs
.
Add the hashtocurve-kotlin
dependency to your project.
Select a HashToCurve
suite and configure a domain separation tag (see Domain Separation Requirements). With the resulting function, you can hash any byte array to the related elliptic curve. The result is encoded as a Point(x: ByteArray, y: ByteArray)
with components that contain the big-endian encoding of affine curve point coordinates.
See HashToCurveSpec for example usage.
Some test vectors from RFC 9380 are used.