Giter VIP home page Giter VIP logo

sagar133 / erc721-nft-zokrates-zksnarks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hossam-magdy/erc721-nft-zokrates-zksnarks

0.0 0.0 0.0 914 KB

Decentralized/blokchain-based real-estate listing project using ERC721 (NFT), zero-knowledge proofs (zk-SNARKS / ZoKrates), and open marketplace (OpenSea). It is the final project in Blockchain developer nanodegree: https://udacity.com/course/nd1309

Shell 0.69% JavaScript 15.25% Solidity 84.07%

erc721-nft-zokrates-zksnarks's Introduction

Capstone Project: Decentralized Housing

Links, addresses and TX hashes:

Collection/marketplace on OpenSea: https://testnets.opensea.io/collection/hcustomerc721token

Contracts addresses

Tokens minted and listed for sale:

https://testnets.opensea.io/assets/0xb30721f2c6873aeec65e43259804ee1541a34f45/1 https://testnets.opensea.io/assets/0xb30721f2c6873aeec65e43259804ee1541a34f45/2 https://testnets.opensea.io/assets/0xb30721f2c6873aeec65e43259804ee1541a34f45/3 https://testnets.opensea.io/assets/0xb30721f2c6873aeec65e43259804ee1541a34f45/5 https://testnets.opensea.io/assets/0xb30721f2c6873aeec65e43259804ee1541a34f45/7 https://testnets.opensea.io/assets/0xb30721f2c6873aeec65e43259804ee1541a34f45/9

These tokens were owned and marked for sale by 0x6c0ebe2a2cdbea429fd3719f56fb57d7719396f7, then bought by 0xecc93d9486493ed1022298d1f43305ab85b1ea70.

To run the tests

  • Install truffle of the version mentioned below
  • Clone the repo
  • yarn install
  • truffle test

Versions used:

Truffle v5.4.25 (core: 5.4.25)
Solidity - 0.8.11 (solc-js)
Node v14.18.1
Web3.js v1.5.3
ZoKrates v0.7.10

Development

Using ZoKrates:

ZoKrates CLI

shortcut cmd: yarn zokrates-all

cd zokrates/code
yarn zokrates compile -i ./square/square.zok
yarn zokrates setup
# generates witness with the args (fn inputs) 3 and 9 (3*3 == 9, so the inputs[1] should be 1)
yarn zokrates compute-witness -a 3 9 && cp witness ./generated/witness1
# generates `proof.json`
yarn zokrates generate-proof && cp proof.json ./generated/proof1.json
yarn zokrates export-verifier
yarn zokrates-cp && yarn format

For generating 10 proofs and witnesses (witness, contains the relealed info "square root"): for i in {3..12}; do yarn zokrates compute-witness -a $(( i * 20 )) $(( i * i * 20 * 20 )) && cp witness ./generated/witness$(( i - 2 )) && yarn zokrates generate-proof && cp proof.json ./generated/proof$(( i - 2 )).json; done;

[OR] the detailed/manual version:

docker run -it -v ${PWD}/zokrates/code:/home/zokrates/code -w /home/zokrates/code zokrates/zokrates:0.7.10 /bin/bash

# ref: https://zokrates.github.io/gettingstarted.html
# compile - Generates: `out` binary
zokrates compile -i ./square/square.zok
# perform the setup phase - Generates: `proving.key` and `verification.key` (uses `out` binary)
zokrates setup
# execute the program - Generates: `witness` (uses `out` binary)
zokrates compute-witness -a 337 113569
# generate a proof of computation - Generates: `proof.json` (uses `proving.key` and `witness`)
zokrates generate-proof
# export a solidity verifier - Generates: `verifier.sol` (uses `verification.key`)
zokrates export-verifier
# or verify natively
zokrates verify

Useful resources for ZoKrates and zk-SNARKs

Resources:

  • Fleek makes it easy to build websites and apps on the new open web: permissionless, trustless, censorship resistant, and free of centralized gatekeepers
  • Kite: Code Faster. Stay in Flow. Kite adds AI powered code completions to your code editor, giving developers superpowers
  • If you are interested in becoming an ethereum freelancer in blocklancer will interest you.
  • The World’s First Real Estate NFT, one way to turn this Udacity project into a reality.
  • This interesting article about a new dApp called Bloom
  • Learn Ethereum is a book to go deeper in the technical topics and algorithms in Ethereum. This is an advanced technical book. In the book you will explore the blockchain-based decentralized platform and understand how Ethereum works with Dapps examples.

Expand/Collapse

Source: https://github.com/udacity/Blockchain-Capstone

Udacity Blockchain Capstone

The capstone will build upon the knowledge you have gained in the course in order to build a decentralized housing product.

Project Steps

  1. Clone the project repository
  2. Explore the code base.
  3. Fill out ERC721 Mintable Contract in ERC721Mintable.sol
  4. Write test cases TestERC721Mintable.js
  5. Compile and pass test cases in TestERC721Mintable.js
  6. Implement Zokrates
    • Using Docker to install and instantiate a Zokrates zkSnarks development environment
    • Completes the Zokrates proof in square.code by adding the variable names in square.code
    • Compile program
    • Trusted setup
    • Compute witness
    • Generate Proof
    • Export Verifier.sol
    • Note: This project uses solidity version 0.5.2 so you will be required to update the code in Verifier.sol accordingly based on the compiler errors you receive
  7. Write a test script to verify the solidity contract generated by Zokrates executed successfully - TestSquareVerifier.js
  8. Write test contract for ZK and ERC721 integration - SolnSquareVerifier.sol
  9. Compile and pass with TestSolnSquareVerifier.js
  10. Deploy latest contracts generated by Zokrates (a.k.a verifier.sol)
  11. Deploy SolnSquareVerifier contract to Rinkeby network
  12. Mint 10 tokens
  13. Generate OpenSea marketplace
  14. Test and Verify OpenSea with your SolnSquareVerifier tokens
    • List 5 of your tokens on the marketplace
    • Purchase those 5 tokens using a different address
  15. Complete required documentation and submit!

Project Resources

erc721-nft-zokrates-zksnarks's People

Contributors

hossam-magdy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.