Skip to content

Commit

Permalink
Remove crypto-exports crate
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Sep 23, 2020
1 parent 92b9f61 commit 028206a
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 83 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ Cargo.lock
loadtest_accounts_*

go_to_env.sh

core/lib/storage/.env
15 changes: 2 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ members = [

# Libraries
"core/lib/circuit",
"core/lib/crypto_exports",
"core/lib/eth_client",
"core/lib/models",
"core/lib/plasma",
Expand Down
1 change: 0 additions & 1 deletion core/bin/data_restore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ futures = { version = "0.3", features = ["compat"] }
chrono = { version = "0.4", features = ["serde", "rustc-serialize"] }
tokio = { version = "0.2", features = ["full"] }

crypto_exports = { path = "../../lib/crypto_exports", version = "0.1.0" }
plasma = { path = "../../lib/plasma", version = "0.1.1" }
models = { path = "../../lib/models", version = "0.0.1" }
storage = { path = "../../lib/storage", version = "0.0.1" }
Expand Down
1 change: 0 additions & 1 deletion core/bin/key_generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ authors = [
]

[dependencies]
crypto_exports = { path = "../../lib/crypto_exports", version = "0.1.0" }
models = { path = "../../lib/models", version = "0.0.1" }
circuit= { path = "../../lib/circuit", version = "0.1.1" }
zksync_config = { path = "../../lib/config", version = "0.1.0" }
Expand Down
4 changes: 2 additions & 2 deletions core/bin/key_generator/src/franklin_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use circuit::exit_circuit::ZksyncExitCircuit;
use circuit::operation::{
Operation, OperationArguments, OperationBranch, OperationBranchWitness, SignatureData,
};
use crypto_exports::bellman::plonk::{make_verification_key, setup, transpile_with_gates_count};
use crypto_exports::bellman::Circuit;
use zksync_config::AvailableBlockSizesConfig;
use zksync_crypto::bellman::plonk::{make_verification_key, setup, transpile_with_gates_count};
use zksync_crypto::bellman::Circuit;
use zksync_crypto::params;
use zksync_crypto::Engine;
use zksync_prover_utils::fs_utils::{
Expand Down
1 change: 0 additions & 1 deletion core/bin/prover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2018"
plasma = { path = "../../lib/plasma", version = "0.1.1" }
models = { path = "../../lib/models", version = "0.0.1" }
circuit = { path = "../../lib/circuit", version = "0.1.1"}
crypto_exports = { path = "../../lib/crypto_exports", version = "0.1.0" }
zksync_crypto = { path = "../../lib/crypto", version = "0.1.0" }
zksync_config = { path = "../../lib/config", version = "0.1.0" }
zksync_utils = { path = "../../lib/utils", version = "0.1.0" }
Expand Down
2 changes: 1 addition & 1 deletion core/bin/prover/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::fmt;
use std::sync::{mpsc, Arc, Mutex};
use std::{thread, time};
// External deps
use crypto_exports::pairing::ff::PrimeField;
use num::BigUint;
use zksync_crypto::pairing::ff::PrimeField;
// Workspace deps
use circuit::{
circuit::FranklinCircuit,
Expand Down
44 changes: 22 additions & 22 deletions core/lib/circuit/src/playground/plonk_playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ fn test_transpile_deposit_franklin_existing_account() {
"root hash in state keeper and witness generation code mismatch"
);

use crypto_exports::franklin_crypto::bellman::pairing::bn256::Bn256;
use crypto_exports::franklin_crypto::bellman::plonk::adaptor::alternative::*;
use crypto_exports::franklin_crypto::bellman::plonk::plonk::generator::*;
use crypto_exports::franklin_crypto::bellman::plonk::plonk::prover::*;
use crypto_exports::franklin_crypto::bellman::Circuit;
use zksync_crypto::franklin_crypto::bellman::pairing::bn256::Bn256;
use zksync_crypto::franklin_crypto::bellman::plonk::adaptor::alternative::*;
use zksync_crypto::franklin_crypto::bellman::plonk::plonk::generator::*;
use zksync_crypto::franklin_crypto::bellman::plonk::plonk::prover::*;
use zksync_crypto::franklin_crypto::bellman::Circuit;

let mut transpiler = Transpiler::new();

Expand All @@ -67,7 +67,7 @@ fn test_transpile_deposit_franklin_existing_account() {

let hints = transpiler.into_hints();

use crypto_exports::franklin_crypto::bellman::plonk::cs::Circuit as PlonkCircuit;
use zksync_crypto::franklin_crypto::bellman::plonk::cs::Circuit as PlonkCircuit;

let adapted_curcuit = AdaptorCircuit::new(c.clone(), &hints);

Expand Down Expand Up @@ -134,9 +134,9 @@ fn test_new_transpile_deposit_franklin_existing_account_validate_only() {
"root hash in state keeper and witness generation code mismatch"
);

use crypto_exports::franklin_crypto::bellman::pairing::bn256::Bn256;
use crypto_exports::franklin_crypto::bellman::plonk::better_cs::adaptor::*;
use crypto_exports::franklin_crypto::bellman::plonk::*;
use zksync_crypto::franklin_crypto::bellman::pairing::bn256::Bn256;
use zksync_crypto::franklin_crypto::bellman::plonk::better_cs::adaptor::*;
use zksync_crypto::franklin_crypto::bellman::plonk::*;

// let mut transpiler = Transpiler::new();

Expand All @@ -158,7 +158,7 @@ fn test_new_transpile_deposit_franklin_existing_account_validate_only() {
hints_hist.insert("into quadratic gate".to_owned(), 0);
hints_hist.insert("into multiplication gate".to_owned(), 0);

use crypto_exports::franklin_crypto::bellman::plonk::better_cs::adaptor::TranspilationVariant;
use zksync_crypto::franklin_crypto::bellman::plonk::better_cs::adaptor::TranspilationVariant;

for (_, h) in hints.iter() {
match h {
Expand Down Expand Up @@ -244,9 +244,9 @@ fn test_new_transpile_deposit_franklin_existing_account() {
"root hash in state keeper and witness generation code mismatch"
);

use crypto_exports::franklin_crypto::bellman::pairing::bn256::Bn256;
use crypto_exports::franklin_crypto::bellman::plonk::commitments::transcript::keccak_transcript::RollingKeccakTranscript;
use crypto_exports::franklin_crypto::bellman::plonk::*;
use zksync_crypto::franklin_crypto::bellman::pairing::bn256::Bn256;
use zksync_crypto::franklin_crypto::bellman::plonk::commitments::transcript::keccak_transcript::RollingKeccakTranscript;
use zksync_crypto::franklin_crypto::bellman::plonk::*;

// let mut transpiler = Transpiler::new();

Expand All @@ -266,7 +266,7 @@ fn test_new_transpile_deposit_franklin_existing_account() {
hints_hist.insert("into quadratic gate".to_owned(), 0);
hints_hist.insert("into multiplication gate".to_owned(), 0);

use crypto_exports::franklin_crypto::bellman::plonk::better_cs::adaptor::TranspilationVariant;
use zksync_crypto::franklin_crypto::bellman::plonk::better_cs::adaptor::TranspilationVariant;

for (_, h) in hints.iter() {
match h {
Expand Down Expand Up @@ -344,7 +344,7 @@ fn test_new_transpile_deposit_franklin_existing_account() {
make_precomputations(&setup).expect("must make precomputations for proving");
println!("Precomputations generated: {}s", timer.elapsed().as_secs());

use crypto_exports::franklin_crypto::bellman::plonk::fft::cooley_tukey_ntt::*;
use zksync_crypto::franklin_crypto::bellman::plonk::fft::cooley_tukey_ntt::*;

let omegas_bitreversed = BitReversedOmegas::<Fr>::new_for_domain_size(size);
let omegas_inv_bitreversed =
Expand Down Expand Up @@ -418,15 +418,15 @@ fn test_fma_transpile_deposit_franklin_existing_account() {
"root hash in state keeper and witness generation code mismatch"
);

use crypto_exports::franklin_crypto::bellman::pairing::bn256::Bn256;
use crypto_exports::franklin_crypto::bellman::plonk::better_cs::cs::PlonkCsWidth4WithNextStepParams;
use crypto_exports::franklin_crypto::bellman::plonk::better_cs::fma_adaptor::Transpiler;
use zksync_crypto::franklin_crypto::bellman::pairing::bn256::Bn256;
use zksync_crypto::franklin_crypto::bellman::plonk::better_cs::cs::PlonkCsWidth4WithNextStepParams;
use zksync_crypto::franklin_crypto::bellman::plonk::better_cs::fma_adaptor::Transpiler;

let mut transpiler = Transpiler::<Bn256, PlonkCsWidth4WithNextStepParams>::new();

let c = witness_accum.into_circuit_instance();

use crypto_exports::franklin_crypto::bellman::Circuit;
use zksync_crypto::franklin_crypto::bellman::Circuit;
c.clone().synthesize(&mut transpiler).unwrap();

let hints = transpiler.into_hints();
Expand All @@ -438,7 +438,7 @@ fn test_fma_transpile_deposit_franklin_existing_account() {
hints_hist.insert("into multiplication gate".to_owned(), 0);
hints_hist.insert("into fma gate".to_owned(), 0);

use crypto_exports::franklin_crypto::bellman::plonk::better_cs::fma_adaptor::TranspilationVariant;
use zksync_crypto::franklin_crypto::bellman::plonk::better_cs::fma_adaptor::TranspilationVariant;

for (_, h) in hints.iter() {
match h {
Expand Down Expand Up @@ -473,8 +473,8 @@ fn test_fma_transpile_deposit_franklin_existing_account() {

#[test]
fn print_available_setup_powers() {
use crypto_exports::franklin_crypto::bellman::pairing::bn256::Bn256;
use crypto_exports::franklin_crypto::bellman::plonk::*;
use zksync_crypto::franklin_crypto::bellman::pairing::bn256::Bn256;
use zksync_crypto::franklin_crypto::bellman::plonk::*;

let calculate_setup_power = |chunks: usize| -> (usize, u32) {
let circuit = {
Expand Down
10 changes: 5 additions & 5 deletions core/lib/circuit/src/witness/close_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ impl CloseAccountWitness<Bn256> {
//
// use crate::circuit::FranklinCircuit;
// use bellman::Circuit;
// use crypto_exports::franklin_crypto::bellman::pairing::ff::{Field, PrimeField};
// use crypto_exports::franklin_crypto::alt_babyjubjub::AltJubjubBn256;
// use crypto_exports::franklin_crypto::circuit::test::*;
// use crypto_exports::franklin_crypto::eddsa::{PrivateKey, PublicKey};
// use crypto_exports::franklin_crypto::jubjub::FixedGenerators;
// use zksync_crypto::franklin_crypto::bellman::pairing::ff::{Field, PrimeField};
// use zksync_crypto::franklin_crypto::alt_babyjubjub::AltJubjubBn256;
// use zksync_crypto::franklin_crypto::circuit::test::*;
// use zksync_crypto::franklin_crypto::eddsa::{PrivateKey, PublicKey};
// use zksync_crypto::franklin_crypto::jubjub::FixedGenerators;
// use models::circuit::account::{CircuitAccount, CircuitAccountTree, CircuitBalanceTree};
// use models::circuit::utils::*;
// use models::tx::PackedPublicKey;
Expand Down
5 changes: 4 additions & 1 deletion core/lib/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ authors = ["Igor Aleksanov <[email protected]>"]
edition = "2018"

[dependencies]
franklin_crypto = { package = "franklin-crypto", git = "https://github.com/matter-labs/franklin-crypto.git", branch="check-franklin-circuit-transpile"}
rand = "0.4"

num = { version = "0.2", features = ["serde"] }
crypto_exports = { path = "../crypto_exports", version = "0.1.0" }
zksync_basic_types = { path = "../basic_types", version = "0.1.0" }

serde = "1.0"
Expand All @@ -18,3 +20,4 @@ hex = "0.4"

[dev-dependencies]
serde_json = "1.0"

8 changes: 4 additions & 4 deletions core/lib/crypto/src/circuit/utils.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::params;

use crate::ff;
use crate::franklin_crypto::alt_babyjubjub::JubjubEngine;
use crate::franklin_crypto::bellman::pairing::ff::{BitIterator, PrimeField};
use crate::franklin_crypto::eddsa::PublicKey;
use crate::merkle_tree::hasher::Hasher;
use crate::Fr;
use crypto_exports::ff;
use crypto_exports::franklin_crypto::alt_babyjubjub::JubjubEngine;
use crypto_exports::franklin_crypto::bellman::pairing::ff::{BitIterator, PrimeField};
use crypto_exports::franklin_crypto::eddsa::PublicKey;
use zksync_basic_types::Address;

fn pub_key_hash_self<E: JubjubEngine, H: Hasher<E::Fr>>(
Expand Down
2 changes: 1 addition & 1 deletion core/lib/crypto/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pub fn fe_from_hex<F: PrimeField>(value: &str) -> Result<F, failure::Error> {
mod tests {
use super::*;

use crate::rand::{Rand, SeedableRng, XorShiftRng};
use crate::Fr;
use crypto_exports::rand::{Rand, SeedableRng, XorShiftRng};

/// Checks that converting FE to the hex form and back results
/// in the same FE.
Expand Down
10 changes: 10 additions & 0 deletions core/lib/crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ use crate::franklin_crypto::{
jubjub::{FixedGenerators, JubjubEngine},
};

mod crypto_exports {
pub use crate::franklin_crypto::bellman;
pub use crate::franklin_crypto::bellman::pairing;
pub use crate::franklin_crypto::bellman::pairing::ff;
pub use franklin_crypto;
pub use rand;
}

pub use crypto_exports::*;

pub mod circuit;
pub mod convert;
pub mod merkle_tree;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/crypto/src/merkle_tree/parallel_smt.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Sparse Merkle tree with batch updates
use super::hasher::Hasher;
use crate::ff::{PrimeField, PrimeFieldRepr};
use crate::primitives::GetBits;
use crate::Fr;
use crypto_exports::ff::{PrimeField, PrimeFieldRepr};

use fnv::FnvHashMap;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/crypto/src/merkle_tree/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::hasher::Hasher;
use crate::merkle_tree::{parallel_smt, sequential_smt, PedersenHasher};
use crate::primitives::GetBits;
use crate::rand::{Rng, SeedableRng, XorShiftRng};
use crate::{Engine, Fr};
use crypto_exports::rand::{Rng, SeedableRng, XorShiftRng};

/// Applies the proof for the element and compares it against the expected
/// root hash.
Expand Down
11 changes: 0 additions & 11 deletions core/lib/crypto_exports/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions core/lib/crypto_exports/src/lib.rs

This file was deleted.

1 change: 0 additions & 1 deletion core/lib/plasma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ log = "0.4"
failure = "0.1"

[dev-dependencies]
crypto_exports = { path = "../crypto_exports", version = "0.1.0" }
criterion = "0.3.0"
web3 = "0.10.0"

Expand Down
2 changes: 1 addition & 1 deletion core/lib/plasma/benches/criterion/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use std::collections::HashMap;
use criterion::{black_box, criterion_group, BatchSize, Bencher, Criterion, Throughput};
use web3::types::H256;
// Workspace uses
use crypto_exports::rand::{thread_rng, Rng};
use models::{
account::{Account, PubKeyHash},
priority_ops::{Deposit, FullExit},
tx::{ChangePubKey, PackedEthSignature, Transfer, Withdraw},
AccountId, AccountMap, Address, BlockNumber, FranklinPriorityOp, FranklinTx, TokenId,
};
use zksync_crypto::rand::{thread_rng, Rng};
use zksync_crypto::{priv_key_from_fs, PrivateKey};
// Local uses
use plasma::state::PlasmaState;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/plasma/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ impl PlasmaState {
#[cfg(test)]
mod tests {
use super::*;
use crypto_exports::rand::{Rng, SeedableRng, XorShiftRng};
use zksync_crypto::rand::{Rng, SeedableRng, XorShiftRng};

#[test]
fn plasma_state_reversing_updates() {
Expand Down
Loading

0 comments on commit 028206a

Please sign in to comment.