-
Notifications
You must be signed in to change notification settings - Fork 22
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
Private key imported from bytearray should be imported as unsigned #198
Comments
There's also export to unsigned byte array. It basically skips that leading zero byte. One byte could save the world :) |
@romanstrobl Does this have any impact on |
I think that import is without an impact, but once we save key as unsigned, then the older code will not be able to load it correctly (e.g., imported key will be different). That might cause problems during our own development only. For example, If you'll deploy older server to "dev" by accident, but will work against database already filled with keys from newer code. But this is in general irrelevant, because the only problem so far is with test vectors, generated from mobile SDK. But I agree, that mathematically correct is to use unsigned integers. |
See how BC handles decoding of points: We use this BC method in method |
You are right the problem is only when we use test vectors from mobile SDK, which is rare. The other question is compatibility with BC library which uses unsigned byte[] for conversions of all raw keys (see usages of |
We should use unsigned conversion when converting
byte[]
representation of thed
number toBigInteger
. See Bouncy Castle utility method:https://github.com/bcgit/bc-java/blob/ff19d41ba1968fe381d67794d32d959aca307406/core/src/main/java/org/bouncycastle/util/BigIntegers.java#L108
The text was updated successfully, but these errors were encountered: