fix dependency

This commit is contained in:
collin 2020-06-01 18:35:43 -07:00
parent 8ab5108558
commit 69df8306a5
24 changed files with 122 additions and 86 deletions

View File

@ -1,8 +1,10 @@
use crate::errors::GroupError;
use crate::{ConstrainedValue, GroupType, InputValue};
use crate::{errors::GroupError, ConstrainedValue, GroupType, InputValue};
use snarkos_errors::gadgets::SynthesisError;
use snarkos_models::curves::{Field, PrimeField};
use snarkos_models::gadgets::r1cs::ConstraintSystem;
use snarkos_models::{
curves::{Field, PrimeField},
gadgets::r1cs::ConstraintSystem,
};
pub(crate) fn group_from_input<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
cs: &mut CS,

View File

@ -12,8 +12,7 @@ use snarkos_models::{
curves::{Field, PrimeField},
gadgets::r1cs::ConstraintSystem,
};
use std::env::current_dir;
use std::fs;
use std::{env::current_dir, fs};
impl<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>> ConstrainedProgram<F, G, CS> {
pub fn enforce_import(

View File

@ -1,7 +1,6 @@
//! An in memory store to keep track of defined names when constraining a Leo program.
use crate::constraints::ConstrainedValue;
use crate::GroupType;
use crate::{constraints::ConstrainedValue, GroupType};
use snarkos_models::{
curves::{Field, PrimeField},

View File

@ -1,7 +1,6 @@
use crate::errors::{FunctionError, ImportError, IntegerError};
use std::io;
use std::path::PathBuf;
use std::{io, path::PathBuf};
#[derive(Debug, Error)]
pub enum CompilerError {

View File

@ -1,4 +1,5 @@
use crate::errors::ValueError;
use snarkos_errors::gadgets::SynthesisError;
#[derive(Debug, Error)]

View File

@ -1,5 +1,4 @@
use std::io;
use std::path::PathBuf;
use std::{io, path::PathBuf};
#[derive(Debug, Error)]
pub enum ImportError {

View File

@ -1,4 +1,5 @@
use crate::errors::{BooleanError, ExpressionError, FieldElementError, IntegerError, ValueError};
use snarkos_errors::gadgets::SynthesisError;
#[derive(Debug, Error)]

View File

@ -1,7 +1,6 @@
use crate::errors::{GroupError, IntegerError};
use std::num::ParseIntError;
use std::str::ParseBoolError;
use std::{num::ParseIntError, str::ParseBoolError};
#[derive(Debug, Error)]
pub enum ValueError {

View File

@ -1,22 +1,27 @@
use crate::errors::GroupError;
use crate::GroupType;
use crate::{errors::GroupError, GroupType};
use snarkos_curves::edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq};
use snarkos_curves::templates::twisted_edwards_extended::GroupAffine;
use snarkos_curves::{
edwards_bls12::{EdwardsAffine, EdwardsParameters, Fq},
templates::twisted_edwards_extended::GroupAffine,
};
use snarkos_errors::gadgets::SynthesisError;
use snarkos_gadgets::curves::edwards_bls12::EdwardsBlsGadget;
use snarkos_models::curves::AffineCurve;
use snarkos_models::gadgets::curves::{FpGadget, GroupGadget};
use snarkos_models::gadgets::r1cs::ConstraintSystem;
use snarkos_models::gadgets::utilities::alloc::AllocGadget;
use snarkos_models::gadgets::utilities::boolean::Boolean;
use snarkos_models::gadgets::utilities::eq::{ConditionalEqGadget, EqGadget};
use snarkos_models::gadgets::utilities::select::CondSelectGadget;
use snarkos_models::gadgets::utilities::{ToBitsGadget, ToBytesGadget};
use std::borrow::Borrow;
use std::ops::Sub;
use std::str::FromStr;
use snarkos_models::gadgets::utilities::uint8::UInt8;
use snarkos_models::{
curves::AffineCurve,
gadgets::{
curves::{FpGadget, GroupGadget},
r1cs::ConstraintSystem,
utilities::{
alloc::AllocGadget,
boolean::Boolean,
eq::{ConditionalEqGadget, EqGadget},
select::CondSelectGadget,
uint8::UInt8,
ToBitsGadget, ToBytesGadget,
},
},
};
use std::{borrow::Borrow, ops::Sub, str::FromStr};
#[derive(Clone, Debug)]
pub enum EdwardsGroupType {
@ -268,12 +273,18 @@ impl CondSelectGadget<Fq> for EdwardsGroupType {
}
impl ToBitsGadget<Fq> for EdwardsGroupType {
fn to_bits<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<Boolean>, SynthesisError> {
fn to_bits<CS: ConstraintSystem<Fq>>(
&self,
mut cs: CS,
) -> Result<Vec<Boolean>, SynthesisError> {
let self_gadget = self.allocated(&mut cs)?;
self_gadget.to_bits(cs)
}
fn to_bits_strict<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<Boolean>, SynthesisError> {
fn to_bits_strict<CS: ConstraintSystem<Fq>>(
&self,
mut cs: CS,
) -> Result<Vec<Boolean>, SynthesisError> {
let self_gadget = self.allocated(&mut cs)?;
self_gadget.to_bits_strict(cs)
}
@ -285,7 +296,10 @@ impl ToBytesGadget<Fq> for EdwardsGroupType {
self_gadget.to_bytes(cs)
}
fn to_bytes_strict<CS: ConstraintSystem<Fq>>(&self, mut cs: CS) -> Result<Vec<UInt8>, SynthesisError> {
fn to_bytes_strict<CS: ConstraintSystem<Fq>>(
&self,
mut cs: CS,
) -> Result<Vec<UInt8>, SynthesisError> {
let self_gadget = self.allocated(&mut cs)?;
self_gadget.to_bytes_strict(cs)
}

View File

@ -1,10 +1,17 @@
use crate::errors::GroupError;
use snarkos_models::curves::Field;
use snarkos_models::gadgets::r1cs::ConstraintSystem;
use snarkos_models::gadgets::utilities::alloc::AllocGadget;
use snarkos_models::gadgets::utilities::eq::{ConditionalEqGadget, EqGadget};
use snarkos_models::gadgets::utilities::select::CondSelectGadget;
use snarkos_models::gadgets::utilities::{ToBitsGadget, ToBytesGadget};
use snarkos_models::{
curves::Field,
gadgets::{
r1cs::ConstraintSystem,
utilities::{
alloc::AllocGadget,
eq::{ConditionalEqGadget, EqGadget},
select::CondSelectGadget,
ToBitsGadget, ToBytesGadget,
},
},
};
use std::fmt::Debug;
pub mod edwards_bls12;

View File

@ -3,16 +3,17 @@
use crate::Import;
use snarkos_models::curves::{Field, PrimeField};
use snarkos_models::gadgets::{
r1cs::Variable as R1CSVariable,
utilities::{
boolean::Boolean, uint128::UInt128, uint16::UInt16, uint32::UInt32, uint64::UInt64,
uint8::UInt8,
use snarkos_models::{
curves::{Field, PrimeField},
gadgets::{
r1cs::Variable as R1CSVariable,
utilities::{
boolean::Boolean, uint128::UInt128, uint16::UInt16, uint32::UInt32, uint64::UInt64,
uint8::UInt8,
},
},
};
use std::collections::HashMap;
use std::marker::PhantomData;
use std::{collections::HashMap, marker::PhantomData};
/// An identifier in the constrained program.
#[derive(Clone, PartialEq, Eq, Hash)]

View File

@ -2,10 +2,12 @@
use crate::{ast, types, Import, ImportSymbol};
use snarkos_models::curves::{Field, PrimeField};
use snarkos_models::gadgets::utilities::{
boolean::Boolean, uint128::UInt128, uint16::UInt16, uint32::UInt32, uint64::UInt64,
uint8::UInt8,
use snarkos_models::{
curves::{Field, PrimeField},
gadgets::utilities::{
boolean::Boolean, uint128::UInt128, uint16::UInt16, uint32::UInt32, uint64::UInt64,
uint8::UInt8,
},
};
use std::collections::HashMap;

View File

@ -1,10 +1,9 @@
use crate::{compile_program, get_error, get_output, EdwardsConstrainedValue, EdwardsTestCompiler};
use leo_compiler::errors::IntegerError;
use leo_compiler::{
errors::{CompilerError, FunctionError},
errors::{CompilerError, FunctionError, IntegerError},
ConstrainedValue, InputValue, Integer,
};
use snarkos_models::gadgets::utilities::uint32::UInt32;
const DIRECTORY_NAME: &str = "tests/array/";

View File

@ -1,10 +1,9 @@
use crate::{compile_program, get_error, get_output, EdwardsConstrainedValue, EdwardsTestCompiler};
use leo_compiler::errors::{BooleanError, ExpressionError};
use leo_compiler::{
errors::{CompilerError, FunctionError, StatementError},
errors::{BooleanError, CompilerError, ExpressionError, FunctionError, StatementError},
ConstrainedValue, InputValue,
};
use snarkos_models::gadgets::utilities::boolean::Boolean;
const DIRECTORY_NAME: &str = "tests/boolean/";

View File

@ -2,12 +2,12 @@ use crate::{
compile_program, get_error, get_output, integer::u32::output_one, EdwardsConstrainedValue,
EdwardsTestCompiler,
};
use leo_compiler::{
errors::{CompilerError, ExpressionError, FunctionError, StatementError},
ConstrainedCircuitMember, ConstrainedValue, Expression, Function, Identifier, Integer,
Statement, Type,
};
use snarkos_models::gadgets::utilities::uint32::UInt32;
const DIRECTORY_NAME: &str = "tests/circuit/";

View File

@ -1,10 +1,9 @@
use crate::{compile_program, get_error, get_output, EdwardsConstrainedValue, EdwardsTestCompiler};
use leo_compiler::errors::FieldElementError;
use leo_compiler::{
errors::{CompilerError, FunctionError},
errors::{CompilerError, FieldElementError, FunctionError},
ConstrainedValue, FieldElement, InputValue,
};
use snarkos_curves::edwards_bls12::Fq;
use snarkos_models::curves::Field;

View File

@ -2,11 +2,11 @@ use crate::{
compile_program, get_error, get_output, integer::u32::output_one, EdwardsConstrainedValue,
EdwardsTestCompiler,
};
use leo_compiler::{
errors::{CompilerError, ExpressionError, FunctionError, StatementError},
ConstrainedValue,
};
use snarkos_models::gadgets::utilities::boolean::Boolean;
const DIRECTORY_NAME: &str = "tests/function/";

View File

@ -1,16 +1,19 @@
use crate::{compile_program, get_error, get_output, EdwardsConstrainedValue, EdwardsTestCompiler};
use leo_compiler::group::edwards_bls12::EdwardsGroupType;
use leo_compiler::{ConstrainedValue, InputValue};
use crate::{
boolean::{output_false, output_true},
compile_program, get_error, get_output, EdwardsConstrainedValue, EdwardsTestCompiler,
};
use leo_compiler::{
errors::{CompilerError, FunctionError, StatementError},
group::edwards_bls12::EdwardsGroupType,
ConstrainedValue, InputValue,
};
use snarkos_curves::edwards_bls12::{EdwardsAffine, Fq};
use snarkos_models::curves::Group;
use crate::boolean::{output_false, output_true};
use leo_compiler::errors::{CompilerError, FunctionError, StatementError};
use snarkos_gadgets::curves::edwards_bls12::EdwardsBlsGadget;
use snarkos_models::gadgets::curves::GroupGadget;
use snarkos_models::gadgets::r1cs::TestConstraintSystem;
use snarkos_models::gadgets::utilities::alloc::AllocGadget;
use snarkos_models::{
curves::Group,
gadgets::{curves::GroupGadget, r1cs::TestConstraintSystem, utilities::alloc::AllocGadget},
};
use std::str::FromStr;
const DIRECTORY_NAME: &str = "tests/group/";

View File

@ -1,8 +1,10 @@
use crate::{compile_program, get_error, get_output, EdwardsConstrainedValue, EdwardsTestCompiler};
use leo_compiler::{
errors::{CompilerError, FunctionError, IntegerError},
types::Integer,
ConstrainedValue, InputValue,
};
use leo_compiler::{types::Integer, ConstrainedValue, InputValue};
use leo_compiler::errors::{CompilerError, FunctionError, IntegerError};
use snarkos_models::gadgets::utilities::uint32::UInt32;
const DIRECTORY_NAME: &str = "tests/integer/u32/";

View File

@ -9,9 +9,11 @@ pub mod integer;
pub mod mutability;
pub mod statement;
use leo_compiler::{compiler::Compiler, errors::CompilerError, ConstrainedValue};
use leo_compiler::{
compiler::Compiler, errors::CompilerError, group::edwards_bls12::EdwardsGroupType,
ConstrainedValue,
};
use leo_compiler::group::edwards_bls12::EdwardsGroupType;
use snarkos_curves::edwards_bls12::Fq;
use snarkos_models::gadgets::r1cs::TestConstraintSystem;
use std::env::current_dir;

View File

@ -1,10 +1,10 @@
use crate::{compile_program, EdwardsConstrainedValue, EdwardsTestCompiler};
use leo_compiler::{
errors::{CompilerError, FunctionError, StatementError},
types::{InputValue, Integer},
ConstrainedValue,
};
use snarkos_curves::edwards_bls12::Fq;
use snarkos_models::gadgets::{r1cs::TestConstraintSystem, utilities::uint32::UInt32};

View File

@ -3,6 +3,7 @@ use crate::{
integer::u32::{output_one, output_zero},
};
use leo_compiler::InputValue;
use snarkos_curves::edwards_bls12::Fq;
use snarkos_models::gadgets::r1cs::TestConstraintSystem;

View File

@ -2,14 +2,18 @@ use crate::directories::{source::SOURCE_DIRECTORY_NAME, OutputsDirectory};
use crate::errors::{BuildError, CLIError};
use crate::files::{ChecksumFile, MainFile, Manifest, MAIN_FILE_NAME};
use crate::{cli::*, cli_types::*};
use leo_compiler::compiler::Compiler;
use leo_compiler::{
compiler::Compiler,
group::edwards_bls12::EdwardsGroupType
};
use snarkos_algorithms::snark::KeypairAssembly;
use snarkos_curves::bls12_377::Bls12_377;
use snarkos_curves::{
bls12_377::Bls12_377,
edwards_bls12::Fq
};
use clap::ArgMatches;
use leo_compiler::group::edwards_bls12::EdwardsGroupType;
use snarkos_curves::edwards_bls12::Fq;
use std::convert::TryFrom;
use std::env::current_dir;

View File

@ -2,18 +2,22 @@ use crate::commands::BuildCommand;
use crate::errors::{CLIError, VerificationKeyFileError};
use crate::files::{Manifest, ProvingKeyFile, VerificationKeyFile};
use crate::{cli::*, cli_types::*};
use leo_compiler::compiler::Compiler;
use leo_compiler::{
compiler::Compiler,
group::edwards_bls12::EdwardsGroupType
};
use snarkos_algorithms::snark::{
generate_random_parameters, prepare_verifying_key, Parameters, PreparedVerifyingKey,
};
use snarkos_curves::bls12_377::Bls12_377;
use snarkos_curves::{
bls12_377::Bls12_377,
edwards_bls12::Fq
};
use snarkos_utilities::bytes::ToBytes;
use clap::ArgMatches;
use leo_compiler::group::edwards_bls12::EdwardsGroupType;
use rand::thread_rng;
use snarkos_curves::edwards_bls12::Fq;
use std::convert::TryFrom;
use std::env::current_dir;
use std::time::Instant;