-
Notifications
You must be signed in to change notification settings - Fork 10
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
Include MASP Transaction
hash in the wrapper signature
#50
Comments
Hey @murisi! As we are just about to complete the shielded hash verification, we will start solving this issue, but we have some questions, where you might be able to help us. So far, the signMasp method that we have is returning the hash of the complete transaction (similarly to zcash), and the spend signatures can be retrieved with the getSpendSignature method. From our understanding, you are requesting the signMasp to return not a hash but the wrapper signature, similar to the one for non-masp transactions, including the Masp transaction. |
Hi @chcmedeiros , great thanks for the work on the shielded hash verification issue!
Conceptually a
Ultimately the wrapper signature must cover over every byte in the ledger-namada/app/src/crypto.c Line 397 in 6e0ac0f
SHA-256(0x04 || Borsh serialization of Transaction) (see https://github.com/anoma/namada/blob/24eebc7ec68c30f66f8c92a257f5d9acef75258f/crates/tx/src/types.rs#L878) where the concerned Transaction has valid authorizations (in the place of the dummy/placeholder authorizations contained by the Transaction that was sent to the hardware wallet for signing). (Side note: we used the Transaction Borsh serialization to compute the MASP section hash because it includes authorization data unlike the TxId digest.)
Would it be possible for the hardware wallet to do this directly? It seems to me that we just need to patch/overwrite the dummy/placeholder spend signatures and binding signature in the |
Hey @murisi ! Thanks for the clarification, I think it will be possible to do it in the app directly. But let me check with some more certainty and discuss with the team, so we can come with the best solution. |
Hey @murisi ! I think we can do it without the need for an extra round of communication. Can you point us to a place in your SDK or documention where we can confirm the binding signature computation? |
Hi @chcmedeiros , great thanks! See this code for computing the binding signature: https://github.com/anoma/masp/blob/8d83b172698098fba393006016072bc201ed9ab7/masp_proofs/src/sapling/prover.rs#L277 . At a higher level, the computations are also described here: https://zips.z.cash/protocol/protocol.pdf#saplingbalance although our code is generalized to support multiple asset generators. Let me know if you have any further questions... |
Hi @chcmedeiros ! How is the binding signature computation going? Is there any additional information we can furnish you with for this issue? Thanks! |
Hey @murisi ! We are working on computing the binding signature, so we can replace it by the dummy one. |
Hey @murisi. We made some good progress. Do you think it is possible to have a MASP transaction, with some debug on the expected value of binding sig, so we could run some test in our implementation? |
Hi @chcmedeiros . In order to get the release done sooner, could we please postpone closing the issue? Essentially we've manage to get the |
Hey @murisi. But you will still need for us to add the Masp hash on the wrapper signature, right ? |
Ah yes, you're right. The MASP hash is still needed in the wrapper signature. Thanks!
This is the part of this issue that we can leave out for now. Your current Rust crate API is fine and we have already integrated it. And the team is fine with requiring hardware wallet users to do separately the confirmation for the MASP Transactions and one for the wrapper (at least for now). Apologies for the confusion. |
@murisi do you think is possible to have a transaction with the dummy values replaced with computed ones so we can have a test for MASP wrapper signature generation? |
I've reread the specifications and I think that I can make the Namada client It seems to me that only the spend authorization signatures for each spend description must be computed on the hardware wallet since that computation requires knowledge of |
Yes, let me produce the test vectors for wrapper signatures that cover over MASP |
I've just checked the Given that we will no longer be computing the binding signature on the hardware wallet, is any additional information still required to test MASP wrapper signature generation? |
I don't think we need any additional info regarding that. Only the test vectors for the test cases where TxId digest computations on the hardware wallet don't match |
Hi @chcmedeiros . Please also find attached test vectors to show some of the computations happening during the signing process. They look like:
|
@murisi those Sign info is regarding the signature of a spend right? If so I will use this to test the spend signature generation |
@chcmedeiros Yes exactly, thanks. The link properly formatted: masp_signing_testvectors.txt |
Hey @murisi ! Regarding the spend signing, I was able to verify sbar and rbar calculation process, starting from the data_2_be_signed, rsk and t from your debug vectors. Going to check if the issue now might be on rsk, rk computation or sign_hash. |
Hi @chcmedeiros . Great, thanks. Let me know if anything comes up...
Thanks. Looking at https://zips.z.cash/protocol/nu5.pdf#concretereddsa , |
Hi @chcmedeiros . Whenever I try to sign MASP transactions I get the following error after pressing selecting/pressing "Approve" on the hardware wallet:
See attached some logs of the calls I'm making. Am I doing something wrong? |
Hey @murisi. So if I understood right, the methods to generate the randomness will be called more than the number of the spends/outputs/converts that will be present in the builder? If so, then the problem might be indeed in the crypto_check_masp when we are getting the randomness values to compute cv for comparison. We might not be getting the random vaue that namadac is using. |
Hi @chcmedeiros . Yes, this would make integrating the Ledger app into
Ah, I see. My bad. Is there a way to make this work? I.e. allow |
@murisi I am doing some testing to be sure. But I would say if you should use the first |
For any
Tx
that contains and uses a MASPTransaction
(i.e. some field likeTransfer::shielded_section_hash
contains its TxId) , the Namada Ledger app must produce a wrapper signature that is also over the hash of the MASPTransaction
section. (In addition to everything else put intoledger-namada/app/src/crypto.c
Line 373 in ca9da5e
Transaction
section must be hashed only after the placeholders in it have been replaced by valid authorization signatures and a valid binding signature. The reason for this requirement is that the wrapper signature is intended to prevent malicious actors from tampering with any part of aTx
, including anyTransaction
embedded within it. The hash of a MASPTransaction
section is computed as the SHA-256 hash of 0x04 (DISCRIMINANT_MASP_TX
) followed by theTransaction
bytes (i.e. the SHA-256 hash of the byte vector consumed byreadMaspTx
).The text was updated successfully, but these errors were encountered: