mirror of
https://github.com/factorgroup/nightmarket.git
synced 2026-01-12 06:58:15 -05:00
contracts
WiP: NightMarket
A zero knowledge marketplace for Dark Forest coordinates. A 0xParc Learning Group project - work in progress.
Quicklinks
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/coordinateENCODE(XY, KEY)// I encrypted data with keyhash(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 keyENCODE(KEY, SHARED_KEY)// Encrypt KEY, s.t. buyer can decrypt offlinehash(KEY) ==> output// I encrypted the correct keyBUYER_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
keybeing sold - key[1] = right half of
keybeing 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
- 0xParc for study group
- DF plugins
- DF Circuits
- EthMarketPlace
- Maci
- Poseidon Encryption, Paper
Description
Languages
JavaScript
79%
Circom
18.9%
TypeScript
2.1%