hyperledger-archives/indy-sdk

Nodejs: Invalid signatures when submitting a multi-signed transaction

Riff451 opened this issue · 1 comments

Hello,
I'm receiving the following error when calling the nodejs wrapper submitRequest function:

{
    "reqId": "<redacted>",
    "op": "REQNACK",
    "identifier": "<redacted_my_did>",
    "reason": "client request invalid: insufficient number of valid signatures, 2 is required but 0 valid and 2 invalid have been provided. The following signatures are invalid: did=<redacted_my_did>, signature=MP8493v2gTBFvrXbCVLQVFmWCKh3PwySaVfmSqE1ADYD6PE8awEu6T6r71YtukofYv7mcF4svJWQGmvsn4YtH8b; did=<redacted_endorser_did>, signature=2v45KTeydaSY4gT3tYBLmb4pNmwfgrshiDj5bV4Eq8i25JDcUMmxLXCDucSe6Qx9L7kwNRLAmGSrf4qEXTx6srPj"
}

If I try to use the indy-cli with the same configurations (DID/Verkey, etc.) I can manually multi-sign the transaction and submit successfully the request to the ledger.

In my app, which uses the nodejs wrapper, I've double checked the generated signatures and for the same txn I get the same signatures returned from the indy-cli.

The app code does something like this:

multiSignedRequest = await indy.multiSignRequest(ENDORSER_WALLET_HANDLE, this.ENDORSER_DID, request.transaction);
result = await indy.submitRequest(ENDORSER_POOL_HANDLE, multiSignedRequest);

where request.transaction is the txn json string already signed with my DID.

I don't understand what I'm doing wrong. :)

Here's my current environment:

  • Staging NET
  • OS: Ubuntu 18.04
  • libindy: 1.16.0-bionic
  • indy-cli: 1.16.0-bionic
  • indy-sdk nodejs wrapper: 1.16.0-dev-1655
  • node: v16.18.0
  • npm: 8.19.2
  • build-essential: 12.4ubuntu1
  • gcc: 4:7.4.0-1ubuntu2.3
  • g++: 4:7.4.0-1ubuntu2.3
  • make: 4.1-9.1ubuntu1
  • Python3: 3.6.9

Thanks in advance for any help.

It turned out that the nodejs wrapper does a JSON.parse:

https://github.com/hyperledger/indy-sdk/blob/ae9f8a252bb99e8b80c6d34c6c985fd95abfadef/wrappers/nodejs/src/index.js#L15-L23

And I think the reqId in the output of multiSignRequest was changed because it's a number too big to be contained in a js Number type. The workaround was to update manually the reqId of the multiSignRequest output with the original unchanged reqId. If the request is already of type string the wrapper doesn't do anything and passes the txn as is to libindy.

Should the wrapper take this issue with large numbers into considerations?
Thanks.