Giter Site home page Giter Site logo

pememoni / fairblock Goto Github PK

View Code? Open in Web Editor NEW
13.0 1.0 1.0 1.04 MB

Consensus-level Front-running protection mechanism using Threshold Identity-Based Encryption

Go 2.12% JavaScript 45.34% HTML 0.01% Vue 0.03% SCSS 0.01% TypeScript 52.50%
mev blockchain defi dex identity-based-encryption cosmos-sdk starport front-running amm

fairblock's Introduction

Fairblock

Original Logo

This repo has been developed during my academic publications in grad school, for recent developments of Fairblock (as a start-up) please check here

Fairblock is a front-running protection mechanism for blockchain applications. While blockchain systems are quickly gaining popularity, front-running remains a major obstacle to fair exchange and other blockchain applications. FairBlock shows how to apply Identity-Based Encryption (IBE) to prevent front-running with minimal bandwidth overheads. In our approach, to decrypt a block of N transaction, the number of messages sent across the network only grows linearly with the size of decrypting committees, S. That is, to decrypt a set of N transactions sequenced at a specific block, a committee only needs to exchange $S$ decryption shares (independent of N). In comparison, previous solutions based on the threshold encryption schemes, where each transaction in a block must be decrypted separately by the committee, resulting in bandwidth overhead of N * S. This project has implemented FairBlock in the consensus layer i.e. consensus validators are also the ones who are responsible for extracting a private key for decrypting encrypted transactions in each block target. This project
The blockchain for this application is built using Cosmos SDK and created with Starport. In an alternative approach, FairBlock is implemented using smart contracts as the communication layer for smart contract blockchains such as Avalanche and Ethereum.

Check out our publications on Fairblock: SecureComm 2022 paper Thesis on FairBlock

Screen Shot 2022-02-23 at 7 06 26 PM

Get started

Blockchain

- Install Starport:
curl https://get.starport.network/[email protected]! | bash
- Set correct GOPATH:
export PATH=$PATH:$(go env GOPATH)/bin
- Run FairBlock Blockchain:
starport chain serve

serve command installs dependencies, builds, initializes, and starts FairBlock.

Transactions

- Set target for encrypted messages e.g. buying an NFT, Auction, MEV opportunity:
FairBlockd tx fairblock submit-target "description of target" "block height that IBE private key should be extracted" --from "client"
- Submit encrpyted messages (bids, offers, or any other sensitive information that can be used for front-running attacks if leaked)
FairBlockd tx fairblock submit-encrypted "plaintext for message" "IBE Encrpytion of message with public key derived from target block height" "deposit"  --from "sender of encrypted message" 

plaintext of message will be converted to SHA256 on the client as a cryptographic commitment. The messages are never leaked to any public entity which might want to front-run

- Validators Submit their IBE private key share for target block height
FairBlockd tx fairblock submit-share "IBE key share for alice" "target block height" --from "alice"
- Original sender submits a commitment for his/her plaintext of encrypted message OR a decrpytor uses IBE private key shares and computes a private key to decrypt the encrypted message with the incentive of taking the original sender's deposit
FairBlockd tx fairblock commit-decryption "plaintext of message"  --from "sender or decryptor"

The plaintext of commited decryption will be converted to SHA256 on the client side so the plaintexts are never leaked to any public entity which might want to front-run

- Original sender or the decryptor Reveals the plaintext of his/her commited decryption to take back or win the deposit
FairBlockd tx fairblock reveal-decryption "plaintext of message" --from "sender or decryptor" 

Queries

- Query current block information
FairBlockd q block
- Query target
FairBlockd q fairblock list-target --output json
- Query shares
FairBlockd q fairblock list-share --output json
- Query encrypted messages
FairBlockd q fairblock list-encryptedtx --output json
- Query commits
FairBlockd q fairblock list-commit --output json

Configure

The blockchain in development can be configured with config.yml.

Web Frontend

Run the following commands to install dependencies and start a Vue.js-based web app:

cd vue
npm install
npm run serve

The frontend app is built using the @starport/vue and @starport/vuex packages.

Distributed Identity-Based Encryption

  1. cd distributedIBE/ibe
  2. go mod tidy
  3. go test
  • This project has been built based on Vuvuzela and tcpaillier projects
  • This implementation has not been vetted for a production setting, use with caution
  • This project has been tested on Linux

Useful Resources

Identity-Based Encryption

Boneh-Franklin IBE Scheme

DKG protocol on Blockchain for IBE without a trusted dealer

Ethereum is a Dark Forest

Front-running presentation by Phil Daian at IEEE Symposium on Security and Privacy

Escaping the Dark Forest

fairblock's People

Contributors

pememoni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sbnair

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.