diff --git a/compiler/src/errors/value/integer.rs b/compiler/src/errors/value/integer.rs index ee9a5e6ab1..eb0096e400 100644 --- a/compiler/src/errors/value/integer.rs +++ b/compiler/src/errors/value/integer.rs @@ -15,9 +15,8 @@ // along with the Leo library. If not, see . use leo_ast::{FormattedError, IntegerType, LeoError, Span, Type}; -use leo_gadgets::errors::SignedIntegerError; -use snarkvm_gadgets::errors::SignedIntegerError as SnarkVMSignedIntegerError; +use snarkvm_gadgets::errors::SignedIntegerError; use snarkvm_r1cs::SynthesisError; #[derive(Debug, Error)] @@ -69,15 +68,6 @@ impl IntegerError { Self::new_from_span(message, span) } - pub fn snarkvm_error(error: SnarkVMSignedIntegerError, span: &Span) -> Self { - let message = format!( - "the integer operation failed due to the signed integer error `{:?}`", - error - ); - - Self::new_from_span(message, span) - } - pub fn synthesis(error: SynthesisError, span: &Span) -> Self { let message = format!("integer operation failed due to the synthesis error `{}`", error); diff --git a/compiler/src/value/integer/integer.rs b/compiler/src/value/integer/integer.rs index 6022788c35..40368405ec 100644 --- a/compiler/src/value/integer/integer.rs +++ b/compiler/src/value/integer/integer.rs @@ -18,7 +18,6 @@ use crate::{errors::IntegerError, IntegerTrait}; use leo_asg::{ConstInt, IntegerType, Span}; use leo_ast::InputValue; -use leo_gadgets::signed_integer::*; use snarkvm_fields::{Field, PrimeField}; use snarkvm_gadgets::traits::utilities::{ @@ -27,7 +26,7 @@ use snarkvm_gadgets::traits::utilities::{ bits::comparator::{ComparatorGadget, EvaluateLtGadget}, boolean::Boolean, eq::{ConditionalEqGadget, EqGadget, EvaluateEqGadget}, - int::Int8, + int::{Int128, Int16, Int32, Int64, Int8}, select::CondSelectGadget, uint::*, }; diff --git a/compiler/src/value/integer/macros.rs b/compiler/src/value/integer/macros.rs index c216cb9918..932a646fa4 100644 --- a/compiler/src/value/integer/macros.rs +++ b/compiler/src/value/integer/macros.rs @@ -14,11 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::signed_integer::*; - use snarkvm_gadgets::traits::utilities::{ boolean::Boolean, - int::Int8, + int::{Int128, Int16, Int32, Int64, Int8}, uint::{UInt128, UInt16, UInt32, UInt64, UInt8}, }; use std::fmt::Debug; @@ -85,9 +83,7 @@ macro_rules! match_unsigned_integer { macro_rules! match_signed_integer { ($integer: ident, $span: ident => $expression: expr) => { match $integer { - Integer::I8($integer) => Some(Integer::I8( - $expression.map_err(|e| IntegerError::snarkvm_error(e, $span))?, - )), + Integer::I8($integer) => Some(Integer::I8($expression.map_err(|e| IntegerError::signed(e, $span))?)), Integer::I16($integer) => Some(Integer::I16($expression.map_err(|e| IntegerError::signed(e, $span))?)), Integer::I32($integer) => Some(Integer::I32($expression.map_err(|e| IntegerError::signed(e, $span))?)), Integer::I64($integer) => Some(Integer::I64($expression.map_err(|e| IntegerError::signed(e, $span))?)), @@ -138,9 +134,9 @@ macro_rules! match_integers_span { $expression.map_err(|e| IntegerError::synthesis(e, $span))?, )), - (Integer::I8($a), Integer::I8($b)) => Some(Integer::I8( - $expression.map_err(|e| IntegerError::snarkvm_error(e, $span))?, - )), + (Integer::I8($a), Integer::I8($b)) => { + Some(Integer::I8($expression.map_err(|e| IntegerError::signed(e, $span))?)) + } (Integer::I16($a), Integer::I16($b)) => { Some(Integer::I16($expression.map_err(|e| IntegerError::signed(e, $span))?)) } diff --git a/gadgets/benches/integer_arithmetic.rs b/gadgets/benches/integer_arithmetic.rs index ccdb6cb7c3..2bdd0b7842 100644 --- a/gadgets/benches/integer_arithmetic.rs +++ b/gadgets/benches/integer_arithmetic.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use leo_gadgets::{Int128, Int16, Int32, Int64}; - use snarkvm_gadgets::traits::utilities::{ alloc::AllocGadget, arithmetic::{Add, Div, Mul, Sub}, - int::Int8, + int::{Int128, Int16, Int32, Int64, Int8}, }; use snarkvm_r1cs::{ConstraintSystem, Fr, TestConstraintSystem}; @@ -29,6 +27,7 @@ use std::i128; use criterion::{criterion_group, criterion_main, Criterion}; +// TODO: move these benchmarks to snarkvm? macro_rules! create_add_bench { ($bench_name:ident, $bench_id:expr, $foo_name:ident, $std_type:ty, $bit_type:ty) => { fn $bench_name(c: &mut Criterion) { diff --git a/gadgets/src/bits/rca.rs b/gadgets/src/bits/rca.rs index 1f16cb5a3c..86b7a8cf65 100644 --- a/gadgets/src/bits/rca.rs +++ b/gadgets/src/bits/rca.rs @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{bits::FullAdder, signed_integer::*}; - use snarkvm_fields::{Field, PrimeField}; use snarkvm_gadgets::traits::utilities::boolean::Boolean; use snarkvm_r1cs::{ConstraintSystem, SynthesisError}; diff --git a/gadgets/src/lib.rs b/gadgets/src/lib.rs index 38eed81ac1..d2ba9d58da 100644 --- a/gadgets/src/lib.rs +++ b/gadgets/src/lib.rs @@ -14,12 +14,12 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -#[macro_use] -extern crate thiserror; +// #[macro_use] +// extern crate thiserror; -pub mod bits; +// pub mod bits; -pub mod errors; +// pub mod errors; -pub mod signed_integer; -pub use self::signed_integer::*; +// pub mod signed_integer; +// pub use self::signed_integer::*; diff --git a/gadgets/tests/mod.rs b/gadgets/tests/mod.rs index 39c7dd79cc..898f5b4c27 100644 --- a/gadgets/tests/mod.rs +++ b/gadgets/tests/mod.rs @@ -14,5 +14,5 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -pub mod signed_integer; -pub use self::signed_integer::*; +// pub mod signed_integer; +// pub use self::signed_integer::*; diff --git a/gadgets/tests/signed_integer/mod.rs b/gadgets/tests/signed_integer/mod.rs index e262f23bc9..73b3adce90 100644 --- a/gadgets/tests/signed_integer/mod.rs +++ b/gadgets/tests/signed_integer/mod.rs @@ -14,8 +14,9 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -pub mod i128; -pub mod i16; -pub mod i32; -pub mod i64; +// Todo: move these tests to snarkvm. +// pub mod i128; +// pub mod i16; +// pub mod i32; +// pub mod i64; // pub mod i8;