arkworks_utils/mimc_params/
mod.rs1use super::{parse_vec, Bytes, Curve, FromHexError};
2
3pub use ark_std::vec::Vec;
4
5pub struct MimcData {
6 pub constants: Vec<Bytes>,
7 pub rounds: u16,
8 pub width: u8,
9}
10
11impl MimcData {
12 pub fn new(constants: Vec<Bytes>, rounds: u16, width: u8) -> Self {
13 Self {
14 constants,
15 rounds,
16 width,
17 }
18 }
19}
20
21pub fn setup_mimc_params(curve: Curve, rounds: u16, width: u8) -> Result<MimcData, FromHexError> {
22 match (curve, rounds, width) {
23 #[cfg(feature = "mimc_ed_on_bn254_220")]
24 (Curve::Bn254, 220, 3) => {
25 #[path = "./ed_on_bn254_220.rs"]
26 pub mod ed_on_bn254_220;
27 use ed_on_bn254_220::{CONSTANTS, MIMC_ROUNDS, WIDTH};
28 get_mimc_data(CONSTANTS, MIMC_ROUNDS, WIDTH)
29 }
30 _ => unimplemented!(),
31 }
32}
33
34pub fn get_mimc_data(constants: &[&str], rounds: u16, width: u8) -> Result<MimcData, FromHexError> {
35 let constants = parse_vec(constants.to_vec())?;
36 Ok(MimcData::new(constants, rounds, width))
37}