Coder Social home page Coder Social logo

bitcoin-stark / khepri Goto Github PK

View Code? Open in Web Editor NEW
55.0 7.0 16.0 290 KB

STARK-proven Stateful Bitcoin client enabling hyper fast trustless sync and checkpoints.

License: MIT License

Makefile 0.15% Cairo 96.66% Python 3.19%
bitcoin cairo cairo-lang lightning-network stark starknet zero-knowledge zkp

khepri's Introduction

Khepri

STARK-proven Stateful Bitcoin client enabling hyper fast trustless sync and checkpoints.

Architecture

Khepri Architecture

Description

The idea of Khepri is to leverage Stark proof system in order to solve some issues in Bitcoin ecosystem or at least enhance the user experience.

With Stark proofs and Cairo, we have the ability to verify the integrity of a computation without having to naively redo all computation. Hence a verifier can be sure of the honest execution of a program, without the need of executing it and check the result.

The verification of the proof is exponentially faster than the naive execution of the program, which provide scalability.

Moreover, the overhead of generating the proof is negligible compared to the normal execution without the generation of the proof.

This mechanism can enable a lot of potential optimizations on several use cases.

What kind of problems can we solve with this super power ? Well, there are so many issues we could imagine to tackle with this approach, here are some cool features that could be enabled with this system:

  • hyper fast & trustless synchronization (IBD)
  • enhanced Simplified Payment Verification
  • protection against DoS on the P2P layer

In short, Khepri is a proof of concept to demonstrate how STARK proofs can be leveraged for Bitcoin without changing the protocol.

Usage

⚠️ WARNING! ⚠️

This is repo contains highly experimental code. Expect rapid iteration. Use at your own risk.

Set up the project

📦 Install the requirements

⛏️ Compile

protostar build

🌡️ Test

protostar test

📄 License

khepri is released under the MIT.

khepri's People

Contributors

abdelstark avatar bal7hazar avatar ofux avatar skuzminsky avatar tekkac avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

khepri's Issues

Proof Logic around recreating Txid

Take a JSON of data that defines the bitcoin transaction:

{
txid of input: "",
vIn of input: 0,
outputAddresses:[],
vOut Balances:[],
OP_Return: ""
}

Possibly also scriptsig/pubscriptkey of previous transaction, probably not the signature

OP_Return for future reference (such as proving a USDT send).

We should be able to take the JSON in call data and prove it checks out with the txid provided in the call data.

Proof Logic around Tx Inclusion

Having verified that the proposed payment tx is valid for our trade, we want to prove the given txid is included in the block by tracing its merkle branch of proven spends.

Interface for Call Data

Write a simple wrapper to take Call Data from a user including their proposed txid for payment, the JSON data about it, and pass that to the other functions in the system.

Store block headers

Description

There are multiple consensus rules that require past data from previous block headers.
For convenience we will store block headers data entirely. We expect it will help reorg management later.

Acceptance Criteria

  • Block headers data are stored
  • Block headers data are accessible by number and by hash

Rewrite a safe version of the SHA256 library

Description

Fix the implementation of SHA256 so that it verifies the output via finalize_sha256.

Context

The official Cairo SHA256 library only handles up to 55 bytes length inputs. Our ad-hoc version can handle input up to 80 bytes, however it is unsafe as the hint verification is skipped.

Suggestion

Write a safe Cairo SHA256 library, based on the official one, that can handle arbitrary size inputs. This could be done as an external library that would replace the one in src/utils/sha256/

Rule: Check Proof Of Work

Description

Implement a rule to check the proof of work:

  • Compute the target from nBits
  • Verify the block header hash is smaller than the target.

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.