@@ -49,7 +49,6 @@ pub use ethers_core::{
4949 Address , Block , Bytes , Signature , H160 , H256 , H64 , U256 , U64 ,
5050 } ,
5151} ;
52- use halo2curves:: { bn256:: Fr , group:: ff:: PrimeField } ;
5352use serde:: { de, Deserialize , Deserializer , Serialize } ;
5453use std:: {
5554 collections:: { HashMap , HashSet } ,
@@ -92,41 +91,6 @@ pub mod base64 {
9291 }
9392}
9493
95- /// Trait used to reduce verbosity with the declaration of the [`Field`]
96- /// trait and its repr.
97- pub trait Field :
98- PrimeField < Repr = [ u8 ; 32 ] > + poseidon_base:: hash:: Hashable + std:: convert:: From < Fr >
99- {
100- /// Re-expose zero element as a function
101- fn zero ( ) -> Self {
102- Self :: ZERO
103- }
104-
105- /// Re-expose one element as a function
106- fn one ( ) -> Self {
107- Self :: ONE
108- }
109-
110- /// Expose the lower 128 bits
111- fn get_lower_128 ( & self ) -> u128 {
112- u128:: from_le_bytes ( self . to_repr ( ) . as_ref ( ) [ ..16 ] . try_into ( ) . unwrap ( ) )
113- }
114- }
115-
116- // Impl custom `Field` trait for BN256 Fr to be used and consistent with the
117- // rest of the workspace.
118- impl Field for Fr { }
119-
120- // Impl custom `Field` trait for BN256 Fq to be used and consistent with the
121- // rest of the workspace.
122- // impl Field for Fq {}
123-
124- /// Trait used to define types that can be converted to a 256 bit scalar value.
125- pub trait ToScalar < F > {
126- /// Convert the type to a scalar value.
127- fn to_scalar ( & self ) -> Option < F > ;
128- }
129-
13094/// Trait used to convert a type to a [`Word`].
13195pub trait ToWord {
13296 /// Convert the type to a [`Word`].
@@ -179,14 +143,6 @@ impl<'de> Deserialize<'de> for DebugU256 {
179143 }
180144}
181145
182- impl < F : Field > ToScalar < F > for DebugU256 {
183- fn to_scalar ( & self ) -> Option < F > {
184- let mut bytes = [ 0u8 ; 32 ] ;
185- self . to_little_endian ( & mut bytes) ;
186- F :: from_repr ( bytes) . into ( )
187- }
188- }
189-
190146impl ToBigEndian for DebugU256 {
191147 /// Encode the value as byte array in big endian.
192148 fn to_be_bytes ( & self ) -> [ u8 ; 32 ] {
@@ -243,14 +199,6 @@ impl ToU16LittleEndian for U256 {
243199 }
244200}
245201
246- impl < F : Field > ToScalar < F > for U256 {
247- fn to_scalar ( & self ) -> Option < F > {
248- let mut bytes = [ 0u8 ; 32 ] ;
249- self . to_little_endian ( & mut bytes) ;
250- F :: from_repr ( bytes) . into ( )
251- }
252- }
253-
254202impl ToAddress for U256 {
255203 fn to_address ( & self ) -> Address {
256204 Address :: from_slice ( & self . to_be_bytes ( ) [ 12 ..] )
@@ -321,33 +269,6 @@ impl ToWord for Word {
321269 }
322270}
323271
324- impl < F : Field > ToScalar < F > for Address {
325- fn to_scalar ( & self ) -> Option < F > {
326- let mut bytes = [ 0u8 ; 32 ] ;
327- bytes[ 32 - Self :: len_bytes ( ) ..] . copy_from_slice ( self . as_bytes ( ) ) ;
328- bytes. reverse ( ) ;
329- F :: from_repr ( bytes) . into ( )
330- }
331- }
332-
333- impl < F : Field > ToScalar < F > for bool {
334- fn to_scalar ( & self ) -> Option < F > {
335- self . to_word ( ) . to_scalar ( )
336- }
337- }
338-
339- impl < F : Field > ToScalar < F > for u64 {
340- fn to_scalar ( & self ) -> Option < F > {
341- Some ( F :: from ( * self ) )
342- }
343- }
344-
345- impl < F : Field > ToScalar < F > for usize {
346- fn to_scalar ( & self ) -> Option < F > {
347- u64:: try_from ( * self ) . ok ( ) . map ( F :: from)
348- }
349- }
350-
351272/// Code hash related
352273/// the empty keccak code hash
353274pub static KECCAK_CODE_HASH_EMPTY : LazyLock < Hash > = LazyLock :: new ( || {
0 commit comments