-
Notifications
You must be signed in to change notification settings - Fork 157
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
SignedMessage::new_from_part result in 'Secp signature verification failed' error because of Network value #1419
Comments
Is the signature wrong or the recovered address? I'm new to Filecoin and try to understand how different networks are handled. It appears you use |
Looks like we set all addresses to a mainnet default: https://github.com/ChainSafe/forest/blob/main/vm/address/src/lib.rs#L59 |
Hi @q9f
I verified the signature independently and it is a valid one. I tried then to get the recovered address and I had the same
I also notice that. I am not sure what I did that would make it work for testnet but not mainnet. It does bug me. |
@q9f Are you sure about that? Seems we set the default network here: Lines 32 to 39 in 356757e
Disclaimer - I'm new here and I don't have a full picture (yet!). :) |
We are all new here 🤣 The problem is, as far as I understand it, that we default to mainnet in case we are not running a configured client/daemon. How do the crypto crates function if they are only tasked to recover a signature? The TODO in the address crate suggests that someone stumbled upon that before us already and suggested there need to be more flexibility. |
Would it fix this problem once this one is closed ? #1402 I had this problem in the past and after talking to one of the dev they added this function for me to be able to change the network from the default : https://github.com/ChainSafe/forest/blob/main/vm/address/src/lib.rs#L167 |
#1402 is much more involved, and while it is arguably slightly related, it wouldn't necessarily address this issue. |
Do you think we could perform only a partial comparison here for verification? forest/crypto/src/signature.rs Line 153 in 674fba5
That is to say, compare only the Lines 65 to 68 in 7727b33
If I understand correctly this is our reference: And given the I believe it should be fine as it compares only the payload (right?). Or are there other implications I should be more aware of? |
Well, it's all about assumptions. Traditionally, you do not compare addresses at all, instead you compare the uncompressed public keys and derive the address in a later step for convenience. The way it is implemented in Forest leaves room for speculation.
I would do 1 or 2, but not 3 as this might break things we are not aware of. |
I am a bit concerned by the fact that a testnet signed transaction can be broadcasted in mainnet. Shouldn't something in the way we sign integrate the notion of network ? |
Replay protection should definitely be part of the transaction protocol specification. This is less of a client-specific issue. In Ethereum, you basically sign the chain ID and encode it in the How does Filecoin deal with this? |
Ah yes, I see, the network was in the address string itself, my bad. In general it looks to me like the same issue exists in the reference Lotus implementation, the logic looks the same, is this correct? So whichever approach we'd take it'd be best to be aligned with Lotus on this one? |
If this is the case, we might want to bring this up during the next core dev call... |
Hey, great discussion here!
|
Thank you!
In this case, we will disregard the prefix and just match the payload, as @LesnyRumcajs suggested. 👍🏼
What does a transaction in Filecoin look like and where can I read more about that? |
posted this filecoin-project/FIPs#301 and proposed an FIP. |
Describe the bug
Cannot build SignedMessage using
new_from_part
because the recovered address has the wrong network.See here : https://github.com/ChainSafe/forest/blob/main/crypto/src/signature.rs#L150
To Reproduce
See this issue with the test case using testnet and mainnet address : Zondax/filecoin-signing-tools#422
Expected behaviour
I expect the recovered address to have the same network value than in the unsigned message.
Other information and links
All the step
forest/vm/message/src/signed_message.rs
Line 29 in 4eb74f9
https://github.com/ChainSafe/forest/blob/main/crypto/src/signature.rs#L105
https://github.com/ChainSafe/forest/blob/main/crypto/src/signature.rs#L136
https://github.com/ChainSafe/forest/blob/main/crypto/src/signature.rs#L150
https://github.com/ChainSafe/forest/blob/main/crypto/src/signature.rs#L187
https://github.com/ChainSafe/forest/blob/main/crypto/src/signature.rs#L200
The text was updated successfully, but these errors were encountered: