Giter VIP home page Giter VIP logo

franklin-crypto's Introduction

Warning

This crate has been archived. Development has moved to the zksync-crypto repository. Please use it instead.

franklin-crypto: Gadget library for PLONK/Plookup

This repository contains only the gadgets for PLONK proofs system (to be used together with dev branch of our Bellman repo) including embedded curve/EcDSA support, RNS based field math, non-algebraic hashes via lookup tables, and base primitives.

Security Warnings

This library is under development and has not been reviewed.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

franklin-crypto's People

Contributors

akash-chandrakar avatar baldyash avatar barichek avatar dvush avatar ebfull avatar emilluta avatar furkhat avatar gluk64 avatar gtank avatar jasondavies avatar kobigurk avatar konstantce avatar otani88 avatar poma avatar popzxc avatar rex4539 avatar saitima avatar shamatar avatar str4d avatar tymurkhr avatar yorik 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

franklin-crypto's Issues

build error

I want to try the recursive_aggregation function of zksync v1.1., but when I build the branch plonk_gadgets#b72d5cf7 , which is required by the recursive_aggregation_circuit
, it occurs the following errors:

Compiling franklin-crypto v0.0.5 (https://github.com/matter-labs/franklin-crypto?branch=plonk_gadgets#b72d5cf7)
error[E0277]: the trait bound E: pairing_ce::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:43:38
|
43 | pub trait PoseidonCsSBox<E: Engine>: SBox {
| ^^^^^^^ the trait pairing_ce::Engine is not implemented for E
|
help: consider further restricting this bound with + pairing_ce::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:43:29
|
43 | pub trait PoseidonCsSBox<E: Engine>: SBox {
| ^^^^^^
= note: required by poseidon_hash::SBox

error[E0277]: the trait bound E: pairing_ce::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:49:17
|
49 | impl<E: Engine> PoseidonCsSBox for QuinticSBox {
| ^^^^^^^^^^^^^^^^^ the trait pairing_ce::Engine is not implemented for E
|
help: consider further restricting this bound with + pairing_ce::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:49:9
|
49 | impl<E: Engine> PoseidonCsSBox for QuinticSBox {
| ^^^^^^
= note: required because of the requirements on the impl of poseidon_hash::SBox<E> for poseidon_hash::QuinticSBox<E>

error[E0277]: the trait bound E: bellman::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:95:26
|
95 | AccumulatingToAbsorb(Vec<Num>),
| ^^^^^^^^^^^ the trait bellman::Engine is not implemented for E
|
::: /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/allocated_num.rs:31:1
|
31 | pub enum Num<E: Engine> {
| ----------------------- required by plonk::circuit::allocated_num::Num
|
help: consider further restricting this bound with + bellman::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:94:16
|
94 | enum OpMode<E: PoseidonEngine> {
| ^^^^^^^^^^^^^^

error[E0277]: the trait bound E: bellman::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:100:5
|
100 | internal_state: Vec<LinearCombination>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bellman::Engine is not implemented for E
|
::: /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/linear_combination.rs:39:1
|
39 | pub struct LinearCombination<E: Engine> {
| --------------------------------------- required by plonk::circuit::linear_combination::LinearCombination
|
help: consider further restricting this bound with + bellman::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:99:38
|
99 | pub struct StatefulPoseidonGadget<E: PoseidonEngine> {
| ^^^^^^^^^^^^^^

error[E0277]: the trait bound E: bellman::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:105:75
|
43 | pub trait PoseidonCsSBox<E: Engine>: SBox {
| -------------------------------------------- required by plonk::circuit::poseidon::PoseidonCsSBox
...
105 | where <::Params as PoseidonHashParams>::SBox: PoseidonCsSBox
| ^^^^^^^^^^^^^^^^^ the trait bellman::Engine is not implemented for E
|
help: consider restricting this type parameter with where E: bellman::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:104:6
|
104 | impl<E: PoseidonEngine> StatefulPoseidonGadget
| ^

error[E0277]: the trait bound E: pairing_ce::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:53:9
|
53 | &self,
| ^^^^^ the trait pairing_ce::Engine is not implemented for E
|
help: consider further restricting this bound with + pairing_ce::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:49:9
|
49 | impl<E: Engine> PoseidonCsSBox for QuinticSBox {
| ^^^^^^
= note: required by poseidon_hash::QuinticSBox

error[E0277]: the trait bound E: pairing_ce::Engine is not satisfied
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:85:9
|
85 | &self,
| ^^^^^ the trait pairing_ce::Engine is not implemented for E
|
help: consider further restricting this bound with + pairing_ce::Engine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:49:9
|
49 | impl<E: Engine> PoseidonCsSBox for QuinticSBox {
| ^^^^^^
= note: required by poseidon_hash::QuinticSBox

error[E0277]: the trait bound E: bellman::ScalarEngine is not satisfied in plonk::circuit::linear_combination::LinearCombination<E>
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:120:16
|
120 | state: &[LinearCombination],
| ^^^^^^^^^^^^^^^^^^^^^^^ within plonk::circuit::linear_combination::LinearCombination<E>, the trait bellman::ScalarEngine is not implemented for E
|
help: consider restricting this type parameter with where E: bellman::ScalarEngine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:104:6
|
104 | impl<E: PoseidonEngine> StatefulPoseidonGadget
| ^
= note: required because it appears within the type plonk::circuit::linear_combination::LinearCombination<E>
= note: slice and array elements must have Sized type

error[E0277]: the trait bound E: bellman::ScalarEngine is not satisfied in plonk::circuit::linear_combination::LinearCombination<E>
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:353:10
|
353 | ) -> Result<LinearCombination, SynthesisError> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within plonk::circuit::linear_combination::LinearCombination<E>, the trait bellman::ScalarEngine is not implemented for E
|
help: consider restricting this type parameter with where E: bellman::ScalarEngine
--> /Users/chenhuan/.cargo/git/checkouts/franklin-crypto-4c6ecf4148c62588/b72d5cf/src/plonk/circuit/poseidon.rs:104:6
|
104 | impl<E: PoseidonEngine> StatefulPoseidonGadget
| ^
= note: required because it appears within the type plonk::circuit::linear_combination::LinearCombination<E>
= note: required by std::result::Result

error: aborting due to 9 previous errors

For more information about this error, try rustc --explain E0277.
error: could not compile franklin-crypto.

To learn more, run the command again with --verbose.

what is the multi tables usage for of Sha256Gadget ?

Hi, buddy

I am reading code regarding Sha256Gadget with lookup method involved. I am not sure multi tables usage for of Sha256Gadget as below:
pub struct Sha256Gadget<E: Engine> {
// is is possible to reduce the number of constraints even more by exploiting not only d_next,
// but also c_prev
use_c_prev : bool,

// the purpose of these parameters is discussed before the "normalize" function
ch_num_of_chunks: usize,
// NOTE : actually the majority vand sheduler bases are the same (4), so there is no reason for their corresponding
// number of chunks to be different
maj_and_sheduler_num_of_chunks: usize,

**// tables used for chooser (ch) implementation    
sha256_base7_rot6_table: Arc<LookupTableApplication<E>>,
sha256_base7_rot3_extr10_table: Arc<LookupTableApplication<E>>,
sha256_ch_normalization_table: Arc<LookupTableApplication<E>>,

// tables used for majority (maj) implementation
sha256_base4_rot2_table: Arc<LookupTableApplication<E>>,
// the special property of this table is that it operates on 10-but chunks
sha256_base4_rot2_width10_table: Arc<LookupTableApplication<E>>,
sha256_maj_sheduler_normalization_table: Arc<LookupTableApplication<E>>,

// tables used for message expansion (message sheduler, in other terms)
sha256_base4_rot7_table: Arc<LookupTableApplication<E>>,**
// for normalization we are going to use the same table as in majority function - as their bases (4) are the same!
// we also implement R_3 and S_19 (see below) with the help of specially crafted addtional tables,
// namely: Sha256ShedulerHelperTable
sha256_sheduler_helper_table : Arc<LookupTableApplication<E>>,

// there is an option to handle of range checks via globally defined range table
// if there is no such table available, we are not going to create such a range table ourselves
// instead we accomplish rabge checks via sha_specific sparse_rotate tables
// in fact, there is not much benefit from using 16-bit range table than our inner 11-bit tables
// but if we are given one as a gift. why not to exploit it?
use_global_range_table: bool,
global_range_table_width: usize,
global_range_table: Option<Arc<LookupTableApplication<E>>>,
max_of_width: usize,

// constants 
iv: [E::Fr; 8],
round_constants: [E::Fr; 64],

}

I know the original sha256 algorithm process , but still confusing with circuit & lookup applied implementation, Is there any doc on design or someone tells some clues ?
Appreciate your classification!

Thanks

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.