Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local paths for in-workspace dependencies #7

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

This repository contains the cryptography libraries for ZKsync project.

- [ff](./crates/ff) and [ff_derive](./crates/ff_derive/)
- [pairing](./crates/pairing/)
- [bellman](./crates/bellman/)
- [franklin-crypto](./crates/franklin-crypto/)
- [boojum](./crates/boojum/)
- [boojum](./crates/boojum/) and [cs_derive](./crates/cs_derive/)
- [rescue-poseidon](./crates/rescue-poseidon/)
- [Solidity verification contract generator](./crates/codegen) and [CLI application](./crates/codegen-bin/).

Expand Down
24 changes: 11 additions & 13 deletions crates/bellman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,24 @@ edition = "2018"
crate-type = ["cdylib", "lib", "staticlib"]

[dependencies]
pairing = {package = "pairing_ce", version = "=0.28.6", path = "../pairing" }

rand = "0.4"
bit-vec = { version = "0.6", features = ["serde"] }
cfg-if = "1.*"
smallvec = "1.10"
arrayvec = "0.7"
byteorder = "1"
num_cpus = "1"
serde = {version = "1", features = ["derive", "rc"]}

pairing = {package = "pairing_ce", version = "=0.28.6" }
# pairing = {package = "pairing_ce", path = "../pairing"}

futures = {package = "futures", version = "0.3", default-features = false, features = ["executor"]}
crossbeam = {version = "0.7", optional = true}
prefetch = {version = "0.2", optional = true}
web-sys = {version = "0.3", optional = true, features = ["console", "Performance", "Window"]}
tiny-keccak = {version = "1.5", optional = true}
blake2-rfc = {version = "0.2.18", optional = true}
blake2s_simd = {version = "0.5"}
lazy_static = {version = "1", optional = true}
serde = { version = "1", features = ["derive", "rc"] }
futures = { version = "0.3", default-features = false, features = ["executor"] }
crossbeam = { version = "0.7", optional = true }
prefetch = { version = "0.2", optional = true }
web-sys = { version = "0.3", optional = true, features = ["console", "Performance", "Window"] }
tiny-keccak = { version = "1.5", optional = true }
blake2-rfc = { version = "0.2.18", optional = true }
blake2s_simd = { version = "0.5" }
lazy_static = { version = "1", optional = true }
hex = "0.4"

[features]
Expand Down
6 changes: 4 additions & 2 deletions crates/boojum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ license = "MIT OR Apache-2.0"
keywords = ["blockchain", "zksync"]
categories = ["cryptography"]
description = "Boojum cryptographic library"
exclude = [ "profiling-target" ]

[dependencies]
cs_derive = { version = "=0.2.2", path = "../cs_derive" }
pairing = { package = "pairing_ce", version = "=0.28.6", path = "../pairing" }

derivative = "2"
serde = { version = "1", features = ["derive"] }
rand = "0.8"
Expand All @@ -25,12 +29,10 @@ arrayvec = "0.7"
const_format = "0.2"
bincode = "1.3"
ethereum-types = "=0.14.1"
cs_derive = { version = "=0.2.2", path = "./cs_derive" }
itertools = "0.10"
blake2 = "0.10"
sha2 = "0.10"
num-modular = "0.5.1"
pairing = { package = "pairing_ce", version = "=0.28.6" }
crypto-bigint = "0.5"
convert_case = "0.6"
firestorm = "0.5"
Expand Down
6 changes: 3 additions & 3 deletions crates/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ description = "ZKsync solidity codegen for vks"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
franklin-crypto = { version = "=0.2.2", features = ["plonk"], path = "../franklin-crypto" }
rescue_poseidon = { version = "=0.5.2", path = "../rescue-poseidon" }

handlebars = "3.5.5"
serde = "1"
serde_derive = "1"
serde_json = "1"

franklin-crypto = {features = ["plonk"], version = "=0.1.0" }
rescue-poseidon = {package = "rescue_poseidon", version = "=0.4.1" }

hex = "0.4.3"
paste = "1.0"
ethereum-types = "=0.14.1"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use proc_macro2::{Ident, Literal, Span, TokenStream};
use proc_macro_error::abort_call_site;
use quote::quote;
use syn::{
parse_macro_input, token::Comma, Attribute, Data, DeriveInput, Fields, GenericParam, Generics,
Type, TypeArray, TypePath,
};
use syn::{parse_macro_input, token::Comma, Attribute, Data, DeriveInput, Fields, GenericParam, Generics, Type, TypeArray, TypePath};

use crate::utils::*;

Expand All @@ -14,29 +11,18 @@ const PRETTY_COMPARISON_ATTR: &'static str = "DerivePrettyComparison";
pub(crate) fn derive_allocatable(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let derived_input = parse_macro_input!(input as DeriveInput);

let DeriveInput {
ident,
data,
generics,
attrs,
..
} = derived_input.clone();
let DeriveInput { ident, data, generics, attrs, .. } = derived_input.clone();

let serde_remove_bounds =
if let Some(serde_remove_bounds) = fetch_attr_nopanic(SERDE_REMOVE_BOUNDS, &attrs) {
let serde_remove_bounds =
syn::parse_str::<syn::Expr>(&serde_remove_bounds).expect("has attr as Expr");
let serde_remove_bounds = if let Some(serde_remove_bounds) = fetch_attr_nopanic(SERDE_REMOVE_BOUNDS, &attrs) {
let serde_remove_bounds = syn::parse_str::<syn::Expr>(&serde_remove_bounds).expect("has attr as Expr");

serde_remove_bounds == syn::parse_str::<syn::Expr>("true").unwrap()
} else {
false
};
serde_remove_bounds == syn::parse_str::<syn::Expr>("true").unwrap()
} else {
false
};

let derive_pretty_comparison = if let Some(derive_pretty_comparison) =
fetch_attr_from_list(PRETTY_COMPARISON_ATTR, &attrs)
{
let derive_pretty_comparison =
syn::parse_str::<syn::Expr>(&derive_pretty_comparison).expect("has attr as Expr");
let derive_pretty_comparison = if let Some(derive_pretty_comparison) = fetch_attr_from_list(PRETTY_COMPARISON_ATTR, &attrs) {
let derive_pretty_comparison = syn::parse_str::<syn::Expr>(&derive_pretty_comparison).expect("has attr as Expr");

derive_pretty_comparison == syn::parse_str::<syn::Expr>("true").unwrap()
} else {
Expand All @@ -58,45 +44,29 @@ pub(crate) fn derive_allocatable(input: proc_macro::TokenStream) -> proc_macro::
let field_ident = field.ident.clone().expect("a field ident");

let allocation_line = match field.ty {
Type::Path(ref _path_ty) => {
derive_allocate_by_type_path(&field_ident, _path_ty)
}
Type::Array(ref _arr_ty) => {
derive_allocate_by_array_type(&field_ident, _arr_ty)
}
Type::Path(ref _path_ty) => derive_allocate_by_type_path(&field_ident, _path_ty),
Type::Array(ref _arr_ty) => derive_allocate_by_array_type(&field_ident, _arr_ty),
_ => abort_call_site!("only array and path types are allowed"),
};
allocations.extend(allocation_line);

let allocation_without_value_line = match field.ty {
Type::Path(ref _path_ty) => {
derive_allocate_without_value_by_type_path(&field_ident, _path_ty)
}
Type::Array(ref _arr_ty) => {
derive_allocate_without_value_by_array_type(&field_ident, _arr_ty)
}
Type::Path(ref _path_ty) => derive_allocate_without_value_by_type_path(&field_ident, _path_ty),
Type::Array(ref _arr_ty) => derive_allocate_without_value_by_array_type(&field_ident, _arr_ty),
_ => abort_call_site!("only array and path types are allowed"),
};
allocations_without_value.extend(allocation_without_value_line);

let allocations_as_constant_line = match field.ty {
Type::Path(ref _path_ty) => {
derive_allocate_as_constant_by_type_path(&field_ident, _path_ty)
}
Type::Array(ref _arr_ty) => {
derive_allocate_as_constant_by_array_type(&field_ident, _arr_ty)
}
Type::Path(ref _path_ty) => derive_allocate_as_constant_by_type_path(&field_ident, _path_ty),
Type::Array(ref _arr_ty) => derive_allocate_as_constant_by_array_type(&field_ident, _arr_ty),
_ => abort_call_site!("only array and path types are allowed"),
};
allocations_as_constant.extend(allocations_as_constant_line);

let placeholder_init_line = match field.ty {
Type::Path(ref _path_ty) => {
derive_placeholder_witness_by_type(&field_ident, _path_ty)
}
Type::Array(ref _arr_ty) => {
derive_placeholder_witness_by_array_type(&field_ident, _arr_ty)
}
Type::Path(ref _path_ty) => derive_placeholder_witness_by_type(&field_ident, _path_ty),
Type::Array(ref _arr_ty) => derive_placeholder_witness_by_array_type(&field_ident, _arr_ty),
_ => abort_call_site!("only array and path types are allowed"),
};

Expand Down Expand Up @@ -225,7 +195,7 @@ pub(crate) fn derive_allocatable(input: proc_macro::TokenStream) -> proc_macro::
};

if derive_pretty_comparison {
expanded.extend(quote!{
expanded.extend(quote! {
impl #generics PrettyComparison<F> for #ident<#type_params_of_allocated_struct> #where_clause {
fn find_diffs(a: &Self::Witness, b: &Self::Witness) -> Vec<String> {
let mut comparison_lines = vec![];
Expand Down Expand Up @@ -369,20 +339,14 @@ pub(crate) fn get_equivalent_type_recursive(original_ty: &Type) -> (Type, SerdeD
<#ty as CSAllocatable<F>>::Witness
};
let ts = proc_macro::TokenStream::from(ts);
(
Type::Path(syn::parse::<TypePath>(ts).unwrap()),
SerdeDeriveToUse::BigArray,
)
(Type::Path(syn::parse::<TypePath>(ts).unwrap()), SerdeDeriveToUse::BigArray)
}
Type::Path(ty) => {
let ts = quote! {
<#ty as CSAllocatable<F>>::Witness
};
let ts = proc_macro::TokenStream::from(ts);
(
Type::Path(syn::parse::<TypePath>(ts).unwrap()),
SerdeDeriveToUse::Default,
)
(Type::Path(syn::parse::<TypePath>(ts).unwrap()), SerdeDeriveToUse::Default)
}
_ => abort_call_site!("only array and path types are allowed"),
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
use proc_macro2::{Span, TokenStream};
use proc_macro_error::abort_call_site;
use quote::quote;
use syn::{
parse_macro_input, punctuated::Punctuated, token::Comma, DeriveInput, GenericParam, Generics,
Type, WhereClause,
};
use syn::{parse_macro_input, punctuated::Punctuated, token::Comma, DeriveInput, GenericParam, Generics, Type, WhereClause};

use crate::utils::*;

const BOUND_ATTR_NAME: &'static str = "CSSelectableBound";

pub(crate) fn derive_select(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let derived_input = parse_macro_input!(input as DeriveInput);
let DeriveInput {
ident,
generics,
data,
attrs,
..
} = derived_input.clone();
let DeriveInput { ident, generics, data, attrs, .. } = derived_input.clone();

let mut struct_initializations = TokenStream::new();
let mut field_selections = TokenStream::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ pub(crate) fn fetch_attr_nopanic(name: &str, attrs: &[syn::Attribute]) -> Option
None
}

pub(crate) fn has_proper_small_field_parameter<P>(
generic_params: &Punctuated<GenericParam, P>,
expected: &GenericParam,
) -> bool {
pub(crate) fn has_proper_small_field_parameter<P>(generic_params: &Punctuated<GenericParam, P>, expected: &GenericParam) -> bool {
for p in generic_params.iter() {
if p == expected {
return true;
Expand All @@ -98,10 +95,7 @@ pub(crate) fn has_proper_small_field_parameter<P>(
return false;
}

pub(crate) fn get_type_params_from_generics<P: Clone + Default>(
generics: &Generics,
punc: &P,
) -> Punctuated<Ident, P> {
pub(crate) fn get_type_params_from_generics<P: Clone + Default>(generics: &Generics, punc: &P) -> Punctuated<Ident, P> {
let type_params = generics.type_params();
let const_params = generics.const_params();

Expand All @@ -128,10 +122,7 @@ pub(crate) fn get_witness_ident(original_ident: &Ident) -> Ident {
syn::parse_str(&witness_ident_str).unwrap()
}

pub(crate) fn get_type_params_from_generics_output_params<P: Clone + Default>(
generics: &Generics,
punc: &P,
) -> Punctuated<GenericParam, P> {
pub(crate) fn get_type_params_from_generics_output_params<P: Clone + Default>(generics: &Generics, punc: &P) -> Punctuated<GenericParam, P> {
let type_params = generics.type_params();
let const_params = generics.const_params();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
use proc_macro2::{Span, TokenStream};
use proc_macro_error::abort_call_site;
use quote::quote;
use syn::{
parse_macro_input, punctuated::Punctuated, token::Comma, DeriveInput, GenericParam, Type,
WhereClause,
};
use syn::{parse_macro_input, punctuated::Punctuated, token::Comma, DeriveInput, GenericParam, Type, WhereClause};

use crate::utils::*;

const BOUND_ATTR_NAME: &'static str = "CSVarLengthEncodableBound";

pub(crate) fn derive_var_length_encodable(
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
pub(crate) fn derive_var_length_encodable(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let derived_input = parse_macro_input!(input as DeriveInput);
let DeriveInput {
ident,
generics,
data,
attrs,
..
} = derived_input.clone();
let DeriveInput { ident, generics, data, attrs, .. } = derived_input.clone();

let mut length_impls = TokenStream::new();
let mut field_impls = TokenStream::new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
use proc_macro2::{Span, TokenStream};
use proc_macro_error::abort_call_site;
use quote::quote;
use syn::{
parse_macro_input, punctuated::Punctuated, token::Comma, DeriveInput, GenericParam, Generics,
Type, WhereClause,
};
use syn::{parse_macro_input, punctuated::Punctuated, token::Comma, DeriveInput, GenericParam, Generics, Type, WhereClause};

use crate::utils::*;

const BOUND_ATTR_NAME: &'static str = "WitnessHookBound";

pub(crate) fn derive_witness_hook(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let derived_input = parse_macro_input!(input as DeriveInput);
let DeriveInput {
ident,
generics,
data,
attrs,
..
} = derived_input.clone();
let DeriveInput { ident, generics, data, attrs, .. } = derived_input.clone();

let mut struct_initializations = TokenStream::new();
let mut field_selections = TokenStream::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@ use crate::utils::*;

const BOUND_ATTR_NAME: &'static str = "WitnessVarLengthEncodableBound";

pub(crate) fn derive_witness_var_length_encodable(
input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
pub(crate) fn derive_witness_var_length_encodable(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let derived_input = parse_macro_input!(input as DeriveInput);
let DeriveInput {
ident,
generics,
data,
attrs,
..
} = derived_input.clone();
let DeriveInput { ident, generics, data, attrs, .. } = derived_input.clone();

let mut witness_to_buffer_impls = TokenStream::new();
let mut witness_length_impls = TokenStream::new();
Expand Down
5 changes: 2 additions & 3 deletions crates/ff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ license = "MIT/Apache-2.0"
repository = "https://github.com/matter-labs/ff"
edition = "2018"
exclude = [
"ff_derive_const",
"tester",
"asm_tester"
]

[dependencies]
ff_derive_ce = { version = "0.11", optional = true, path = "../ff_derive" }

byteorder = "1"
rand = "0.4"
ff_derive_ce = { version = "0.11", optional = true }
# ff_derive_ce = { path = "ff_derive", optional = true }
hex = {version = "0.4"}
serde = "1"

Expand Down
4 changes: 0 additions & 4 deletions crates/ff/ff_derive/src/asm/mod.rs

This file was deleted.

Loading
Loading