WiP: NightMarket

A zero knowledge marketplace for Dark Forest coordinates. A 0xParc Learning Group project - work in progress.

Quickstart

  • Install: yarn install
  • Test circuits: yarn test
  • Deploy circuits: circom:prod

Directory

  • /circuits/list: Circuits for generating a coordinate listing
  • /circuits/sale: Circuits for fulfilling a sale to buyer
  • /circuits/utils: Shared utility circuits
  • /circuits/test: Circuit unit tests
  • /client: Dark Forest plugin code
  • /contracts: Contract and verifier code

Spec

  • Sellers list any valid Dark Forest coordinates at a fixed price
  • Multiple buyers can purchase these coordinates
  • Sellers can attest their planet has certain biomes

Circuit Design

LIST

Prove: Seller has (x,y) coords, and sell a KEY used to encrypt it

  • hash(XY,PLANETHASH_KEY) ==> valid_coord // I know a valid data/coordinate
  • ENCODE(XY, KEY) // I encrypted data with key
  • hash(KEY) // I commit to the secret key

SALE

Prove: Seller encrypted KEY with a SHARED_KEY from a ECDH key exchange with Buyer

  • SHAREDKEY <== ecdh(sellerPrivKey, buyerPubKey) // An ECDH shared key
  • ENCODE(KEY, SHARED_KEY) // Encrypt KEY, s.t. buyer can decrypt offline
  • hash(KEY) ==> output // I encrypted the correct key
  • BUYER_PUBKEY ==> output // I used the correct buyer key

ENCODE

Scheme: Encryption using a 5-wide Poseidon in SpongeWrap with (0, len=2, Kx ,Ky , N) as input.

  • List:
    • message[0] = planet x coordinate
    • message[1] = planet y coordinate
    • key[0] = left half of key being sold
    • key[1] = right half of key being sold
  • Sale:
    • message[0] = key[0]
    • message[1] = key[1]
    • key[0] = k_x of shared key
    • key[1] = k_y of shared key

Escrow Contract

Acknowledgements

Description
No description provided
Readme 128 MiB
Languages
JavaScript 79%
Circom 18.9%
TypeScript 2.1%