From ba3ca6069a16da992e92bcd30fa7e9b1593d7bc8 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 16 Feb 2021 14:41:59 -0500 Subject: [PATCH] refactor Field + PrimeField -> PrimeField, all tests still pass --- compiler/src/compiler.rs | 8 +++--- compiler/src/console/assert.rs | 4 +-- compiler/src/console/console.rs | 4 +-- compiler/src/console/format.rs | 7 ++--- compiler/src/constraints/constraints.rs | 6 ++-- compiler/src/definition/definition.rs | 4 +-- compiler/src/expression/arithmetic/add.rs | 7 ++--- compiler/src/expression/arithmetic/div.rs | 7 ++--- compiler/src/expression/arithmetic/mul.rs | 7 ++--- compiler/src/expression/arithmetic/negate.rs | 7 ++--- compiler/src/expression/arithmetic/pow.rs | 7 ++--- compiler/src/expression/arithmetic/sub.rs | 7 ++--- compiler/src/expression/array/access.rs | 7 ++--- compiler/src/expression/array/array.rs | 7 ++--- compiler/src/expression/array/index.rs | 7 ++--- compiler/src/expression/binary/binary.rs | 7 ++--- compiler/src/expression/circuit/access.rs | 7 ++--- compiler/src/expression/circuit/circuit.rs | 7 ++--- .../src/expression/conditional/conditional.rs | 4 +-- compiler/src/expression/expression.rs | 4 +-- .../src/expression/function/core_circuit.rs | 7 ++--- compiler/src/expression/function/function.rs | 7 ++--- compiler/src/expression/logical/and.rs | 4 +-- compiler/src/expression/logical/not.rs | 4 +-- compiler/src/expression/logical/or.rs | 4 +-- compiler/src/expression/relational/eq.rs | 4 +-- compiler/src/expression/relational/ge.rs | 7 ++--- compiler/src/expression/relational/gt.rs | 7 ++--- compiler/src/expression/relational/le.rs | 7 ++--- compiler/src/expression/relational/lt.rs | 7 ++--- compiler/src/expression/tuple/access.rs | 7 ++--- compiler/src/expression/tuple/tuple.rs | 7 ++--- .../expression/variable_ref/variable_ref.rs | 4 +-- compiler/src/function/function.rs | 4 +-- compiler/src/function/input/array.rs | 7 ++--- compiler/src/function/input/input_keyword.rs | 7 ++--- compiler/src/function/input/input_section.rs | 7 ++--- .../src/function/input/main_function_input.rs | 7 ++--- compiler/src/function/input/tuple.rs | 7 ++--- compiler/src/function/main_function.rs | 7 ++--- compiler/src/function/mut_target.rs | 7 ++--- compiler/src/function/result/result.rs | 4 +-- compiler/src/output/output_bytes.rs | 4 +-- compiler/src/prelude/blake2s.rs | 6 ++-- compiler/src/prelude/mod.rs | 9 ++---- compiler/src/program/program.rs | 6 ++-- compiler/src/statement/assign/assign.rs | 4 +-- compiler/src/statement/assign/assignee.rs | 7 ++--- compiler/src/statement/block/block.rs | 4 +-- .../src/statement/conditional/conditional.rs | 4 +-- .../src/statement/definition/definition.rs | 7 ++--- compiler/src/statement/iteration/iteration.rs | 4 +-- compiler/src/statement/return_/return_.rs | 7 ++--- compiler/src/statement/statement.rs | 4 +-- compiler/src/value/address/address.rs | 12 ++++---- compiler/src/value/boolean/input.rs | 6 ++-- compiler/src/value/field/field_type.rs | 28 +++++++++---------- compiler/src/value/field/input.rs | 6 ++-- compiler/src/value/group/input.rs | 9 ++---- compiler/src/value/integer/integer.rs | 24 ++++++++-------- compiler/src/value/value.rs | 18 ++++++------ gadgets/src/arithmetic/add.rs | 2 +- gadgets/src/bits/comparator.rs | 4 +-- gadgets/src/bits/rca.rs | 2 +- 64 files changed, 168 insertions(+), 267 deletions(-) diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index e0dd355ae9..60f7f87099 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -33,7 +33,7 @@ use leo_state::verify_local_data_commitment; use snarkvm_dpc::{base_dpc::instantiated::Components, SystemParameters}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::r1cs::{ConstraintSynthesizer, ConstraintSystem}, }; @@ -46,7 +46,7 @@ use std::{ /// Stores information to compile a Leo program. #[derive(Clone)] -pub struct Compiler> { +pub struct Compiler> { program_name: String, main_file_path: PathBuf, output_directory: PathBuf, @@ -57,7 +57,7 @@ pub struct Compiler> { _group: PhantomData, } -impl> Compiler { +impl> Compiler { /// /// Returns a new Leo program compiler. /// @@ -261,7 +261,7 @@ impl> Compiler { } } -impl> ConstraintSynthesizer for Compiler { +impl> ConstraintSynthesizer for Compiler { /// /// Synthesizes the circuit with program input. /// diff --git a/compiler/src/console/assert.rs b/compiler/src/console/assert.rs index 38d79ba497..f7a60082fc 100644 --- a/compiler/src/console/assert.rs +++ b/compiler/src/console/assert.rs @@ -27,11 +27,11 @@ use leo_asg::{Expression, Span}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn evaluate_console_assert>( &mut self, cs: &mut CS, diff --git a/compiler/src/console/console.rs b/compiler/src/console/console.rs index ba9b8db271..010b0bf5cf 100644 --- a/compiler/src/console/console.rs +++ b/compiler/src/console/console.rs @@ -20,11 +20,11 @@ use crate::{errors::ConsoleError, program::ConstrainedProgram, statement::get_in use leo_asg::{ConsoleFunction, ConsoleStatement}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn evaluate_console_function_call>( &mut self, cs: &mut CS, diff --git a/compiler/src/console/format.rs b/compiler/src/console/format.rs index ee680a77e0..2f42776233 100644 --- a/compiler/src/console/format.rs +++ b/compiler/src/console/format.rs @@ -19,12 +19,9 @@ use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType}; use leo_asg::FormattedString; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn format>( &mut self, cs: &mut CS, diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 593b70a2b0..b97c0a2da6 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -23,12 +23,12 @@ use leo_input::LeoInputParser; use leo_package::inputs::InputPairs; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::r1cs::{ConstraintSystem, TestConstraintSystem}, }; use std::path::Path; -pub fn generate_constraints, CS: ConstraintSystem>( +pub fn generate_constraints, CS: ConstraintSystem>( cs: &mut CS, asg: &Asg, input: &Input, @@ -50,7 +50,7 @@ pub fn generate_constraints, CS: Constrai } } -pub fn generate_test_constraints>( +pub fn generate_test_constraints>( asg: &Asg, input: InputPairs, main_file_path: &Path, diff --git a/compiler/src/definition/definition.rs b/compiler/src/definition/definition.rs index b968be1341..181054c599 100644 --- a/compiler/src/definition/definition.rs +++ b/compiler/src/definition/definition.rs @@ -19,9 +19,9 @@ use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Variable; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn store_definition(&mut self, variable: &Variable, value: ConstrainedValue) { let variable = variable.borrow(); diff --git a/compiler/src/expression/arithmetic/add.rs b/compiler/src/expression/arithmetic/add.rs index b122e9188f..33b3171496 100644 --- a/compiler/src/expression/arithmetic/add.rs +++ b/compiler/src/expression/arithmetic/add.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_add, CS: ConstraintSystem>( +pub fn enforce_add, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/div.rs b/compiler/src/expression/arithmetic/div.rs index 07637c9406..29cf9dcaef 100644 --- a/compiler/src/expression/arithmetic/div.rs +++ b/compiler/src/expression/arithmetic/div.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_div, CS: ConstraintSystem>( +pub fn enforce_div, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/mul.rs b/compiler/src/expression/arithmetic/mul.rs index b959d3c8f0..c0acdadd40 100644 --- a/compiler/src/expression/arithmetic/mul.rs +++ b/compiler/src/expression/arithmetic/mul.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_mul, CS: ConstraintSystem>( +pub fn enforce_mul, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/negate.rs b/compiler/src/expression/arithmetic/negate.rs index 8cd42843e6..ee920ba70a 100644 --- a/compiler/src/expression/arithmetic/negate.rs +++ b/compiler/src/expression/arithmetic/negate.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_negate, CS: ConstraintSystem>( +pub fn enforce_negate, CS: ConstraintSystem>( cs: &mut CS, value: ConstrainedValue, span: &Span, diff --git a/compiler/src/expression/arithmetic/pow.rs b/compiler/src/expression/arithmetic/pow.rs index c342704751..bcac31609b 100644 --- a/compiler/src/expression/arithmetic/pow.rs +++ b/compiler/src/expression/arithmetic/pow.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_pow, CS: ConstraintSystem>( +pub fn enforce_pow, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/sub.rs b/compiler/src/expression/arithmetic/sub.rs index abe23b64d1..14658e0afe 100644 --- a/compiler/src/expression/arithmetic/sub.rs +++ b/compiler/src/expression/arithmetic/sub.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_sub, CS: ConstraintSystem>( +pub fn enforce_sub, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/array/access.rs b/compiler/src/expression/array/access.rs index 58a149f36e..87f15fba3e 100644 --- a/compiler/src/expression/array/access.rs +++ b/compiler/src/expression/array/access.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_array_access>( &mut self, diff --git a/compiler/src/expression/array/array.rs b/compiler/src/expression/array/array.rs index 5a2992bdcb..5ec2b52385 100644 --- a/compiler/src/expression/array/array.rs +++ b/compiler/src/expression/array/array.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce array expressions pub fn enforce_array>( &mut self, diff --git a/compiler/src/expression/array/index.rs b/compiler/src/expression/array/index.rs index 4b41031907..67be2bc902 100644 --- a/compiler/src/expression/array/index.rs +++ b/compiler/src/expression/array/index.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub(crate) fn enforce_index>( &mut self, cs: &mut CS, diff --git a/compiler/src/expression/binary/binary.rs b/compiler/src/expression/binary/binary.rs index 0199e0cecf..9aeba58eb1 100644 --- a/compiler/src/expression/binary/binary.rs +++ b/compiler/src/expression/binary/binary.rs @@ -20,14 +20,11 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::Expression; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; type ConstrainedValuePair = (ConstrainedValue, ConstrainedValue); -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_binary_expression>( &mut self, diff --git a/compiler/src/expression/circuit/access.rs b/compiler/src/expression/circuit/access.rs index dc2310ded5..672d3656c7 100644 --- a/compiler/src/expression/circuit/access.rs +++ b/compiler/src/expression/circuit/access.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{CircuitAccessExpression, Node}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_circuit_access>( &mut self, diff --git a/compiler/src/expression/circuit/circuit.rs b/compiler/src/expression/circuit/circuit.rs index e1862a94af..4b8942c462 100644 --- a/compiler/src/expression/circuit/circuit.rs +++ b/compiler/src/expression/circuit/circuit.rs @@ -24,12 +24,9 @@ use crate::{ }; use leo_asg::{CircuitInitExpression, CircuitMemberBody, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn enforce_circuit>( &mut self, cs: &mut CS, diff --git a/compiler/src/expression/conditional/conditional.rs b/compiler/src/expression/conditional/conditional.rs index 97974e1818..3deb2cc47a 100644 --- a/compiler/src/expression/conditional/conditional.rs +++ b/compiler/src/expression/conditional/conditional.rs @@ -21,11 +21,11 @@ use leo_asg::{Expression, Span}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::select::CondSelectGadget}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce ternary conditional expression #[allow(clippy::too_many_arguments)] pub fn enforce_conditional_expression>( diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 83d01ce83d..261e97e053 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -31,11 +31,11 @@ use leo_asg::{expression::*, ConstValue, Expression, Node}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub(crate) fn enforce_expression>( &mut self, cs: &mut CS, diff --git a/compiler/src/expression/function/core_circuit.rs b/compiler/src/expression/function/core_circuit.rs index f0d88c94b7..7de16f7fa6 100644 --- a/compiler/src/expression/function/core_circuit.rs +++ b/compiler/src/expression/function/core_circuit.rs @@ -17,13 +17,10 @@ use crate::{program::ConstrainedProgram, value::ConstrainedValue, CoreCircuit, G use crate::errors::ExpressionError; use leo_asg::{Expression, Function, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; use std::sync::Arc; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Call a default core circuit function with arguments #[allow(clippy::too_many_arguments)] pub fn enforce_core_circuit_call_expression, C: CoreCircuit>( diff --git a/compiler/src/expression/function/function.rs b/compiler/src/expression/function/function.rs index c6011eb112..3ffe6ad0ed 100644 --- a/compiler/src/expression/function/function.rs +++ b/compiler/src/expression/function/function.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Function, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_function_call_expression>( &mut self, diff --git a/compiler/src/expression/logical/and.rs b/compiler/src/expression/logical/and.rs index 142cb08d6b..a7c1613a27 100644 --- a/compiler/src/expression/logical/and.rs +++ b/compiler/src/expression/logical/and.rs @@ -20,11 +20,11 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -pub fn enforce_and, CS: ConstraintSystem>( +pub fn enforce_and, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/logical/not.rs b/compiler/src/expression/logical/not.rs index a4f8ba2ce5..59d0842695 100644 --- a/compiler/src/expression/logical/not.rs +++ b/compiler/src/expression/logical/not.rs @@ -19,9 +19,9 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; -pub fn evaluate_not>( +pub fn evaluate_not>( value: ConstrainedValue, span: &Span, ) -> Result, BooleanError> { diff --git a/compiler/src/expression/logical/or.rs b/compiler/src/expression/logical/or.rs index ed7876d994..d1df2fab88 100644 --- a/compiler/src/expression/logical/or.rs +++ b/compiler/src/expression/logical/or.rs @@ -20,11 +20,11 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -pub fn enforce_or, CS: ConstraintSystem>( +pub fn enforce_or, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/eq.rs b/compiler/src/expression/relational/eq.rs index 1a1e215879..2df94b159b 100644 --- a/compiler/src/expression/relational/eq.rs +++ b/compiler/src/expression/relational/eq.rs @@ -20,14 +20,14 @@ use crate::{enforce_and, errors::ExpressionError, value::ConstrainedValue, Group use leo_asg::Span; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, eq::EvaluateEqGadget}, }, }; -pub fn evaluate_eq, CS: ConstraintSystem>( +pub fn evaluate_eq, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/ge.rs b/compiler/src/expression/relational/ge.rs index 5f5ef8fa73..9664f9bbd6 100644 --- a/compiler/src/expression/relational/ge.rs +++ b/compiler/src/expression/relational/ge.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_ge, CS: ConstraintSystem>( +pub fn evaluate_ge, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/gt.rs b/compiler/src/expression/relational/gt.rs index 2d6978bf85..f596e4cf64 100644 --- a/compiler/src/expression/relational/gt.rs +++ b/compiler/src/expression/relational/gt.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_gt, CS: ConstraintSystem>( +pub fn evaluate_gt, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/le.rs b/compiler/src/expression/relational/le.rs index 8e20e753e7..e824a4fb55 100644 --- a/compiler/src/expression/relational/le.rs +++ b/compiler/src/expression/relational/le.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_le, CS: ConstraintSystem>( +pub fn evaluate_le, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/lt.rs b/compiler/src/expression/relational/lt.rs index 6c68456ac3..a4d2b4f746 100644 --- a/compiler/src/expression/relational/lt.rs +++ b/compiler/src/expression/relational/lt.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::comparator::EvaluateLtGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_lt, CS: ConstraintSystem>( +pub fn evaluate_lt, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/tuple/access.rs b/compiler/src/expression/tuple/access.rs index 3ed3b47451..ccca481aad 100644 --- a/compiler/src/expression/tuple/access.rs +++ b/compiler/src/expression/tuple/access.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_tuple_access>( &mut self, diff --git a/compiler/src/expression/tuple/tuple.rs b/compiler/src/expression/tuple/tuple.rs index f4520d9070..6884f50e88 100644 --- a/compiler/src/expression/tuple/tuple.rs +++ b/compiler/src/expression/tuple/tuple.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::Expression; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce tuple expressions pub fn enforce_tuple>( &mut self, diff --git a/compiler/src/expression/variable_ref/variable_ref.rs b/compiler/src/expression/variable_ref/variable_ref.rs index 2cfac36ad3..54de37daf5 100644 --- a/compiler/src/expression/variable_ref/variable_ref.rs +++ b/compiler/src/expression/variable_ref/variable_ref.rs @@ -19,9 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::VariableRef; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce a variable expression by getting the resolved value pub fn evaluate_ref(&mut self, variable_ref: &VariableRef) -> Result, ExpressionError> { // Evaluate the identifier name in the current function scope diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index efa2ebf29b..434f2b64e0 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -22,11 +22,11 @@ use leo_asg::{Expression, FunctionBody, FunctionQualifier}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub(crate) fn enforce_function>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/array.rs b/compiler/src/function/input/array.rs index f5e6ab2bf3..7aabc3e93c 100644 --- a/compiler/src/function/input/array.rs +++ b/compiler/src/function/input/array.rs @@ -21,12 +21,9 @@ use crate::{errors::FunctionError, program::ConstrainedProgram, value::Constrain use leo_asg::Type; use leo_ast::{InputValue, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_array>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/input_keyword.rs b/compiler/src/function/input/input_keyword.rs index 37f32d9cf1..a26fca1bdd 100644 --- a/compiler/src/function/input/input_keyword.rs +++ b/compiler/src/function/input/input_keyword.rs @@ -19,17 +19,14 @@ use leo_asg::{CircuitBody, CircuitMemberBody, Type}; use leo_ast::{Identifier, Input, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; pub const RECORD_VARIABLE_NAME: &str = "record"; pub const REGISTERS_VARIABLE_NAME: &str = "registers"; pub const STATE_VARIABLE_NAME: &str = "state"; pub const STATE_LEAF_VARIABLE_NAME: &str = "state_leaf"; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_input_keyword>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/input_section.rs b/compiler/src/function/input/input_section.rs index cbfee12200..f322d7db7d 100644 --- a/compiler/src/function/input/input_section.rs +++ b/compiler/src/function/input/input_section.rs @@ -19,14 +19,11 @@ use leo_asg::{AsgConvertError, CircuitBody, CircuitMemberBody}; use leo_ast::{Identifier, InputValue, Parameter}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; use indexmap::IndexMap; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_input_section>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/main_function_input.rs b/compiler/src/function/input/main_function_input.rs index 11c3f8b536..c93c4eda29 100644 --- a/compiler/src/function/input/main_function_input.rs +++ b/compiler/src/function/input/main_function_input.rs @@ -32,12 +32,9 @@ use crate::{ use leo_asg::Type; use leo_ast::{InputValue, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_main_function_input>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/tuple.rs b/compiler/src/function/input/tuple.rs index add3eb9240..ba9974f787 100644 --- a/compiler/src/function/input/tuple.rs +++ b/compiler/src/function/input/tuple.rs @@ -21,12 +21,9 @@ use crate::{errors::FunctionError, program::ConstrainedProgram, value::Constrain use leo_asg::Type; use leo_ast::{InputValue, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_tuple>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index e858db1b73..bf29abf27f 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -22,12 +22,9 @@ use leo_asg::{Expression, FunctionBody, FunctionQualifier}; use leo_ast::Input; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn enforce_main_function>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/mut_target.rs b/compiler/src/function/mut_target.rs index 2b1a20674a..b3d8f03226 100644 --- a/compiler/src/function/mut_target.rs +++ b/compiler/src/function/mut_target.rs @@ -35,12 +35,9 @@ use leo_asg::{ }; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { fn prepare_mut_access>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index c575f7d9ee..cc3d4caed2 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -27,14 +27,14 @@ use crate::{ use leo_asg::{Span, Type}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, select::CondSelectGadget}, }, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// /// Returns a conditionally selected result from the given possible function returns and /// given function return type. diff --git a/compiler/src/output/output_bytes.rs b/compiler/src/output/output_bytes.rs index c050c71749..5e82e70563 100644 --- a/compiler/src/output/output_bytes.rs +++ b/compiler/src/output/output_bytes.rs @@ -18,7 +18,7 @@ use crate::{errors::OutputBytesError, ConstrainedValue, GroupType, REGISTERS_VAR use leo_asg::Program; use leo_ast::{Parameter, Registers, Span}; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; use serde::{Deserialize, Serialize}; @@ -31,7 +31,7 @@ impl OutputBytes { &self.0 } - pub fn new_from_constrained_value>( + pub fn new_from_constrained_value>( program: &Program, registers: &Registers, value: ConstrainedValue, diff --git a/compiler/src/prelude/blake2s.rs b/compiler/src/prelude/blake2s.rs index 874ee4e826..0e3c3854dc 100644 --- a/compiler/src/prelude/blake2s.rs +++ b/compiler/src/prelude/blake2s.rs @@ -21,7 +21,7 @@ use crate::{errors::ExpressionError, ConstrainedValue, GroupType, Integer}; use leo_asg::{FunctionBody, Span}; use snarkvm_gadgets::algorithms::prf::Blake2sGadget; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ algorithms::PRFGadget, r1cs::ConstraintSystem, @@ -31,7 +31,7 @@ use snarkvm_models::{ pub struct Blake2s; -fn unwrap_argument>(arg: ConstrainedValue) -> Vec { +fn unwrap_argument>(arg: ConstrainedValue) -> Vec { if let ConstrainedValue::Array(args) = arg { assert_eq!(args.len(), 32); // asg enforced args.into_iter() @@ -48,7 +48,7 @@ fn unwrap_argument>(arg: ConstrainedValue } } -impl> CoreCircuit for Blake2s { +impl> CoreCircuit for Blake2s { fn call_function>( &self, cs: &mut CS, diff --git a/compiler/src/prelude/mod.rs b/compiler/src/prelude/mod.rs index 1c924668f8..a4ed90c154 100644 --- a/compiler/src/prelude/mod.rs +++ b/compiler/src/prelude/mod.rs @@ -21,12 +21,9 @@ pub use blake2s::*; use crate::{errors::ExpressionError, ConstrainedValue, GroupType}; use leo_asg::{FunctionBody, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub trait CoreCircuit>: Send + Sync { +pub trait CoreCircuit>: Send + Sync { fn call_function>( &self, cs: &mut CS, @@ -37,7 +34,7 @@ pub trait CoreCircuit>: Send + Sync { ) -> Result, ExpressionError>; } -pub fn resolve_core_circuit>(name: &str) -> impl CoreCircuit { +pub fn resolve_core_circuit>(name: &str) -> impl CoreCircuit { match name { "blake2s" => Blake2s, _ => unimplemented!("invalid core circuit: {}", name), diff --git a/compiler/src/program/program.rs b/compiler/src/program/program.rs index bdcbd0d44d..df243555af 100644 --- a/compiler/src/program/program.rs +++ b/compiler/src/program/program.rs @@ -19,17 +19,17 @@ use crate::{value::ConstrainedValue, GroupType}; use leo_asg::Program; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; use indexmap::IndexMap; use uuid::Uuid; -pub struct ConstrainedProgram> { +pub struct ConstrainedProgram> { pub asg: Program, identifiers: IndexMap>, } -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn new(asg: Program) -> Self { Self { asg, diff --git a/compiler/src/statement/assign/assign.rs b/compiler/src/statement/assign/assign.rs index 24a0957df5..7694dc86ae 100644 --- a/compiler/src/statement/assign/assign.rs +++ b/compiler/src/statement/assign/assign.rs @@ -20,14 +20,14 @@ use crate::{arithmetic::*, errors::StatementError, program::ConstrainedProgram, use leo_asg::{AssignOperation, AssignStatement, Span}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, select::CondSelectGadget}, }, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_assign_statement>( &mut self, diff --git a/compiler/src/statement/assign/assignee.rs b/compiler/src/statement/assign/assignee.rs index f7e4b873f6..e88597929c 100644 --- a/compiler/src/statement/assign/assignee.rs +++ b/compiler/src/statement/assign/assignee.rs @@ -19,10 +19,7 @@ use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{AssignAccess, AssignStatement, Identifier, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; pub(crate) enum ResolvedAssigneeAccess { ArrayRange(Option, Option), @@ -31,7 +28,7 @@ pub(crate) enum ResolvedAssigneeAccess { Member(Identifier), } -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn resolve_assign>( &mut self, cs: &mut CS, diff --git a/compiler/src/statement/block/block.rs b/compiler/src/statement/block/block.rs index 44b3bb53e0..2c44bbaf25 100644 --- a/compiler/src/statement/block/block.rs +++ b/compiler/src/statement/block/block.rs @@ -20,11 +20,11 @@ use crate::{program::ConstrainedProgram, GroupType, IndicatorAndConstrainedValue use leo_asg::BlockStatement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Evaluates a branch of one or more statements and returns a result in /// the given scope. #[allow(clippy::too_many_arguments)] diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index 37e1e9693d..57291cd72c 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -27,7 +27,7 @@ use crate::{ use leo_asg::ConditionalStatement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; @@ -38,7 +38,7 @@ fn indicator_to_string(indicator: &Boolean) -> String { .unwrap_or_else(|| "[input]".to_string()) } -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforces a conditional statement with one or more branches. /// Due to R1CS constraints, we must evaluate every branch to properly construct the circuit. /// At program execution, we will pass an `indicator` bit down to all child statements within each branch. diff --git a/compiler/src/statement/definition/definition.rs b/compiler/src/statement/definition/definition.rs index df04d9ed6b..fce05a7920 100644 --- a/compiler/src/statement/definition/definition.rs +++ b/compiler/src/statement/definition/definition.rs @@ -19,12 +19,9 @@ use crate::{errors::StatementError, program::ConstrainedProgram, ConstrainedValue, GroupType}; use leo_asg::{DefinitionStatement, Span, Variable}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { fn enforce_multiple_definition( &mut self, variable_names: &[Variable], diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index 1cdaad0952..830546e40b 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -27,14 +27,14 @@ use crate::{ use leo_asg::IterationStatement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, uint::UInt32}, }, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_iteration_statement>( &mut self, diff --git a/compiler/src/statement/return_/return_.rs b/compiler/src/statement/return_/return_.rs index b0195ee3eb..039e87505b 100644 --- a/compiler/src/statement/return_/return_.rs +++ b/compiler/src/statement/return_/return_.rs @@ -19,12 +19,9 @@ use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::ReturnStatement; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn enforce_return_statement>( &mut self, cs: &mut CS, diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 7233d663ab..115f656b77 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -21,14 +21,14 @@ use leo_asg::Statement; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; pub type StatementResult = Result; pub type IndicatorAndConstrainedValue = (Boolean, ConstrainedValue); -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// /// Enforce a program statement. /// Returns a Vector of (indicator, value) tuples. diff --git a/compiler/src/value/address/address.rs b/compiler/src/value/address/address.rs index 87a38ba67a..b8bec3f53c 100644 --- a/compiler/src/value/address/address.rs +++ b/compiler/src/value/address/address.rs @@ -20,7 +20,7 @@ use leo_ast::{InputValue, Span}; use snarkvm_dpc::base_dpc::instantiated::Components; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::{Assignment, ConstraintSystem}, utilities::{ @@ -63,7 +63,7 @@ impl Address { self.bytes.iter().all(|byte| byte.is_constant()) } - pub(crate) fn from_input, CS: ConstraintSystem>( + pub(crate) fn from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, @@ -105,7 +105,7 @@ impl Address { } } -impl AllocGadget for Address { +impl AllocGadget for Address { fn alloc Result, T: Borrow, CS: ConstraintSystem>( cs: CS, value_gen: Fn, @@ -143,7 +143,7 @@ impl AllocGadget for Address { } } -impl EvaluateEqGadget for Address { +impl EvaluateEqGadget for Address { fn evaluate_equal>(&self, mut cs: CS, other: &Self) -> Result { if self.is_constant() && other.is_constant() { Ok(Boolean::Constant(self.eq(other))) @@ -178,7 +178,7 @@ fn cond_equal_helper(first: &Address, second: &Address, cond: bool) -> Result<() } } -impl ConditionalEqGadget for Address { +impl ConditionalEqGadget for Address { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -208,7 +208,7 @@ fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address if cond { first.clone() } else { second.clone() } } -impl CondSelectGadget for Address { +impl CondSelectGadget for Address { fn conditionally_select>( mut cs: CS, cond: &Boolean, diff --git a/compiler/src/value/boolean/input.rs b/compiler/src/value/boolean/input.rs index cbced4ff02..32119dfda3 100644 --- a/compiler/src/value/boolean/input.rs +++ b/compiler/src/value/boolean/input.rs @@ -21,14 +21,14 @@ use leo_ast::{InputValue, Span}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{alloc::AllocGadget, boolean::Boolean}, }, }; -pub(crate) fn allocate_bool>( +pub(crate) fn allocate_bool>( cs: &mut CS, name: &str, option: Option, @@ -41,7 +41,7 @@ pub(crate) fn allocate_bool>( .map_err(|_| BooleanError::missing_boolean(format!("{}: bool", name), span.to_owned())) } -pub(crate) fn bool_from_input, CS: ConstraintSystem>( +pub(crate) fn bool_from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, diff --git a/compiler/src/value/field/field_type.rs b/compiler/src/value/field/field_type.rs index ecf21a5d04..6b91c4bb16 100644 --- a/compiler/src/value/field/field_type.rs +++ b/compiler/src/value/field/field_type.rs @@ -21,7 +21,7 @@ use leo_ast::Span; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ curves::{FieldGadget, FpGadget}, r1cs::ConstraintSystem, @@ -40,12 +40,12 @@ use snarkvm_models::{ use std::{borrow::Borrow, cmp::Ordering}; #[derive(Clone, Debug)] -pub enum FieldType { +pub enum FieldType { Constant(F), Allocated(FpGadget), } -impl FieldType { +impl FieldType { pub fn get_value(&self) -> Option { match self { FieldType::Constant(field) => Some(*field), @@ -186,7 +186,7 @@ impl FieldType { } } -impl AllocGadget for FieldType { +impl AllocGadget for FieldType { fn alloc Result, T: Borrow, CS: ConstraintSystem>( cs: CS, value_gen: Fn, @@ -206,7 +206,7 @@ impl AllocGadget for FieldType { } } -impl PartialEq for FieldType { +impl PartialEq for FieldType { fn eq(&self, other: &Self) -> bool { let self_value = self.get_value(); let other_value = other.get_value(); @@ -215,9 +215,9 @@ impl PartialEq for FieldType { } } -impl Eq for FieldType {} +impl Eq for FieldType {} -impl PartialOrd for FieldType { +impl PartialOrd for FieldType { fn partial_cmp(&self, other: &Self) -> Option { let self_value = self.get_value(); let other_value = other.get_value(); @@ -226,7 +226,7 @@ impl PartialOrd for FieldType { } } -impl EvaluateEqGadget for FieldType { +impl EvaluateEqGadget for FieldType { fn evaluate_equal>(&self, mut _cs: CS, other: &Self) -> Result { match (self, other) { (FieldType::Constant(first), FieldType::Constant(second)) => Ok(Boolean::constant(first.eq(second))), @@ -242,9 +242,9 @@ impl EvaluateEqGadget for FieldType { } } -impl EqGadget for FieldType {} +impl EqGadget for FieldType {} -impl ConditionalEqGadget for FieldType { +impl ConditionalEqGadget for FieldType { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -278,7 +278,7 @@ impl ConditionalEqGadget for FieldType { } } -impl CondSelectGadget for FieldType { +impl CondSelectGadget for FieldType { fn conditionally_select>( mut cs: CS, cond: &Boolean, @@ -301,7 +301,7 @@ impl CondSelectGadget for FieldType { } } -impl ToBitsGadget for FieldType { +impl ToBitsGadget for FieldType { fn to_bits>(&self, mut cs: CS) -> Result, SynthesisError> { let self_gadget = self.allocated(&mut cs)?; self_gadget.to_bits(cs) @@ -313,7 +313,7 @@ impl ToBitsGadget for FieldType { } } -impl ToBytesGadget for FieldType { +impl ToBytesGadget for FieldType { fn to_bytes>(&self, mut cs: CS) -> Result, SynthesisError> { let self_gadget = self.allocated(&mut cs)?; self_gadget.to_bytes(cs) @@ -325,7 +325,7 @@ impl ToBytesGadget for FieldType { } } -impl std::fmt::Display for FieldType { +impl std::fmt::Display for FieldType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self.get_value().ok_or(std::fmt::Error)) } diff --git a/compiler/src/value/field/input.rs b/compiler/src/value/field/input.rs index e3c99edde5..88a6f5b9fe 100644 --- a/compiler/src/value/field/input.rs +++ b/compiler/src/value/field/input.rs @@ -21,11 +21,11 @@ use leo_ast::{InputValue, Span}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::alloc::AllocGadget}, }; -pub(crate) fn allocate_field>( +pub(crate) fn allocate_field>( cs: &mut CS, name: &str, option: Option, @@ -38,7 +38,7 @@ pub(crate) fn allocate_field>( .map_err(|_| FieldError::missing_field(format!("{}: field", name), span.to_owned())) } -pub(crate) fn field_from_input, CS: ConstraintSystem>( +pub(crate) fn field_from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, diff --git a/compiler/src/value/group/input.rs b/compiler/src/value/group/input.rs index a77db5e0fa..274d944e15 100644 --- a/compiler/src/value/group/input.rs +++ b/compiler/src/value/group/input.rs @@ -21,12 +21,9 @@ use leo_asg::{GroupValue, Span}; use leo_ast::InputValue; use snarkvm_errors::gadgets::SynthesisError; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub(crate) fn allocate_group, CS: ConstraintSystem>( +pub(crate) fn allocate_group, CS: ConstraintSystem>( cs: &mut CS, name: &str, option: Option, @@ -39,7 +36,7 @@ pub(crate) fn allocate_group, CS: Constra .map_err(|_| GroupError::missing_group(format!("{}: group", name), span.to_owned())) } -pub(crate) fn group_from_input, CS: ConstraintSystem>( +pub(crate) fn group_from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, diff --git a/compiler/src/value/integer/integer.rs b/compiler/src/value/integer/integer.rs index 8386ffb2ff..51b2a7c848 100644 --- a/compiler/src/value/integer/integer.rs +++ b/compiler/src/value/integer/integer.rs @@ -298,7 +298,7 @@ impl Integer { Self::allocate_type(cs, integer_type, name, option, span) } - pub fn negate>( + pub fn negate>( self, cs: &mut CS, span: &Span, @@ -312,7 +312,7 @@ impl Integer { result.ok_or_else(|| IntegerError::negate_operation(span.to_owned())) } - pub fn add>( + pub fn add>( self, cs: &mut CS, other: Self, @@ -328,7 +328,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("+".to_string(), span.to_owned())) } - pub fn sub>( + pub fn sub>( self, cs: &mut CS, other: Self, @@ -344,7 +344,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("-".to_string(), span.to_owned())) } - pub fn mul>( + pub fn mul>( self, cs: &mut CS, other: Self, @@ -360,7 +360,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("*".to_string(), span.to_owned())) } - pub fn div>( + pub fn div>( self, cs: &mut CS, other: Self, @@ -376,7 +376,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("รท".to_string(), span.to_owned())) } - pub fn pow>( + pub fn pow>( self, cs: &mut CS, other: Self, @@ -393,7 +393,7 @@ impl Integer { } } -impl EvaluateEqGadget for Integer { +impl EvaluateEqGadget for Integer { fn evaluate_equal>(&self, cs: CS, other: &Self) -> Result { let a = self; let b = other; @@ -404,7 +404,7 @@ impl EvaluateEqGadget for Integer { } } -impl EvaluateLtGadget for Integer { +impl EvaluateLtGadget for Integer { fn less_than>(&self, cs: CS, other: &Self) -> Result { let a = self; let b = other; @@ -414,11 +414,11 @@ impl EvaluateLtGadget for Integer { } } -impl ComparatorGadget for Integer {} +impl ComparatorGadget for Integer {} -impl EqGadget for Integer {} +impl EqGadget for Integer {} -impl ConditionalEqGadget for Integer { +impl ConditionalEqGadget for Integer { fn conditional_enforce_equal>( &self, cs: CS, @@ -438,7 +438,7 @@ impl ConditionalEqGadget for Integer { } } -impl CondSelectGadget for Integer { +impl CondSelectGadget for Integer { fn conditionally_select>( cs: CS, cond: &Boolean, diff --git a/compiler/src/value/value.rs b/compiler/src/value/value.rs index 83db492511..6fec55729d 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -21,7 +21,7 @@ use leo_asg::{CircuitBody, Identifier, Span, Type}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, eq::ConditionalEqGadget, select::CondSelectGadget}, @@ -30,10 +30,10 @@ use snarkvm_models::{ use std::{fmt, sync::Arc}; #[derive(Clone, PartialEq, Eq)] -pub struct ConstrainedCircuitMember>(pub Identifier, pub ConstrainedValue); +pub struct ConstrainedCircuitMember>(pub Identifier, pub ConstrainedValue); #[derive(Clone, PartialEq, Eq)] -pub enum ConstrainedValue> { +pub enum ConstrainedValue> { // Data types Address(Address), Boolean(Boolean), @@ -51,7 +51,7 @@ pub enum ConstrainedValue> { CircuitExpression(Arc, Vec>), } -impl> ConstrainedValue { +impl> ConstrainedValue { pub(crate) fn to_type(&self, span: &Span) -> Result { Ok(match self { // Data types @@ -82,7 +82,7 @@ impl> ConstrainedValue { } } -impl> fmt::Display for ConstrainedValue { +impl> fmt::Display for ConstrainedValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { // Data types @@ -129,13 +129,13 @@ impl> fmt::Display for ConstrainedValue> fmt::Debug for ConstrainedValue { +impl> fmt::Debug for ConstrainedValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self) } } -impl> ConditionalEqGadget for ConstrainedValue { +impl> ConditionalEqGadget for ConstrainedValue { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -179,7 +179,7 @@ impl> ConditionalEqGadget for Constrai } } -impl> CondSelectGadget for ConstrainedValue { +impl> CondSelectGadget for ConstrainedValue { fn conditionally_select>( mut cs: CS, cond: &Boolean, @@ -256,7 +256,7 @@ impl> CondSelectGadget for Constrained } } -impl> CondSelectGadget for ConstrainedCircuitMember { +impl> CondSelectGadget for ConstrainedCircuitMember { fn conditionally_select>( cs: CS, cond: &Boolean, diff --git a/gadgets/src/arithmetic/add.rs b/gadgets/src/arithmetic/add.rs index ad60182080..5b82a38794 100644 --- a/gadgets/src/arithmetic/add.rs +++ b/gadgets/src/arithmetic/add.rs @@ -36,7 +36,7 @@ where // Implement unsigned integers macro_rules! add_uint_impl { ($($gadget: ident),*) => ($( - impl Add for $gadget { + impl Add for $gadget { type ErrorType = SynthesisError; fn add>( diff --git a/gadgets/src/bits/comparator.rs b/gadgets/src/bits/comparator.rs index 7e5f2a59be..d77001d18b 100644 --- a/gadgets/src/bits/comparator.rs +++ b/gadgets/src/bits/comparator.rs @@ -53,7 +53,7 @@ where macro_rules! uint_cmp_impl { ($($gadget: ident),*) => ($( /* Bitwise less than comparison of two unsigned integers */ - impl EvaluateLtGadget for $gadget { + impl EvaluateLtGadget for $gadget { fn less_than>(&self, mut cs: CS, other: &Self) -> Result { let mut result = Boolean::constant(true); @@ -91,7 +91,7 @@ macro_rules! uint_cmp_impl { } /* Bitwise comparison of two unsigned integers */ - impl ComparatorGadget for $gadget {} + impl ComparatorGadget for $gadget {} )*) } diff --git a/gadgets/src/bits/rca.rs b/gadgets/src/bits/rca.rs index 6a07cf672e..96c75b505c 100644 --- a/gadgets/src/bits/rca.rs +++ b/gadgets/src/bits/rca.rs @@ -51,7 +51,7 @@ impl RippleCarryAdder for Vec { macro_rules! rpc_impl { ($($gadget: ident)*) => ($( - impl RippleCarryAdder for $gadget { + impl RippleCarryAdder for $gadget { fn add_bits>(&self, cs: CS, other: &Self) -> Result, SynthesisError> { self.bits.add_bits(cs, &other.bits) }