Skip to content

Exposes to Java, through JNI, the ginger-lib components needed by the Zendoo sidechain SDK.

License

Notifications You must be signed in to change notification settings

HorizenOfficial/zendoo-sc-cryptolib

Repository files navigation

zendoo-sc-cryptolib

zendoo-sc-cryptolib is a Rust crate that exposes to Java, through JNI, the ginger-lib components needed by the Zendoo sidechain SDK.

In particular it exposes interfaces to:

  • handle the finite fields that are the alphabets of the zk Proving Systems
  • call the Poseidon function, a Snark friendly hashing algorithm
  • use a full in-memory Poseidon-based Merkle Tree, thus optimized for performance but limited in size (depending on the available RAM)
  • manage the SCTxsCommitmentTree, as described in section 4.1.3 of the Zendoo paper
  • compute and verify Schnorr signatures, handle associated keypairs
  • compute and verify a VRF proof, fetch a VRF output, handle associated keypairs (to support Ouroborous-style PoS sidechain consensus)
  • create and manage Zendoo Sidechain proofs

The library includes also an example of a simple Zendoo sidechain proving circuit that can be used to create proofs for backward transfer certificates. This demo circuit can prove that a given certificate was signed by a minimum number of signers, all belonging to a defined set of approved signers. For more info, pls see the specific document. The circuit is offered as an example to developers, to help them build their own circuits, that will match their sidechain logic and needs.

Please note: the code is in development. No guarantees are provided about its security and functionality

Release Notes

The current release does not yet serve proof composition. The proving system has been switched from Groth16 to our Marlin variant Coboundary Marlin. Support has been introduced to create Final Darlin proofs, as per last step of our recursive PCD scheme (See HGB for details), but not yet implemented.

Build guide

The library compiles on the stable Rust toolchain. To install Rust, just install rustup by following the instructions here, or via your platform's package manager.

After that, use cargo, the standard Rust build tool, to build the library:

git clone https://github.com/HorizenOfficial/zendoo-sc-cryptolib.git
cd zendoo-sc-cryptolib
cargo build --release

This library comes with unit tests for each of the provided crates. Run the tests with:

cargo test

More detailed build guide, as well as instructions to build the .jar, can be found in our build guide.

Extras

In order to build and use SNAPSHOT.jar package version refer to the following documentation