remove print statements

This commit is contained in:
collin 2020-09-15 14:19:15 -07:00
parent 5341c28805
commit b071b85b8c
7 changed files with 27 additions and 70 deletions

View File

@ -46,8 +46,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
)?
.extract_circuit(span.clone())?;
println!("static");
// Find static circuit function
let matched_function = circuit.members.into_iter().find(|member| match member {
CircuitMember::CircuitFunction(_static, function) => function.identifier == circuit_member,

View File

@ -35,8 +35,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
arguments: Vec<Expression>,
span: Span,
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
println!("function call");
println!("arguments {:?}", arguments);
let function_value = self.enforce_expression(
cs,
file_scope.clone(),
@ -45,17 +43,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
*function.clone(),
)?;
// if let ConstrainedValue::CoreFunction(core_function) = function_value {
// let mut argument_values = vec![];
// for argument in arguments.into_iter() {
// let argument_value = self.enforce_expression(cs, file_scope.clone(), function_scope.clone(), None, argument)?;
// argument_values.push(argument_value);
// }
//
// return enforce_core_function(cs, file_scope, function_scope, core_function, argument_values, span)
// .map_err(|error| ExpressionError::from(Box::new(error)));
// }
let (outer_scope, function_call) = function_value.extract_function(file_scope.clone(), span.clone())?;
let name_unique = format!(

View File

@ -13,14 +13,14 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{errors::FunctionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType, Integer};
use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType, Integer};
use crate::errors::ExpressionError;
use leo_core::{blake2s::unstable::hash::Blake2sFunction, call_core_function, CoreFunctionArgument};
use leo_typed::{Expression, Span, Type};
use leo_core::{call_core_function, CoreFunctionArgument};
use leo_typed::{Expression, Type};
use snarkos_models::{
curves::{Field, PrimeField},
gadgets::{r1cs::ConstraintSystem, utilities::uint::UInt8},
gadgets::r1cs::ConstraintSystem,
};
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
@ -29,13 +29,10 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
cs: &mut CS,
file_scope: String,
function_scope: String,
expected_type: Option<Type>,
_expected_type: Option<Type>,
function: String,
arguments: Vec<Expression>,
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
println!("function call {}", function);
println!("argument names {:?}", arguments);
// Get the value of each core function argument
let mut argument_values = vec![];
for argument in arguments.into_iter() {
@ -45,35 +42,15 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
argument_values.push(core_function_argument);
}
// println!("argument values {:?}", argument_values);
// Call the core function in `leo-core`
let res = call_core_function(cs, function, argument_values);
// Temporarily return empty array
let empty = vec![ConstrainedValue::Integer(Integer::U8(UInt8::constant(0))); 32];
let array = res
.into_iter()
.map(|uint| ConstrainedValue::Integer(Integer::U8(uint)))
.collect();
return Ok(ConstrainedValue::Array(empty));
return Ok(ConstrainedValue::Array(array));
}
}
// fn enforce_blake2s_function<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<F>>(
// cs: CS,
// file_scope: String,
// caller_scope: String,
// arguments: Vec<ConstrainedValue<F, G>>,
// span: Span,
// ) -> Result<ConstrainedValue<F, G>, FunctionError> {
//
// // length of input to hash function must be 1
// // if arguments.len() != 1 {
// // return Err(FunctionError::)
// // }
//
// let argument_expression = arguments[0].clone();
//
// let argument_value =
//
//
// return Ok(ConstrainedValue::Array(vec![]));
// }

View File

@ -22,9 +22,7 @@ pub static CORE_PACKAGE_NAME: &str = "core";
impl ImportParser {
// import a core package into scope
pub fn parse_core_package(&mut self, package: &Package) -> Result<(), ImportError> {
println!("expecting core package {}", package);
self.insert_core_package(package);
Ok(())
}
}

View File

@ -15,30 +15,23 @@
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use crate::{new_scope, ConstrainedProgram, ConstrainedValue, GroupType};
use leo_typed::{Identifier, ImportSymbol, Package, PackageAccess};
use leo_typed::Package;
use leo_core::{blake2s::unstable::hash::Blake2sFunction, CorePackageList};
use leo_core::CorePackageList;
use snarkos_models::curves::{Field, PrimeField};
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
pub(crate) fn store_core_package(&mut self, scope: String, package: Package) {
println!("storing core package: {}", package);
// create core package list
println!("creating core package list");
// Create list of imported core packages.
let list = CorePackageList::from_package_access(package.access);
println!("{:?}", list);
// fetch packages from `leo-core`
println!("fetching packages from leo core");
// Fetch core packages from `leo-core`.
let symbol_list = list.to_symbols();
for (symbol, circuit) in symbol_list.symbols() {
let symbol_name = new_scope(scope.clone(), symbol);
// store packages
println!("storing dependencies from leo core into leo program");
println!("{}", symbol_name);
self.store(symbol_name, ConstrainedValue::CircuitDefinition(circuit))
}
}

View File

@ -14,13 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
use leo_typed::{Function, FunctionInput, Identifier, InputVariable, Span};
use crate::CoreFunctionArgument;
use snarkos_gadgets::algorithms::prf::Blake2sGadget;
use snarkos_models::{
curves::{Field, PrimeField},
gadgets::{algorithms::PRFGadget, r1cs::ConstraintSystem, utilities::ToBytesGadget},
gadgets::{
algorithms::PRFGadget,
r1cs::ConstraintSystem,
utilities::{uint::UInt8, ToBytesGadget},
},
};
#[derive(Clone, PartialEq, Eq)]
@ -31,7 +34,7 @@ impl Blake2sFunction {
mut cs: CS,
arguments: Vec<CoreFunctionArgument>,
//_span: Span // todo: return errors using `leo-typed` span
) {
) -> Vec<UInt8> {
// The check evaluation gadget should have two arguments: seed and input
if arguments.len() != 2 {
println!("incorrect number of arguments")
@ -41,6 +44,8 @@ impl Blake2sFunction {
let input = &arguments[1].0[..];
let res = Blake2sGadget::check_evaluation_gadget(cs.ns(|| "blake2s hash"), seed, input).unwrap();
println!("output {:?}", res.to_bytes(cs).unwrap().len());
let bytes = res.to_bytes(cs).unwrap();
// println!("output {:?}", res.to_bytes(cs).unwrap().len());
bytes
}
}

View File

@ -27,7 +27,6 @@ use leo_typed::{
IntegerType,
Package,
PackageAccess,
Span,
Statement,
Type,
};
@ -194,8 +193,6 @@ impl CorePackageList {
PackageAccess::Symbol(_symbol) => unimplemented!("cannot import a symbol directly from Leo core"),
PackageAccess::Multiple(_) => unimplemented!("multiple imports not yet implemented for Leo core"),
PackageAccess::SubPackage(package) => {
println!("importing package access {}", *package);
let core_package = CorePackage::from(*package);
new.push(core_package);
@ -236,11 +233,13 @@ pub fn call_core_function<F: Field + PrimeField, CS: ConstraintSystem<F>>(
arguments: Vec<CoreFunctionArgument>,
//_span: Span // todo: return errors using `leo-typed` span
) -> Vec<UInt8> {
// Match core function name here
if function_name.ne("core_blake2s_unstable") {
// todo: convert this to a real error
println!("core dne error");
}
// Hardcode blake2s core function call
let res = Blake2sFunction::hash(cs, arguments);
return vec![];
return res;
}