Grinnode-live / 2020-grin-bug-bash-challenge

Finding bugs in Grin-Wallet & Grin-nodes for a bounty prior to Grin fork v5.
3 stars 1 forks source link

[GRIN-Wallet] Slatepack payment proof export and verification #18

Closed phyro closed 3 years ago

phyro commented 3 years ago

Description: By default, whenever a transaction is sent to a destination Slatepack Address, a payment proof is created automatically. Test that export and verification of a payment proof works.

Note that as of right now, the payment proofs only work for the sender-initiated flow. They can't be done with the receiver-initiated flow (invoice).

Prerequisites: Setup two GRIN-Wallets (1) + (2) and send funds from wallet (1) to wallet (2) via Slatepacks through either Tor or Text method. This should create a payment proof for the sender. The transaction should be broadcasted and mined.

Example: The sender (wallet who finalized tx) can export the payment proof by specifying the tx-id (-i) or tx-log-id (-t) of a transaction, and choosing the path for the proof file, e.g:

grin-wallet export_proof -i 4 "~/Documents/proof.txt"

He can then provide this proof to any wallet for verification. To verify:

grin-wallet verify_proof /path/proof.txt

This will ensure that:

Expected result: Payment proof verification should result in a valid payment proof.

Payment proof's signatures are valid.

Note: More about these flows can be read on:

  1. https://docs.grin.mw/wiki/services/slatepack-integration/#payment-proofs
  2. https://docs.grin.mw/getting-started/quickstart/send/
mojitoo commented 3 years ago

Prerequisites:

Step 1 (send)

The send command is the first step of building an interactive transaction. The transaction can either be an instant synchronous exchange through Tor, or it can be an asynchronous process. for this example i choosed to transact through Tor.

grin-wallet send -d grin1vm68yyu6f5gyz7tk7zwjf2ws5vu44wkyurd84as0tnums2fsahks8x3zjc 0.1 

Password: 
20201219 10:21:33.829 WARN grin_wallet_api::owner - Attempting to send transaction via TOR
Tx sent successfully
Command 'send' completed successfully

Wallet receiver was reachable over tor, and transaction completed successfully.

Step 2 (generate proof of transaction)

using the export_proof command, The sender can generate a proof to resolve future payment disputes and prove they sent funds to the correct recipient. The sender can export the payment proof by specifying the transaction id (-i) (obtained by txs) or the tx-UUID (-t), and choosing the path for the proof file.

grin-wallet export_proof -i 12 "/Users/workstation/Downloads/proof.txt" 
Password: 
20201219 10:23:41.465 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20201219 10:23:42.306 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201219 10:23:42.314 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201219 10:23:42.315 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning Complete
20201219 10:23:43.932 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 0% complete
20201219 10:23:44.745 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201219 10:23:44.753 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning - 99% complete
20201219 10:23:44.754 WARN grin_wallet_libwallet::api_impl::owner_updater - Scanning Complete
20201219 10:23:44.771 WARN grin_wallet_controller::command - Payment proof exported to /Users/workstation/Downloads/proof.txt
Command 'export_proof' completed successfully

Step 3 (verify proof of transaction)

The sender can then provide this proof to any other wallet for verification.

This will ensure that:

On top of that, if the receiver's address in the transaction belongs to the same wallet who's verifying, then the user will be informed as follows:

grin-wallet verify_proof "/Users/workstation/Downloads/proof.txt"

Password: 
Payment proof's signatures are valid.
The proof's sender address belongs to this wallet.
Command 'verify_proof' completed successfully
marekyggdrasil commented 3 years ago

@mojitoo I forgot to ask, can you please provide version of the wallet?

mojitoo commented 3 years ago