fix imports

This commit is contained in:
collin 2020-05-05 18:40:25 -07:00
parent d7167f5b2b
commit dcd484a62f
17 changed files with 91 additions and 75 deletions

View File

@ -1,6 +1,7 @@
use leo_compiler::errors::CompilerError; use leo_compiler::{self, ast, errors::CompilerError, ParameterValue, Program};
use leo_compiler::{self, ast, ParameterValue, Program};
use from_pest::FromPest;
use rand::thread_rng;
use snarkos_algorithms::snark::{ use snarkos_algorithms::snark::{
create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof, create_random_proof, generate_random_parameters, prepare_verifying_key, verify_proof,
}; };
@ -10,9 +11,6 @@ use snarkos_models::{
curves::{Field, PrimeField}, curves::{Field, PrimeField},
gadgets::r1cs::{ConstraintSynthesizer, ConstraintSystem}, gadgets::r1cs::{ConstraintSynthesizer, ConstraintSystem},
}; };
use from_pest::FromPest;
use rand::thread_rng;
use std::{ use std::{
fs, fs,
marker::PhantomData, marker::PhantomData,

View File

@ -1,8 +1,4 @@
//! Abstract syntax tree (ast) representation from leo.pest. //! Abstract syntax tree (ast) representation from leo.pest.
//!
//! @file zokrates_program.rs
//! @author Howard Wu <howard@aleo.org>
//! @date 2020
use from_pest::{ConversionError, FromPest, Void}; use from_pest::{ConversionError, FromPest, Void};
use pest::{ use pest::{

View File

@ -1,5 +1,6 @@
use crate::errors::CompilerError; //! Compiles a Leo program from a file path.
use crate::{ast, ParameterValue, Program, ResolvedProgram, ResolvedValue};
use crate::{ast, errors::CompilerError, ParameterValue, Program, ResolvedProgram, ResolvedValue};
use snarkos_errors::gadgets::SynthesisError; use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::{ use snarkos_models::{

View File

@ -1,13 +1,17 @@
//! Methods to enforce constraints on booleans in a resolved aleo program. //! Methods to enforce constraints on booleans in a resolved Leo program.
use crate::constraints::{ResolvedProgram, ResolvedValue}; use crate::{
use crate::{new_variable_from_variable, ParameterModel, ParameterValue, Variable}; constraints::{new_variable_from_variable, ResolvedProgram, ResolvedValue},
types::{ParameterModel, ParameterValue, Variable},
};
use snarkos_errors::gadgets::SynthesisError; use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::{ curves::{Field, PrimeField},
r1cs::ConstraintSystem, gadgets::{
utilities::{alloc::AllocGadget, boolean::Boolean, eq::EqGadget}, r1cs::ConstraintSystem,
utilities::{alloc::AllocGadget, boolean::Boolean, eq::EqGadget},
},
}; };
impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> { impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {

View File

@ -1,14 +1,17 @@
//! Methods to enforce constraints on expressions in a resolved aleo program. //! Methods to enforce constraints on expressions in a resolved Leo program.
use crate::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue};
use crate::{ use crate::{
new_variable_from_variable, Expression, RangeOrExpression, ResolvedStructMember, constraints::{
SpreadOrExpression, StructMember, Variable, new_scope_from_variable, new_variable_from_variable, ResolvedProgram, ResolvedStructMember,
ResolvedValue,
},
types::{Expression, RangeOrExpression, SpreadOrExpression, StructMember, Variable},
}; };
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::r1cs::ConstraintSystem; curves::{Field, PrimeField},
use snarkos_models::gadgets::utilities::boolean::Boolean; gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean},
};
impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> { impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
/// Enforce a variable expression by getting the resolved value /// Enforce a variable expression by getting the resolved value

View File

@ -1,13 +1,17 @@
//! Methods to enforce constraints on field elements in a resolved aleo program. //! Methods to enforce constraints on field elements in a resolved Leo program.
use crate::constraints::{ResolvedProgram, ResolvedValue}; use crate::{
use crate::{new_variable_from_variable, FieldElement, ParameterModel, ParameterValue, Variable}; constraints::{new_variable_from_variable, FieldElement, ResolvedProgram, ResolvedValue},
types::{ParameterModel, ParameterValue, Variable},
};
use snarkos_errors::gadgets::SynthesisError; use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::{ curves::{Field, PrimeField},
r1cs::{ConstraintSystem, LinearCombination, Variable as R1CSVariable}, gadgets::{
utilities::uint32::UInt32, r1cs::{ConstraintSystem, LinearCombination, Variable as R1CSVariable},
utilities::uint32::UInt32,
},
}; };
impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> { impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {

View File

@ -1,14 +1,17 @@
//! Methods to enforce constraints on integers in a resolved aleo program. //! Methods to enforce constraints on integers in a resolved Leo program.
use crate::constraints::{ResolvedProgram, ResolvedValue}; use crate::{
use crate::{new_variable_from_variable, Integer, ParameterModel, ParameterValue, Variable}; constraints::{new_variable_from_variable, ResolvedProgram, ResolvedValue},
types::{Integer, ParameterModel, ParameterValue, Variable},
};
use snarkos_errors::gadgets::SynthesisError; use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::utilities::eq::EqGadget; curves::{Field, PrimeField},
use snarkos_models::gadgets::{ gadgets::{
r1cs::ConstraintSystem, r1cs::ConstraintSystem,
utilities::{alloc::AllocGadget, boolean::Boolean, uint32::UInt32}, utilities::{alloc::AllocGadget, boolean::Boolean, eq::EqGadget, uint32::UInt32},
},
}; };
impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> { impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {

View File

@ -1,4 +1,5 @@
//! Methods to enforce constraints and construct a resolved aleo program. //! Methods to enforce the main function with arguments in
//! a resolved Leo program.
use crate::{ use crate::{
ast, ast,
@ -6,13 +7,15 @@ use crate::{
new_scope, new_scope_from_variable, new_variable_from_variables, ResolvedProgram, new_scope, new_scope_from_variable, new_variable_from_variables, ResolvedProgram,
ResolvedValue, ResolvedValue,
}, },
types::{Expression, Function, Program, Type}, types::{Expression, Function, ParameterValue, Program, Type},
Import, ParameterValue, Import,
}; };
use from_pest::FromPest; use from_pest::FromPest;
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::r1cs::ConstraintSystem; curves::{Field, PrimeField},
gadgets::r1cs::ConstraintSystem,
};
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;

View File

@ -1,10 +1,10 @@
//! Module containing methods to enforce constraints in an aleo program //! Module containing methods to enforce constraints in an Leo program
pub mod boolean; pub mod boolean;
pub use boolean::*; pub use boolean::*;
pub mod constraints; pub mod main_function;
pub use constraints::*; pub use main_function::*;
pub mod expression; pub mod expression;
pub use expression::*; pub use expression::*;

View File

@ -1,12 +1,12 @@
//! An in memory store to keep track of defined names when constraining an aleo program. //! An in memory store to keep track of defined names when constraining a Leo program.
use crate::constraints::ResolvedValue; use crate::{constraints::ResolvedValue, types::Variable};
use crate::types::Variable;
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::r1cs::ConstraintSystem; curves::{Field, PrimeField},
use std::collections::HashMap; gadgets::r1cs::ConstraintSystem,
use std::marker::PhantomData; };
use std::{collections::HashMap, marker::PhantomData};
pub struct ResolvedProgram<F: Field + PrimeField, CS: ConstraintSystem<F>> { pub struct ResolvedProgram<F: Field + PrimeField, CS: ConstraintSystem<F>> {
pub resolved_names: HashMap<String, ResolvedValue<F>>, pub resolved_names: HashMap<String, ResolvedValue<F>>,

View File

@ -1,10 +1,12 @@
//! The in memory stored value for a defined name in a resolved aleo program. //! The in memory stored value for a defined name in a resolved Leo program.
use crate::types::{Function, Struct, Type, Variable}; use crate::types::{Function, Struct, Type, Variable};
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::{ curves::{Field, PrimeField},
r1cs::Variable as R1CSVariable, utilities::boolean::Boolean, utilities::uint32::UInt32, gadgets::{
r1cs::Variable as R1CSVariable, utilities::boolean::Boolean, utilities::uint32::UInt32,
},
}; };
use std::fmt; use std::fmt;

View File

@ -1,14 +1,16 @@
//! Methods to enforce constraints on statements in a resolved aleo program. //! Methods to enforce constraints on statements in a resolved Leo program.
use crate::constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue};
use crate::{ use crate::{
Assignee, ConditionalNestedOrEnd, ConditionalStatement, Expression, Integer, RangeOrExpression, constraints::{new_scope_from_variable, ResolvedProgram, ResolvedValue},
Statement, Type, Variable, types::{
Assignee, ConditionalNestedOrEnd, ConditionalStatement, Expression, Integer,
RangeOrExpression, Statement, Type, Variable,
},
}; };
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::{
use snarkos_models::gadgets::{ curves::{Field, PrimeField},
r1cs::ConstraintSystem, utilities::boolean::Boolean, utilities::uint32::UInt32, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean, utilities::uint32::UInt32},
}; };
impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> { impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {

View File

@ -1,3 +1,5 @@
//! The Import type for a Leo program.
use crate::Variable; use crate::Variable;
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::curves::{Field, PrimeField};

View File

@ -1,4 +1,4 @@
//! Module containing structs and types that make up an Leo program. //! Module containing structs and types that make up a Leo program.
#[macro_use] #[macro_use]
extern crate failure; extern crate failure;

View File

@ -1,4 +1,4 @@
//! A typed program in aleo consists of import, struct, and function definitions. //! A typed Leo program consists of import, struct, and function definitions.
//! Each defined type consists of typed statements and expressions. //! Each defined type consists of typed statements and expressions.
use crate::Import; use crate::Import;

View File

@ -1,4 +1,4 @@
//! Format display functions for zokrates_program types. //! Format display functions for Leo types.
use crate::{ use crate::{
Assignee, ConditionalNestedOrEnd, ConditionalStatement, Expression, Function, FunctionName, Assignee, ConditionalNestedOrEnd, ConditionalStatement, Expression, Function, FunctionName,

View File

@ -1,11 +1,9 @@
//! Logic to convert from an abstract syntax tree (ast) representation to a typed aleo program. //! Logic to convert from an abstract syntax tree (ast) representation to a Leo program.
use crate::{ast, FunctionName}; use crate::{ast, types, Import, ImportSymbol};
use crate::{types, Import, ImportSymbol};
use snarkos_models::curves::{Field, PrimeField}; use snarkos_models::curves::{Field, PrimeField};
use std::collections::HashMap; use std::{collections::HashMap, marker::PhantomData};
use std::marker::PhantomData;
/// pest ast -> types::Variable /// pest ast -> types::Variable
@ -730,7 +728,7 @@ impl<'ast, F: Field + PrimeField> types::Program<F> {
); );
}); });
if let Some(main_function) = functions.get(&FunctionName("main".into())) { if let Some(main_function) = functions.get(&types::FunctionName("main".into())) {
num_parameters = main_function.parameters.len(); num_parameters = main_function.parameters.len();
} }