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