Zondax / ledger-filecoin

Filecoin app for Ledger Nano S and X
Apache License 2.0
26 stars 17 forks source link

Cannot sign message with params using Nano S ledger | error_message: "Data is invalid : Unexpected number of items" #105

Closed fabriziogianni7 closed 2 years ago

fabriziogianni7 commented 2 years ago

I'm trying to sign a message with simple params but I can't do that. I'm using a Nano S ledger with expert mode: enabled I updated the Filecoin Ledger App and the ledger firmware

I have this error:

error_message: "Data is invalid : Unexpected number of items"
return_code: 27012
signature_compact: 
Uint8Array(28) 
[85, 110, 

Debugging, I saw that I'm calling sign() function and it returns this error.

the message I want to send look like this:

from: "t1y6grz7kkjs5wyvg4mp5jqjl3unqt7t5ktqlrf2q"
gasfeecap: "101365"
gaslimit: 277620
gaspremium: "100311"
method: 0
nonce: 0
params: "Y2lhbw=="
to: "t01000"
value: "0"

the call:

await this.ledgerApp.sign(m/44'/${this.lotusNode.code}'/0'/0/${indexAccount}, Buffer.from(serializedMessage, 'hex'))

in my package.json:

"@zondax/ledger-filecoin": "^0.11.1",

I'm using this to format the params:

Buffer.from('ciao','hex').toString('base64'))

Thank you very much for supporting

rllola commented 2 years ago

Hello @fabriziogianni7 ,

If I am not mistaken when signing a transaction with method 0 the app doesn't expect to have any parameters given and if so will reject the transaction.

Is there any reason why you are trying to sign a simple send transaction with parameters ?

fabriziogianni7 commented 2 years ago

ok, thank you. yes. we would like to 'verify' the address passing in some random 4 digit string. do you know what method should I use then?

rllola commented 2 years ago

Just by curiosity, does such a transaction is valid when send to a Filecoin node ? If a Filecoin node support such a transaction it might make sense to be a bit more loose on ledger app.

Could you give a bit more context on why you want to verify an address by signing a transaction ? Would this transaction be broadcasted ?

fabriziogianni7 commented 2 years ago

Sure, So, we want to see if users are sending transaction using our Dapp. We need to do it just once and we will return the messageCID.

rllola commented 2 years ago

Have you tried with a signed transaction but that's not been signed with the ledger app ? Or you want to use the ledger app as a way to sign your transaction ?

We need to do it just once and we will return the messageCID.

So it won't be broadcasted.

If you are just looking for a way to sign a transaction for testing you might be interested in this library : https://github.com/Zondax/filecoin-signing-tools

fabriziogianni7 commented 2 years ago

Yes, Signing without ledger is working. I wanted to do the same with ledger

rllola commented 2 years ago

Got it. So I don't see it working with an other method for now.

What we can do is to remove the restriction on method 0 and allow signing if there is parameter. However it will take a bit of time and this change will need to be approved beforehand.

fabriziogianni7 commented 2 years ago

How long you think it does take to do that? Thank you very much for the support.

rllola commented 2 years ago

It is difficult to tell because there is a long process when releasing new update.

However you should be able to test it by compiling directly from the repo. I would advice to do it on a new ledger without any sensible data on it and to proceed with caution tho. I think next week I can have a branch for you to test against.

EDIT: also please note that this would need to be green light first

fabriziogianni7 commented 2 years ago

ok. Thank you very much. let me know if I can be of any help then!

rllola commented 2 years ago

Hi @fabriziogianni7 Here the branch : https://github.com/Zondax/ledger-filecoin/tree/misc/transfer-params You can follow the instructions in the README to test it on a ledger (that has nothing on it).