You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried signing a byte[] message with a private key in a project using the web3J library and it runs into an error. The library calls a sign method of its ECKeyPair class, which uses the ECDSASigner of this library, which is the reason I am raising the issue here.
While calling the sign()method of the ECKeyPair object, it creates ECPrivateKeyParameters which are passed to the init() method of the ECDSASigner object. There, it is using it to create ECKeyParameters.
This ECKeyParameters are used in the generateSignature(byte[] var1) method, to retrieve the n and d fields of the ECDomainParamters to calculate the signature. This two values however, are of different lengths, which leads to an ArrayIndexOutOfBoundsException in the HMacDSAKCalculator.init() method, which is trying to calculate the signature.
As I am only passing the EcKeyPair created with a private key to the method of the library and it is forwarding the values to ECDSASigner without interferring, I assume that there must be a issue creating the ECKeyParameters. As I am also only passing the EcKeyPair (and the to be signed message, but it is never used before this issue, so it can't be relevant) and tried different ways of generating the private key for generating them, I also don't know where I am doing something wrong.
Help is really appreciated!
Cheers
The text was updated successfully, but these errors were encountered:
It sounds like the private key ('d') was generated incorrectly. It has to be less than the group order from the domain parameters ('n'). You should track down where the key pair was actually created and find out why.
It may be helpful to use the latest release (1.63) since we added validation in the ECPrivateKeyParameters constructor; the error should show up closer to the problem code.
I tried signing a byte[] message with a private key in a project using the web3J library and it runs into an error. The library calls a sign method of its ECKeyPair class, which uses the
ECDSASigner
of this library, which is the reason I am raising the issue here.While calling the
sign()
method of theECKeyPair
object, it createsECPrivateKeyParameters
which are passed to theinit()
method of theECDSASigner
object. There, it is using it to createECKeyParameters
.This ECKeyParameters are used in the
generateSignature(byte[] var1)
method, to retrieve then
andd
fields of theECDomainParamters
to calculate the signature. This two values however, are of different lengths, which leads to an ArrayIndexOutOfBoundsException in theHMacDSAKCalculator.init()
method, which is trying to calculate the signature.As I am only passing the EcKeyPair created with a private key to the method of the library and it is forwarding the values to
ECDSASigner
without interferring, I assume that there must be a issue creating theECKeyParameters
. As I am also only passing the EcKeyPair (and the to be signed message, but it is never used before this issue, so it can't be relevant) and tried different ways of generating the private key for generating them, I also don't know where I am doing something wrong.Help is really appreciated!
Cheers
The text was updated successfully, but these errors were encountered: