mimblewimble / grin-wallet

Grin Wallet
Apache License 2.0
182 stars 133 forks source link

[WIP] [Contracts] Early payment proofs #681

Closed yeastplume closed 1 year ago

yeastplume commented 1 year ago

Following on from experimental slate V5, changes, this aims to implement an experimental version of early proofs into the contracts branch. Note that `legacy' transaction workflows are not affected.

Other notes

yeastplume commented 1 year ago

This is mostly working now, note the new owner and foreign API functions to retrieve and verify proofs, as well as the contract_early_proofs test that demonstrates it all in action:

Note an exported proof with witness data (with no memo field) currently looks like this, a sender would provide this as well as the recipient wallet address for verification by any wallet's foreign API. A verifier looks up the given kernel, rebuilds the signature message from the given data and validates the signature.

{
  "proof_type": 1,
  "amount": "5000000000",
  "receiver_public_nonce": "02c6d5a13828310c1a3119b838e605f0c09894b8c293a3251e0256d5b281323d24",
  "receiver_public_excess": "03a325d02765d795b048b39fa0c4498ed8131fa331a620329b2c95de67e78733ff",
  "sender_address": "9eeead9b0e90c02e2db75b48e152252dab792b889f967329d695793605959a2d",
  "timestamp": 1685102955,
  "promise_signature": "9bd4030265fea7580fddb0d56fa115f1376186677b286dc855c067c68f5abc75cf701f29c36f027d0d9e2f0b51e00df37b92acf0aadf7ae012b2f30da8847d08",
  "witness_data": {
    "kernel_index": "16",
    "kernel_commitment": "086ff2f22ccfe3ea9b11d594dbf63e340d50c6d9841dca16437f0c9299a6322696",
    "sender_partial_sig": "4a80e076c5e89b1b689564439a56e0f9d906aae6d80bf79090fdcf11fb4311059879404578bc0a0927b677f5d773df308fdaec17590d3377e16e7c9744d5e9c1"
  }
}
yeastplume commented 1 year ago

Since PR is already large, going to merge this and start newer ones for cleanup work + additional testing