This is an implementation of EdDSA in Java. Structurally, it is based on the ref10 implementation in SUPERCOP (see https://ed25519.cr.yp.to/software.html).
There are two internal implementations:
Download the latest .jar from the releases tab and place it in your classpath.
Gradle users:
compile 'net.i2p.crypto:eddsa:0.3.0'
Java 7 and above are supported.
The JUnit4 tests require the Hamcrest library hamcrest-all.jar
.
This code is released to the public domain and can be used for any purpose. See LICENSE.txt
for details.
There are no guarantees that this is secure for all cases, and users should review the code themselves before depending on it. PRs that fix bugs or improve reviewability are very welcome. Additionally:
For ease of following, here are the main methods in ref10 and their equivalents in this codebase:
EdDSA Operation | ref10 function | Java function |
---|---|---|
Generate keypair | crypto_sign_keypair |
EdDSAPrivateKeySpec constructor |
Sign message | crypto_sign |
EdDSAEngine.engineSign |
Verify signature | crypto_sign_open |
EdDSAEngine.engineVerify |
EdDSA point arithmetic | ref10 function | Java function |
---|---|---|
R = b * B |
ge_scalarmult_base |
GroupElement.scalarMultiply |
R = a*A + b*B |
ge_double_scalarmult_vartime |
GroupElement.doubleScalarMultiplyVariableTime |
R = 2 * P |
ge_p2_dbl |
GroupElement.dbl |
R = P + Q |
ge_madd , ge_add |
GroupElement.madd , GroupElement.add |
R = P - Q |
ge_msub , ge_sub |
GroupElement.msub , GroupElement.sub |
EdDSANamedCurveTable.defineCurve()
, which will be rarely called.ED_25519
, and the curve specification has a public
constant ED_25519_CURVE_SPEC
to avoid repeated lookups when converting to and from encoded form for the
public or private keys.GroupElement
is now completely immutable, and all fields final, to avoid the need for synchronized
blocks over mutable fields. This required some new constructors and paths to construction.EdDSAPublicKeySpec.getNegativeA()
and EdDSAPublicKey.getNegativeA()
now evaluate lazily, taking
advantage of the immutability of GroupElement.negate()
. This boosts the performance of the public key
constructor when the key is just being passed around rather than used.Ed25519
in EdDSANamedCurveTable
, and the previous public constant (containing the
older inaccurate name) has been removed.