Skip to content

Proof verification before withdrawal #106

Open
Darlington02 opened this issue Jul 14, 2022 · 2 comments
Open

Proof verification before withdrawal #106

Darlington02 opened this issue Jul 14, 2022 · 2 comments

Comments

@Darlington02
Copy link

Hello,

Just out of curiosity, i want to ask, why the need to generate proof first, before a user can confirm withdrawal, if we'd still need to check for a valid proof when trying to process withdrawal in smart contract?

Why not do every thing in just one process since the withdraw function will throw for invalid proof?

@markisus
Copy link

If you mean to ask why the proof can't be generated by the solidity function which handles withdraw, it's because proof generation needs the secret key used during deposit. There is no way that the withdraw function can know what this secret key is, so it must be passed in by the user. However, the user cannot simply pass this secret key directly, because it would be exposed in the clear on the blockchain and susceptible to front-running by miners, who could then redirect the withdraw to their own account. So the secret key is scrambled into a cryptographic proof before sending it over to the blockhain.

@Darlington02
Copy link
Author

Thank you @markisus

But the proof verification happens in the browser right? So i was just thinking in the front end code, rather than put the verification and withdrawal codes in two different js functions, how about a single function which handles both, verifies proof first, and if verification was successful, calls the contract's withdrawal function, otherwise it throws..

Rather than the two step processes of tornado, which verifies proof, before you confirm withdrawal.

Just a UX thought, wanted to confirm if it has security disadvantages.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants