Code Monkey home page Code Monkey logo

bulletproofs-gadgets's Introduction

Bulletproofs Gadgets

Zero Knowledge Proofs gadgets built using the pure Java Bulletproofs implementation.

Bulletproofs are short non-interactive zero-knowledge proofs that require no trusted setup.

Read More about Bulletproofs

Paper (B. Bünz, J. Bootle, D. Boneh, A. Poelstra, P. Wuille, and G. Maxwell. Bulletproofs: Short proofs for confidential transactions and more. 2018 IEEE Symposium on Security and Privacy (SP), pages 315–334, May 2018)

Partially based on the Rust implementation by Lovesh Harchandani

Gradle Groovy DSL

implementation 'com.weavechain:bulletproofs-gadgets:1.0.6'

Gradle Kotlin DSL

implementation("com.weavechain:bulletproofs-gadgets:1.0.6")

Apache Maven

<dependency>
  <groupId>com.weavechain</groupId>
  <artifactId>bulletproofs-gadgets</artifactId>
  <version>1.0.6</version>
</dependency>

Gadgets

  • NumberInRange
  • NumbersInRange
  • NumberIsPositive
  • NumbersArePositive
  • NumbersSumTo
  • RecordsWithHashesSumTo
  • RecordsWithHashPreImageSumTo
  • RecordsAddUpdateProof
  • NumberIsNonZero
  • NumbersAreNonZero
  • NumberIsZero
  • NumberIsNotEqual
  • NumberIsEqual
  • NumberInList
  • NumberNotInList
  • NumberIsGreaterOrEqual
  • NumberIsLessOrEqual
  • MiMCHashPreImage
  • MiMCStringHashPreImage

Warning

This bulletproofs gadgets library has been partially audited and is provided as-is, we make no guarantees or warranties to its safety, security and reliability.

Usage

Few usage samples below:

Number In Range
NumberInRangeParams params = new NumberInRangeParams(
        10L,
        100L,
        31
);

Long value = 16L;

PedersenCommitment pc = PedersenCommitment.getDefault();

Scalar rnd = Utils.randomScalar();
BulletProofGenerators bg1 = new BulletProofGenerators(128, 1);
Proof proof = bulletProofs.generate(Gadgets.number_in_range, value, params, rnd, pc, bg1);

Proof proof2 = Proof.deserialize(proof.serialize());

BulletProofGenerators bg2 = new BulletProofGenerators(128, 1);
boolean match = bulletProofs.verify(Gadgets.number_in_range, params, proof2, pc, bg2);
System.out.println(match ? "Success" : "Fail");
Numbers Sum To
NumbersSumToParams params = new NumbersSumToParams(10L, 4, 10);

List<Long> values = List.of(1L, 2L, 3L, 4L);

PedersenCommitment pc = PedersenCommitment.getDefault();

Scalar rnd = Utils.randomScalar();
BulletProofGenerators bg1 = new BulletProofGenerators(128, 1);
Proof proof = bulletProofs.generate(Gadgets.numbers_sum_to, values, params, rnd, pc, bg1);

Proof proof2 = Proof.deserialize(proof.serialize());

BulletProofGenerators bg2 = new BulletProofGenerators(128, 1);
boolean match = bulletProofs.verify(Gadgets.numbers_sum_to, params, proof2, pc, bg2);
System.out.println(match ? "Success" : "Fail");
Number In List
NumberInListParams params = new NumberInListParams(List.of(1L, 3L, 128L, 145L), 8);

Long value = 128L;

PedersenCommitment pc = PedersenCommitment.getDefault();

Scalar rnd = Utils.randomScalar();
BulletProofGenerators bg1 = new BulletProofGenerators(128, 1);
Proof proof = bulletProofs.generate(Gadgets.number_in_list, value, params, rnd, pc, bg1);

Proof proof2 = Proof.deserialize(proof.serialize());

BulletProofGenerators bg2 = new BulletProofGenerators(128, 1);
boolean match = bulletProofs.verify(Gadgets.number_in_list, params, proof2, pc, bg2);
System.out.println(match ? "Success" : "Fail");

Weavechain

Weavechain is a Layer-0 for Data, adding Web3 Security and Data Economics to data stored in private vaults in any of the traditional databases.

Read more on https://docs.weavechain.com

bulletproofs-gadgets's People

Contributors

ix42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

omarelnaggar

bulletproofs-gadgets'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.