diff --git a/Cargo.lock b/Cargo.lock index eff9abd4af..cf0444284d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -604,6 +604,41 @@ dependencies = [ "snarkos-models", ] +[[package]] +name = "leo-benchmark" +version = "0.1.0" +dependencies = [ + "from-pest", + "lazy_static", + "leo-program", + "pest", + "pest-ast", + "pest_derive", + "rand 0.7.3", + "snarkos-algorithms", + "snarkos-curves", + "snarkos-errors", + "snarkos-gadgets", + "snarkos-models", +] + +[[package]] +name = "leo-program" +version = "0.1.0" +dependencies = [ + "from-pest", + "lazy_static", + "pest", + "pest-ast", + "pest_derive", + "rand 0.7.3", + "snarkos-algorithms", + "snarkos-curves", + "snarkos-errors", + "snarkos-gadgets", + "snarkos-models", +] + [[package]] name = "libc" version = "0.2.67" diff --git a/Cargo.toml b/Cargo.toml index fbf4a1cba7..cd660f70e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,14 @@ edition = "2018" [lib] name = "leo" -path = "src/lib.rs" +path = "program/src/lib.rs" [[bin]] name = "leo" -path = "src/main.rs" +path = "benchmark/src/main.rs" + +[workspace] +members = [ "benchmark", "program" ] [dependencies] snarkos-algorithms = { path = "../snarkOS/algorithms", version = "0.8.0" } diff --git a/benchmark/Cargo.toml b/benchmark/Cargo.toml new file mode 100644 index 0000000000..b415248975 --- /dev/null +++ b/benchmark/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "leo-benchmark" +version = "0.1.0" +authors = ["The Aleo Team "] +edition = "2018" + +[dependencies] +leo-program = { path = "../program", version = "0.1.0" } + +snarkos-algorithms = { path = "../../snarkOS/algorithms", version = "0.8.0" } +snarkos-curves = { path = "../../snarkOS/curves", version = "0.8.0" } +snarkos-errors = { path = "../../snarkOS/errors", version = "0.8.0" } +snarkos-gadgets = { path = "../../snarkOS/gadgets", version = "0.8.0" } +snarkos-models = { path = "../../snarkOS/models", version = "0.8.0" } + +from-pest = { version = "0.3.1" } +lazy_static = { version = "1.3.0" } +pest = { version = "2.0" } +pest-ast = { version = "0.3.3" } +pest_derive = { version = "2.0" } +rand = { version = "0.7" } diff --git a/simple.leo b/benchmark/simple.leo similarity index 100% rename from simple.leo rename to benchmark/simple.leo diff --git a/simple_import.leo b/benchmark/simple_import.leo similarity index 100% rename from simple_import.leo rename to benchmark/simple_import.leo diff --git a/src/main.rs b/benchmark/src/main.rs similarity index 94% rename from src/main.rs rename to benchmark/src/main.rs index 7a1dc6e066..baea1f03d1 100644 --- a/src/main.rs +++ b/benchmark/src/main.rs @@ -1,4 +1,4 @@ -use leo::*; +use leo_program::{self, ast}; use snarkos_algorithms::snark::{ create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof, @@ -45,11 +45,11 @@ impl ConstraintSynthesizer for Benchmark { let syntax_tree = ast::File::from_pest(&mut file).expect("infallible"); // println!("{:#?}", syntax_tree); - let program = program::Program::<'_, F>::from(syntax_tree); + let program = leo_program::Program::<'_, F>::from(syntax_tree); println!(" compiled: {:#?}", program); let program = program.name("simple".into()); - program::ResolvedProgram::generate_constraints(cs, program); + leo_program::ResolvedProgram::generate_constraints(cs, program); Ok(()) } diff --git a/program/Cargo.toml b/program/Cargo.toml new file mode 100644 index 0000000000..edf6119c79 --- /dev/null +++ b/program/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "leo-program" +version = "0.1.0" +authors = ["The Aleo Team "] +edition = "2018" + +[dependencies] +snarkos-algorithms = { path = "../../snarkOS/algorithms", version = "0.8.0" } +snarkos-curves = { path = "../../snarkOS/curves", version = "0.8.0" } +snarkos-errors = { path = "../../snarkOS/errors", version = "0.8.0" } +snarkos-gadgets = { path = "../../snarkOS/gadgets", version = "0.8.0" } +snarkos-models = { path = "../../snarkOS/models", version = "0.8.0" } + +from-pest = { version = "0.3.1" } +lazy_static = { version = "1.3.0" } +pest = { version = "2.0" } +pest-ast = { version = "0.3.3" } +pest_derive = { version = "2.0" } +rand = { version = "0.7" } diff --git a/program/README.md b/program/README.md new file mode 100644 index 0000000000..308f42e8dc --- /dev/null +++ b/program/README.md @@ -0,0 +1 @@ +# leo-program diff --git a/src/ast.rs b/program/src/ast.rs similarity index 100% rename from src/ast.rs rename to program/src/ast.rs diff --git a/src/program/constraints/boolean.rs b/program/src/constraints/boolean.rs similarity index 95% rename from src/program/constraints/boolean.rs rename to program/src/constraints/boolean.rs index ecf9549b7d..25bc5e5bc8 100644 --- a/src/program/constraints/boolean.rs +++ b/program/src/constraints/boolean.rs @@ -1,11 +1,7 @@ //! Methods to enforce constraints on booleans in a resolved aleo program. -//! -//! @file boolean.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::constraints::{ResolvedProgram, ResolvedValue}; -use crate::program::{new_variable_from_variable, Parameter, Variable}; +use crate::constraints::{ResolvedProgram, ResolvedValue}; +use crate::{new_variable_from_variable, Parameter, Variable}; use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::gadgets::{ diff --git a/src/program/constraints/constraints.rs b/program/src/constraints/constraints.rs similarity index 97% rename from src/program/constraints/constraints.rs rename to program/src/constraints/constraints.rs index 057cbf6676..6b5a3a6013 100644 --- a/src/program/constraints/constraints.rs +++ b/program/src/constraints/constraints.rs @@ -1,12 +1,8 @@ //! Methods to enforce constraints a resolved aleo program. -//! -//! @file constraints.rs -//! @author Collin Chin -//! @date 2020 use crate::ast; -use crate::program::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue}; -use crate::program::{Expression, Function, Import, Program, Statement, Type}; +use crate::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue}; +use crate::{Expression, Function, Import, Program, Statement, Type}; use from_pest::FromPest; use snarkos_models::curves::{Field, PrimeField}; diff --git a/src/program/constraints/expression.rs b/program/src/constraints/expression.rs similarity index 98% rename from src/program/constraints/expression.rs rename to program/src/constraints/expression.rs index 423b9c21a5..18df489b9b 100644 --- a/src/program/constraints/expression.rs +++ b/program/src/constraints/expression.rs @@ -1,11 +1,7 @@ //! Methods to enforce constraints on expressions in a resolved aleo program. -//! -//! @file expression.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue}; -use crate::program::{ +use crate::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue}; +use crate::{ Expression, RangeOrExpression, ResolvedStructMember, SpreadOrExpression, StructMember, Variable, }; diff --git a/src/program/constraints/field_element.rs b/program/src/constraints/field_element.rs similarity index 94% rename from src/program/constraints/field_element.rs rename to program/src/constraints/field_element.rs index 7e6491c620..9ff0229e14 100644 --- a/src/program/constraints/field_element.rs +++ b/program/src/constraints/field_element.rs @@ -1,11 +1,7 @@ //! Methods to enforce constraints on field elements in a resolved aleo program. -//! -//! @file field_element.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::constraints::{ResolvedProgram, ResolvedValue}; -use crate::program::{new_variable_from_variable, Parameter, Variable}; +use crate::constraints::{ResolvedProgram, ResolvedValue}; +use crate::{new_variable_from_variable, Parameter, Variable}; use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}; diff --git a/src/program/constraints/integer.rs b/program/src/constraints/integer.rs similarity index 95% rename from src/program/constraints/integer.rs rename to program/src/constraints/integer.rs index 3219311a87..2ba9da1f61 100644 --- a/src/program/constraints/integer.rs +++ b/program/src/constraints/integer.rs @@ -1,11 +1,7 @@ //! Methods to enforce constraints on integers in a resolved aleo program. -//! -//! @file integer.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::constraints::{ResolvedProgram, ResolvedValue}; -use crate::program::{new_variable_from_variable, Integer, Parameter, Variable}; +use crate::constraints::{ResolvedProgram, ResolvedValue}; +use crate::{new_variable_from_variable, Integer, Parameter, Variable}; use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::gadgets::{ diff --git a/src/program/constraints/mod.rs b/program/src/constraints/mod.rs similarity index 82% rename from src/program/constraints/mod.rs rename to program/src/constraints/mod.rs index 98773cf436..bb21afb799 100644 --- a/src/program/constraints/mod.rs +++ b/program/src/constraints/mod.rs @@ -1,8 +1,4 @@ //! Module containing methods to enforce constraints in an aleo program -//! -//! @file constraints/mod.rs -//! @author Collin Chin -//! @date 2020 pub mod boolean; pub use boolean::*; diff --git a/src/program/constraints/resolved_program.rs b/program/src/constraints/resolved_program.rs similarity index 92% rename from src/program/constraints/resolved_program.rs rename to program/src/constraints/resolved_program.rs index f006198ac0..e7400bf52d 100644 --- a/src/program/constraints/resolved_program.rs +++ b/program/src/constraints/resolved_program.rs @@ -1,11 +1,7 @@ //! An in memory store to keep track of defined names when constraining an aleo program. -//! -//! @file resolved_program.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::constraints::ResolvedValue; -use crate::program::types::Variable; +use crate::constraints::ResolvedValue; +use crate::types::Variable; use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::gadgets::r1cs::ConstraintSystem; diff --git a/src/program/constraints/resolved_value.rs b/program/src/constraints/resolved_value.rs similarity index 95% rename from src/program/constraints/resolved_value.rs rename to program/src/constraints/resolved_value.rs index b159c0ab10..e07952334b 100644 --- a/src/program/constraints/resolved_value.rs +++ b/program/src/constraints/resolved_value.rs @@ -1,10 +1,6 @@ //! The in memory stored value for a defined name in a resolved aleo program. -//! -//! @file resolved_value.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::types::{Function, Struct, Type, Variable}; +use crate::types::{Function, Struct, Type, Variable}; use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::gadgets::{utilities::boolean::Boolean, utilities::uint32::UInt32}; diff --git a/src/program/constraints/statement.rs b/program/src/constraints/statement.rs similarity index 97% rename from src/program/constraints/statement.rs rename to program/src/constraints/statement.rs index 8e85da2aab..07d75be183 100644 --- a/src/program/constraints/statement.rs +++ b/program/src/constraints/statement.rs @@ -1,11 +1,7 @@ //! Methods to enforce constraints on statements in a resolved aleo program. -//! -//! @file statement.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue}; -use crate::program::{Assignee, Expression, Integer, RangeOrExpression, Statement, Type, Variable}; +use crate::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue}; +use crate::{Assignee, Expression, Integer, RangeOrExpression, Statement, Type, Variable}; use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::gadgets::{r1cs::ConstraintSystem, utilities::uint32::UInt32}; diff --git a/src/program/imports.rs b/program/src/imports.rs similarity index 100% rename from src/program/imports.rs rename to program/src/imports.rs diff --git a/src/leo.pest b/program/src/leo.pest similarity index 100% rename from src/leo.pest rename to program/src/leo.pest diff --git a/src/program/mod.rs b/program/src/lib.rs similarity index 51% rename from src/program/mod.rs rename to program/src/lib.rs index 274f6b930f..33b53b3b98 100644 --- a/src/program/mod.rs +++ b/program/src/lib.rs @@ -1,8 +1,14 @@ -//! Module containing structs and types that make up an aleo program. -//! -//! @file aleo_program/mod.rs -//! @author Collin Chin -//! @date 2020 +//! Module containing structs and types that make up an Leo program. + +extern crate from_pest; +#[macro_use] +extern crate lazy_static; +extern crate pest; +extern crate pest_ast; +#[macro_use] +extern crate pest_derive; + +pub mod ast; pub mod constraints; pub use self::constraints::*; diff --git a/src/program/types.rs b/program/src/types.rs similarity index 97% rename from src/program/types.rs rename to program/src/types.rs index c1c0fe4c51..612ba0df8d 100644 --- a/src/program/types.rs +++ b/program/src/types.rs @@ -1,11 +1,7 @@ //! A typed program in aleo consists of import, struct, and function definitions. //! Each defined type consists of typed statements and expressions. -//! -//! @file types.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::Import; +use crate::Import; use snarkos_models::curves::{Field, PrimeField}; use std::collections::HashMap; diff --git a/src/program/types_display.rs b/program/src/types_display.rs similarity index 98% rename from src/program/types_display.rs rename to program/src/types_display.rs index a3609547f1..e89d90cbc7 100644 --- a/src/program/types_display.rs +++ b/program/src/types_display.rs @@ -1,10 +1,6 @@ //! Format display functions for zokrates_program types. -//! -//! @file zokrates_program.rs -//! @author Collin Chin -//! @date 2020 -use crate::program::{ +use crate::{ Assignee, Expression, Function, FunctionName, Integer, Parameter, RangeOrExpression, SpreadOrExpression, Statement, Struct, StructField, Type, Variable, }; diff --git a/src/program/types_from.rs b/program/src/types_from.rs similarity index 99% rename from src/program/types_from.rs rename to program/src/types_from.rs index bce72baeb8..ba44a4e17d 100644 --- a/src/program/types_from.rs +++ b/program/src/types_from.rs @@ -1,11 +1,7 @@ //! Logic to convert from an abstract syntax tree (ast) representation to a typed aleo program. -//! -//! @file types_from.rs -//! @author Collin Chin -//! @date 2020 use crate::ast; -use crate::program::{types, Import, PathString}; +use crate::{types, Import, PathString}; use snarkos_models::curves::{Field, PrimeField}; use std::collections::HashMap; diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 2a09da9bab..0000000000 --- a/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -extern crate from_pest; -extern crate pest; -extern crate pest_ast; -#[macro_use] -extern crate pest_derive; - -#[macro_use] -extern crate lazy_static; - -pub mod ast; -pub mod program;