Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in Ed25519FieldElement.invert #57

Open
mckpm opened this issue Apr 13, 2018 · 1 comment
Open

NullPointerException in Ed25519FieldElement.invert #57

mckpm opened this issue Apr 13, 2018 · 1 comment

Comments

@mckpm
Copy link

mckpm commented Apr 13, 2018

We occasionally see this crash in the field (haven't managed to reproduce):

#0. Crashed: main
       at net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.java:67)
       at org.stellar.sdk.KeyPair.(KeyPair.java:29)
       at org.stellar.sdk.KeyPair.fromAccountId(KeyPair.java:104)
[...]

Fatal Exception: java.lang.ExceptionInInitializerError
       at net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.java:67)
       at org.stellar.sdk.KeyPair.(KeyPair.java:29)
       at org.stellar.sdk.KeyPair.fromAccountId(KeyPair.java:104)
[...]

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'b.a.a.a.a.e b.a.a.a.a.e.g()' on a null object reference
       at net.i2p.crypto.eddsa.math.ed25519.Ed25519FieldElement.invert(Ed25519FieldElement.java:811)
       at net.i2p.crypto.eddsa.math.GroupElement.precompute(GroupElement.java:472)
       at net.i2p.crypto.eddsa.math.Curve.createPoint(Curve.java:78)
       at net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable.(EdDSANamedCurveTable.java:43)
       at net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.java:67)
       at org.stellar.sdk.KeyPair.(KeyPair.java:29)
       at org.stellar.sdk.KeyPair.fromAccountId(KeyPair.java:104)
[...]
@str4d str4d added this to the 0.3.1 milestone May 5, 2018
@str4d str4d added the heisenbug label Feb 2, 2019
@str4d str4d removed this from the 0.3.1 milestone Feb 2, 2019
@str4d
Copy link
Owner

str4d commented Feb 2, 2019

invert() is being called here:

// TODO-CR BR: check that this == base point when the method is called.
Bi = this;
for (int i = 0; i < 32; i++) {
GroupElement Bij = Bi;
for (int j = 0; j < 8; j++) {
final FieldElement recip = Bij.Z.invert();

At the crash point, invert() is doing this:

// 2^201 - 2^1
t2 = t2.square();
// 2^250 - 2^50
for (int i = 1; i < 50; ++i) {
t2 = t2.square();
}

So my initial guess would be that t2.square() returns null at some point either before or during that loop, and the subsequent iteration then has t2 set to null, causing the NPE. However, Ed25519FieldElement.square() never returns null (it does deterministic maths and then calls a constructor, which can never return null but does potentially throw an IAE). So... I'm going to leave this open until someone else can reproduce this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants