ed25519-java icon indicating copy to clipboard operation
ed25519-java copied to clipboard

Simple Diffie-Hellman computation fails.

Open shumy-tools opened this issue 5 years ago • 1 comments

A simple computation as:

final FieldElement nodeSecret = Utils.getRandomFieldElement();
final GroupElement nodeKey = Utils.basePoint.scalarMultiply(nodeSecret.toByteArray());
    
final FieldElement termSecret = Utils.getRandomFieldElement();
final GroupElement termKey = Utils.basePoint.scalarMultiply(termSecret.toByteArray());
    
nodeKey.scalarMultiply(termSecret.toByteArray());

Fails with:

Exception in thread "main" java.lang.NullPointerException
at net.i2p.crypto.eddsa.math.GroupElement.select(GroupElement.java:930)
at net.i2p.crypto.eddsa.math.GroupElement.scalarMultiply(GroupElement.java:964)
at AOTMainTest.main(AOTMainTest.java:26)

shumy-tools avatar Jan 13 '20 18:01 shumy-tools

I'll have a brief look into this at some point, but I recommend using curve25519-elisabeth for these kinds of computations: https://github.com/cryptography-cafe/curve25519-elisabeth

str4d avatar Apr 29 '20 05:04 str4d