GithubHelp home page GithubHelp logo

samuelslavka / zk-wallet Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 37.37 MB

Mobile Cryptocurrency Wallet Based on zk-SNARKs and Smart Contracts

License: MIT License

JavaScript 6.13% Starlark 0.51% Java 15.29% Ruby 0.88% Objective-C 3.79% Solidity 19.55% Makefile 0.66% Dockerfile 0.38% Python 18.82% TypeScript 33.96% Shell 0.04%
react-native blockchain ethereum flask smart-contracts

zk-wallet's Introduction

Mobile Cryptocurrency Wallet Based on zk-SNARKs and Smart Contracts

A framework for mobile wallet that utilizes zk-SNARKs as a storage optimization technique.

Server is able to create zk-SNARK proofs of headers batch validity and publish them to smart contract. Client uses these proofs as checkpoints for its local header chain.

Requirements

  • docker
  • docker-compose
  • yarn
  • metro
  • python3

Smart contracts setup

Compile and setup zokrates (warning creates toxic waste)

Included zokrates setup is predefined for 32 header batches

make compile

Deploy current vesion of smart contract in smartContracts/build/contracts

Uses validator genereated during make compile. Deploys to predefined provider in constants.py.

make deploy 

blockchain ids are constants set in smart contract:

  • 0 - btc starting in genesis
  • 1 - btc starting in a test block
  • 2 - bch starting in genesis
  • 3 - bch starting in a test block

Custom proof and witness creation

Will create proofs for 32 header sized chinks starting with [start height] and ending at [end height] if [end height] is lower than start of chunk+32 the proof will be genrated for start of chunk+32 anyway. It is also a computationaly heavy task.

python3 ./Server/main.py proof [blockchainId] [start height] [end height]

Proof publishing to smart contract

Will publish previosuly generated proofs when wider range than 32 the proofs will be batched into single message, creating only one chckpoin.

python3 ./Server/main.py interact [blockchainId] [start height] [end height]

Client setup

SDK and cosntants are fully described in ./ZkWallet/README.md

Client dev env execution:

yarn react-native start

yarn react-native run

Server setup

Server uses rest api for providing up to date Contract address and abi. You can configure them in the app as constants and server will be unecessary. Constants and functionality are fully described in ./Server/README.md

Build docker image

make init

Run dockerized flask

make dev

File structure

./Nginx - proxy point
./Server - server implementation
    /src/bitcoin - bitcoin data gathering and parsing implementation
    /src/ethereum - ethereum contract deployment and interaction
    /src/utils - general utils
    /src/smartContracts - contracts and zokrates handlers
        /contracts  - contract programs
        /zokrates - zokrates program and generated data
./ZkWallet - wallet implementation
    /android/app/src/main/java/com/zkwallet - Native module implementation with geth instatiation
    /src - main react native module
        /app - app files
            /components - app components
            /config - global constants
            /navigation - navigation configuration
            /redux - state managment
            /screens - screen components
            /utilities - general utilities
./Zokrates - functioning zokrates toolbox

General testing

Provided makefile also contains an easy to execute shotcuts for testig. It uses previously mentioned python script.

  • Creates proof for first 32 headers. make proof
  • Submits the previously created proof to smart contract make intercat
  • Calls clients function to check current head of smart contract header chain. make call

zk-wallet's People

Contributors

samuelslavka avatar

Stargazers

Zihan avatar Decentraluis avatar  avatar

Watchers

 avatar

zk-wallet's Issues

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.