social-dist0rtion-protocol / planet-a

The Tragedy of the CO₂mmons
MIT License
10 stars 3 forks source link

Implement Trade view #5

Closed TimDaub closed 5 years ago

TimDaub commented 5 years ago

Scope

Screen Shot 2019-07-16 at 14 26 36

Deliverables

Note

Roles

bounty gardener: @TimDaub / 10% bounty worker: name / 75% bounty reviewer: name / 15%

johannbarbie commented 5 years ago

Planet A - screen flow (1)

here are some more details in the mock: https://docs.google.com/drawings/d/1rcTgrE9ZsbClerhOGthGe9J6eLHYrQnq7ZJp8h7mwYs

vrde commented 5 years ago

Unit test that implements this functionality.

johannbarbie commented 5 years ago

Spec for QR code generation:

  1. query getUnspent(citizenAddr, passportColor) and read first passport data as dataBefore.
  2. update CO2 in passport data as dataAfter.
  3. create sig by ecsign(hashPersonalMessage(dataBefore, dataAfter), PRIV).
  4. concatenate | 2 bytes passportColor | 20 bytes citizenAddr | 32 bytes dataAfter | 32 bytes sigR | 32 bytes sigS | 1 byte sigV |.
  5. build URL https://toco2.leap.rocks/trade#<119 bytes receipt encoded as base64 url (rfc4648)>.

Spec for scanning and verifying QR code:

  1. scan URL, extract passportColor, citizenAddr, dataAfter and sig.
  2. query getUnspent(citizenAddr, passportColor), take first result, read data as dataBefore.
  3. ecrecover(hashPersonalMessage(dataBefore, dataAfter)) and compare to citizenAddr, should match.
  4. use sig and dataAfter in transaction payload.