hotshot_contract_adapter/
lib.rs1use alloy::primitives::U256;
4use ark_ff::{BigInteger, PrimeField};
5
6#[allow(dead_code)]
7pub(crate) mod bindings;
8mod copy;
9pub mod evm;
10pub mod jellyfish;
11pub mod light_client;
12pub mod sol_types;
13pub mod stake_table;
14
15pub fn field_to_u256<F: PrimeField>(f: F) -> U256 {
17 if F::MODULUS_BIT_SIZE > 256 {
18 panic!("Shouldn't convert a >256-bit field to U256");
19 }
20 U256::from_le_slice(&f.into_bigint().to_bytes_le())
21}
22
23pub fn u256_to_field<F: PrimeField>(x: U256) -> F {
25 let bytes: [u8; 32] = x.to_le_bytes();
26 F::from_le_bytes_mod_order(&bytes)
27}