From ab9e086275c440884199017bbb8aad6b3623e80b Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Thu, 18 Jul 2024 18:42:11 +0200 Subject: [PATCH 1/6] feat: implement poseidon (width = 3) --- Cargo.toml | 9 +- felt/Cargo.toml | 7 + src/felt252.rs => felt/src/lib.rs | 20 + merkle/Cargo.toml | 7 + src/merkle/mod.rs => merkle/src/lib.rs | 0 poseidon/Cargo.toml | 20 + poseidon/README.md | 1 + poseidon/benches/poseidon.rs | 45 + poseidon/build.rs | 349 +++++ poseidon/poseidon3.txt | 462 ++++++ poseidon/src/constants.rs | 7 + poseidon/src/lib.rs | 193 +++ src/lib.rs | 5 - util/Cargo.toml | 10 + {src => util/src}/channel/mod.rs | 0 util/src/lib.rs | 2 + util/src/poseidon/consts.rs | 1834 ++++++++++++++++++++++++ util/src/poseidon/mod.rs | 161 +++ 18 files changed, 3122 insertions(+), 10 deletions(-) create mode 100644 felt/Cargo.toml rename src/felt252.rs => felt/src/lib.rs (64%) create mode 100644 merkle/Cargo.toml rename src/merkle/mod.rs => merkle/src/lib.rs (100%) create mode 100644 poseidon/Cargo.toml create mode 100644 poseidon/README.md create mode 100644 poseidon/benches/poseidon.rs create mode 100644 poseidon/build.rs create mode 100644 poseidon/poseidon3.txt create mode 100644 poseidon/src/constants.rs create mode 100644 poseidon/src/lib.rs delete mode 100644 src/lib.rs create mode 100644 util/Cargo.toml rename {src => util/src}/channel/mod.rs (100%) create mode 100644 util/src/lib.rs create mode 100644 util/src/poseidon/consts.rs create mode 100644 util/src/poseidon/mod.rs diff --git a/Cargo.toml b/Cargo.toml index b06cc52..96300c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,8 @@ -[package] -name = "pumice" -version = "0.1.0" -edition = "2021" +[workspace] +members = ["felt", "merkle", "poseidon"] +resolver = "2" -[dependencies] +[workspace.dependencies] anyhow = "1.0.86" ark-ff = "0.4.2" ark-poly = "0.4.2" diff --git a/felt/Cargo.toml b/felt/Cargo.toml new file mode 100644 index 0000000..96e1a57 --- /dev/null +++ b/felt/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "felt" +version = "0.1.0" +edition = "2021" + +[dependencies] +ark-ff.workspace = true diff --git a/src/felt252.rs b/felt/src/lib.rs similarity index 64% rename from src/felt252.rs rename to felt/src/lib.rs index 1621e26..6e5f4e0 100644 --- a/src/felt252.rs +++ b/felt/src/lib.rs @@ -1,3 +1,5 @@ +use ark_ff::Zero; + pub use container::Felt252; #[allow(non_local_definitions)] @@ -16,6 +18,24 @@ mod container { pub type Felt252 = Fp256>; } +/// This method is used for testing / debugging purposes. +/// It provides a convenient way to create a `Felt252` from a hex string. +/// +/// Warning: this method is slow and will panic if the input is not a valid hex string. +pub fn hex(hex: &str) -> Felt252 { + let mut chars = hex.chars(); + assert!(chars.next().unwrap() == '0'); + assert!(chars.next().unwrap() == 'x'); + + let mut res = Felt252::zero(); + for digit in chars { + let val = u8::from_str_radix(&digit.to_string(), 0x10).unwrap(); + res *= Felt252::from(0x10u64); + res += Felt252::from(val as u64); + } + res +} + #[cfg(test)] mod tests { use super::*; diff --git a/merkle/Cargo.toml b/merkle/Cargo.toml new file mode 100644 index 0000000..3c11bfc --- /dev/null +++ b/merkle/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "merkle" +version = "0.1.0" +edition = "2021" + +[dependencies] +ark-ff.workspace = true diff --git a/src/merkle/mod.rs b/merkle/src/lib.rs similarity index 100% rename from src/merkle/mod.rs rename to merkle/src/lib.rs diff --git a/poseidon/Cargo.toml b/poseidon/Cargo.toml new file mode 100644 index 0000000..1126e19 --- /dev/null +++ b/poseidon/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "poseidon" +version = "0.1.0" +edition = "2021" + +[dependencies] +ark-ff.workspace = true +felt = { path = "../felt" } + +[dev-dependencies] +criterion = "0.5.1" + +[[bench]] +name = "poseidon" +harness = false + +[build-dependencies] +chumsky = "0.9.3" +ark-ff.workspace = true +felt = { path = "../felt" } diff --git a/poseidon/README.md b/poseidon/README.md new file mode 100644 index 0000000..4bc35ae --- /dev/null +++ b/poseidon/README.md @@ -0,0 +1 @@ +# StarkWare Poseidon diff --git a/poseidon/benches/poseidon.rs b/poseidon/benches/poseidon.rs new file mode 100644 index 0000000..5fed677 --- /dev/null +++ b/poseidon/benches/poseidon.rs @@ -0,0 +1,45 @@ +use ark_ff::BigInt; +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +use felt::Felt252; +use poseidon::{FieldHasher, Poseidon3}; + +fn criterion_benchmark(c: &mut Criterion) { + let left = Felt252::new(BigInt([ + 0xdeadbeefdeadbeef, + 0xdeadbeefdeadbeef, + 0xdeadbeefdeadbeef, + 0xdeadbeefdeadbeef, + ])); + + let right = Felt252::new(BigInt([ + 0xcafebabecafebabe, + 0xcafebabecafebabe, + 0xcafebabecafebabe, + 0xcafebabecafebabe, + ])); + + let elems = [left, right].into_iter().cycle(); + let elems_4 = elems.clone().take(4).collect::>(); + let elems_8 = elems.clone().take(8).collect::>(); + let elems_16 = elems.clone().take(16).collect::>(); + + c.bench_function("Poseidon3::pair", |b| { + b.iter(|| black_box(Poseidon3::pair(left, right))) + }); + + c.bench_function("Poseidon3::hash(|4|)", |b| { + b.iter(|| black_box(Poseidon3::hash(&elems_4))) + }); + + c.bench_function("Poseidon3::hash(|8|)", |b| { + b.iter(|| black_box(Poseidon3::hash(&elems_8))) + }); + + c.bench_function("Poseidon3::hash(|16|)", |b| { + b.iter(|| black_box(Poseidon3::hash(&elems_16))) + }); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/poseidon/build.rs b/poseidon/build.rs new file mode 100644 index 0000000..847655b --- /dev/null +++ b/poseidon/build.rs @@ -0,0 +1,349 @@ +use std::{env, fs, path::Path}; + +use ark_ff::{BigInt, Field, PrimeField}; + +use chumsky::{ + self, + error::Simple, + primitive::{choice, empty, end, just}, + text::{self, TextParser}, + Parser, +}; + +use felt::Felt252; + +// parse the round keys +const WIDTH: usize = 3; + +#[derive(Debug, Clone)] +enum Options { + Rate(Number), + Capacity(Number), + FullRounds(Number), + PartialRounds(Number), + Mds(Vec>), + RoundKeys(Vec>), +} + +#[derive(Debug, Clone, Eq, PartialEq)] +enum Sign { + Plus, + Minus, +} + +#[derive(Debug, Clone)] +struct Number { + sign: Sign, + digits: String, +} + +impl Number { + fn i64(&self) -> i64 { + match self.sign { + Sign::Plus => self.digits.parse().unwrap(), + Sign::Minus => -self.digits.parse::().unwrap(), + } + } + + fn usize(&self) -> usize { + assert_eq!(self.sign, Sign::Plus); + self.digits.parse().unwrap() + } + + fn field(&self) -> F { + assert_eq!(self.sign, Sign::Plus); + let mut res = F::ZERO; + for c in self.digits.chars() { + let digit = match c { + '0' => F::from(0u64), + '1' => F::from(1u64), + '2' => F::from(2u64), + '3' => F::from(3u64), + '4' => F::from(4u64), + '5' => F::from(5u64), + '6' => F::from(6u64), + '7' => F::from(7u64), + '8' => F::from(8u64), + '9' => F::from(9u64), + _ => panic!("Invalid digit"), + }; + res = res * F::from(10u64) + digit; + } + res + } +} + +fn parse() -> impl Parser, Error = Simple> { + fn opt(c: char) -> impl Parser> + Clone { + choice((just(c).map(|_| true), empty().map(|_| false))) + } + + let num = opt('-') + .then(text::int(10)) + .map(|(neg, digits)| Number { + sign: if neg { Sign::Minus } else { Sign::Plus }, + digits, + }) + .padded(); + + let row = num.clone().separated_by(just(',').padded()).delimited_by( + just('[').padded(), + opt(',').padded().then(just(']')).padded(), + ); + + let mxt = row + .separated_by(just(',').padded()) + .delimited_by( + just('[').padded(), + opt(',').padded().then(just(']')).padded(), + ) + .padded(); + + let eq = just("=").padded(); + + let opt = choice(( + // parse the rate + just("Rate") + .then(eq) + .then(num.clone()) + .map(|(_, num)| Options::Rate(num)), + // parse the capacity + just("Capacity") + .then(eq) + .then(num.clone()) + .map(|(_, num)| Options::Capacity(num)), + // parse the number of full rounds + just("FullRounds") + .then(eq) + .then(num.clone()) + .map(|(_, num)| Options::FullRounds(num)), + // parse the number of partial rounds + just("PartialRounds") + .then(eq) + .then(num.clone()) + .map(|(_, num)| Options::PartialRounds(num)), + // parse the matrix + just("MDS") + .then(eq) + .then(mxt.clone()) + .map(|(_, m)| Options::Mds(m)), + // parse the round keys list + just("RoundKeys") + .then(eq) + .then(mxt.clone()) + .map(|(_, m)| Options::RoundKeys(m)), + )); + + opt.padded().repeated().then(end()).map(|(v, _)| v) +} + +#[allow(clippy::single_char_add_str)] +fn main() { + // open poseidon3.txt + let input = include_str!("poseidon3.txt"); + + // parse the input + let parsed = parse().parse(input).unwrap(); + + // extract the options + let mut rate = None; + let mut capacity = None; + let mut full_rounds = None; + let mut partial_rounds = None; + let mut mds = None; + let mut round_keys = None; + for opt in parsed { + match opt { + Options::Rate(n) => { + assert!(rate.is_none()); + rate = Some(n) + } + Options::Capacity(n) => { + assert!(capacity.is_none()); + capacity = Some(n) + } + Options::FullRounds(n) => { + assert!(full_rounds.is_none()); + full_rounds = Some(n) + } + Options::PartialRounds(n) => { + assert!(partial_rounds.is_none()); + partial_rounds = Some(n) + } + Options::Mds(m) => { + assert!(mds.is_none()); + mds = Some(m) + } + Options::RoundKeys(m) => { + assert!(round_keys.is_none()); + round_keys = Some(m) + } + } + } + + // check that all options are present + let rate = rate.expect("Rate not found"); + let capacity = capacity.expect("Capacity not found"); + let full_rounds = full_rounds.expect("FullRounds not found"); + let partial_rounds = partial_rounds.expect("PartialRounds not found"); + let mds = mds.expect("MDS not found"); + let round_keys = round_keys.expect("RoundKeys not found"); + + // check that the mds matrix is the expected one + let mds: Vec> = mds + .iter() + .map(|row| row.iter().map(|n| n.i64()).collect()) + .collect(); + assert_eq!(mds, vec![vec![3, 1, 1], vec![1, -1, 1], vec![1, 1, -2]]); + + let rate = rate.usize(); + let capacity = capacity.usize(); + let rounds_full = full_rounds.usize(); + let rounds_partial = partial_rounds.usize(); + + // expected number of round keys + assert_eq!(rate + capacity, WIDTH); + assert_eq!(rounds_full + rounds_partial, round_keys.len()); + assert_eq!(rounds_full % 2, 0); + + // parse the round keys + let mut parsed_keys: Vec> = vec![]; + for key in round_keys { + let key: Vec = key.iter().map(|n| n.field()).collect(); + assert_eq!(key.len(), WIDTH); + parsed_keys.push(key); + } + + // precompute the compressed round keys + fn compute_compressed_round_keys( + rnd_full_first: &[[Felt252; WIDTH]], + rnd_partial: &[[Felt252; WIDTH]], + rnd_full_last: &[[Felt252; WIDTH]], + ) -> Vec { + // output + let mut out = Vec::new(); + + // full rounds + for key in rnd_full_first { + out.push(key[0]); + out.push(key[1]); + out.push(key[2]); + } + + // handle partial rounds + let mut st = [Felt252::ZERO, Felt252::ZERO, Felt252::ZERO]; + for key in rnd_partial { + // add round constant + st[0] += key[0]; + st[1] += key[1]; + st[2] += key[2]; + + // add the state to the output + out.push(st[2]); + st[2] = Felt252::ZERO; + + // mix state + // M = ( + // ( 3, 1, 1), + // ( 1,-1, 1), + // ( 1, 1, -2) + // ) + // see: + // https://github.com/starkware-industries/poseidon/blob/main/poseidon3.txt + let t0 = st[0] + st[1]; + let t1 = t0 + st[2]; + st[0] = t1 + st[0].double(); + st[1] = t1 - st[1].double(); + st[2] = t0 - st[2].double(); + } + + // add the first of the last full-round keys + st[0] += rnd_full_last[0][0]; + st[1] += rnd_full_last[0][1]; + st[2] += rnd_full_last[0][2]; + out.push(st[0]); + out.push(st[1]); + out.push(st[2]); + + // handle remaining full rounds + for key in rnd_full_last.iter().skip(1) { + out.push(key[0]); + out.push(key[1]); + out.push(key[2]); + } + + out + } + + // split round keys into full and partial rounds + let keys = parsed_keys + .iter() + .cloned() + .map(|key| { + let key: [Felt252; WIDTH] = key.try_into().unwrap(); + key + }) + .collect::>(); + + let (first_full, rem) = keys.split_at(rounds_full / 2); + let (partial, last_full) = rem.split_at(rounds_partial); + + assert_eq!(partial.len(), rounds_partial); + assert_eq!(last_full.len(), rounds_full / 2); + assert_eq!(first_full.len(), rounds_full / 2); + + fn fmt_field(field: Felt252) -> String { + let bn: BigInt<4> = field.into_bigint(); + let vs = bn.0; + assert_eq!(vs.len(), 4); + format!( + " Felt252::new(BigInt([0x{:016x},0x{:016x},0x{:016x},0x{:016x}]))", + vs[0], vs[1], vs[2], vs[3] + ) + } + + // generate the compressed round keys + let compressed = compute_compressed_round_keys(first_full, partial, last_full); + + let mut output = String::new(); + + output.push_str("#[allow(dead_code)]\n"); + output.push_str(format!("pub const RATE: usize = {};\n", rate).as_str()); + output.push_str("\n"); + + output.push_str("#[allow(dead_code)]\n"); + output.push_str(format!("pub const CAPACITY: usize = {};\n", capacity).as_str()); + output.push_str("\n"); + + output.push_str("#[allow(dead_code)]\n"); + output.push_str(format!("pub const WIDTH: usize = {};\n", WIDTH).as_str()); + output.push_str("\n"); + + output.push_str("#[allow(dead_code)]\n"); + output.push_str(format!("pub const ROUNDS_FULL: usize = {};\n", rounds_full).as_str()); + output.push_str("\n"); + + output.push_str("#[allow(dead_code)]\n"); + output.push_str(format!("pub const ROUNDS_PARTIAL: usize = {};\n", rounds_partial).as_str()); + output.push_str("\n"); + + output.push_str("#[allow(dead_code)]\n"); + output.push_str( + format!( + "pub const ROUND_KEYS_COMPRESSED: [Felt252; {}] = [\n", + compressed.len() + ) + .as_str(), + ); + for key in compressed { + output.push_str(&format!("{},\n", fmt_field(key))); + } + output.push_str("];"); + output.push_str("\n"); + + // write the output to the file + let out_dir = env::var_os("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("cnst.rs"); + fs::write(&dest_path, output).unwrap(); + println!("cargo::rerun-if-changed=build.rs"); +} diff --git a/poseidon/poseidon3.txt b/poseidon/poseidon3.txt new file mode 100644 index 0000000..734a87b --- /dev/null +++ b/poseidon/poseidon3.txt @@ -0,0 +1,462 @@ +Rate = 2 +Capacity = 1 +FullRounds = 8 +PartialRounds = 83 +MDS = [[3, 1, 1], [1, -1, 1], [1, 1, -2]] +RoundKeys = [ + [ + 2950795762459345168613727575620414179244544320470208355568817838579231751791, + 1587446564224215276866294500450702039420286416111469274423465069420553242820, + 1645965921169490687904413452218868659025437693527479459426157555728339600137, + ], + [ + 2782373324549879794752287702905278018819686065818504085638398966973694145741, + 3409172630025222641379726933524480516420204828329395644967085131392375707302, + 2379053116496905638239090788901387719228422033660130943198035907032739387135, + ], + [ + 2570819397480941104144008784293466051718826502582588529995520356691856497111, + 3546220846133880637977653625763703334841539452343273304410918449202580719746, + 2720682389492889709700489490056111332164748138023159726590726667539759963454, + ], + [ + 1899653471897224903834726250400246354200311275092866725547887381599836519005, + 2369443697923857319844855392163763375394720104106200469525915896159690979559, + 2354174693689535854311272135513626412848402744119855553970180659094265527996, + ], + [ + 2404084503073127963385083467393598147276436640877011103379112521338973185443, + 950320777137731763811524327595514151340412860090489448295239456547370725376, + 2121140748740143694053732746913428481442990369183417228688865837805149503386, + ], + [ + 2372065044800422557577242066480215868569521938346032514014152523102053709709, + 2618497439310693947058545060953893433487994458443568169824149550389484489896, + 3518297267402065742048564133910509847197496119850246255805075095266319996916, + ], + [ + 340529752683340505065238931581518232901634742162506851191464448040657139775, + 1954876811294863748406056845662382214841467408616109501720437541211031966538, + 813813157354633930267029888722341725864333883175521358739311868164460385261, + ], + [ + 71901595776070443337150458310956362034911936706490730914901986556638720031, + 2789761472166115462625363403490399263810962093264318361008954888847594113421, + 2628791615374802560074754031104384456692791616314774034906110098358135152410, + ], + [ + 3617032588734559635167557152518265808024917503198278888820567553943986939719, + 2624012360209966117322788103333497793082705816015202046036057821340914061980, + 149101987103211771991327927827692640556911620408176100290586418839323044234, + ], + [ + 1039927963829140138166373450440320262590862908847727961488297105916489431045, + 2213946951050724449162431068646025833746639391992751674082854766704900195669, + 2792724903541814965769131737117981991997031078369482697195201969174353468597, + ], + [ + 3212031629728871219804596347439383805499808476303618848198208101593976279441, + 3343514080098703935339621028041191631325798327656683100151836206557453199613, + 614054702436541219556958850933730254992710988573177298270089989048553060199, + ], + [ + 148148081026449726283933484730968827750202042869875329032965774667206931170, + 1158283532103191908366672518396366136968613180867652172211392033571980848414, + 1032400527342371389481069504520755916075559110755235773196747439146396688513, + ], + [ + 806900704622005851310078578853499250941978435851598088619290797134710613736, + 462498083559902778091095573017508352472262817904991134671058825705968404510, + 1003580119810278869589347418043095667699674425582646347949349245557449452503, + ], + [ + 619074932220101074089137133998298830285661916867732916607601635248249357793, + 2635090520059500019661864086615522409798872905401305311748231832709078452746, + 978252636251682252755279071140187792306115352460774007308726210405257135181, + ], + [ + 1766912167973123409669091967764158892111310474906691336473559256218048677083, + 1663265127259512472182980890707014969235283233442916350121860684522654120381, + 3532407621206959585000336211742670185380751515636605428496206887841428074250, + ], + [ + 2507023127157093845256722098502856938353143387711652912931112668310034975446, + 3321152907858462102434883844787153373036767230808678981306827073335525034593, + 3039253036806065280643845548147711477270022154459620569428286684179698125661, + ], + [ + 103480338868480851881924519768416587261556021758163719199282794248762465380, + 2394049781357087698434751577708655768465803975478348134669006211289636928495, + 2660531560345476340796109810821127229446538730404600368347902087220064379579, + ], + [ + 3603166934034556203649050570865466556260359798872408576857928196141785055563, + 1553799760191949768532188139643704561532896296986025007089826672890485412324, + 2744284717053657689091306578463476341218866418732695211367062598446038965164, + ], + [ + 320745764922149897598257794663594419839885234101078803811049904310835548856, + 979382242100682161589753881721708883681034024104145498709287731138044566302, + 1860426855810549882740147175136418997351054138609396651615467358416651354991, + ], + [ + 336173081054369235994909356892506146234495707857220254489443629387613956145, + 1632470326779699229772327605759783482411227247311431865655466227711078175883, + 921958250077481394074960433988881176409497663777043304881055317463712938502, + ], + [ + 3034358982193370602048539901033542101022185309652879937418114324899281842797, + 25626282149517463867572353922222474817434101087272320606729439087234878607, + 3002662261401575565838149305485737102400501329139562227180277188790091853682, + ], + [ + 2939684373453383817196521641512509179310654199629514917426341354023324109367, + 1076484609897998179434851570277297233169621096172424141759873688902355505136, + 2575095284833160494841112025725243274091830284746697961080467506739203605049, + ], + [ + 3565075264617591783581665711620369529657840830498005563542124551465195621851, + 2197016502533303822395077038351174326125210255869204501838837289716363437993, + 331415322883530754594261416546036195982886300052707474899691116664327869405, + ], + [ + 1935011233711290003793244296594669823169522055520303479680359990463281661839, + 3495901467168087413996941216661589517270845976538454329511167073314577412322, + 954195417117133246453562983448451025087661597543338750600301835944144520375, + ], + [ + 1271840477709992894995746871435810599280944810893784031132923384456797925777, + 2565310762274337662754531859505158700827688964841878141121196528015826671847, + 3365022288251637014588279139038152521653896670895105540140002607272936852513, + ], + [ + 1660592021628965529963974299647026602622092163312666588591285654477111176051, + 970104372286014048279296575474974982288801187216974504035759997141059513421, + 2617024574317953753849168721871770134225690844968986289121504184985993971227, + ], + [ + 999899815343607746071464113462778273556695659506865124478430189024755832262, + 2228536129413411161615629030408828764980855956560026807518714080003644769896, + 2701953891198001564547196795777701119629537795442025393867364730330476403227, + ], + [ + 837078355588159388741598313782044128527494922918203556465116291436461597853, + 2121749601840466143704862369657561429793951309962582099604848281796392359214, + 771812260179247428733132708063116523892339056677915387749121983038690154755, + ], + [ + 3317336423132806446086732225036532603224267214833263122557471741829060578219, + 481570067997721834712647566896657604857788523050900222145547508314620762046, + 242195042559343964206291740270858862066153636168162642380846129622127460192, + ], + [ + 2855462178889999218204481481614105202770810647859867354506557827319138379686, + 3525521107148375040131784770413887305850308357895464453970651672160034885202, + 1320839531502392535964065058804908871811967681250362364246430459003920305799, + ], + [ + 2514191518588387125173345107242226637171897291221681115249521904869763202419, + 2798335750958827619666318316247381695117827718387653874070218127140615157902, + 2808467767967035643407948058486565877867906577474361783201337540214875566395, + ], + [ + 3551834385992706206273955480294669176699286104229279436819137165202231595747, + 1219439673853113792340300173186247996249367102884530407862469123523013083971, + 761519904537984520554247997444508040636526566551719396202550009393012691157, + ], + [ + 3355402549169351700500518865338783382387571349497391475317206324155237401353, + 199541098009731541347317515995192175813554789571447733944970283654592727138, + 192100490643078165121235261796864975568292640203635147901612231594408079071, + ], + [ + 1187019357602953326192019968809486933768550466167033084944727938441427050581, + 189525349641911362389041124808934468936759383310282010671081989585219065700, + 2831653363992091308880573627558515686245403755586311978724025292003353336665, + ], + [ + 2052859812632218952608271535089179639890275494426396974475479657192657094698, + 1670756178709659908159049531058853320846231785448204274277900022176591811072, + 3538757242013734574731807289786598937548399719866320954894004830207085723125, + ], + [ + 710549042741321081781917034337800036872214466705318638023070812391485261299, + 2345013122330545298606028187653996682275206910242635100920038943391319595180, + 3528369671971445493932880023233332035122954362711876290904323783426765912206, + ], + [ + 1167120829038120978297497195837406760848728897181138760506162680655977700764, + 3073243357129146594530765548901087443775563058893907738967898816092270628884, + 378514724418106317738164464176041649567501099164061863402473942795977719726, + ], + [ + 333391138410406330127594722511180398159664250722328578952158227406762627796, + 1727570175639917398410201375510924114487348765559913502662122372848626931905, + 968312190621809249603425066974405725769739606059422769908547372904403793174, + ], + [ + 360659316299446405855194688051178331671817370423873014757323462844775818348, + 1386580151907705298970465943238806620109618995410132218037375811184684929291, + 3604888328937389309031638299660239238400230206645344173700074923133890528967, + ], + [ + 2496185632263372962152518155651824899299616724241852816983268163379540137546, + 486538168871046887467737983064272608432052269868418721234810979756540672990, + 1558415498960552213241704009433360128041672577274390114589014204605400783336, + ], + [ + 3512058327686147326577190314835092911156317204978509183234511559551181053926, + 2235429387083113882635494090887463486491842634403047716936833563914243946191, + 1290896777143878193192832813769470418518651727840187056683408155503813799882, + ], + [ + 1143310336918357319571079551779316654556781203013096026972411429993634080835, + 3235435208525081966062419599803346573407862428113723170955762956243193422118, + 1293239921425673430660897025143433077974838969258268884994339615096356996604, + ], + [ + 236252269127612784685426260840574970698541177557674806964960352572864382971, + 1733907592497266237374827232200506798207318263912423249709509725341212026275, + 302004309771755665128395814807589350526779835595021835389022325987048089868, + ], + [ + 3018926838139221755384801385583867283206879023218491758435446265703006270945, + 39701437664873825906031098349904330565195980985885489447836580931425171297, + 908381723021746969965674308809436059628307487140174335882627549095646509778, + ], + [ + 219062858908229855064136253265968615354041842047384625689776811853821594358, + 1283129863776453589317845316917890202859466483456216900835390291449830275503, + 418512623547417594896140369190919231877873410935689672661226540908900544012, + ], + [ + 1792181590047131972851015200157890246436013346535432437041535789841136268632, + 370546432987510607338044736824316856592558876687225326692366316978098770516, + 3323437805230586112013581113386626899534419826098235300155664022709435756946, + ], + [ + 910076621742039763058481476739499965761942516177975130656340375573185415877, + 1762188042455633427137702520675816545396284185254002959309669405982213803405, + 2186362253913140345102191078329764107619534641234549431429008219905315900520, + ], + [ + 2230647725927681765419218738218528849146504088716182944327179019215826045083, + 1069243907556644434301190076451112491469636357133398376850435321160857761825, + 2695241469149243992683268025359863087303400907336026926662328156934068747593, + ], + [ + 1361519681544413849831669554199151294308350560528931040264950307931824877035, + 1339116632207878730171031743761550901312154740800549632983325427035029084904, + 790593524918851401449292693473498591068920069246127392274811084156907468875, + ], + [ + 2723400368331924254840192318398326090089058735091724263333980290765736363637, + 3457180265095920471443772463283225391927927225993685928066766687141729456030, + 1483675376954327086153452545475557749815683871577400883707749788555424847954, + ], + [ + 2926303836265506736227240325795090239680154099205721426928300056982414025239, + 543969119775473768170832347411484329362572550684421616624136244239799475526, + 237401230683847084256617415614300816373730178313253487575312839074042461932, + ], + [ + 844568412840391587862072008674263874021460074878949862892685736454654414423, + 151922054871708336050647150237534498235916969120198637893731715254687336644, + 1299332034710622815055321547569101119597030148120309411086203580212105652312, + ], + [ + 487046922649899823989594814663418784068895385009696501386459462815688122993, + 1104883249092599185744249485896585912845784382683240114120846423960548576851, + 1458388705536282069567179348797334876446380557083422364875248475157495514484, + ], + [ + 850248109622750774031817200193861444623975329881731864752464222442574976566, + 2885843173858536690032695698009109793537724845140477446409245651176355435722, + 3027068551635372249579348422266406787688980506275086097330568993357835463816, + ], + [ + 3231892723647447539926175383213338123506134054432701323145045438168976970994, + 1719080830641935421242626784132692936776388194122314954558418655725251172826, + 1172253756541066126131022537343350498482225068791630219494878195815226839450, + ], + [ + 1619232269633026603732619978083169293258272967781186544174521481891163985093, + 3495680684841853175973173610562400042003100419811771341346135531754869014567, + 1576161515913099892951745452471618612307857113799539794680346855318958552758, + ], + [ + 2618326122974253423403350731396350223238201817594761152626832144510903048529, + 2696245132758436974032479782852265185094623165224532063951287925001108567649, + 930116505665110070247395429730201844026054810856263733273443066419816003444, + ], + [ + 2786389174502246248523918824488629229455088716707062764363111940462137404076, + 1555260846425735320214671887347115247546042526197895180675436886484523605116, + 2306241912153325247392671742757902161446877415586158295423293240351799505917, + ], + [ + 411529621724849932999694270803131456243889635467661223241617477462914950626, + 1542495485262286701469125140275904136434075186064076910329015697714211835205, + 1853045663799041100600825096887578544265580718909350942241802897995488264551, + ], + [ + 2963055259497271220202739837493041799968576111953080503132045092194513937286, + 2303806870349915764285872605046527036748108533406243381676768310692344456050, + 2622104986201990620910286730213140904984256464479840856728424375142929278875, + ], + [ + 2369987021925266811581727383184031736927816625797282287927222602539037105864, + 285070227712021899602056480426671736057274017903028992288878116056674401781, + 3034087076179360957800568733595959058628497428787907887933697691951454610691, + ], + [ + 469095854351700119980323115747590868855368701825706298740201488006320881056, + 360001976264385426746283365024817520563236378289230404095383746911725100012, + 3438709327109021347267562000879503009590697221730578667498351600602230296178, + ], + [ + 63573904800572228121671659287593650438456772568903228287754075619928214969, + 3470881855042989871434874691030920672110111605547839662680968354703074556970, + 724559311507950497340993415408274803001166693839947519425501269424891465492, + ], + [ + 880409284677518997550768549487344416321062350742831373397603704465823658986, + 6876255662475867703077362872097208259197756317287339941435193538565586230, + 2701916445133770775447884812906226786217969545216086200932273680400909154638, + ], + [ + 425152119158711585559310064242720816611629181537672850898056934507216982586, + 1475552998258917706756737045704649573088377604240716286977690565239187213744, + 2413772448122400684309006716414417978370152271397082147158000439863002593561, + ], + [ + 392160855822256520519339260245328807036619920858503984710539815951012864164, + 1075036996503791536261050742318169965707018400307026402939804424927087093987, + 2176439430328703902070742432016450246365760303014562857296722712989275658921, + ], + [ + 1413865976587623331051814207977382826721471106513581745229680113383908569693, + 4879283427490523253696177116563427032332223531862961281430108575019551814, + 3392583297537374046875199552977614390492290683707960975137418536812266544902, + ], + [ + 3600854486849487646325182927019642276644093512133907046667282144129939150983, + 2779924664161372134024229593301361846129279572186444474616319283535189797834, + 2722699960903170449291146429799738181514821447014433304730310678334403972040, + ], + [ + 819109815049226540285781191874507704729062681836086010078910930707209464699, + 3046121243742768013822760785918001632929744274211027071381357122228091333823, + 1339019590803056172509793134119156250729668216522001157582155155947567682278, + ], + [ + 1933279639657506214789316403763326578443023901555983256955812717638093967201, + 2138221547112520744699126051903811860205771600821672121643894708182292213541, + 2694713515543641924097704224170357995809887124438248292930846280951601597065, + ], + [ + 2471734202930133750093618989223585244499567111661178960753938272334153710615, + 504903761112092757611047718215309856203214372330635774577409639907729993533, + 1943979703748281357156510253941035712048221353507135074336243405478613241290, + ], + [ + 684525210957572142559049112233609445802004614280157992196913315652663518936, + 1705585400798782397786453706717059483604368413512485532079242223503960814508, + 192429517716023021556170942988476050278432319516032402725586427701913624665, + ], + [ + 1586493702243128040549584165333371192888583026298039652930372758731750166765, + 686072673323546915014972146032384917012218151266600268450347114036285993377, + 3464340397998075738891129996710075228740496767934137465519455338004332839215, + ], + [ + 2805249176617071054530589390406083958753103601524808155663551392362371834663, + 667746464250968521164727418691487653339733392025160477655836902744186489526, + 1131527712905109997177270289411406385352032457456054589588342450404257139778, + ], + [ + 1908969485750011212309284349900149072003218505891252313183123635318886241171, + 1025257076985551890132050019084873267454083056307650830147063480409707787695, + 2153175291918371429502545470578981828372846236838301412119329786849737957977, + ], + [ + 3410257749736714576487217882785226905621212230027780855361670645857085424384, + 3442969106887588154491488961893254739289120695377621434680934888062399029952, + 3029953900235731770255937704976720759948880815387104275525268727341390470237, + ], + [ + 85453456084781138713939104192561924536933417707871501802199311333127894466, + 2730629666577257820220329078741301754580009106438115341296453318350676425129, + 178242450661072967256438102630920745430303027840919213764087927763335940415, + ], + [ + 2844589222514708695700541363167856718216388819406388706818431442998498677557, + 3547876269219141094308889387292091231377253967587961309624916269569559952944, + 2525005406762984211707203144785482908331876505006839217175334833739957826850, + ], + [ + 3096397013555211396701910432830904669391580557191845136003938801598654871345, + 574424067119200181933992948252007230348512600107123873197603373898923821490, + 1714030696055067278349157346067719307863507310709155690164546226450579547098, + ], + [ + 2339895272202694698739231405357972261413383527237194045718815176814132612501, + 3562501318971895161271663840954705079797767042115717360959659475564651685069, + 69069358687197963617161747606993436483967992689488259107924379545671193749, + ], + [ + 2614502738369008850475068874731531583863538486212691941619835266611116051561, + 655247349763023251625727726218660142895322325659927266813592114640858573566, + 2305235672527595714255517865498269719545193172975330668070873705108690670678, + ], + [ + 926416070297755413261159098243058134401665060349723804040714357642180531931, + 866523735635840246543516964237513287099659681479228450791071595433217821460, + 2284334068466681424919271582037156124891004191915573957556691163266198707693, + ], + [ + 1812588309302477291425732810913354633465435706480768615104211305579383928792, + 2836899808619013605432050476764608707770404125005720004551836441247917488507, + 2989087789022865112405242078196235025698647423649950459911546051695688370523, + ], + [ + 68056284404189102136488263779598243992465747932368669388126367131855404486, + 505425339250887519581119854377342241317528319745596963584548343662758204398, + 2118963546856545068961709089296976921067035227488975882615462246481055679215, + ], + [ + 2253872596319969096156004495313034590996995209785432485705134570745135149681, + 1625090409149943603241183848936692198923183279116014478406452426158572703264, + 179139838844452470348634657368199622305888473747024389514258107503778442495, + ], + [ + 1567067018147735642071130442904093290030432522257811793540290101391210410341, + 2737301854006865242314806979738760349397411136469975337509958305470398783585, + 3002738216460904473515791428798860225499078134627026021350799206894618186256, + ], + [ + 374029488099466837453096950537275565120689146401077127482884887409712315162, + 973403256517481077805460710540468856199855789930951602150773500862180885363, + 2691967457038172130555117632010860984519926022632800605713473799739632878867, + ], + [ + 3515906794910381201365530594248181418811879320679684239326734893975752012109, + 148057579455448384062325089530558091463206199724854022070244924642222283388, + 1541588700238272710315890873051237741033408846596322948443180470429851502842, + ], + [ + 147013865879011936545137344076637170977925826031496203944786839068852795297, + 2630278389304735265620281704608245039972003761509102213752997636382302839857, + 1359048670759642844930007747955701205155822111403150159614453244477853867621, + ], + [ + 2438984569205812336319229336885480537793786558293523767186829418969842616677, + 2137792255841525507649318539501906353254503076308308692873313199435029594138, + 2262318076430740712267739371170174514379142884859595360065535117601097652755, + ], + [ + 2792703718581084537295613508201818489836796608902614779596544185252826291584, + 2294173715793292812015960640392421991604150133581218254866878921346561546149, + 2770011224727997178743274791849308200493823127651418989170761007078565678171, + ], +] diff --git a/poseidon/src/constants.rs b/poseidon/src/constants.rs new file mode 100644 index 0000000..bed528a --- /dev/null +++ b/poseidon/src/constants.rs @@ -0,0 +1,7 @@ +use ark_ff::BigInt; +use felt::Felt252; +use std::include; + +// poseidon constants +// created by build.rs +include!(concat!(env!("OUT_DIR"), "/cnst.rs")); diff --git a/poseidon/src/lib.rs b/poseidon/src/lib.rs new file mode 100644 index 0000000..716d10d --- /dev/null +++ b/poseidon/src/lib.rs @@ -0,0 +1,193 @@ +mod constants; + +use constants::{ + RATE, + ROUNDS_FULL, + ROUNDS_PARTIAL, + ROUND_KEYS_COMPRESSED, + WIDTH, // total width of the state +}; + +use ark_ff::{BigInt, Field}; +use felt::Felt252; +use std::marker::PhantomData; + +pub trait FieldHasher { + fn hash(input: &[F]) -> F; + + fn pair(left: F, right: F) -> F; +} + +pub struct Poseidon3 { + _ph: PhantomData, +} + +#[inline] +fn s_box(x: F) -> F { + x.square() * x +} + +impl Poseidon3 { + fn mix(st: &mut [Felt252; WIDTH]) { + // linear layer: mix state + // M = ( + // ( 3, 1, 1), + // ( 1,-1, 1), + // ( 1, 1, -2) + // ) + // see: + // https://github.com/starkware-industries/poseidon/blob/main/poseidon3.txt + let t0 = st[0] + st[1]; + let t1 = t0 + st[2]; + st[0] = t1 + st[0].double(); + st[1] = t1 - st[1].double(); + st[2] = t0 - st[2].double(); + } + + fn round_partial<'a>(st: &mut [Felt252; WIDTH], key: &mut impl Iterator) { + // add round constant + st[2] += key.next().unwrap(); + + // apply S-box + st[2] = s_box(st[2]); + + // linear layer + Self::mix(st); + } + + fn round_full<'a>(st: &mut [Felt252; WIDTH], key: &mut impl Iterator) { + // add full round constant + st[0] += key.next().unwrap(); + st[1] += key.next().unwrap(); + st[2] += key.next().unwrap(); + + // apply S-box + st[0] = s_box(st[0]); + st[1] = s_box(st[1]); + st[2] = s_box(st[2]); + + // linear layer + Self::mix(st); + } + + fn perm(mut st: [Felt252; WIDTH]) -> [Felt252; WIDTH] { + let mut keys = ROUND_KEYS_COMPRESSED.iter(); + debug_assert_eq!(ROUNDS_FULL % 2, 0); + debug_assert_eq!( + ROUND_KEYS_COMPRESSED.len(), + ROUNDS_FULL * 3 + ROUNDS_PARTIAL + ); + + // initial full rounds + for _ in 0..ROUNDS_FULL / 2 { + Self::round_full(&mut st, &mut keys); + } + + // middle partial rounds + for _ in 0..ROUNDS_PARTIAL { + Self::round_partial(&mut st, &mut keys); + } + + // final full rounds + for _ in 0..ROUNDS_FULL / 2 { + Self::round_full(&mut st, &mut keys); + } + + // ensure we consumed all keys + debug_assert_eq!(keys.next(), None); + st + } +} + +impl FieldHasher for Poseidon3 { + fn hash(input: &[Felt252]) -> Felt252 { + // initialize state + let mut st = [Felt252::ZERO; WIDTH]; + let mut iter = input.chunks_exact(RATE); + + // handle regular chunks + for chunk in iter.by_ref() { + st[0] += chunk[0]; + st[1] += chunk[1]; + st = Self::perm(st); + } + + // handle remainer and padding + match iter.remainder() { + [last] => { + st[0] += *last; + st[1] += Felt252::ONE; + } + [] => { + st[0] += Felt252::ONE; + } + _ => unreachable!(), + } + + // apply the final permutation + st = Self::perm(st); + st[0] + } + + /// Observe that: + /// + /// pair(x, y) != hash([x, y]) + fn pair(left: Felt252, right: Felt252) -> Felt252 { + const PAD: Felt252 = Felt252::new(BigInt([0x2, 0x0, 0x0, 0x0])); + let st = Self::perm([left, right, PAD]); + st[0] + } +} + +#[test] +fn test_poseidon3_hash_empty_input() { + assert_eq!( + Poseidon3::hash(&[]), + felt::hex("0x2272be0f580fd156823304800919530eaa97430e972d7213ee13f4fbf7a5dbc") + ); +} + +#[test] +fn test_poseidon3_hash_many_single_input() { + assert_eq!( + Poseidon3::hash(&[ + // + felt::hex("0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204",) + ]), + felt::hex("0x7d1f569e0e898982de6515c20132703410abca88ee56100e02df737fc4bf10e") + ); +} + +#[test] +fn test_poseidon3_hash_many_two_inputs() { + assert_eq!( + Poseidon3::hash(&[ + felt::hex("0x259f432e6f4590b9a164106cf6a659eb4862b21fb97d43588561712e8e5216a"), + felt::hex("0x5487ce1af19922ad9b8a714e61a441c12e0c8b2bad640fb19488dec4f65d4d9"), + ]), + felt::hex("0x70869d36570fc0b364777c9322373fb7e15452d2282ebdb5b4f3212669f2e7") + ); +} + +#[test] +fn test_poseidon3_pair() { + let lhs = felt::hex("0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"); + let rhs = felt::hex("0x259f432e6f4590b9a164106cf6a659eb4862b21fb97d43588561712e8e5216a"); + let hsh = felt::hex("0x4be9af45b942b4b0c9f04a15e37b7f34f8109873ef7ef20e9eef8a38a3011e1"); + assert_eq!(Poseidon3::pair(lhs, rhs), hsh); +} + +#[test] +fn test_poseidon3_permutation() { + let input = [ + felt::hex("0x0000000000000000000000000000000000000000000000000000000000000000"), + felt::hex("0x0000000000000000000000000000000000000000000000000000000000000000"), + felt::hex("0x0000000000000000000000000000000000000000000000000000000000000000"), + ]; + let output = [ + felt::hex("0x079e8d1e78258000a28fc9d49e233bc6852357968577b1e386550ed6a9086133"), + felt::hex("0x03840d003d0f3f96dbb796ff6aa6a63be5b5404b91ccaabca256154cbb6fb984"), + felt::hex("0x01eb39da3f7d3b04142d0ac83d9da00c9325a61fb2ef326e50b70eaa8a3c7cc7"), + ]; + assert_eq!(Poseidon3::::perm(input), output); +} diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index 1725964..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod channel; -mod felt252; -mod merkle; - -pub use felt252::Felt252; diff --git a/util/Cargo.toml b/util/Cargo.toml new file mode 100644 index 0000000..b5d2292 --- /dev/null +++ b/util/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "util" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow.workspace = true +ark-ff.workspace = true +ark-poly.workspace = true +felt = { path = "../felt" } diff --git a/src/channel/mod.rs b/util/src/channel/mod.rs similarity index 100% rename from src/channel/mod.rs rename to util/src/channel/mod.rs diff --git a/util/src/lib.rs b/util/src/lib.rs new file mode 100644 index 0000000..a20e5b8 --- /dev/null +++ b/util/src/lib.rs @@ -0,0 +1,2 @@ +mod channel; +mod poseidon; diff --git a/util/src/poseidon/consts.rs b/util/src/poseidon/consts.rs new file mode 100644 index 0000000..6d5e2ff --- /dev/null +++ b/util/src/poseidon/consts.rs @@ -0,0 +1,1834 @@ +use ark_ff::BigInt; + +use felt::Felt252; + +pub const RATE: usize = 2; +pub const CAPACITY: usize = 1; +pub const WIDTH: usize = RATE + CAPACITY; +pub const ROUNDS_PARTIAL: usize = 83; +pub const ROUNDS_FULL: usize = 8; +pub const ROUNDS: usize = ROUNDS_FULL + ROUNDS_PARTIAL; + +// https://github.com/starkware-industries/poseidon/tree/main +pub const ROUND_CONSTANTS: [[Felt252; WIDTH]; ROUNDS] = [ + [ + Felt252::new(BigInt([ + 0x80b7fd8eac77fe6f, + 0xe58e2ad98109ae47, + 0x39dd92f9562a30b9, + 0x06861759ea556a23, + ])), + Felt252::new(BigInt([ + 0xe4ab1a22f27508c4, + 0x3da43f76abf28a64, + 0xffc8397a3d00425a, + 0x03827681995d5af9, + ])), + Felt252::new(BigInt([ + 0x7a0dbe17704a8309, + 0x2cac75dc279b2d68, + 0xe7f760a2277dc7cb, + 0x03a3956d2fad44d0, + ])), + ], + [ + Felt252::new(BigInt([ + 0x882031afe67ef4cd, + 0x291c78f926a2d1c6, + 0xf13c4282214aa759, + 0x0626c47a7d421fe1, + ])), + Felt252::new(BigInt([ + 0xadfe17baca05d6a6, + 0x2d327fcc948d772c, + 0x5bd6df5518cfd41f, + 0x078985f8e1650503, + ])), + Felt252::new(BigInt([ + 0x142dcf34341696ff, + 0xc6e26a68b456dc1d, + 0x204c659875341243, + 0x05427f10867514a3, + ])), + ], + [ + Felt252::new(BigInt([ + 0x0465e60edce699d7, + 0x847cd2c5d9d4cb8b, + 0x454361733f0883c5, + 0x05af083f36e4c729, + ])), + Felt252::new(BigInt([ + 0xc77e709bfd388882, + 0x2d3975f92ff84b1a, + 0x54fa3f74f7b352a5, + 0x07d71701bde3d06d, + ])), + Felt252::new(BigInt([ + 0xe39584467a6b1d3e, + 0xac1b64f699ffea44, + 0x9c26f8a6320a1c5e, + 0x0603da0688201900, + ])), + ], + [ + Felt252::new(BigInt([ + 0x613b9721f6453a5d, + 0xeebd8870fd13a36b, + 0x8e79ce13f47ad1cd, + 0x04332a6f6bde2f28, + ])), + Felt252::new(BigInt([ + 0xc9e8caeb5cba78e7, + 0x4b9a813aaeff60d6, + 0x5310a04c4dec2e7e, + 0x053d0ebf61664c68, + ])), + Felt252::new(BigInt([ + 0x1bfc2d15eaabfebc, + 0x6c82f99f928494ee, + 0x5ae5ebcb88028d2a, + 0x05346a6889484583, + ])), + ], + [ + Felt252::new(BigInt([ + 0x98147e69dd91e5a3, + 0x8694ab61f2387970, + 0xa7631ccaecb7a4ab, + 0x0550a9e24176509e, + ])), + Felt252::new(BigInt([ + 0x2b5794daa2687000, + 0x0f48ad3ed77c8b26, + 0xaa62773fedd3570e, + 0x0219dcccb783b1cb, + ])), + Felt252::new(BigInt([ + 0x92864c00f54a3f9a, + 0x3433b6ab9dd5a995, + 0x3453cc97445954bf, + 0x04b085eb1df4258c, + ])), + ], + [ + Felt252::new(BigInt([ + 0xe2da084e5aabb78d, + 0x5a465939d04b6c72, + 0x3af2bf3c03e420ea, + 0x053e8a8e8a404c50, + ])), + Felt252::new(BigInt([ + 0xf4f9ada962be8ca8, + 0xfb4049cb137faf5d, + 0x1bd14d2537fe5c19, + 0x05ca045c1312c09d, + ])), + Felt252::new(BigInt([ + 0x9939c46c162517f4, + 0x6820b1ed97596a96, + 0x44997e959f27a5b0, + 0x07c74922a456802c, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5dc6f519bb7ab83f, + 0xf2526a20f9167043, + 0x6bf5088614b9684f, + 0x00c0bba6880d2e68, + ])), + Felt252::new(BigInt([ + 0x843849cd0f87934a, + 0xc1a6203741decd72, + 0xd708dd07234c1b2d, + 0x04526bcaec43e8eb, + ])), + Felt252::new(BigInt([ + 0xbfe1ec7f01d613ed, + 0xbef44d92edc6d5b0, + 0xd81efaea5a75a434, + 0x01cc9a17b00d3607, + ])), + ], + [ + Felt252::new(BigInt([ + 0x0bc7b4a4fde8f01f, + 0xe1eb7284e2b28ed9, + 0x12aa8cdbead0bc1c, + 0x0028b1e269b84c40, + ])), + Felt252::new(BigInt([ + 0xbb724dc7a994498d, + 0x0c19656bcb945b58, + 0x1d9a2482fbdaf659, + 0x062af2f41d76c4ad, + ])), + Felt252::new(BigInt([ + 0x59e285eee627df1a, + 0x2269bed2dc0d4dbf, + 0xb2618213b0d1bf4a, + 0x05cfd7e44946daa6, + ])), + ], + [ + Felt252::new(BigInt([ + 0xc31955dc8386a747, + 0xcf0312ab9f16ac9b, + 0x56fdd1b94da8d3bb, + 0x07ff2afb40f33008, + ])), + Felt252::new(BigInt([ + 0x9b3248ee326e929c, + 0xab40efae6fa9cd91, + 0x83e90bab8ae37f8a, + 0x05cd236bdc15b541, + ])), + Felt252::new(BigInt([ + 0x741a90bbd53a698a, + 0x2bd999084e30688e, + 0x60c946418bf0e582, + 0x005463841390e22d, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8226e7406144f805, + 0x7efd44a4e51890ae, + 0xb2021f13eb4d7174, + 0x024c940fff3fe8c8, + ])), + Felt252::new(BigInt([ + 0x7fc77d45e1b04555, + 0x153ca4c02172dd1d, + 0x8dc88f05393d9d03, + 0x04e50cb07b387326, + ])), + Felt252::new(BigInt([ + 0xd0b32e1189b6dcb5, + 0x1d9b499c35f375d7, + 0x7b430e53238d2bab, + 0x062ca053e4da0fc8, + ])), + ], + [ + Felt252::new(BigInt([ + 0x951bff3d3d7e1191, + 0x19cd89100adff965, + 0xaaf37fe0b851bc24, + 0x0719f20ac59d1ebc, + ])), + Felt252::new(BigInt([ + 0x98935cf47d55a8fd, + 0x4050ac92ca52f5c7, + 0x6a82fe5bb90807f4, + 0x07645ca5e87a9f91, + ])), + Felt252::new(BigInt([ + 0x015391ca63663767, + 0x23d4b71d17133438, + 0x200eed38d248ecda, + 0x015b8aeaca96ab53, + ])), + ], + [ + Felt252::new(BigInt([ + 0x96c1b658bf10b2e2, + 0xb98799e908f928c1, + 0xaa8252f106292ac3, + 0x0053d94dbbca7cb2, + ])), + Felt252::new(BigInt([ + 0x3913831c34de2d1e, + 0x942b447c615c0f03, + 0xc6f4c0a3b70edbb3, + 0x028f90b403e240f1, + ])), + Felt252::new(BigInt([ + 0xb70ae6e770e22081, + 0x9699dd2feb36e3e5, + 0xe1161c4d0bf02515, + 0x02485167dc233ba6, + ])), + ], + [ + Felt252::new(BigInt([ + 0xe938607a5feca6e8, + 0x88f7fdaacdd58698, + 0xff7de548541dd269, + 0x01c8b08a90d6ee46, + ])), + Felt252::new(BigInt([ + 0xce05b16901c4881e, + 0x0c7c4df5ecdad643, + 0x66b75e79d146f988, + 0x0105c3bf5cba2564, + ])), + Felt252::new(BigInt([ + 0x965418b02dbc6bd7, + 0xd5015b85dfbd77b2, + 0x627a65a21bef2106, + 0x0238019787f4cc0b, + ])), + ], + [ + Felt252::new(BigInt([ + 0x3a6ebc99a6ddc5e1, + 0x5c15b52dec817292, + 0xb73dce29a5f24c46, + 0x015e624d7698fdf9, + ])), + Felt252::new(BigInt([ + 0x79f612fde5800a0a, + 0xca0c2efef23b04a4, + 0xf56bc056ad8bf740, + 0x05d3688ba56f34fd, + ])), + Felt252::new(BigInt([ + 0x811c69ae363b444d, + 0x2e26d872d98b3cce, + 0x9e67ed336e82dc6c, + 0x0229abdef3fef7ae, + ])), + ], + [ + Felt252::new(BigInt([ + 0xac58daf2d3fc44db, + 0xb2c43d1e33c92b57, + 0xee400801a56f236d, + 0x03e8096ecfcbcde2, + ])), + Felt252::new(BigInt([ + 0x02265352c57db9bd, + 0xe6a7cd4e1b47bf6a, + 0x108d605aae834c7c, + 0x03ad5fec670d7039, + ])), + Felt252::new(BigInt([ + 0xadca32046aeaef0a, + 0x4ef597fff1f98557, + 0x75877afdbb4df679, + 0x07cf4598c0cf1438, + ])), + ], + [ + Felt252::new(BigInt([ + 0xca0ec7a123c00ad6, + 0x4170c37841fef49a, + 0x4a4d1c4c8f27932e, + 0x058aecc0081b5513, + ])), + Felt252::new(BigInt([ + 0xec09308d65d2ca61, + 0xe4ef3c859db5b714, + 0x5460b71995790396, + 0x0757b4b7ee98e0a1, + ])), + Felt252::new(BigInt([ + 0x48dc6cc226718b5d, + 0x963d2b54fd2b7ed3, + 0xf3cd974f43322169, + 0x06b82800937f8981, + ])), + ], + [ + Felt252::new(BigInt([ + 0x606b34a60b1e9c64, + 0xa044f14088fedae9, + 0x73427e34ab8fbb7c, + 0x003a915b18147072, + ])), + Felt252::new(BigInt([ + 0x9a627689547bfbef, + 0xc0bb609d367b7626, + 0xf9bc01028ff44195, + 0x054afbf1bd990043, + ])), + Felt252::new(BigInt([ + 0xb08375edf6e762bb, + 0x2c3852df2d991470, + 0xb9524c7d01493107, + 0x05e1ceb846fe1422, + ])), + ], + [ + Felt252::new(BigInt([ + 0x6b2b01c1bec0814b, + 0x16709e0c48e3020c, + 0xbe5dff3ce06e8cb9, + 0x07f751f98968212e, + ])), + Felt252::new(BigInt([ + 0xd45cd6dfbff811e4, + 0xbea7f01d226b68b6, + 0xfc3180616e340536, + 0x036f6b64463f7c29, + ])), + Felt252::new(BigInt([ + 0x7ed4fe4fe8e0dbac, + 0x8dd4d0e469d6703d, + 0xb4511d74fe8de8b4, + 0x061135c9846faf39, + ])), + ], + [ + Felt252::new(BigInt([ + 0x7fbaad907fc912b8, + 0xa4ba83cc6e0ae352, + 0x59b78f6acfca9a21, + 0x00b58921a3fbdbb5, + ])), + Felt252::new(BigInt([ + 0x6e52821c2e2b1b1e, + 0x211d84eb2fb27b81, + 0xb9d16b61c2973847, + 0x022a4f8a5cdc7474, + ])), + Felt252::new(BigInt([ + 0xb112f810ad67036f, + 0xdeb1765c61516ffc, + 0xfeccbbc9a50b2cee, + 0x041cf6db5d6145ed, + ])), + ], + [ + Felt252::new(BigInt([ + 0xade9de11416b6831, + 0xac6a0ff2fdfab744, + 0x1cfc05fa8f4aec6f, + 0x00be44689973db2b, + ])), + Felt252::new(BigInt([ + 0x51df0b8239be148b, + 0x6d148a237142dc49, + 0x6489cda45128096d, + 0x039bf209c4e117e1, + ])), + Felt252::new(BigInt([ + 0x07c7eb980ea03a06, + 0x2a58282643860b57, + 0x2b93310b8ce37b09, + 0x0209cf541e5f74fc, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8c22dd5afa95326d, + 0x7232e122287036d1, + 0x0bdc218ba681b6ba, + 0x06b562e6005f34ee, + ])), + Felt252::new(BigInt([ + 0x670e7a35dea38c8f, + 0xa2a39c8aca11a914, + 0x5dc6d5f59253a627, + 0x000e8103a23902be, + ])), + Felt252::new(BigInt([ + 0xbbf345de2d552f72, + 0x3ef8ca7468d68f4f, + 0x06bdc1b4d5f9bed8, + 0x06a3725548c664fd, + ])), + ], + [ + Felt252::new(BigInt([ + 0xb447b4af006a4a37, + 0x11a45c0aa21eb4eb, + 0x605d0f01a8eccc5f, + 0x067fcd6997472e8e, + ])), + Felt252::new(BigInt([ + 0x64c95db6ecb5cff0, + 0x2a44366f77792d40, + 0x4075784d28c06c16, + 0x026144c95c8de363, + ])), + Felt252::new(BigInt([ + 0x895dc1466f350239, + 0x6fd875e3725061df, + 0x4b3a874eb6307cda, + 0x05b173c8b0eb7e9c, + ])), + ], + [ + Felt252::new(BigInt([ + 0x370f2165c3d54ddb, + 0xc448f877e53298b6, + 0x87bae06ad491d391, + 0x07e1c2d6fde8ac9f, + ])), + Felt252::new(BigInt([ + 0xfa433b57ca6627a9, + 0x8f74d61e7771f9e3, + 0x996f451b156fe4e2, + 0x04db779f3e5b7424, + ])), + Felt252::new(BigInt([ + 0xe240eed6970993dd, + 0x825c3f71114acb93, + 0x713435ec06b6fed7, + 0x00bb930d8a6c6583, + ])), + ], + [ + Felt252::new(BigInt([ + 0x89e9579c046e878f, + 0x99d3a08814c31c41, + 0xd708467e9296fb55, + 0x04472d73b2830565, + ])), + Felt252::new(BigInt([ + 0x2cc23612b11170e2, + 0x614d23739b7cb205, + 0x9e10e3c883ca5ce5, + 0x07ba9c303dfee2d8, + ])), + Felt252::new(BigInt([ + 0x822548eb9c4dc4b7, + 0x6356cb133e97579b, + 0x0425dc9b2c1ed30e, + 0x021c0e3319ede47f, + ])), + ], + [ + Felt252::new(BigInt([ + 0x65c1d41e877eb191, + 0x32e53b7dc4f49475, + 0x37b09933816e2a09, + 0x02cfd61139e50ddd, + ])), + Felt252::new(BigInt([ + 0x2f30acd37e26d8e7, + 0x5bdd10b3f170b0dc, + 0x844544d92ee0eca6, + 0x05abea18941a4976, + ])), + Felt252::new(BigInt([ + 0xe5a751b7ce6bcc21, + 0x4ea28ae28b26e6ee, + 0x7a6265e44fef6f72, + 0x077088fdb015c794, + ])), + ], + [ + Felt252::new(BigInt([ + 0x120dce84e6122b73, + 0x6b4ce33cddbc8446, + 0x5b3e3c43cfd44307, + 0x03abdc9d67723132, + ])), + Felt252::new(BigInt([ + 0x7a602662c2d62c4d, + 0x2ca94879ccfab81a, + 0x2e5d00b6b83e52a5, + 0x02250f430b7fe7d1, + ])), + Felt252::new(BigInt([ + 0xbbb1efb79a25861b, + 0x12660e7bd156d6ca, + 0x1fb24ef76d57912b, + 0x05c92ef479c11bb5, + ])), + ], + [ + Felt252::new(BigInt([ + 0xfcf784a63a0fd5c6, + 0xfd08fd4208a785cf, + 0x510f616fa8b87900, + 0x0235ec597391648b, + ])), + Felt252::new(BigInt([ + 0x5523c00b372cc668, + 0x396b5c0ba3376e85, + 0x207be77e9d11e38f, + 0x04ed4e872eb7e736, + ])), + Felt252::new(BigInt([ + 0xfb7d861c4f275a1b, + 0x3d46afa705908f68, + 0xb756ef3f6331890b, + 0x05f9406febca3879, + ])), + ], + [ + Felt252::new(BigInt([ + 0x97edf441abdaa49d, + 0x5f17b0384661f06d, + 0x621a9f61b68873c0, + 0x01d9c501d9ff1fba, + ])), + Felt252::new(BigInt([ + 0xfa530f41c535952e, + 0x69e37ba694774c4d, + 0x34982c8e28d2f6e1, + 0x04b0de22bbd0a585, + ])), + Felt252::new(BigInt([ + 0xc49d6fd1b033d903, + 0xd319f0e3648b2574, + 0x02186aabb291eca0, + 0x01b4d48bd38a3f86, + ])), + ], + [ + Felt252::new(BigInt([ + 0x19702cefcead4bab, + 0x6b6596bbd2f4e657, + 0x1725d8aa67ddba62, + 0x07558bbea55584bf, + ])), + Felt252::new(BigInt([ + 0x0a44cf7a3eef17be, + 0x70b157d56ece95b6, + 0x561ea174600e266a, + 0x01108f1a9500a52f, + ])), + Felt252::new(BigInt([ + 0x567289b67087bf60, + 0xc209fb90caab6668, + 0x2becb92b4b6ae3f8, + 0x008913d96a4f36b1, + ])), + ], + [ + Felt252::new(BigInt([ + 0x23f4d8a6f32867a6, + 0xca2e99f5742b6bf2, + 0x16926346857dec8c, + 0x06502262c51ad8f6, + ])), + Felt252::new(BigInt([ + 0xcd3a5931d2ec0e52, + 0xe962ea034378b343, + 0x2889280505c915bd, + 0x07cb5fcdc0089281, + ])), + Felt252::new(BigInt([ + 0x01b221c4d2a1ce87, + 0x5baea3bc96b8cd1f, + 0xf90be9781a151514, + 0x02eb919524a89a26, + ])), + ], + [ + Felt252::new(BigInt([ + 0xc1c63e8de3ec3d73, + 0xed0662c0161223e3, + 0xeada46635e3567dc, + 0x058efb6272921bc5, + ])), + Felt252::new(BigInt([ + 0xd6955e7844d4f88e, + 0x94254a1ac34acd46, + 0xb436d205ffc2a395, + 0x062fcd49ca9c7587, + ])), + Felt252::new(BigInt([ + 0x06fcf837aef5313b, + 0x85e5941e54bd3a21, + 0xe62d9acce0b625f8, + 0x0635895330838846, + ])), + ], + [ + Felt252::new(BigInt([ + 0x629f8b41fefb12e3, + 0x78a17f119d5e6e70, + 0x6d47a5f4d23b92a3, + 0x07da445b81e9b3d3, + ])), + Felt252::new(BigInt([ + 0x43b7016256118343, + 0xa9027882bef17389, + 0x9fc5737e189d5096, + 0x02b22dab62f0817e, + ])), + Felt252::new(BigInt([ + 0xfbef432b790e50d5, + 0xd5bdea769be8fcb8, + 0xbacdfed1d27664d0, + 0x01af01472348f395, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5b682e5ac6360309, + 0x9284163c8e4986bc, + 0x1de313b9390f79ec, + 0x076b172dbbeec5a3, + ])), + Felt252::new(BigInt([ + 0xf0bdb2905b3e0862, + 0x9b30ddb4178d46de, + 0x0f362f6cb423d200, + 0x0070efaeae36f6af, + ])), + Felt252::new(BigInt([ + 0x25a0e4117ccaeedf, + 0xd28c4942b8036a1c, + 0x0a39872686b84ee1, + 0x006cb99b36e521ac, + ])), + ], + [ + Felt252::new(BigInt([ + 0xfd1b8a4fc1dc6055, + 0xfb3d0fe5bb3aa743, + 0x0bbf9674e544bda0, + 0x029fd44305a5a9a7, + ])), + Felt252::new(BigInt([ + 0xaa6363d6619f9764, + 0xa11a6778d8848142, + 0x3629b184d8c36db3, + 0x006b447ded1046e8, + ])), + Felt252::new(BigInt([ + 0xc14b58f5b8989b59, + 0x357cceb6946fdc51, + 0xcbfcf55a77339b5d, + 0x0642a8b4be4ba812, + ])), + ], + [ + Felt252::new(BigInt([ + 0x7acd79ae1d95882a, + 0xbc51a73700bd794a, + 0xcc6cc6aa5b6e775c, + 0x0489e0a26f65a1ee, + ])), + Felt252::new(BigInt([ + 0x1b9d57b9a02e9200, + 0x816428f45a06293c, + 0xbf78ab5dc2fd1d24, + 0x03b19d4ef195975b, + ])), + Felt252::new(BigInt([ + 0x2884c52039013df5, + 0x71596f9cd59e55ad, + 0xa576b74790b21949, + 0x07d2dd994756eacb, + ])), + ], + [ + Felt252::new(BigInt([ + 0x02970ef0f2e8c5f3, + 0x8b3327e29e9e7650, + 0xf300df869823b9f1, + 0x01922810cc08f50b, + ])), + Felt252::new(BigInt([ + 0x71cbd4a88ed418ac, + 0x39c04376aafff057, + 0x1d46e1d79a70745b, + 0x052f3afaf7c9102f, + ])), + Felt252::new(BigInt([ + 0x376c5bcab6ea788e, + 0x89552bbe53dcc46b, + 0xa95260f44203086e, + 0x07ccfc88e44a0507, + ])), + ], + [ + Felt252::new(BigInt([ + 0x19e40a1ab008dd9c, + 0xf5157dd8e067bc88, + 0x4100228beff83823, + 0x02949125939e6ad9, + ])), + Felt252::new(BigInt([ + 0x078ba6e1912e1014, + 0x72d6811dde135af4, + 0x4273ce4ee6929ba3, + 0x06cb64e3a0d37a6a, + ])), + Felt252::new(BigInt([ + 0xded4bf5953837fae, + 0xad43714257949cd9, + 0x62f05f688129bf30, + 0x00d63b53707acf89, + ])), + ], + [ + Felt252::new(BigInt([ + 0x942092b32ef152d4, + 0xbb7d7460a6965702, + 0xd13bb968b4ea22d0, + 0x00bcb1549c9cabb5, + ])), + Felt252::new(BigInt([ + 0x0ca25b8d8fe798c1, + 0x2792a7205ba0531a, + 0xf5ead698fe76f649, + 0x03d1c5233657ce31, + ])), + Felt252::new(BigInt([ + 0x279f450b79f97516, + 0x48e26a83074558d9, + 0x066c2808b1e16ea4, + 0x02240b9755182ee9, + ])), + ], + [ + Felt252::new(BigInt([ + 0xc9b43ab6615a646c, + 0xfe8d70882137de70, + 0x0fe8e54f343cef59, + 0x00cc203d8b0f90e3, + ])), + Felt252::new(BigInt([ + 0xfa68e03c1f77910b, + 0x119e937dea9d2100, + 0xe061bacdc175ea9e, + 0x0310c6cc475d9346, + ])), + Felt252::new(BigInt([ + 0x97b83667049106c7, + 0xcbdbe033f5786993, + 0x20bc947defced0d8, + 0x07f84b639f52e574, + ])), + ], + [ + Felt252::new(BigInt([ + 0xbe4e1da8de3e164a, + 0x7e9f038cb32ec35a, + 0xd89c4562f57139f4, + 0x0584ca7f01262c5b, + ])), + Felt252::new(BigInt([ + 0x531f9afa78abbbde, + 0xe02fdc72e01e9510, + 0xaf7d02f562868be3, + 0x01135eefaf69b6e4, + ])), + Felt252::new(BigInt([ + 0x36a0d876856a99e8, + 0xd350c88b56f62c6d, + 0x0a50a3d33805827a, + 0x0372082b8a6c0710, + ])), + ], + [ + Felt252::new(BigInt([ + 0xc119e3d12462dfe6, + 0x9674f132e33898f0, + 0x87499bac1a143fc5, + 0x07c3c12b819a8aad, + ])), + Felt252::new(BigInt([ + 0x46bd9b75a23836cf, + 0xc056ce9e29d602eb, + 0x5b84157cfeff6822, + 0x04f1354c51e8f690, + ])), + Felt252::new(BigInt([ + 0xef3973548fbd2fca, + 0x8ac360150e849950, + 0x075739ba206507a0, + 0x02da9f26a8271659, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5fd78dd550702843, + 0x3f6a65ff50801aa7, + 0x11b5ec29195e38cc, + 0x0287173956a2beb1, + ])), + Felt252::new(BigInt([ + 0x4ae6ba7f9201e126, + 0x1c7f3227f6a7a4a6, + 0x212420095a51c841, + 0x07273101c190ff64, + ])), + Felt252::new(BigInt([ + 0x99258ee4c98005fc, + 0x749b03d3d3491696, + 0x3ebeb61e500687de, + 0x02dbf2a6b56b26d2, + ])), + ], + [ + Felt252::new(BigInt([ + 0xe4b910efd706c7fb, + 0xab89ef8d92530394, + 0x808e67f00ab89b52, + 0x0085b6cbb29739a6, + ])), + Felt252::new(BigInt([ + 0x3e06ce26b08925a3, + 0xb493fa9589fd937e, + 0x1dacbcbadfd5b910, + 0x03d55b5f1171efda, + ])), + Felt252::new(BigInt([ + 0x24f6ae2a9b16e90c, + 0x44f7a2f8135c2078, + 0x7d16b3b295410c0e, + 0x00aaedaa6ef2fa70, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5c1cd0d496ccf5e1, + 0x89b80f8adc5d1891, + 0x6c6331e9f1a5c4cc, + 0x06aca6ebf70b1cb4, + ])), + Felt252::new(BigInt([ + 0x77e9dd157fb27761, + 0x4d5e90003e6d37c6, + 0xabb010f831d403d9, + 0x001678602af36c28, + ])), + Felt252::new(BigInt([ + 0xfe60a0a8f508bad2, + 0x2cd3f4b0526a88aa, + 0x41b547fefdf36d4c, + 0x02022036bdf687f0, + ])), + ], + [ + Felt252::new(BigInt([ + 0x353d4e2e8d1d4af6, + 0xf9b8dfe49fb63e32, + 0xca664397414bdfb8, + 0x007bfc350957c968, + ])), + Felt252::new(BigInt([ + 0x3c5e2176f7ad79af, + 0x81f43a499b27a06d, + 0xc24ea29ccd1d15ab, + 0x02d639cbd418cb9f, + ])), + Felt252::new(BigInt([ + 0x4779569f64506e0c, + 0xe0dee3369e5fbc0f, + 0x88403d5b39687a1f, + 0x00ecdea7f959a4d4, + ])), + ], + [ + Felt252::new(BigInt([ + 0x1d4e34357154b558, + 0xf22e5f2d28c490e2, + 0xb70658e2f1992ef9, + 0x03f656bdc4fefd92, + ])), + Felt252::new(BigInt([ + 0x6594e19fddd59254, + 0xfec47596f8a6f4ce, + 0x2319638ccab9033d, + 0x00d1b8cb1561eed3, + ])), + Felt252::new(BigInt([ + 0x2d1e8b4e2ec1f192, + 0x6f281ec2941da722, + 0xf86ef6ea01545ad7, + 0x0758ffc77c62e3e0, + ])), + ], + [ + Felt252::new(BigInt([ + 0x29a591c95e6fcac5, + 0x596aacd28f83c32f, + 0x995386e96aeaa1b4, + 0x020315ca079570df, + ])), + Felt252::new(BigInt([ + 0x54884b316b740d8d, + 0x2cfe76b84a9d1b0f, + 0xcb05f3d6ff9c8d9f, + 0x03e55cf341e7c280, + ])), + Felt252::new(BigInt([ + 0x67c81203bf650c68, + 0xe92c029007a06f6e, + 0xeede9749739be452, + 0x04d56feb32cde74f, + ])), + ], + [ + Felt252::new(BigInt([ + 0xe8089f465403c89b, + 0x497f7599fb8145d7, + 0x33b6171eaa6a2544, + 0x04ee807aa678a9a4, + ])), + Felt252::new(BigInt([ + 0x0f9a8ad2ef2b3821, + 0x1f365e56a1bc579d, + 0x48cb5f394de2cb6e, + 0x025d2bacc8f1ee75, + ])), + Felt252::new(BigInt([ + 0xf237d15feb17bd49, + 0xcd4b278811924af1, + 0x9fc20051f6501268, + 0x05f573de597ce170, + ])), + ], + [ + Felt252::new(BigInt([ + 0x682cf85ddac86deb, + 0x3c1e84a1dcf8b33c, + 0x5826a280e053cf7a, + 0x030297c3c54a505f, + ])), + Felt252::new(BigInt([ + 0x6a052b93a8339ae8, + 0xc6bc79b69b8709fe, + 0x43c7526a59783f03, + 0x02f5e9c47c9a86e0, + ])), + Felt252::new(BigInt([ + 0xd4a27a416c72b84b, + 0x1da7deec83e130bc, + 0x29f9c23065ff8ccb, + 0x01bf75c7a739da8d, + ])), + ], + [ + Felt252::new(BigInt([ + 0xdb8e864df3c3c675, + 0x29cd27fc4e91eeab, + 0x5989017bd5c4cfdc, + 0x060563d5f852ae87, + ])), + Felt252::new(BigInt([ + 0x1005be1cd16ccf9e, + 0xf8156c20e3131bd7, + 0x0969635468daec94, + 0x07a4b1d70885aa82, + ])), + Felt252::new(BigInt([ + 0x0f39c10e59cc5852, + 0xb8b85cf718cd1d40, + 0xf1e201cd62aa4600, + 0x0347bb025695e497, + ])), + ], + [ + Felt252::new(BigInt([ + 0xa8aa666292e9e217, + 0x2c4c9c2de413691b, + 0x9e7f9381eb6ab0de, + 0x06783ab1e1ef97bb, + ])), + Felt252::new(BigInt([ + 0xd6a7bfb4e5b0dd46, + 0xfd9c4cb99d534deb, + 0x7b3870a07823c081, + 0x0133e0280c6de90e, + ])), + Felt252::new(BigInt([ + 0x4fd0216eb925beec, + 0xa2f093695573dff9, + 0x2fb5db72460b3560, + 0x00865d450ce29dc4, + ])), + ], + [ + Felt252::new(BigInt([ + 0xcd81a6b301664e57, + 0x48efba06bcbb414e, + 0x35526dabacf0dee9, + 0x01de023f840e054a, + ])), + Felt252::new(BigInt([ + 0x190631ab1a5388c4, + 0xc7cc7b892a292d38, + 0x805015a96f724c5a, + 0x0055fc1e341bfdf7, + ])), + Felt252::new(BigInt([ + 0x01a307ef8d532858, + 0x162706a3e624faca, + 0xe7b27bf51552d2b5, + 0x02df6557bfd4a4e7, + ])), + ], + [ + Felt252::new(BigInt([ + 0x046d73d0507f6271, + 0xf8f226da95e4d629, + 0xd92a6bd3e9c1d55e, + 0x0113a8a66962ce08, + ])), + Felt252::new(BigInt([ + 0x4f3367b08c008e53, + 0xca1076033db5c2de, + 0x7f2c889874ba5b44, + 0x0271577d6ee9fa37, + ])), + Felt252::new(BigInt([ + 0x291d311866538574, + 0xf1ccb956fc673bc5, + 0xb0365c09348a561e, + 0x03396b33911219b6, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5398f69c8f321636, + 0x6170baa3c3436e6a, + 0xc8a7d89e89918930, + 0x01e1392f2da08549, + ])), + Felt252::new(BigInt([ + 0x9c876bd2e7d694ca, + 0x33e313b1a9a5b6d6, + 0xdf118e1d6e7c61a3, + 0x0661545081032013, + ])), + Felt252::new(BigInt([ + 0x73516f0cacdeec88, + 0xf66d00533574e465, + 0x776edbd432d20eb8, + 0x06b14294e71cd7fb, + ])), + ], + [ + Felt252::new(BigInt([ + 0x915cab6eb1a1d4f2, + 0x1fe2a18e2406c671, + 0x338b1c41df31e4e5, + 0x07252fbbb06c2848, + ])), + Felt252::new(BigInt([ + 0x7f5327cb00ff99da, + 0x430c03645747621b, + 0xbcf5a09807c69679, + 0x03ccf71be7cc2a9a, + ])), + Felt252::new(BigInt([ + 0x7757cd816dac919a, + 0x9b39001d03444161, + 0x6a9f7c97b4ceef0a, + 0x029778dc707504fa, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5a8f5b27bb98d4c5, + 0x491f7bbf86a26aa5, + 0x33590d34e3bae36e, + 0x039473f6f06bb99e, + ])), + Felt252::new(BigInt([ + 0x7063dde91c08c027, + 0x4ad92bab187e8141, + 0x895caa0215f996fd, + 0x07ba7c32f875b71b, + ])), + Felt252::new(BigInt([ + 0x839e5d769bdab6b6, + 0x0ed083148a5f4c92, + 0x03b22aac82abf83b, + 0x037c1367e49cbfc4, + ])), + ], + [ + Felt252::new(BigInt([ + 0x7ae34157c0b2d951, + 0xc2068375ff933eb3, + 0xb53ffcf833cdfa05, + 0x05c9eb899931d2f4, + ])), + Felt252::new(BigInt([ + 0x31f2ca26c6e3b661, + 0xc1557ffdc1ffd073, + 0xc27772fb50a7d2e5, + 0x05f6054a4d48698e, + ])), + Felt252::new(BigInt([ + 0x91df64664dcd7774, + 0xfd0fec827960e40a, + 0xb0fab83e8c7d1e8b, + 0x020e6d62a2fe0fe9, + ])), + ], + [ + Felt252::new(BigInt([ + 0xb0d026d14ffd6aac, + 0xff17adf51f528caf, + 0x120c426fe0e409c2, + 0x06290a56a489ad52, + ])), + Felt252::new(BigInt([ + 0x6279f6fc315edc7c, + 0x5a32ca4c10141728, + 0x2267a6f7ece34270, + 0x03703f16f990342c, + ])), + Felt252::new(BigInt([ + 0x95b680dd296df3fd, + 0x92e2c630f70e4391, + 0x9a0c32b5a9a307ba, + 0x05194962daf6679b, + ])), + ], + [ + Felt252::new(BigInt([ + 0xd2400d9b515ee5e2, + 0xb5fd4bea2aa58b98, + 0x242c34617b01340f, + 0x00e8eae20a79a7c1, + ])), + Felt252::new(BigInt([ + 0xfec65242afa5cd45, + 0xd00dd7c2894fae4f, + 0xae28bfb28def7cd8, + 0x0369058169d63091, + ])), + Felt252::new(BigInt([ + 0x9c7b93103fd78167, + 0xcfdff0973190ab18, + 0x74077503ee472f22, + 0x0418c963bc97195a, + ])), + ], + [ + Felt252::new(BigInt([ + 0xd4db559720156386, + 0xb8c97112d14a25b4, + 0x5b28b3f4dc93167f, + 0x068d07a3eefc78dc, + ])), + Felt252::new(BigInt([ + 0x8748583a61836372, + 0x5ba0b5557375003f, + 0xf15a3c4241c98ba2, + 0x0517e892228df2d4, + ])), + Felt252::new(BigInt([ + 0xc9c99538792e279b, + 0x74ac20ad8100c41d, + 0xa150116e7932f8fe, + 0x05cc0f0f6cf9be94, + ])), + ], + [ + Felt252::new(BigInt([ + 0x1668884c0be41ec8, + 0x0883543e821f0f5c, + 0x29bdb1f8a648e482, + 0x053d5d7863434c66, + ])), + Felt252::new(BigInt([ + 0xf2528f67de24fdf5, + 0xb072218912dd0d9d, + 0xa600bf53f8101707, + 0x00a158126b89e6b0, + ])), + Felt252::new(BigInt([ + 0x8d073bed2fede503, + 0x4c204bed60672b8d, + 0xe582069a698323d4, + 0x06b53b807265387e, + ])), + ], + [ + Felt252::new(BigInt([ + 0xacc9e0ca2091fda0, + 0xe53be83bde9601a9, + 0x6de0877efd58c01b, + 0x01097fb448406b7a, + ])), + Felt252::new(BigInt([ + 0xe37ca441f5a31bec, + 0x49ce1fefde66333c, + 0x3902396389d67b30, + 0x00cbc0ff7239d376, + ])), + Felt252::new(BigInt([ + 0x8141ebef84280e72, + 0x38ceebd64603f68a, + 0x632eb43d57b5c5d8, + 0x079a3d91dd8a309c, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8900e7598a368db9, + 0x1185078218eceb93, + 0x5300f74e8f6de8fe, + 0x0023fb472fe57513, + ])), + Felt252::new(BigInt([ + 0x23ebda18bfb67c2a, + 0x7a6ba87cc33e8a8e, + 0xa4c63a6b9494c0bd, + 0x07ac73134016d2a8, + ])), + Felt252::new(BigInt([ + 0x5df6e31c3dcf8f14, + 0xc163d9ab17bb035d, + 0x03f1b5c5ee2485cc, + 0x019a16068c3eac9c, + ])), + ], + [ + Felt252::new(BigInt([ + 0x92134d90def073ea, + 0x20ee86a925725ac3, + 0x4d4ef9fd16347528, + 0x01f24b4356a6bbfd, + ])), + Felt252::new(BigInt([ + 0x7305971592333d36, + 0x528fb70727f35d81, + 0xadd59b6b4d11c60a, + 0x0003e44e7f7aeea6, + ])), + Felt252::new(BigInt([ + 0xcbd94cd7513d394e, + 0xe85987ae57bc9807, + 0x14535a511ed3eb4f, + 0x05f93b02f8267414, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5ca2d3bada29523a, + 0xfd1cc76e670607e3, + 0xd71c3d51d4197fa3, + 0x00f0a0a88db99247, + ])), + Felt252::new(BigInt([ + 0x64bdde3e77608db0, + 0xd2b6f2e80626af65, + 0xacac1e211431fd4c, + 0x03432226916d31f3, + ])), + Felt252::new(BigInt([ + 0xa3830528d59cf919, + 0xb0b82940ef5f393c, + 0x8175192845a7ad74, + 0x055625941bfea6f4, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8e2e585e318e20a4, + 0x783e9b92f9276b85, + 0x7dfe4f8cb3ef1b39, + 0x00ddf48695b20447, + ])), + Felt252::new(BigInt([ + 0xd3194578b08ae8e3, + 0x434ee50d4953e7c5, + 0x8851a679ab2a1490, + 0x0260730a657ff8f3, + ])), + Felt252::new(BigInt([ + 0xbcd206842b961aa9, + 0xd7132775b398d324, + 0x96283840bdb79ba6, + 0x04cfd231373aa46d, + ])), + ], + [ + Felt252::new(BigInt([ + 0x81e963de57eff25d, + 0x7ebc659e74fd48f9, + 0xf14fa0bc0b2191a2, + 0x03203843c41cd453, + ])), + Felt252::new(BigInt([ + 0x93705872e647cc46, + 0x260f5e77a54b0062, + 0xfb8435d1c86bf76c, + 0x0002c2f6ae5624d1, + ])), + Felt252::new(BigInt([ + 0x1535022014765f06, + 0x85b0e142b6975238, + 0xb3e561384ef2e73a, + 0x0780225456e63903, + ])), + ], + [ + Felt252::new(BigInt([ + 0x41cc432a75c81887, + 0x3082fc954b9a9ff6, + 0xfd21b07f8e296061, + 0x07f602ec1a80a051, + ])), + Felt252::new(BigInt([ + 0xf0c8c118ca7e6bca, + 0x23fe77cd7c1ab432, + 0xb60f6aaf7022b7d3, + 0x062561b0a0a72239, + ])), + Felt252::new(BigInt([ + 0xb9b84a8a03b70bc8, + 0x2450c186d093754c, + 0xa69b05dea16b1cf2, + 0x0604fe5a6a22344a, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8682eaf88aef2b7b, + 0x6eada5995905189f, + 0xd3dc140bf5f9b76f, + 0x01cf9987a4044716, + ])), + Felt252::new(BigInt([ + 0xee42ce22cbfbacbf, + 0xdebee233e91b50e9, + 0x3db47a4bdd60cf69, + 0x06bc0b2487c1eece, + ])), + Felt252::new(BigInt([ + 0xcbf87ab7ea0792e6, + 0x7620c51356d2c6ad, + 0xa11403b93e90338b, + 0x02f5dbb5055eb749, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8489e5fc4a550f61, + 0x5f63b8a623a9cf31, + 0x29743c43883d59c4, + 0x0446328f4dddae65, + ])), + Felt252::new(BigInt([ + 0x58584d2c48f5af25, + 0x25817b43d3583999, + 0xca6c4010fb4b481a, + 0x04ba30c5240cde5b, + ])), + Felt252::new(BigInt([ + 0xe39a32f89c2c8a89, + 0x708351d2cf19af5f, + 0xc89209117734ae85, + 0x05f5275f76425b15, + ])), + ], + [ + Felt252::new(BigInt([ + 0x15e1be8e6af2fc17, + 0x993cdda4eb8cb924, + 0xe18c7f98df3b2f7b, + 0x0576f3b5156f4763, + ])), + Felt252::new(BigInt([ + 0x93c0e8e12d35ef3d, + 0xf84a61719ed5adbb, + 0xed5a44b55a5b026d, + 0x011dc3f15cba928a, + ])), + Felt252::new(BigInt([ + 0xa6442b8feda04dca, + 0xe1c1d9ea047d75f8, + 0xd9896403ae4f543a, + 0x044c40e6bd52e91a, + ])), + ], + [ + Felt252::new(BigInt([ + 0xc914ad01166026d8, + 0x1954bf90fe9ea4e2, + 0xbd0ccbf4974e80ac, + 0x01836d733a54013e, + ])), + Felt252::new(BigInt([ + 0xf84ca02ce731b3ac, + 0x7611df8037761f00, + 0xa8159d306ef08472, + 0x03c553be9776b628, + ])), + Felt252::new(BigInt([ + 0xe342f5017076a059, + 0x401ae11a6d757843, + 0xda1c7b87e0436b1b, + 0x006ce94781c1a23f, + ])), + ], + [ + Felt252::new(BigInt([ + 0x371cc2daa0acd0ed, + 0xe107f457812effb7, + 0x0253be9f00f4e6b9, + 0x0381ec71fbdef316, + ])), + Felt252::new(BigInt([ + 0xfe0ffa7bf2a8f1a1, + 0xd4fb574aa687bafd, + 0x6490d847320d9f3c, + 0x01844da9cc0eeadc, + ])), + Felt252::new(BigInt([ + 0x2acfd7f9b65a812f, + 0xedf9710104745968, + 0xbb27fea5b401483d, + 0x07a8bf471f902d5a, + ])), + ], + [ + Felt252::new(BigInt([ + 0x6b0d063839e56327, + 0x6f5a9cdff7aecb6e, + 0x41915fb51ac17445, + 0x0633b6fb004de624, + ])), + Felt252::new(BigInt([ + 0x7535fd70fbc50ab6, + 0xbbe546ba88fed8b1, + 0x771200382bfc6d17, + 0x0179ee5cec496194, + ])), + Felt252::new(BigInt([ + 0x2cae194330bf8c42, + 0xb0312446f07435ac, + 0xea9891b42d565256, + 0x02806c0786185986, + ])), + ], + [ + Felt252::new(BigInt([ + 0x56ac9bb6ee041393, + 0x603bb2cdfd26bfa3, + 0x90c7a6b8af194b8b, + 0x0438703d948708ae, + ])), + Felt252::new(BigInt([ + 0xa585d58a920035af, + 0x1c56f4e02225c628, + 0x7153bd3a482b7f6e, + 0x024446628f56029d, + ])), + Felt252::new(BigInt([ + 0xbd96025e5435e259, + 0xae48f6606790d817, + 0xb0685cdeeea3a253, + 0x04c2a76e5ce832e8, + ])), + ], + [ + Felt252::new(BigInt([ + 0x70983b8caa0e0300, + 0x57d5e4ce1ab122d3, + 0x92933c079b148aed, + 0x078a233235209945, + ])), + Felt252::new(BigInt([ + 0xb87070ba51ec22c0, + 0xadce1aa691b19e6d, + 0x51144ea5937dd07c, + 0x079ca6c5e1025b21, + ])), + Felt252::new(BigInt([ + 0x314e48922af79c5d, + 0x4a442ebfd1ac5d17, + 0xf952d9d34f8d6bd8, + 0x06b2e4a46e37af3c, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8e3529e0d03435c2, + 0x1ca7d443f11e34a1, + 0xb6805d93d3d8d74e, + 0x00305d6cd95cc2ea, + ])), + Felt252::new(BigInt([ + 0x15c7c17b37fbf9a9, + 0xabb7aea70cc624a4, + 0xb39743ed23f8956c, + 0x06097b4b8b90db14, + ])), + Felt252::new(BigInt([ + 0xf96288707c18893f, + 0xd3bdcc90865b0f0a, + 0x845bdb98373e77da, + 0x0064e1b3f16c26c8, + ])), + ], + [ + Felt252::new(BigInt([ + 0x7f1579ae911fd335, + 0x21c56014af2ffdf5, + 0x23384d841221b734, + 0x0649fafe673f21e6, + ])), + Felt252::new(BigInt([ + 0xd1ba288a77fefe30, + 0x2baa2f4d19005a49, + 0x6b294404e849722f, + 0x07d806dccbf1a269, + ])), + Felt252::new(BigInt([ + 0x59119c44aafc7522, + 0x7a03f48f443be6d6, + 0xc0b3e2db1a9a235d, + 0x05951a37da53e3bb, + ])), + ], + [ + Felt252::new(BigInt([ + 0xc816a1607a907731, + 0x10496a31bdacb542, + 0x4d1912c3554ae3d0, + 0x06d87fa479fb5952, + ])), + Felt252::new(BigInt([ + 0x462a3ac892acc9b2, + 0x0a712a0b12bb6fc9, + 0xd473ad73466b4e8c, + 0x01451cccd4200fa9, + ])), + Felt252::new(BigInt([ + 0xd82dd1efdc0763da, + 0x832ca0faa15e1c4e, + 0x07642535f1ca9b03, + 0x03ca1b6400b3e510, + ])), + ], + [ + Felt252::new(BigInt([ + 0xf993a99c7a1a4d95, + 0xb0dd024ff4162539, + 0x60ad1516a8f13592, + 0x052c55735b2f0a65, + ])), + Felt252::new(BigInt([ + 0x62951d65f6b924cd, + 0xe750bd5ce3e9fa5e, + 0xf0149d1dee29617d, + 0x07e04de60aa80132, + ])), + Felt252::new(BigInt([ + 0x3edf63291c0a5495, + 0x303ef29e26f28922, + 0xe47c4c8fab71c8f8, + 0x00271784e6920a68, + ])), + ], + [ + Felt252::new(BigInt([ + 0x6b49514af43d0c69, + 0xc8afe93f17b7f0e5, + 0x60a04b8f0adaa603, + 0x05c7c19061a84d59, + ])), + Felt252::new(BigInt([ + 0x38e4436f5482eafe, + 0x090943c2959dea1b, + 0x419da337cb79061e, + 0x0172db5affe783af, + ])), + Felt252::new(BigInt([ + 0x46a9e061a2cb9456, + 0x21a7ecbadf188097, + 0x0eac9fe4082916f0, + 0x0518b7975a6d8d31, + ])), + ], + [ + Felt252::new(BigInt([ + 0x755a0315f1e196db, + 0xd74b8ae5e37b34e8, + 0xd4bbc2440a9f5061, + 0x020c5539dc45dd56, + ])), + Felt252::new(BigInt([ + 0x5a9d8bc213b90b14, + 0xa977b47208283cf3, + 0x08bc7d516e80efc3, + 0x01ea6f5fb309fa4a, + ])), + Felt252::new(BigInt([ + 0x7d1f766541e29ded, + 0xfd424b5de167c725, + 0xfdd8ddd8ba9cfe2e, + 0x050ce323c5128dc7, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8919284c613cb7d8, + 0x5b865f5b7d1b497a, + 0x695538b41d3c2821, + 0x0401e37d0e276547, + ])), + Felt252::new(BigInt([ + 0x0fab9cf57c57397b, + 0x55daa12cc61261cc, + 0x7f2893056fc58802, + 0x0645a0de30acc311, + ])), + Felt252::new(BigInt([ + 0x76b66ae7fa3d495b, + 0xd4fdc9d0d69219f6, + 0xd9e988d75f09f698, + 0x069bc3841eb0a310, + ])), + ], + [ + Felt252::new(BigInt([ + 0x84baf523f136bdc6, + 0x7cf0ae0c455cda54, + 0x4bdd47c38fe72db4, + 0x002684bbe315ad2c, + ])), + Felt252::new(BigInt([ + 0xe4acb821fd8a13ee, + 0x88858c2afa664365, + 0x68202e8d34e5595a, + 0x011e0f83c547ca5c, + ])), + Felt252::new(BigInt([ + 0xcac945f1097b82ef, + 0xd0f86ac66c1e5a5e, + 0x5966567ceec34315, + 0x04af4a7635f8c751, + ])), + ], + [ + Felt252::new(BigInt([ + 0x5c72b11f4c74b271, + 0x1dc48894d2bb4622, + 0x3cb7158908ccc18b, + 0x04fba58cf8aaf489, + ])), + Felt252::new(BigInt([ + 0x38b0f44c8a2a0e20, + 0x9a7f89be0ead679a, + 0x8cc90da2e664f8c2, + 0x0397c4c169115b46, + ])), + Felt252::new(BigInt([ + 0x20998f59ec7bacff, + 0x1f326dd7f32be22e, + 0xbad397fa5dd13c50, + 0x006563b9ebb6450d, + ])), + ], + [ + Felt252::new(BigInt([ + 0x36cd79e9cb817165, + 0xfec48562076dd09c, + 0xea81d307f4c79f9a, + 0x0376edb238f7b630, + ])), + Felt252::new(BigInt([ + 0x58584cda96e2e061, + 0xb337504039690eb8, + 0xf29ed22addcd50a1, + 0x060d4208bb50eb15, + ])), + Felt252::new(BigInt([ + 0x344a52f1df9a9210, + 0x0f30da46918ab020, + 0xdbff1019dc3465ec, + 0x06a37d569d2fbc73, + ])), + ], + [ + Felt252::new(BigInt([ + 0x429130371ac63b1a, + 0x1dc512f1df073c1b, + 0xf412083ff35d2382, + 0x00d3b174c7290c6b, + ])), + Felt252::new(BigInt([ + 0x9fe55e525b980373, + 0x34d974919689fb48, + 0x4b46eb2a5c3b8146, + 0x0226ed3d76347745, + ])), + Felt252::new(BigInt([ + 0x30e8b0080d218513, + 0xf06f4d79bd7ffa19, + 0xe0e7a23d33d2fd9e, + 0x05f3997e7dafcb2d, + ])), + ], + [ + Felt252::new(BigInt([ + 0x8348c3fae8fdf14d, + 0x04f886f7f9d3c164, + 0x434df335a10bbac5, + 0x07c5eec716d94634, + ])), + Felt252::new(BigInt([ + 0xf63d2f55f57e1a7c, + 0x8a89da85553f871e, + 0xe7e24fd22c0f9ad6, + 0x0053cc30d7fe0f84, + ])), + Felt252::new(BigInt([ + 0xfefa4cd58c4ec8fa, + 0x9474a24f6e83b268, + 0x19b95769f4741856, + 0x0368821ee335d718, + ])), + ], + [ + Felt252::new(BigInt([ + 0xf46d6a242bfeb7a1, + 0x72c6d0a61538bdff, + 0x35119816883040da, + 0x005334f75b052c02, + ])), + Felt252::new(BigInt([ + 0xcd49d6dca50aa431, + 0x8f80ee4af2ec6547, + 0xc1020cca9d871ae6, + 0x05d0af4fcbd9e056, + ])), + Felt252::new(BigInt([ + 0x5ab99537901b1e65, + 0xb4699dc00f1d53ba, + 0x4114a19c46d24e00, + 0x030131bce2fba569, + ])), + ], + [ + Felt252::new(BigInt([ + 0x4957660f2e788965, + 0x538f93f13161be3c, + 0xb34c0750ed2e641c, + 0x05646a95a7c1ae86, + ])), + Felt252::new(BigInt([ + 0xc90df47b7d4ec01a, + 0x78581f5259692b52, + 0x9fac36230a11f43e, + 0x04b9f291d7b430c7, + ])), + Felt252::new(BigInt([ + 0xd890e74abae01a13, + 0x3e00becf6ceb4d73, + 0x1a98f19127072dc8, + 0x05006d393d3480f4, + ])), + ], + [ + Felt252::new(BigInt([ + 0x202dc3b26a679d80, + 0xacf4f702e6b346fd, + 0x0e7cb8a115143106, + 0x062c9d42199f3b26, + ])), + Felt252::new(BigInt([ + 0xbf1d9ac2dc5717a5, + 0x7606836eabd8af54, + 0xf180b1a8a13b7f2c, + 0x051274d092db5099, + ])), + Felt252::new(BigInt([ + 0x861a8db0bfff0c5b, + 0xf415e14f0d9cdbed, + 0x7ad0fb7aaa4ca528, + 0x061fc552b8eb75e1, + ])), + ], +]; diff --git a/util/src/poseidon/mod.rs b/util/src/poseidon/mod.rs new file mode 100644 index 0000000..b729253 --- /dev/null +++ b/util/src/poseidon/mod.rs @@ -0,0 +1,161 @@ +use std::{marker::PhantomData, slice::Windows}; + +use ark_ff::{BigInt, Field}; +use consts::{CAPACITY, ROUNDS_FULL, ROUNDS_PARTIAL, ROUND_CONSTANTS, WIDTH}; + +use felt::Felt252; + +mod consts; + +trait FieldHasher { + fn hash(&self, input: &[F]) -> F; + + /// Possibly optimized version of `hash` for pairs. + fn pair(&self, left: F, right: F) -> F { + self.hash(&[left, right]) + } +} + +struct Poseidon { + _ph: PhantomData, +} + +impl Poseidon { + fn round(st: &mut [Felt252; WIDTH], constants: &[Felt252; WIDTH], full: bool) { + // add round constant + st[0] += constants[0]; + st[1] += constants[1]; + st[2] += constants[2]; + + // apply S-box + #[inline] + fn cube(x: F) -> F { + x.square() * x + } + + st[2] = cube(st[2]); + if full { + st[0] = cube(st[0]); + st[1] = cube(st[1]); + } + + // mix state + // M = ( + // ( 3, 1, 1), + // ( 1,-1, 1), + // ( 1, 1, -2) + // ) + // see: + // https://github.com/starkware-industries/poseidon/blob/main/poseidon3.txt + let t0 = st[0] + st[1]; + let t1 = t0 + st[2]; + st[0] = t1 + st[0].double(); + st[1] = t1 - st[1].double(); + st[2] = t0 - st[2].double(); + + println!("st: {:#?}", st); + } + + fn perm(mut st: [Felt252; WIDTH]) -> [Felt252; WIDTH] { + let mut ctx = ROUND_CONSTANTS.iter(); + assert_eq!(ROUNDS_FULL % 2, 0); + + // initial full rounds + for _ in 0..ROUNDS_FULL / 2 { + Self::round(&mut st, ctx.next().unwrap(), true); + } + + // middle partial rounds + for _ in 0..ROUNDS_PARTIAL { + Self::round(&mut st, ctx.next().unwrap(), false); + } + + // final full rounds + for _ in 0..ROUNDS_FULL / 2 { + Self::round(&mut st, ctx.next().unwrap(), true); + } + + st + } +} + +impl FieldHasher for Poseidon { + fn hash(&self, input: &[Felt252]) -> Felt252 { + // initialize state + let mut st = [Felt252::ZERO; WIDTH]; + let mut iter = input.chunks_exact(CAPACITY); + + // handle regular chunks + while let Some(chunk) = iter.next() { + st[0] += chunk[0]; + st[1] += chunk[1]; + st = Self::perm(st); + } + + // handle remainer and padding + match iter.remainder() { + [last] => { + st[0] += *last; + st[1] += Felt252::ONE; + } + [] => { + st[0] += Felt252::ONE; + } + _ => unreachable!(), + } + + // apply the final permutation + st = Self::perm(st); + st[0] + } +} + +#[test] +fn test_hash() {} + +#[test] +fn test_permutation() { + let input = [ + Felt252::new(BigInt([ + 0x0000000000000000, + 0x0000000000000000, + 0x0000000000000000, + 0x0000000000000000, + ])), + Felt252::new(BigInt([ + 0x0000000000000000, + 0x0000000000000000, + 0x0000000000000000, + 0x0000000000000000, + ])), + Felt252::new(BigInt([ + 0x0000000000000000, + 0x0000000000000000, + 0x0000000000000000, + 0x0000000000000000, + ])), + ]; + + let output = [ + Felt252::new(BigInt([ + 0x86550ed6a9086133, + 0x852357968577b1e3, + 0xa28fc9d49e233bc6, + 0x079e8d1e78258000, + ])), + Felt252::new(BigInt([ + 0xa256154cbb6fb984, + 0xe5b5404b91ccaabc, + 0xdbb796ff6aa6a63b, + 0x03840d003d0f3f96, + ])), + Felt252::new(BigInt([ + 0x50b70eaa8a3c7cc7, + 0x9325a61fb2ef326e, + 0x142d0ac83d9da00c, + 0x01eb39da3f7d3b04, + ])), + ]; + + assert_eq!(Poseidon::::perm(input), output); +} From 0f1eeca36c187f8c8139ffb0568b62dcb2af39c0 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Fri, 19 Jul 2024 12:36:28 +0200 Subject: [PATCH 2/6] chore: clippy warning about redundant borrow --- poseidon/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/poseidon/build.rs b/poseidon/build.rs index 847655b..6a4b5e8 100644 --- a/poseidon/build.rs +++ b/poseidon/build.rs @@ -344,6 +344,6 @@ fn main() { // write the output to the file let out_dir = env::var_os("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("cnst.rs"); - fs::write(&dest_path, output).unwrap(); + fs::write(dest_path, output).unwrap(); println!("cargo::rerun-if-changed=build.rs"); } From d3beb84775d49ddcfb34c9879e68b7997e7f072a Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Fri, 19 Jul 2024 12:38:00 +0200 Subject: [PATCH 3/6] chore: placate clippy (for now) We should have this return a useful error. --- merkle/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/merkle/src/lib.rs b/merkle/src/lib.rs index 468d838..c422d0c 100644 --- a/merkle/src/lib.rs +++ b/merkle/src/lib.rs @@ -47,6 +47,7 @@ impl> MerkleTree { /// /// Returns an error type for easier "monadic style" chaining. #[allow(dead_code)] + #[allow(clippy::result_unit_err)] pub fn verify_decommitment( &self, comm: H::Output, From 9bb55c7c47ff4d852e02491e8299f93eb89445b4 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Fri, 19 Jul 2024 13:04:59 +0200 Subject: [PATCH 4/6] refactor: remove old code We need to move the channel trait/impl to a crate. --- util/Cargo.toml | 10 - util/src/channel/mod.rs | 14 - util/src/lib.rs | 2 - util/src/poseidon/consts.rs | 1834 ----------------------------------- util/src/poseidon/mod.rs | 161 --- 5 files changed, 2021 deletions(-) delete mode 100644 util/Cargo.toml delete mode 100644 util/src/channel/mod.rs delete mode 100644 util/src/lib.rs delete mode 100644 util/src/poseidon/consts.rs delete mode 100644 util/src/poseidon/mod.rs diff --git a/util/Cargo.toml b/util/Cargo.toml deleted file mode 100644 index b5d2292..0000000 --- a/util/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "util" -version = "0.1.0" -edition = "2021" - -[dependencies] -anyhow.workspace = true -ark-ff.workspace = true -ark-poly.workspace = true -felt = { path = "../felt" } diff --git a/util/src/channel/mod.rs b/util/src/channel/mod.rs deleted file mode 100644 index df11db1..0000000 --- a/util/src/channel/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -use ark_ff::Field; - -#[allow(dead_code)] -trait Channel { - type Field: Field; - - fn recv_felts(&mut self, n: usize) -> Result, anyhow::Error>; - - fn recv_bytes(&mut self, n: usize) -> Result, anyhow::Error>; - - fn random_number(&mut self, bound: u64) -> u64; - - fn random_field(&mut self) -> Self::Field; -} diff --git a/util/src/lib.rs b/util/src/lib.rs deleted file mode 100644 index a20e5b8..0000000 --- a/util/src/lib.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod channel; -mod poseidon; diff --git a/util/src/poseidon/consts.rs b/util/src/poseidon/consts.rs deleted file mode 100644 index 6d5e2ff..0000000 --- a/util/src/poseidon/consts.rs +++ /dev/null @@ -1,1834 +0,0 @@ -use ark_ff::BigInt; - -use felt::Felt252; - -pub const RATE: usize = 2; -pub const CAPACITY: usize = 1; -pub const WIDTH: usize = RATE + CAPACITY; -pub const ROUNDS_PARTIAL: usize = 83; -pub const ROUNDS_FULL: usize = 8; -pub const ROUNDS: usize = ROUNDS_FULL + ROUNDS_PARTIAL; - -// https://github.com/starkware-industries/poseidon/tree/main -pub const ROUND_CONSTANTS: [[Felt252; WIDTH]; ROUNDS] = [ - [ - Felt252::new(BigInt([ - 0x80b7fd8eac77fe6f, - 0xe58e2ad98109ae47, - 0x39dd92f9562a30b9, - 0x06861759ea556a23, - ])), - Felt252::new(BigInt([ - 0xe4ab1a22f27508c4, - 0x3da43f76abf28a64, - 0xffc8397a3d00425a, - 0x03827681995d5af9, - ])), - Felt252::new(BigInt([ - 0x7a0dbe17704a8309, - 0x2cac75dc279b2d68, - 0xe7f760a2277dc7cb, - 0x03a3956d2fad44d0, - ])), - ], - [ - Felt252::new(BigInt([ - 0x882031afe67ef4cd, - 0x291c78f926a2d1c6, - 0xf13c4282214aa759, - 0x0626c47a7d421fe1, - ])), - Felt252::new(BigInt([ - 0xadfe17baca05d6a6, - 0x2d327fcc948d772c, - 0x5bd6df5518cfd41f, - 0x078985f8e1650503, - ])), - Felt252::new(BigInt([ - 0x142dcf34341696ff, - 0xc6e26a68b456dc1d, - 0x204c659875341243, - 0x05427f10867514a3, - ])), - ], - [ - Felt252::new(BigInt([ - 0x0465e60edce699d7, - 0x847cd2c5d9d4cb8b, - 0x454361733f0883c5, - 0x05af083f36e4c729, - ])), - Felt252::new(BigInt([ - 0xc77e709bfd388882, - 0x2d3975f92ff84b1a, - 0x54fa3f74f7b352a5, - 0x07d71701bde3d06d, - ])), - Felt252::new(BigInt([ - 0xe39584467a6b1d3e, - 0xac1b64f699ffea44, - 0x9c26f8a6320a1c5e, - 0x0603da0688201900, - ])), - ], - [ - Felt252::new(BigInt([ - 0x613b9721f6453a5d, - 0xeebd8870fd13a36b, - 0x8e79ce13f47ad1cd, - 0x04332a6f6bde2f28, - ])), - Felt252::new(BigInt([ - 0xc9e8caeb5cba78e7, - 0x4b9a813aaeff60d6, - 0x5310a04c4dec2e7e, - 0x053d0ebf61664c68, - ])), - Felt252::new(BigInt([ - 0x1bfc2d15eaabfebc, - 0x6c82f99f928494ee, - 0x5ae5ebcb88028d2a, - 0x05346a6889484583, - ])), - ], - [ - Felt252::new(BigInt([ - 0x98147e69dd91e5a3, - 0x8694ab61f2387970, - 0xa7631ccaecb7a4ab, - 0x0550a9e24176509e, - ])), - Felt252::new(BigInt([ - 0x2b5794daa2687000, - 0x0f48ad3ed77c8b26, - 0xaa62773fedd3570e, - 0x0219dcccb783b1cb, - ])), - Felt252::new(BigInt([ - 0x92864c00f54a3f9a, - 0x3433b6ab9dd5a995, - 0x3453cc97445954bf, - 0x04b085eb1df4258c, - ])), - ], - [ - Felt252::new(BigInt([ - 0xe2da084e5aabb78d, - 0x5a465939d04b6c72, - 0x3af2bf3c03e420ea, - 0x053e8a8e8a404c50, - ])), - Felt252::new(BigInt([ - 0xf4f9ada962be8ca8, - 0xfb4049cb137faf5d, - 0x1bd14d2537fe5c19, - 0x05ca045c1312c09d, - ])), - Felt252::new(BigInt([ - 0x9939c46c162517f4, - 0x6820b1ed97596a96, - 0x44997e959f27a5b0, - 0x07c74922a456802c, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5dc6f519bb7ab83f, - 0xf2526a20f9167043, - 0x6bf5088614b9684f, - 0x00c0bba6880d2e68, - ])), - Felt252::new(BigInt([ - 0x843849cd0f87934a, - 0xc1a6203741decd72, - 0xd708dd07234c1b2d, - 0x04526bcaec43e8eb, - ])), - Felt252::new(BigInt([ - 0xbfe1ec7f01d613ed, - 0xbef44d92edc6d5b0, - 0xd81efaea5a75a434, - 0x01cc9a17b00d3607, - ])), - ], - [ - Felt252::new(BigInt([ - 0x0bc7b4a4fde8f01f, - 0xe1eb7284e2b28ed9, - 0x12aa8cdbead0bc1c, - 0x0028b1e269b84c40, - ])), - Felt252::new(BigInt([ - 0xbb724dc7a994498d, - 0x0c19656bcb945b58, - 0x1d9a2482fbdaf659, - 0x062af2f41d76c4ad, - ])), - Felt252::new(BigInt([ - 0x59e285eee627df1a, - 0x2269bed2dc0d4dbf, - 0xb2618213b0d1bf4a, - 0x05cfd7e44946daa6, - ])), - ], - [ - Felt252::new(BigInt([ - 0xc31955dc8386a747, - 0xcf0312ab9f16ac9b, - 0x56fdd1b94da8d3bb, - 0x07ff2afb40f33008, - ])), - Felt252::new(BigInt([ - 0x9b3248ee326e929c, - 0xab40efae6fa9cd91, - 0x83e90bab8ae37f8a, - 0x05cd236bdc15b541, - ])), - Felt252::new(BigInt([ - 0x741a90bbd53a698a, - 0x2bd999084e30688e, - 0x60c946418bf0e582, - 0x005463841390e22d, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8226e7406144f805, - 0x7efd44a4e51890ae, - 0xb2021f13eb4d7174, - 0x024c940fff3fe8c8, - ])), - Felt252::new(BigInt([ - 0x7fc77d45e1b04555, - 0x153ca4c02172dd1d, - 0x8dc88f05393d9d03, - 0x04e50cb07b387326, - ])), - Felt252::new(BigInt([ - 0xd0b32e1189b6dcb5, - 0x1d9b499c35f375d7, - 0x7b430e53238d2bab, - 0x062ca053e4da0fc8, - ])), - ], - [ - Felt252::new(BigInt([ - 0x951bff3d3d7e1191, - 0x19cd89100adff965, - 0xaaf37fe0b851bc24, - 0x0719f20ac59d1ebc, - ])), - Felt252::new(BigInt([ - 0x98935cf47d55a8fd, - 0x4050ac92ca52f5c7, - 0x6a82fe5bb90807f4, - 0x07645ca5e87a9f91, - ])), - Felt252::new(BigInt([ - 0x015391ca63663767, - 0x23d4b71d17133438, - 0x200eed38d248ecda, - 0x015b8aeaca96ab53, - ])), - ], - [ - Felt252::new(BigInt([ - 0x96c1b658bf10b2e2, - 0xb98799e908f928c1, - 0xaa8252f106292ac3, - 0x0053d94dbbca7cb2, - ])), - Felt252::new(BigInt([ - 0x3913831c34de2d1e, - 0x942b447c615c0f03, - 0xc6f4c0a3b70edbb3, - 0x028f90b403e240f1, - ])), - Felt252::new(BigInt([ - 0xb70ae6e770e22081, - 0x9699dd2feb36e3e5, - 0xe1161c4d0bf02515, - 0x02485167dc233ba6, - ])), - ], - [ - Felt252::new(BigInt([ - 0xe938607a5feca6e8, - 0x88f7fdaacdd58698, - 0xff7de548541dd269, - 0x01c8b08a90d6ee46, - ])), - Felt252::new(BigInt([ - 0xce05b16901c4881e, - 0x0c7c4df5ecdad643, - 0x66b75e79d146f988, - 0x0105c3bf5cba2564, - ])), - Felt252::new(BigInt([ - 0x965418b02dbc6bd7, - 0xd5015b85dfbd77b2, - 0x627a65a21bef2106, - 0x0238019787f4cc0b, - ])), - ], - [ - Felt252::new(BigInt([ - 0x3a6ebc99a6ddc5e1, - 0x5c15b52dec817292, - 0xb73dce29a5f24c46, - 0x015e624d7698fdf9, - ])), - Felt252::new(BigInt([ - 0x79f612fde5800a0a, - 0xca0c2efef23b04a4, - 0xf56bc056ad8bf740, - 0x05d3688ba56f34fd, - ])), - Felt252::new(BigInt([ - 0x811c69ae363b444d, - 0x2e26d872d98b3cce, - 0x9e67ed336e82dc6c, - 0x0229abdef3fef7ae, - ])), - ], - [ - Felt252::new(BigInt([ - 0xac58daf2d3fc44db, - 0xb2c43d1e33c92b57, - 0xee400801a56f236d, - 0x03e8096ecfcbcde2, - ])), - Felt252::new(BigInt([ - 0x02265352c57db9bd, - 0xe6a7cd4e1b47bf6a, - 0x108d605aae834c7c, - 0x03ad5fec670d7039, - ])), - Felt252::new(BigInt([ - 0xadca32046aeaef0a, - 0x4ef597fff1f98557, - 0x75877afdbb4df679, - 0x07cf4598c0cf1438, - ])), - ], - [ - Felt252::new(BigInt([ - 0xca0ec7a123c00ad6, - 0x4170c37841fef49a, - 0x4a4d1c4c8f27932e, - 0x058aecc0081b5513, - ])), - Felt252::new(BigInt([ - 0xec09308d65d2ca61, - 0xe4ef3c859db5b714, - 0x5460b71995790396, - 0x0757b4b7ee98e0a1, - ])), - Felt252::new(BigInt([ - 0x48dc6cc226718b5d, - 0x963d2b54fd2b7ed3, - 0xf3cd974f43322169, - 0x06b82800937f8981, - ])), - ], - [ - Felt252::new(BigInt([ - 0x606b34a60b1e9c64, - 0xa044f14088fedae9, - 0x73427e34ab8fbb7c, - 0x003a915b18147072, - ])), - Felt252::new(BigInt([ - 0x9a627689547bfbef, - 0xc0bb609d367b7626, - 0xf9bc01028ff44195, - 0x054afbf1bd990043, - ])), - Felt252::new(BigInt([ - 0xb08375edf6e762bb, - 0x2c3852df2d991470, - 0xb9524c7d01493107, - 0x05e1ceb846fe1422, - ])), - ], - [ - Felt252::new(BigInt([ - 0x6b2b01c1bec0814b, - 0x16709e0c48e3020c, - 0xbe5dff3ce06e8cb9, - 0x07f751f98968212e, - ])), - Felt252::new(BigInt([ - 0xd45cd6dfbff811e4, - 0xbea7f01d226b68b6, - 0xfc3180616e340536, - 0x036f6b64463f7c29, - ])), - Felt252::new(BigInt([ - 0x7ed4fe4fe8e0dbac, - 0x8dd4d0e469d6703d, - 0xb4511d74fe8de8b4, - 0x061135c9846faf39, - ])), - ], - [ - Felt252::new(BigInt([ - 0x7fbaad907fc912b8, - 0xa4ba83cc6e0ae352, - 0x59b78f6acfca9a21, - 0x00b58921a3fbdbb5, - ])), - Felt252::new(BigInt([ - 0x6e52821c2e2b1b1e, - 0x211d84eb2fb27b81, - 0xb9d16b61c2973847, - 0x022a4f8a5cdc7474, - ])), - Felt252::new(BigInt([ - 0xb112f810ad67036f, - 0xdeb1765c61516ffc, - 0xfeccbbc9a50b2cee, - 0x041cf6db5d6145ed, - ])), - ], - [ - Felt252::new(BigInt([ - 0xade9de11416b6831, - 0xac6a0ff2fdfab744, - 0x1cfc05fa8f4aec6f, - 0x00be44689973db2b, - ])), - Felt252::new(BigInt([ - 0x51df0b8239be148b, - 0x6d148a237142dc49, - 0x6489cda45128096d, - 0x039bf209c4e117e1, - ])), - Felt252::new(BigInt([ - 0x07c7eb980ea03a06, - 0x2a58282643860b57, - 0x2b93310b8ce37b09, - 0x0209cf541e5f74fc, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8c22dd5afa95326d, - 0x7232e122287036d1, - 0x0bdc218ba681b6ba, - 0x06b562e6005f34ee, - ])), - Felt252::new(BigInt([ - 0x670e7a35dea38c8f, - 0xa2a39c8aca11a914, - 0x5dc6d5f59253a627, - 0x000e8103a23902be, - ])), - Felt252::new(BigInt([ - 0xbbf345de2d552f72, - 0x3ef8ca7468d68f4f, - 0x06bdc1b4d5f9bed8, - 0x06a3725548c664fd, - ])), - ], - [ - Felt252::new(BigInt([ - 0xb447b4af006a4a37, - 0x11a45c0aa21eb4eb, - 0x605d0f01a8eccc5f, - 0x067fcd6997472e8e, - ])), - Felt252::new(BigInt([ - 0x64c95db6ecb5cff0, - 0x2a44366f77792d40, - 0x4075784d28c06c16, - 0x026144c95c8de363, - ])), - Felt252::new(BigInt([ - 0x895dc1466f350239, - 0x6fd875e3725061df, - 0x4b3a874eb6307cda, - 0x05b173c8b0eb7e9c, - ])), - ], - [ - Felt252::new(BigInt([ - 0x370f2165c3d54ddb, - 0xc448f877e53298b6, - 0x87bae06ad491d391, - 0x07e1c2d6fde8ac9f, - ])), - Felt252::new(BigInt([ - 0xfa433b57ca6627a9, - 0x8f74d61e7771f9e3, - 0x996f451b156fe4e2, - 0x04db779f3e5b7424, - ])), - Felt252::new(BigInt([ - 0xe240eed6970993dd, - 0x825c3f71114acb93, - 0x713435ec06b6fed7, - 0x00bb930d8a6c6583, - ])), - ], - [ - Felt252::new(BigInt([ - 0x89e9579c046e878f, - 0x99d3a08814c31c41, - 0xd708467e9296fb55, - 0x04472d73b2830565, - ])), - Felt252::new(BigInt([ - 0x2cc23612b11170e2, - 0x614d23739b7cb205, - 0x9e10e3c883ca5ce5, - 0x07ba9c303dfee2d8, - ])), - Felt252::new(BigInt([ - 0x822548eb9c4dc4b7, - 0x6356cb133e97579b, - 0x0425dc9b2c1ed30e, - 0x021c0e3319ede47f, - ])), - ], - [ - Felt252::new(BigInt([ - 0x65c1d41e877eb191, - 0x32e53b7dc4f49475, - 0x37b09933816e2a09, - 0x02cfd61139e50ddd, - ])), - Felt252::new(BigInt([ - 0x2f30acd37e26d8e7, - 0x5bdd10b3f170b0dc, - 0x844544d92ee0eca6, - 0x05abea18941a4976, - ])), - Felt252::new(BigInt([ - 0xe5a751b7ce6bcc21, - 0x4ea28ae28b26e6ee, - 0x7a6265e44fef6f72, - 0x077088fdb015c794, - ])), - ], - [ - Felt252::new(BigInt([ - 0x120dce84e6122b73, - 0x6b4ce33cddbc8446, - 0x5b3e3c43cfd44307, - 0x03abdc9d67723132, - ])), - Felt252::new(BigInt([ - 0x7a602662c2d62c4d, - 0x2ca94879ccfab81a, - 0x2e5d00b6b83e52a5, - 0x02250f430b7fe7d1, - ])), - Felt252::new(BigInt([ - 0xbbb1efb79a25861b, - 0x12660e7bd156d6ca, - 0x1fb24ef76d57912b, - 0x05c92ef479c11bb5, - ])), - ], - [ - Felt252::new(BigInt([ - 0xfcf784a63a0fd5c6, - 0xfd08fd4208a785cf, - 0x510f616fa8b87900, - 0x0235ec597391648b, - ])), - Felt252::new(BigInt([ - 0x5523c00b372cc668, - 0x396b5c0ba3376e85, - 0x207be77e9d11e38f, - 0x04ed4e872eb7e736, - ])), - Felt252::new(BigInt([ - 0xfb7d861c4f275a1b, - 0x3d46afa705908f68, - 0xb756ef3f6331890b, - 0x05f9406febca3879, - ])), - ], - [ - Felt252::new(BigInt([ - 0x97edf441abdaa49d, - 0x5f17b0384661f06d, - 0x621a9f61b68873c0, - 0x01d9c501d9ff1fba, - ])), - Felt252::new(BigInt([ - 0xfa530f41c535952e, - 0x69e37ba694774c4d, - 0x34982c8e28d2f6e1, - 0x04b0de22bbd0a585, - ])), - Felt252::new(BigInt([ - 0xc49d6fd1b033d903, - 0xd319f0e3648b2574, - 0x02186aabb291eca0, - 0x01b4d48bd38a3f86, - ])), - ], - [ - Felt252::new(BigInt([ - 0x19702cefcead4bab, - 0x6b6596bbd2f4e657, - 0x1725d8aa67ddba62, - 0x07558bbea55584bf, - ])), - Felt252::new(BigInt([ - 0x0a44cf7a3eef17be, - 0x70b157d56ece95b6, - 0x561ea174600e266a, - 0x01108f1a9500a52f, - ])), - Felt252::new(BigInt([ - 0x567289b67087bf60, - 0xc209fb90caab6668, - 0x2becb92b4b6ae3f8, - 0x008913d96a4f36b1, - ])), - ], - [ - Felt252::new(BigInt([ - 0x23f4d8a6f32867a6, - 0xca2e99f5742b6bf2, - 0x16926346857dec8c, - 0x06502262c51ad8f6, - ])), - Felt252::new(BigInt([ - 0xcd3a5931d2ec0e52, - 0xe962ea034378b343, - 0x2889280505c915bd, - 0x07cb5fcdc0089281, - ])), - Felt252::new(BigInt([ - 0x01b221c4d2a1ce87, - 0x5baea3bc96b8cd1f, - 0xf90be9781a151514, - 0x02eb919524a89a26, - ])), - ], - [ - Felt252::new(BigInt([ - 0xc1c63e8de3ec3d73, - 0xed0662c0161223e3, - 0xeada46635e3567dc, - 0x058efb6272921bc5, - ])), - Felt252::new(BigInt([ - 0xd6955e7844d4f88e, - 0x94254a1ac34acd46, - 0xb436d205ffc2a395, - 0x062fcd49ca9c7587, - ])), - Felt252::new(BigInt([ - 0x06fcf837aef5313b, - 0x85e5941e54bd3a21, - 0xe62d9acce0b625f8, - 0x0635895330838846, - ])), - ], - [ - Felt252::new(BigInt([ - 0x629f8b41fefb12e3, - 0x78a17f119d5e6e70, - 0x6d47a5f4d23b92a3, - 0x07da445b81e9b3d3, - ])), - Felt252::new(BigInt([ - 0x43b7016256118343, - 0xa9027882bef17389, - 0x9fc5737e189d5096, - 0x02b22dab62f0817e, - ])), - Felt252::new(BigInt([ - 0xfbef432b790e50d5, - 0xd5bdea769be8fcb8, - 0xbacdfed1d27664d0, - 0x01af01472348f395, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5b682e5ac6360309, - 0x9284163c8e4986bc, - 0x1de313b9390f79ec, - 0x076b172dbbeec5a3, - ])), - Felt252::new(BigInt([ - 0xf0bdb2905b3e0862, - 0x9b30ddb4178d46de, - 0x0f362f6cb423d200, - 0x0070efaeae36f6af, - ])), - Felt252::new(BigInt([ - 0x25a0e4117ccaeedf, - 0xd28c4942b8036a1c, - 0x0a39872686b84ee1, - 0x006cb99b36e521ac, - ])), - ], - [ - Felt252::new(BigInt([ - 0xfd1b8a4fc1dc6055, - 0xfb3d0fe5bb3aa743, - 0x0bbf9674e544bda0, - 0x029fd44305a5a9a7, - ])), - Felt252::new(BigInt([ - 0xaa6363d6619f9764, - 0xa11a6778d8848142, - 0x3629b184d8c36db3, - 0x006b447ded1046e8, - ])), - Felt252::new(BigInt([ - 0xc14b58f5b8989b59, - 0x357cceb6946fdc51, - 0xcbfcf55a77339b5d, - 0x0642a8b4be4ba812, - ])), - ], - [ - Felt252::new(BigInt([ - 0x7acd79ae1d95882a, - 0xbc51a73700bd794a, - 0xcc6cc6aa5b6e775c, - 0x0489e0a26f65a1ee, - ])), - Felt252::new(BigInt([ - 0x1b9d57b9a02e9200, - 0x816428f45a06293c, - 0xbf78ab5dc2fd1d24, - 0x03b19d4ef195975b, - ])), - Felt252::new(BigInt([ - 0x2884c52039013df5, - 0x71596f9cd59e55ad, - 0xa576b74790b21949, - 0x07d2dd994756eacb, - ])), - ], - [ - Felt252::new(BigInt([ - 0x02970ef0f2e8c5f3, - 0x8b3327e29e9e7650, - 0xf300df869823b9f1, - 0x01922810cc08f50b, - ])), - Felt252::new(BigInt([ - 0x71cbd4a88ed418ac, - 0x39c04376aafff057, - 0x1d46e1d79a70745b, - 0x052f3afaf7c9102f, - ])), - Felt252::new(BigInt([ - 0x376c5bcab6ea788e, - 0x89552bbe53dcc46b, - 0xa95260f44203086e, - 0x07ccfc88e44a0507, - ])), - ], - [ - Felt252::new(BigInt([ - 0x19e40a1ab008dd9c, - 0xf5157dd8e067bc88, - 0x4100228beff83823, - 0x02949125939e6ad9, - ])), - Felt252::new(BigInt([ - 0x078ba6e1912e1014, - 0x72d6811dde135af4, - 0x4273ce4ee6929ba3, - 0x06cb64e3a0d37a6a, - ])), - Felt252::new(BigInt([ - 0xded4bf5953837fae, - 0xad43714257949cd9, - 0x62f05f688129bf30, - 0x00d63b53707acf89, - ])), - ], - [ - Felt252::new(BigInt([ - 0x942092b32ef152d4, - 0xbb7d7460a6965702, - 0xd13bb968b4ea22d0, - 0x00bcb1549c9cabb5, - ])), - Felt252::new(BigInt([ - 0x0ca25b8d8fe798c1, - 0x2792a7205ba0531a, - 0xf5ead698fe76f649, - 0x03d1c5233657ce31, - ])), - Felt252::new(BigInt([ - 0x279f450b79f97516, - 0x48e26a83074558d9, - 0x066c2808b1e16ea4, - 0x02240b9755182ee9, - ])), - ], - [ - Felt252::new(BigInt([ - 0xc9b43ab6615a646c, - 0xfe8d70882137de70, - 0x0fe8e54f343cef59, - 0x00cc203d8b0f90e3, - ])), - Felt252::new(BigInt([ - 0xfa68e03c1f77910b, - 0x119e937dea9d2100, - 0xe061bacdc175ea9e, - 0x0310c6cc475d9346, - ])), - Felt252::new(BigInt([ - 0x97b83667049106c7, - 0xcbdbe033f5786993, - 0x20bc947defced0d8, - 0x07f84b639f52e574, - ])), - ], - [ - Felt252::new(BigInt([ - 0xbe4e1da8de3e164a, - 0x7e9f038cb32ec35a, - 0xd89c4562f57139f4, - 0x0584ca7f01262c5b, - ])), - Felt252::new(BigInt([ - 0x531f9afa78abbbde, - 0xe02fdc72e01e9510, - 0xaf7d02f562868be3, - 0x01135eefaf69b6e4, - ])), - Felt252::new(BigInt([ - 0x36a0d876856a99e8, - 0xd350c88b56f62c6d, - 0x0a50a3d33805827a, - 0x0372082b8a6c0710, - ])), - ], - [ - Felt252::new(BigInt([ - 0xc119e3d12462dfe6, - 0x9674f132e33898f0, - 0x87499bac1a143fc5, - 0x07c3c12b819a8aad, - ])), - Felt252::new(BigInt([ - 0x46bd9b75a23836cf, - 0xc056ce9e29d602eb, - 0x5b84157cfeff6822, - 0x04f1354c51e8f690, - ])), - Felt252::new(BigInt([ - 0xef3973548fbd2fca, - 0x8ac360150e849950, - 0x075739ba206507a0, - 0x02da9f26a8271659, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5fd78dd550702843, - 0x3f6a65ff50801aa7, - 0x11b5ec29195e38cc, - 0x0287173956a2beb1, - ])), - Felt252::new(BigInt([ - 0x4ae6ba7f9201e126, - 0x1c7f3227f6a7a4a6, - 0x212420095a51c841, - 0x07273101c190ff64, - ])), - Felt252::new(BigInt([ - 0x99258ee4c98005fc, - 0x749b03d3d3491696, - 0x3ebeb61e500687de, - 0x02dbf2a6b56b26d2, - ])), - ], - [ - Felt252::new(BigInt([ - 0xe4b910efd706c7fb, - 0xab89ef8d92530394, - 0x808e67f00ab89b52, - 0x0085b6cbb29739a6, - ])), - Felt252::new(BigInt([ - 0x3e06ce26b08925a3, - 0xb493fa9589fd937e, - 0x1dacbcbadfd5b910, - 0x03d55b5f1171efda, - ])), - Felt252::new(BigInt([ - 0x24f6ae2a9b16e90c, - 0x44f7a2f8135c2078, - 0x7d16b3b295410c0e, - 0x00aaedaa6ef2fa70, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5c1cd0d496ccf5e1, - 0x89b80f8adc5d1891, - 0x6c6331e9f1a5c4cc, - 0x06aca6ebf70b1cb4, - ])), - Felt252::new(BigInt([ - 0x77e9dd157fb27761, - 0x4d5e90003e6d37c6, - 0xabb010f831d403d9, - 0x001678602af36c28, - ])), - Felt252::new(BigInt([ - 0xfe60a0a8f508bad2, - 0x2cd3f4b0526a88aa, - 0x41b547fefdf36d4c, - 0x02022036bdf687f0, - ])), - ], - [ - Felt252::new(BigInt([ - 0x353d4e2e8d1d4af6, - 0xf9b8dfe49fb63e32, - 0xca664397414bdfb8, - 0x007bfc350957c968, - ])), - Felt252::new(BigInt([ - 0x3c5e2176f7ad79af, - 0x81f43a499b27a06d, - 0xc24ea29ccd1d15ab, - 0x02d639cbd418cb9f, - ])), - Felt252::new(BigInt([ - 0x4779569f64506e0c, - 0xe0dee3369e5fbc0f, - 0x88403d5b39687a1f, - 0x00ecdea7f959a4d4, - ])), - ], - [ - Felt252::new(BigInt([ - 0x1d4e34357154b558, - 0xf22e5f2d28c490e2, - 0xb70658e2f1992ef9, - 0x03f656bdc4fefd92, - ])), - Felt252::new(BigInt([ - 0x6594e19fddd59254, - 0xfec47596f8a6f4ce, - 0x2319638ccab9033d, - 0x00d1b8cb1561eed3, - ])), - Felt252::new(BigInt([ - 0x2d1e8b4e2ec1f192, - 0x6f281ec2941da722, - 0xf86ef6ea01545ad7, - 0x0758ffc77c62e3e0, - ])), - ], - [ - Felt252::new(BigInt([ - 0x29a591c95e6fcac5, - 0x596aacd28f83c32f, - 0x995386e96aeaa1b4, - 0x020315ca079570df, - ])), - Felt252::new(BigInt([ - 0x54884b316b740d8d, - 0x2cfe76b84a9d1b0f, - 0xcb05f3d6ff9c8d9f, - 0x03e55cf341e7c280, - ])), - Felt252::new(BigInt([ - 0x67c81203bf650c68, - 0xe92c029007a06f6e, - 0xeede9749739be452, - 0x04d56feb32cde74f, - ])), - ], - [ - Felt252::new(BigInt([ - 0xe8089f465403c89b, - 0x497f7599fb8145d7, - 0x33b6171eaa6a2544, - 0x04ee807aa678a9a4, - ])), - Felt252::new(BigInt([ - 0x0f9a8ad2ef2b3821, - 0x1f365e56a1bc579d, - 0x48cb5f394de2cb6e, - 0x025d2bacc8f1ee75, - ])), - Felt252::new(BigInt([ - 0xf237d15feb17bd49, - 0xcd4b278811924af1, - 0x9fc20051f6501268, - 0x05f573de597ce170, - ])), - ], - [ - Felt252::new(BigInt([ - 0x682cf85ddac86deb, - 0x3c1e84a1dcf8b33c, - 0x5826a280e053cf7a, - 0x030297c3c54a505f, - ])), - Felt252::new(BigInt([ - 0x6a052b93a8339ae8, - 0xc6bc79b69b8709fe, - 0x43c7526a59783f03, - 0x02f5e9c47c9a86e0, - ])), - Felt252::new(BigInt([ - 0xd4a27a416c72b84b, - 0x1da7deec83e130bc, - 0x29f9c23065ff8ccb, - 0x01bf75c7a739da8d, - ])), - ], - [ - Felt252::new(BigInt([ - 0xdb8e864df3c3c675, - 0x29cd27fc4e91eeab, - 0x5989017bd5c4cfdc, - 0x060563d5f852ae87, - ])), - Felt252::new(BigInt([ - 0x1005be1cd16ccf9e, - 0xf8156c20e3131bd7, - 0x0969635468daec94, - 0x07a4b1d70885aa82, - ])), - Felt252::new(BigInt([ - 0x0f39c10e59cc5852, - 0xb8b85cf718cd1d40, - 0xf1e201cd62aa4600, - 0x0347bb025695e497, - ])), - ], - [ - Felt252::new(BigInt([ - 0xa8aa666292e9e217, - 0x2c4c9c2de413691b, - 0x9e7f9381eb6ab0de, - 0x06783ab1e1ef97bb, - ])), - Felt252::new(BigInt([ - 0xd6a7bfb4e5b0dd46, - 0xfd9c4cb99d534deb, - 0x7b3870a07823c081, - 0x0133e0280c6de90e, - ])), - Felt252::new(BigInt([ - 0x4fd0216eb925beec, - 0xa2f093695573dff9, - 0x2fb5db72460b3560, - 0x00865d450ce29dc4, - ])), - ], - [ - Felt252::new(BigInt([ - 0xcd81a6b301664e57, - 0x48efba06bcbb414e, - 0x35526dabacf0dee9, - 0x01de023f840e054a, - ])), - Felt252::new(BigInt([ - 0x190631ab1a5388c4, - 0xc7cc7b892a292d38, - 0x805015a96f724c5a, - 0x0055fc1e341bfdf7, - ])), - Felt252::new(BigInt([ - 0x01a307ef8d532858, - 0x162706a3e624faca, - 0xe7b27bf51552d2b5, - 0x02df6557bfd4a4e7, - ])), - ], - [ - Felt252::new(BigInt([ - 0x046d73d0507f6271, - 0xf8f226da95e4d629, - 0xd92a6bd3e9c1d55e, - 0x0113a8a66962ce08, - ])), - Felt252::new(BigInt([ - 0x4f3367b08c008e53, - 0xca1076033db5c2de, - 0x7f2c889874ba5b44, - 0x0271577d6ee9fa37, - ])), - Felt252::new(BigInt([ - 0x291d311866538574, - 0xf1ccb956fc673bc5, - 0xb0365c09348a561e, - 0x03396b33911219b6, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5398f69c8f321636, - 0x6170baa3c3436e6a, - 0xc8a7d89e89918930, - 0x01e1392f2da08549, - ])), - Felt252::new(BigInt([ - 0x9c876bd2e7d694ca, - 0x33e313b1a9a5b6d6, - 0xdf118e1d6e7c61a3, - 0x0661545081032013, - ])), - Felt252::new(BigInt([ - 0x73516f0cacdeec88, - 0xf66d00533574e465, - 0x776edbd432d20eb8, - 0x06b14294e71cd7fb, - ])), - ], - [ - Felt252::new(BigInt([ - 0x915cab6eb1a1d4f2, - 0x1fe2a18e2406c671, - 0x338b1c41df31e4e5, - 0x07252fbbb06c2848, - ])), - Felt252::new(BigInt([ - 0x7f5327cb00ff99da, - 0x430c03645747621b, - 0xbcf5a09807c69679, - 0x03ccf71be7cc2a9a, - ])), - Felt252::new(BigInt([ - 0x7757cd816dac919a, - 0x9b39001d03444161, - 0x6a9f7c97b4ceef0a, - 0x029778dc707504fa, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5a8f5b27bb98d4c5, - 0x491f7bbf86a26aa5, - 0x33590d34e3bae36e, - 0x039473f6f06bb99e, - ])), - Felt252::new(BigInt([ - 0x7063dde91c08c027, - 0x4ad92bab187e8141, - 0x895caa0215f996fd, - 0x07ba7c32f875b71b, - ])), - Felt252::new(BigInt([ - 0x839e5d769bdab6b6, - 0x0ed083148a5f4c92, - 0x03b22aac82abf83b, - 0x037c1367e49cbfc4, - ])), - ], - [ - Felt252::new(BigInt([ - 0x7ae34157c0b2d951, - 0xc2068375ff933eb3, - 0xb53ffcf833cdfa05, - 0x05c9eb899931d2f4, - ])), - Felt252::new(BigInt([ - 0x31f2ca26c6e3b661, - 0xc1557ffdc1ffd073, - 0xc27772fb50a7d2e5, - 0x05f6054a4d48698e, - ])), - Felt252::new(BigInt([ - 0x91df64664dcd7774, - 0xfd0fec827960e40a, - 0xb0fab83e8c7d1e8b, - 0x020e6d62a2fe0fe9, - ])), - ], - [ - Felt252::new(BigInt([ - 0xb0d026d14ffd6aac, - 0xff17adf51f528caf, - 0x120c426fe0e409c2, - 0x06290a56a489ad52, - ])), - Felt252::new(BigInt([ - 0x6279f6fc315edc7c, - 0x5a32ca4c10141728, - 0x2267a6f7ece34270, - 0x03703f16f990342c, - ])), - Felt252::new(BigInt([ - 0x95b680dd296df3fd, - 0x92e2c630f70e4391, - 0x9a0c32b5a9a307ba, - 0x05194962daf6679b, - ])), - ], - [ - Felt252::new(BigInt([ - 0xd2400d9b515ee5e2, - 0xb5fd4bea2aa58b98, - 0x242c34617b01340f, - 0x00e8eae20a79a7c1, - ])), - Felt252::new(BigInt([ - 0xfec65242afa5cd45, - 0xd00dd7c2894fae4f, - 0xae28bfb28def7cd8, - 0x0369058169d63091, - ])), - Felt252::new(BigInt([ - 0x9c7b93103fd78167, - 0xcfdff0973190ab18, - 0x74077503ee472f22, - 0x0418c963bc97195a, - ])), - ], - [ - Felt252::new(BigInt([ - 0xd4db559720156386, - 0xb8c97112d14a25b4, - 0x5b28b3f4dc93167f, - 0x068d07a3eefc78dc, - ])), - Felt252::new(BigInt([ - 0x8748583a61836372, - 0x5ba0b5557375003f, - 0xf15a3c4241c98ba2, - 0x0517e892228df2d4, - ])), - Felt252::new(BigInt([ - 0xc9c99538792e279b, - 0x74ac20ad8100c41d, - 0xa150116e7932f8fe, - 0x05cc0f0f6cf9be94, - ])), - ], - [ - Felt252::new(BigInt([ - 0x1668884c0be41ec8, - 0x0883543e821f0f5c, - 0x29bdb1f8a648e482, - 0x053d5d7863434c66, - ])), - Felt252::new(BigInt([ - 0xf2528f67de24fdf5, - 0xb072218912dd0d9d, - 0xa600bf53f8101707, - 0x00a158126b89e6b0, - ])), - Felt252::new(BigInt([ - 0x8d073bed2fede503, - 0x4c204bed60672b8d, - 0xe582069a698323d4, - 0x06b53b807265387e, - ])), - ], - [ - Felt252::new(BigInt([ - 0xacc9e0ca2091fda0, - 0xe53be83bde9601a9, - 0x6de0877efd58c01b, - 0x01097fb448406b7a, - ])), - Felt252::new(BigInt([ - 0xe37ca441f5a31bec, - 0x49ce1fefde66333c, - 0x3902396389d67b30, - 0x00cbc0ff7239d376, - ])), - Felt252::new(BigInt([ - 0x8141ebef84280e72, - 0x38ceebd64603f68a, - 0x632eb43d57b5c5d8, - 0x079a3d91dd8a309c, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8900e7598a368db9, - 0x1185078218eceb93, - 0x5300f74e8f6de8fe, - 0x0023fb472fe57513, - ])), - Felt252::new(BigInt([ - 0x23ebda18bfb67c2a, - 0x7a6ba87cc33e8a8e, - 0xa4c63a6b9494c0bd, - 0x07ac73134016d2a8, - ])), - Felt252::new(BigInt([ - 0x5df6e31c3dcf8f14, - 0xc163d9ab17bb035d, - 0x03f1b5c5ee2485cc, - 0x019a16068c3eac9c, - ])), - ], - [ - Felt252::new(BigInt([ - 0x92134d90def073ea, - 0x20ee86a925725ac3, - 0x4d4ef9fd16347528, - 0x01f24b4356a6bbfd, - ])), - Felt252::new(BigInt([ - 0x7305971592333d36, - 0x528fb70727f35d81, - 0xadd59b6b4d11c60a, - 0x0003e44e7f7aeea6, - ])), - Felt252::new(BigInt([ - 0xcbd94cd7513d394e, - 0xe85987ae57bc9807, - 0x14535a511ed3eb4f, - 0x05f93b02f8267414, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5ca2d3bada29523a, - 0xfd1cc76e670607e3, - 0xd71c3d51d4197fa3, - 0x00f0a0a88db99247, - ])), - Felt252::new(BigInt([ - 0x64bdde3e77608db0, - 0xd2b6f2e80626af65, - 0xacac1e211431fd4c, - 0x03432226916d31f3, - ])), - Felt252::new(BigInt([ - 0xa3830528d59cf919, - 0xb0b82940ef5f393c, - 0x8175192845a7ad74, - 0x055625941bfea6f4, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8e2e585e318e20a4, - 0x783e9b92f9276b85, - 0x7dfe4f8cb3ef1b39, - 0x00ddf48695b20447, - ])), - Felt252::new(BigInt([ - 0xd3194578b08ae8e3, - 0x434ee50d4953e7c5, - 0x8851a679ab2a1490, - 0x0260730a657ff8f3, - ])), - Felt252::new(BigInt([ - 0xbcd206842b961aa9, - 0xd7132775b398d324, - 0x96283840bdb79ba6, - 0x04cfd231373aa46d, - ])), - ], - [ - Felt252::new(BigInt([ - 0x81e963de57eff25d, - 0x7ebc659e74fd48f9, - 0xf14fa0bc0b2191a2, - 0x03203843c41cd453, - ])), - Felt252::new(BigInt([ - 0x93705872e647cc46, - 0x260f5e77a54b0062, - 0xfb8435d1c86bf76c, - 0x0002c2f6ae5624d1, - ])), - Felt252::new(BigInt([ - 0x1535022014765f06, - 0x85b0e142b6975238, - 0xb3e561384ef2e73a, - 0x0780225456e63903, - ])), - ], - [ - Felt252::new(BigInt([ - 0x41cc432a75c81887, - 0x3082fc954b9a9ff6, - 0xfd21b07f8e296061, - 0x07f602ec1a80a051, - ])), - Felt252::new(BigInt([ - 0xf0c8c118ca7e6bca, - 0x23fe77cd7c1ab432, - 0xb60f6aaf7022b7d3, - 0x062561b0a0a72239, - ])), - Felt252::new(BigInt([ - 0xb9b84a8a03b70bc8, - 0x2450c186d093754c, - 0xa69b05dea16b1cf2, - 0x0604fe5a6a22344a, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8682eaf88aef2b7b, - 0x6eada5995905189f, - 0xd3dc140bf5f9b76f, - 0x01cf9987a4044716, - ])), - Felt252::new(BigInt([ - 0xee42ce22cbfbacbf, - 0xdebee233e91b50e9, - 0x3db47a4bdd60cf69, - 0x06bc0b2487c1eece, - ])), - Felt252::new(BigInt([ - 0xcbf87ab7ea0792e6, - 0x7620c51356d2c6ad, - 0xa11403b93e90338b, - 0x02f5dbb5055eb749, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8489e5fc4a550f61, - 0x5f63b8a623a9cf31, - 0x29743c43883d59c4, - 0x0446328f4dddae65, - ])), - Felt252::new(BigInt([ - 0x58584d2c48f5af25, - 0x25817b43d3583999, - 0xca6c4010fb4b481a, - 0x04ba30c5240cde5b, - ])), - Felt252::new(BigInt([ - 0xe39a32f89c2c8a89, - 0x708351d2cf19af5f, - 0xc89209117734ae85, - 0x05f5275f76425b15, - ])), - ], - [ - Felt252::new(BigInt([ - 0x15e1be8e6af2fc17, - 0x993cdda4eb8cb924, - 0xe18c7f98df3b2f7b, - 0x0576f3b5156f4763, - ])), - Felt252::new(BigInt([ - 0x93c0e8e12d35ef3d, - 0xf84a61719ed5adbb, - 0xed5a44b55a5b026d, - 0x011dc3f15cba928a, - ])), - Felt252::new(BigInt([ - 0xa6442b8feda04dca, - 0xe1c1d9ea047d75f8, - 0xd9896403ae4f543a, - 0x044c40e6bd52e91a, - ])), - ], - [ - Felt252::new(BigInt([ - 0xc914ad01166026d8, - 0x1954bf90fe9ea4e2, - 0xbd0ccbf4974e80ac, - 0x01836d733a54013e, - ])), - Felt252::new(BigInt([ - 0xf84ca02ce731b3ac, - 0x7611df8037761f00, - 0xa8159d306ef08472, - 0x03c553be9776b628, - ])), - Felt252::new(BigInt([ - 0xe342f5017076a059, - 0x401ae11a6d757843, - 0xda1c7b87e0436b1b, - 0x006ce94781c1a23f, - ])), - ], - [ - Felt252::new(BigInt([ - 0x371cc2daa0acd0ed, - 0xe107f457812effb7, - 0x0253be9f00f4e6b9, - 0x0381ec71fbdef316, - ])), - Felt252::new(BigInt([ - 0xfe0ffa7bf2a8f1a1, - 0xd4fb574aa687bafd, - 0x6490d847320d9f3c, - 0x01844da9cc0eeadc, - ])), - Felt252::new(BigInt([ - 0x2acfd7f9b65a812f, - 0xedf9710104745968, - 0xbb27fea5b401483d, - 0x07a8bf471f902d5a, - ])), - ], - [ - Felt252::new(BigInt([ - 0x6b0d063839e56327, - 0x6f5a9cdff7aecb6e, - 0x41915fb51ac17445, - 0x0633b6fb004de624, - ])), - Felt252::new(BigInt([ - 0x7535fd70fbc50ab6, - 0xbbe546ba88fed8b1, - 0x771200382bfc6d17, - 0x0179ee5cec496194, - ])), - Felt252::new(BigInt([ - 0x2cae194330bf8c42, - 0xb0312446f07435ac, - 0xea9891b42d565256, - 0x02806c0786185986, - ])), - ], - [ - Felt252::new(BigInt([ - 0x56ac9bb6ee041393, - 0x603bb2cdfd26bfa3, - 0x90c7a6b8af194b8b, - 0x0438703d948708ae, - ])), - Felt252::new(BigInt([ - 0xa585d58a920035af, - 0x1c56f4e02225c628, - 0x7153bd3a482b7f6e, - 0x024446628f56029d, - ])), - Felt252::new(BigInt([ - 0xbd96025e5435e259, - 0xae48f6606790d817, - 0xb0685cdeeea3a253, - 0x04c2a76e5ce832e8, - ])), - ], - [ - Felt252::new(BigInt([ - 0x70983b8caa0e0300, - 0x57d5e4ce1ab122d3, - 0x92933c079b148aed, - 0x078a233235209945, - ])), - Felt252::new(BigInt([ - 0xb87070ba51ec22c0, - 0xadce1aa691b19e6d, - 0x51144ea5937dd07c, - 0x079ca6c5e1025b21, - ])), - Felt252::new(BigInt([ - 0x314e48922af79c5d, - 0x4a442ebfd1ac5d17, - 0xf952d9d34f8d6bd8, - 0x06b2e4a46e37af3c, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8e3529e0d03435c2, - 0x1ca7d443f11e34a1, - 0xb6805d93d3d8d74e, - 0x00305d6cd95cc2ea, - ])), - Felt252::new(BigInt([ - 0x15c7c17b37fbf9a9, - 0xabb7aea70cc624a4, - 0xb39743ed23f8956c, - 0x06097b4b8b90db14, - ])), - Felt252::new(BigInt([ - 0xf96288707c18893f, - 0xd3bdcc90865b0f0a, - 0x845bdb98373e77da, - 0x0064e1b3f16c26c8, - ])), - ], - [ - Felt252::new(BigInt([ - 0x7f1579ae911fd335, - 0x21c56014af2ffdf5, - 0x23384d841221b734, - 0x0649fafe673f21e6, - ])), - Felt252::new(BigInt([ - 0xd1ba288a77fefe30, - 0x2baa2f4d19005a49, - 0x6b294404e849722f, - 0x07d806dccbf1a269, - ])), - Felt252::new(BigInt([ - 0x59119c44aafc7522, - 0x7a03f48f443be6d6, - 0xc0b3e2db1a9a235d, - 0x05951a37da53e3bb, - ])), - ], - [ - Felt252::new(BigInt([ - 0xc816a1607a907731, - 0x10496a31bdacb542, - 0x4d1912c3554ae3d0, - 0x06d87fa479fb5952, - ])), - Felt252::new(BigInt([ - 0x462a3ac892acc9b2, - 0x0a712a0b12bb6fc9, - 0xd473ad73466b4e8c, - 0x01451cccd4200fa9, - ])), - Felt252::new(BigInt([ - 0xd82dd1efdc0763da, - 0x832ca0faa15e1c4e, - 0x07642535f1ca9b03, - 0x03ca1b6400b3e510, - ])), - ], - [ - Felt252::new(BigInt([ - 0xf993a99c7a1a4d95, - 0xb0dd024ff4162539, - 0x60ad1516a8f13592, - 0x052c55735b2f0a65, - ])), - Felt252::new(BigInt([ - 0x62951d65f6b924cd, - 0xe750bd5ce3e9fa5e, - 0xf0149d1dee29617d, - 0x07e04de60aa80132, - ])), - Felt252::new(BigInt([ - 0x3edf63291c0a5495, - 0x303ef29e26f28922, - 0xe47c4c8fab71c8f8, - 0x00271784e6920a68, - ])), - ], - [ - Felt252::new(BigInt([ - 0x6b49514af43d0c69, - 0xc8afe93f17b7f0e5, - 0x60a04b8f0adaa603, - 0x05c7c19061a84d59, - ])), - Felt252::new(BigInt([ - 0x38e4436f5482eafe, - 0x090943c2959dea1b, - 0x419da337cb79061e, - 0x0172db5affe783af, - ])), - Felt252::new(BigInt([ - 0x46a9e061a2cb9456, - 0x21a7ecbadf188097, - 0x0eac9fe4082916f0, - 0x0518b7975a6d8d31, - ])), - ], - [ - Felt252::new(BigInt([ - 0x755a0315f1e196db, - 0xd74b8ae5e37b34e8, - 0xd4bbc2440a9f5061, - 0x020c5539dc45dd56, - ])), - Felt252::new(BigInt([ - 0x5a9d8bc213b90b14, - 0xa977b47208283cf3, - 0x08bc7d516e80efc3, - 0x01ea6f5fb309fa4a, - ])), - Felt252::new(BigInt([ - 0x7d1f766541e29ded, - 0xfd424b5de167c725, - 0xfdd8ddd8ba9cfe2e, - 0x050ce323c5128dc7, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8919284c613cb7d8, - 0x5b865f5b7d1b497a, - 0x695538b41d3c2821, - 0x0401e37d0e276547, - ])), - Felt252::new(BigInt([ - 0x0fab9cf57c57397b, - 0x55daa12cc61261cc, - 0x7f2893056fc58802, - 0x0645a0de30acc311, - ])), - Felt252::new(BigInt([ - 0x76b66ae7fa3d495b, - 0xd4fdc9d0d69219f6, - 0xd9e988d75f09f698, - 0x069bc3841eb0a310, - ])), - ], - [ - Felt252::new(BigInt([ - 0x84baf523f136bdc6, - 0x7cf0ae0c455cda54, - 0x4bdd47c38fe72db4, - 0x002684bbe315ad2c, - ])), - Felt252::new(BigInt([ - 0xe4acb821fd8a13ee, - 0x88858c2afa664365, - 0x68202e8d34e5595a, - 0x011e0f83c547ca5c, - ])), - Felt252::new(BigInt([ - 0xcac945f1097b82ef, - 0xd0f86ac66c1e5a5e, - 0x5966567ceec34315, - 0x04af4a7635f8c751, - ])), - ], - [ - Felt252::new(BigInt([ - 0x5c72b11f4c74b271, - 0x1dc48894d2bb4622, - 0x3cb7158908ccc18b, - 0x04fba58cf8aaf489, - ])), - Felt252::new(BigInt([ - 0x38b0f44c8a2a0e20, - 0x9a7f89be0ead679a, - 0x8cc90da2e664f8c2, - 0x0397c4c169115b46, - ])), - Felt252::new(BigInt([ - 0x20998f59ec7bacff, - 0x1f326dd7f32be22e, - 0xbad397fa5dd13c50, - 0x006563b9ebb6450d, - ])), - ], - [ - Felt252::new(BigInt([ - 0x36cd79e9cb817165, - 0xfec48562076dd09c, - 0xea81d307f4c79f9a, - 0x0376edb238f7b630, - ])), - Felt252::new(BigInt([ - 0x58584cda96e2e061, - 0xb337504039690eb8, - 0xf29ed22addcd50a1, - 0x060d4208bb50eb15, - ])), - Felt252::new(BigInt([ - 0x344a52f1df9a9210, - 0x0f30da46918ab020, - 0xdbff1019dc3465ec, - 0x06a37d569d2fbc73, - ])), - ], - [ - Felt252::new(BigInt([ - 0x429130371ac63b1a, - 0x1dc512f1df073c1b, - 0xf412083ff35d2382, - 0x00d3b174c7290c6b, - ])), - Felt252::new(BigInt([ - 0x9fe55e525b980373, - 0x34d974919689fb48, - 0x4b46eb2a5c3b8146, - 0x0226ed3d76347745, - ])), - Felt252::new(BigInt([ - 0x30e8b0080d218513, - 0xf06f4d79bd7ffa19, - 0xe0e7a23d33d2fd9e, - 0x05f3997e7dafcb2d, - ])), - ], - [ - Felt252::new(BigInt([ - 0x8348c3fae8fdf14d, - 0x04f886f7f9d3c164, - 0x434df335a10bbac5, - 0x07c5eec716d94634, - ])), - Felt252::new(BigInt([ - 0xf63d2f55f57e1a7c, - 0x8a89da85553f871e, - 0xe7e24fd22c0f9ad6, - 0x0053cc30d7fe0f84, - ])), - Felt252::new(BigInt([ - 0xfefa4cd58c4ec8fa, - 0x9474a24f6e83b268, - 0x19b95769f4741856, - 0x0368821ee335d718, - ])), - ], - [ - Felt252::new(BigInt([ - 0xf46d6a242bfeb7a1, - 0x72c6d0a61538bdff, - 0x35119816883040da, - 0x005334f75b052c02, - ])), - Felt252::new(BigInt([ - 0xcd49d6dca50aa431, - 0x8f80ee4af2ec6547, - 0xc1020cca9d871ae6, - 0x05d0af4fcbd9e056, - ])), - Felt252::new(BigInt([ - 0x5ab99537901b1e65, - 0xb4699dc00f1d53ba, - 0x4114a19c46d24e00, - 0x030131bce2fba569, - ])), - ], - [ - Felt252::new(BigInt([ - 0x4957660f2e788965, - 0x538f93f13161be3c, - 0xb34c0750ed2e641c, - 0x05646a95a7c1ae86, - ])), - Felt252::new(BigInt([ - 0xc90df47b7d4ec01a, - 0x78581f5259692b52, - 0x9fac36230a11f43e, - 0x04b9f291d7b430c7, - ])), - Felt252::new(BigInt([ - 0xd890e74abae01a13, - 0x3e00becf6ceb4d73, - 0x1a98f19127072dc8, - 0x05006d393d3480f4, - ])), - ], - [ - Felt252::new(BigInt([ - 0x202dc3b26a679d80, - 0xacf4f702e6b346fd, - 0x0e7cb8a115143106, - 0x062c9d42199f3b26, - ])), - Felt252::new(BigInt([ - 0xbf1d9ac2dc5717a5, - 0x7606836eabd8af54, - 0xf180b1a8a13b7f2c, - 0x051274d092db5099, - ])), - Felt252::new(BigInt([ - 0x861a8db0bfff0c5b, - 0xf415e14f0d9cdbed, - 0x7ad0fb7aaa4ca528, - 0x061fc552b8eb75e1, - ])), - ], -]; diff --git a/util/src/poseidon/mod.rs b/util/src/poseidon/mod.rs deleted file mode 100644 index b729253..0000000 --- a/util/src/poseidon/mod.rs +++ /dev/null @@ -1,161 +0,0 @@ -use std::{marker::PhantomData, slice::Windows}; - -use ark_ff::{BigInt, Field}; -use consts::{CAPACITY, ROUNDS_FULL, ROUNDS_PARTIAL, ROUND_CONSTANTS, WIDTH}; - -use felt::Felt252; - -mod consts; - -trait FieldHasher { - fn hash(&self, input: &[F]) -> F; - - /// Possibly optimized version of `hash` for pairs. - fn pair(&self, left: F, right: F) -> F { - self.hash(&[left, right]) - } -} - -struct Poseidon { - _ph: PhantomData, -} - -impl Poseidon { - fn round(st: &mut [Felt252; WIDTH], constants: &[Felt252; WIDTH], full: bool) { - // add round constant - st[0] += constants[0]; - st[1] += constants[1]; - st[2] += constants[2]; - - // apply S-box - #[inline] - fn cube(x: F) -> F { - x.square() * x - } - - st[2] = cube(st[2]); - if full { - st[0] = cube(st[0]); - st[1] = cube(st[1]); - } - - // mix state - // M = ( - // ( 3, 1, 1), - // ( 1,-1, 1), - // ( 1, 1, -2) - // ) - // see: - // https://github.com/starkware-industries/poseidon/blob/main/poseidon3.txt - let t0 = st[0] + st[1]; - let t1 = t0 + st[2]; - st[0] = t1 + st[0].double(); - st[1] = t1 - st[1].double(); - st[2] = t0 - st[2].double(); - - println!("st: {:#?}", st); - } - - fn perm(mut st: [Felt252; WIDTH]) -> [Felt252; WIDTH] { - let mut ctx = ROUND_CONSTANTS.iter(); - assert_eq!(ROUNDS_FULL % 2, 0); - - // initial full rounds - for _ in 0..ROUNDS_FULL / 2 { - Self::round(&mut st, ctx.next().unwrap(), true); - } - - // middle partial rounds - for _ in 0..ROUNDS_PARTIAL { - Self::round(&mut st, ctx.next().unwrap(), false); - } - - // final full rounds - for _ in 0..ROUNDS_FULL / 2 { - Self::round(&mut st, ctx.next().unwrap(), true); - } - - st - } -} - -impl FieldHasher for Poseidon { - fn hash(&self, input: &[Felt252]) -> Felt252 { - // initialize state - let mut st = [Felt252::ZERO; WIDTH]; - let mut iter = input.chunks_exact(CAPACITY); - - // handle regular chunks - while let Some(chunk) = iter.next() { - st[0] += chunk[0]; - st[1] += chunk[1]; - st = Self::perm(st); - } - - // handle remainer and padding - match iter.remainder() { - [last] => { - st[0] += *last; - st[1] += Felt252::ONE; - } - [] => { - st[0] += Felt252::ONE; - } - _ => unreachable!(), - } - - // apply the final permutation - st = Self::perm(st); - st[0] - } -} - -#[test] -fn test_hash() {} - -#[test] -fn test_permutation() { - let input = [ - Felt252::new(BigInt([ - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - ])), - Felt252::new(BigInt([ - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - ])), - Felt252::new(BigInt([ - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - 0x0000000000000000, - ])), - ]; - - let output = [ - Felt252::new(BigInt([ - 0x86550ed6a9086133, - 0x852357968577b1e3, - 0xa28fc9d49e233bc6, - 0x079e8d1e78258000, - ])), - Felt252::new(BigInt([ - 0xa256154cbb6fb984, - 0xe5b5404b91ccaabc, - 0xdbb796ff6aa6a63b, - 0x03840d003d0f3f96, - ])), - Felt252::new(BigInt([ - 0x50b70eaa8a3c7cc7, - 0x9325a61fb2ef326e, - 0x142d0ac83d9da00c, - 0x01eb39da3f7d3b04, - ])), - ]; - - assert_eq!(Poseidon::::perm(input), output); -} From 22e1dbebbeb9bd0c77b4b083d835cddedc202bee Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Mon, 22 Jul 2024 12:04:00 +0200 Subject: [PATCH 5/6] refactor: remove build.rs and include processed constants Jaehun is right, this was over-engineered. --- poseidon/Cargo.toml | 5 - poseidon/build.rs | 349 -------------------- poseidon/src/constants.rs | 664 +++++++++++++++++++++++++++++++++++++- 3 files changed, 660 insertions(+), 358 deletions(-) delete mode 100644 poseidon/build.rs diff --git a/poseidon/Cargo.toml b/poseidon/Cargo.toml index 1126e19..49b5e47 100644 --- a/poseidon/Cargo.toml +++ b/poseidon/Cargo.toml @@ -13,8 +13,3 @@ criterion = "0.5.1" [[bench]] name = "poseidon" harness = false - -[build-dependencies] -chumsky = "0.9.3" -ark-ff.workspace = true -felt = { path = "../felt" } diff --git a/poseidon/build.rs b/poseidon/build.rs deleted file mode 100644 index 6a4b5e8..0000000 --- a/poseidon/build.rs +++ /dev/null @@ -1,349 +0,0 @@ -use std::{env, fs, path::Path}; - -use ark_ff::{BigInt, Field, PrimeField}; - -use chumsky::{ - self, - error::Simple, - primitive::{choice, empty, end, just}, - text::{self, TextParser}, - Parser, -}; - -use felt::Felt252; - -// parse the round keys -const WIDTH: usize = 3; - -#[derive(Debug, Clone)] -enum Options { - Rate(Number), - Capacity(Number), - FullRounds(Number), - PartialRounds(Number), - Mds(Vec>), - RoundKeys(Vec>), -} - -#[derive(Debug, Clone, Eq, PartialEq)] -enum Sign { - Plus, - Minus, -} - -#[derive(Debug, Clone)] -struct Number { - sign: Sign, - digits: String, -} - -impl Number { - fn i64(&self) -> i64 { - match self.sign { - Sign::Plus => self.digits.parse().unwrap(), - Sign::Minus => -self.digits.parse::().unwrap(), - } - } - - fn usize(&self) -> usize { - assert_eq!(self.sign, Sign::Plus); - self.digits.parse().unwrap() - } - - fn field(&self) -> F { - assert_eq!(self.sign, Sign::Plus); - let mut res = F::ZERO; - for c in self.digits.chars() { - let digit = match c { - '0' => F::from(0u64), - '1' => F::from(1u64), - '2' => F::from(2u64), - '3' => F::from(3u64), - '4' => F::from(4u64), - '5' => F::from(5u64), - '6' => F::from(6u64), - '7' => F::from(7u64), - '8' => F::from(8u64), - '9' => F::from(9u64), - _ => panic!("Invalid digit"), - }; - res = res * F::from(10u64) + digit; - } - res - } -} - -fn parse() -> impl Parser, Error = Simple> { - fn opt(c: char) -> impl Parser> + Clone { - choice((just(c).map(|_| true), empty().map(|_| false))) - } - - let num = opt('-') - .then(text::int(10)) - .map(|(neg, digits)| Number { - sign: if neg { Sign::Minus } else { Sign::Plus }, - digits, - }) - .padded(); - - let row = num.clone().separated_by(just(',').padded()).delimited_by( - just('[').padded(), - opt(',').padded().then(just(']')).padded(), - ); - - let mxt = row - .separated_by(just(',').padded()) - .delimited_by( - just('[').padded(), - opt(',').padded().then(just(']')).padded(), - ) - .padded(); - - let eq = just("=").padded(); - - let opt = choice(( - // parse the rate - just("Rate") - .then(eq) - .then(num.clone()) - .map(|(_, num)| Options::Rate(num)), - // parse the capacity - just("Capacity") - .then(eq) - .then(num.clone()) - .map(|(_, num)| Options::Capacity(num)), - // parse the number of full rounds - just("FullRounds") - .then(eq) - .then(num.clone()) - .map(|(_, num)| Options::FullRounds(num)), - // parse the number of partial rounds - just("PartialRounds") - .then(eq) - .then(num.clone()) - .map(|(_, num)| Options::PartialRounds(num)), - // parse the matrix - just("MDS") - .then(eq) - .then(mxt.clone()) - .map(|(_, m)| Options::Mds(m)), - // parse the round keys list - just("RoundKeys") - .then(eq) - .then(mxt.clone()) - .map(|(_, m)| Options::RoundKeys(m)), - )); - - opt.padded().repeated().then(end()).map(|(v, _)| v) -} - -#[allow(clippy::single_char_add_str)] -fn main() { - // open poseidon3.txt - let input = include_str!("poseidon3.txt"); - - // parse the input - let parsed = parse().parse(input).unwrap(); - - // extract the options - let mut rate = None; - let mut capacity = None; - let mut full_rounds = None; - let mut partial_rounds = None; - let mut mds = None; - let mut round_keys = None; - for opt in parsed { - match opt { - Options::Rate(n) => { - assert!(rate.is_none()); - rate = Some(n) - } - Options::Capacity(n) => { - assert!(capacity.is_none()); - capacity = Some(n) - } - Options::FullRounds(n) => { - assert!(full_rounds.is_none()); - full_rounds = Some(n) - } - Options::PartialRounds(n) => { - assert!(partial_rounds.is_none()); - partial_rounds = Some(n) - } - Options::Mds(m) => { - assert!(mds.is_none()); - mds = Some(m) - } - Options::RoundKeys(m) => { - assert!(round_keys.is_none()); - round_keys = Some(m) - } - } - } - - // check that all options are present - let rate = rate.expect("Rate not found"); - let capacity = capacity.expect("Capacity not found"); - let full_rounds = full_rounds.expect("FullRounds not found"); - let partial_rounds = partial_rounds.expect("PartialRounds not found"); - let mds = mds.expect("MDS not found"); - let round_keys = round_keys.expect("RoundKeys not found"); - - // check that the mds matrix is the expected one - let mds: Vec> = mds - .iter() - .map(|row| row.iter().map(|n| n.i64()).collect()) - .collect(); - assert_eq!(mds, vec![vec![3, 1, 1], vec![1, -1, 1], vec![1, 1, -2]]); - - let rate = rate.usize(); - let capacity = capacity.usize(); - let rounds_full = full_rounds.usize(); - let rounds_partial = partial_rounds.usize(); - - // expected number of round keys - assert_eq!(rate + capacity, WIDTH); - assert_eq!(rounds_full + rounds_partial, round_keys.len()); - assert_eq!(rounds_full % 2, 0); - - // parse the round keys - let mut parsed_keys: Vec> = vec![]; - for key in round_keys { - let key: Vec = key.iter().map(|n| n.field()).collect(); - assert_eq!(key.len(), WIDTH); - parsed_keys.push(key); - } - - // precompute the compressed round keys - fn compute_compressed_round_keys( - rnd_full_first: &[[Felt252; WIDTH]], - rnd_partial: &[[Felt252; WIDTH]], - rnd_full_last: &[[Felt252; WIDTH]], - ) -> Vec { - // output - let mut out = Vec::new(); - - // full rounds - for key in rnd_full_first { - out.push(key[0]); - out.push(key[1]); - out.push(key[2]); - } - - // handle partial rounds - let mut st = [Felt252::ZERO, Felt252::ZERO, Felt252::ZERO]; - for key in rnd_partial { - // add round constant - st[0] += key[0]; - st[1] += key[1]; - st[2] += key[2]; - - // add the state to the output - out.push(st[2]); - st[2] = Felt252::ZERO; - - // mix state - // M = ( - // ( 3, 1, 1), - // ( 1,-1, 1), - // ( 1, 1, -2) - // ) - // see: - // https://github.com/starkware-industries/poseidon/blob/main/poseidon3.txt - let t0 = st[0] + st[1]; - let t1 = t0 + st[2]; - st[0] = t1 + st[0].double(); - st[1] = t1 - st[1].double(); - st[2] = t0 - st[2].double(); - } - - // add the first of the last full-round keys - st[0] += rnd_full_last[0][0]; - st[1] += rnd_full_last[0][1]; - st[2] += rnd_full_last[0][2]; - out.push(st[0]); - out.push(st[1]); - out.push(st[2]); - - // handle remaining full rounds - for key in rnd_full_last.iter().skip(1) { - out.push(key[0]); - out.push(key[1]); - out.push(key[2]); - } - - out - } - - // split round keys into full and partial rounds - let keys = parsed_keys - .iter() - .cloned() - .map(|key| { - let key: [Felt252; WIDTH] = key.try_into().unwrap(); - key - }) - .collect::>(); - - let (first_full, rem) = keys.split_at(rounds_full / 2); - let (partial, last_full) = rem.split_at(rounds_partial); - - assert_eq!(partial.len(), rounds_partial); - assert_eq!(last_full.len(), rounds_full / 2); - assert_eq!(first_full.len(), rounds_full / 2); - - fn fmt_field(field: Felt252) -> String { - let bn: BigInt<4> = field.into_bigint(); - let vs = bn.0; - assert_eq!(vs.len(), 4); - format!( - " Felt252::new(BigInt([0x{:016x},0x{:016x},0x{:016x},0x{:016x}]))", - vs[0], vs[1], vs[2], vs[3] - ) - } - - // generate the compressed round keys - let compressed = compute_compressed_round_keys(first_full, partial, last_full); - - let mut output = String::new(); - - output.push_str("#[allow(dead_code)]\n"); - output.push_str(format!("pub const RATE: usize = {};\n", rate).as_str()); - output.push_str("\n"); - - output.push_str("#[allow(dead_code)]\n"); - output.push_str(format!("pub const CAPACITY: usize = {};\n", capacity).as_str()); - output.push_str("\n"); - - output.push_str("#[allow(dead_code)]\n"); - output.push_str(format!("pub const WIDTH: usize = {};\n", WIDTH).as_str()); - output.push_str("\n"); - - output.push_str("#[allow(dead_code)]\n"); - output.push_str(format!("pub const ROUNDS_FULL: usize = {};\n", rounds_full).as_str()); - output.push_str("\n"); - - output.push_str("#[allow(dead_code)]\n"); - output.push_str(format!("pub const ROUNDS_PARTIAL: usize = {};\n", rounds_partial).as_str()); - output.push_str("\n"); - - output.push_str("#[allow(dead_code)]\n"); - output.push_str( - format!( - "pub const ROUND_KEYS_COMPRESSED: [Felt252; {}] = [\n", - compressed.len() - ) - .as_str(), - ); - for key in compressed { - output.push_str(&format!("{},\n", fmt_field(key))); - } - output.push_str("];"); - output.push_str("\n"); - - // write the output to the file - let out_dir = env::var_os("OUT_DIR").unwrap(); - let dest_path = Path::new(&out_dir).join("cnst.rs"); - fs::write(dest_path, output).unwrap(); - println!("cargo::rerun-if-changed=build.rs"); -} diff --git a/poseidon/src/constants.rs b/poseidon/src/constants.rs index bed528a..caa3543 100644 --- a/poseidon/src/constants.rs +++ b/poseidon/src/constants.rs @@ -1,7 +1,663 @@ use ark_ff::BigInt; use felt::Felt252; -use std::include; -// poseidon constants -// created by build.rs -include!(concat!(env!("OUT_DIR"), "/cnst.rs")); +#[allow(dead_code)] +pub const RATE: usize = 2; + +#[allow(dead_code)] +pub const CAPACITY: usize = 1; + +#[allow(dead_code)] +pub const WIDTH: usize = 3; + +#[allow(dead_code)] +pub const ROUNDS_FULL: usize = 8; + +#[allow(dead_code)] +pub const ROUNDS_PARTIAL: usize = 83; + +#[allow(dead_code)] +pub const ROUND_KEYS_COMPRESSED: [Felt252; 107] = [ + Felt252::new(BigInt([ + 0x80b7fd8eac77fe6f, + 0xe58e2ad98109ae47, + 0x39dd92f9562a30b9, + 0x06861759ea556a23, + ])), + Felt252::new(BigInt([ + 0xe4ab1a22f27508c4, + 0x3da43f76abf28a64, + 0xffc8397a3d00425a, + 0x03827681995d5af9, + ])), + Felt252::new(BigInt([ + 0x7a0dbe17704a8309, + 0x2cac75dc279b2d68, + 0xe7f760a2277dc7cb, + 0x03a3956d2fad44d0, + ])), + Felt252::new(BigInt([ + 0x882031afe67ef4cd, + 0x291c78f926a2d1c6, + 0xf13c4282214aa759, + 0x0626c47a7d421fe1, + ])), + Felt252::new(BigInt([ + 0xadfe17baca05d6a6, + 0x2d327fcc948d772c, + 0x5bd6df5518cfd41f, + 0x078985f8e1650503, + ])), + Felt252::new(BigInt([ + 0x142dcf34341696ff, + 0xc6e26a68b456dc1d, + 0x204c659875341243, + 0x05427f10867514a3, + ])), + Felt252::new(BigInt([ + 0x0465e60edce699d7, + 0x847cd2c5d9d4cb8b, + 0x454361733f0883c5, + 0x05af083f36e4c729, + ])), + Felt252::new(BigInt([ + 0xc77e709bfd388882, + 0x2d3975f92ff84b1a, + 0x54fa3f74f7b352a5, + 0x07d71701bde3d06d, + ])), + Felt252::new(BigInt([ + 0xe39584467a6b1d3e, + 0xac1b64f699ffea44, + 0x9c26f8a6320a1c5e, + 0x0603da0688201900, + ])), + Felt252::new(BigInt([ + 0x613b9721f6453a5d, + 0xeebd8870fd13a36b, + 0x8e79ce13f47ad1cd, + 0x04332a6f6bde2f28, + ])), + Felt252::new(BigInt([ + 0xc9e8caeb5cba78e7, + 0x4b9a813aaeff60d6, + 0x5310a04c4dec2e7e, + 0x053d0ebf61664c68, + ])), + Felt252::new(BigInt([ + 0x1bfc2d15eaabfebc, + 0x6c82f99f928494ee, + 0x5ae5ebcb88028d2a, + 0x05346a6889484583, + ])), + Felt252::new(BigInt([ + 0x92864c00f54a3f9a, + 0x3433b6ab9dd5a995, + 0x3453cc97445954bf, + 0x04b085eb1df4258c, + ])), + Felt252::new(BigInt([ + 0x5ca5d7b0961f6d96, + 0xfdfe0a8e610e6f2d, + 0x965f12a079b2a169, + 0x0731cfd19d508285, + ])), + Felt252::new(BigInt([ + 0xf8079c1e3587eeaa, + 0x2ecd9e1f9a73d743, + 0xcc6f7a774936b3e7, + 0x0217d08b5339852b, + ])), + Felt252::new(BigInt([ + 0x959e267008518c6e, + 0xcb966ba510c81b20, + 0x63599b13c850dab3, + 0x000c935dd633b0fd, + ])), + Felt252::new(BigInt([ + 0x467fe940e7b8b2be, + 0x8cf5a0a387103971, + 0xee187ed23f79a7d9, + 0x052af8d378dd6772, + ])), + Felt252::new(BigInt([ + 0x6362cda595f8ab75, + 0xaa6e28a7b79b2e50, + 0x1ec9918b9f12fcce, + 0x0294851c98b2682f, + ])), + Felt252::new(BigInt([ + 0xc204b169ab086064, + 0x9da8c30063471494, + 0x824d1021418d4f58, + 0x011b59990bacc280, + ])), + Felt252::new(BigInt([ + 0xb599d49ceb2acd6a, + 0xeb2ce690e6bbdcd0, + 0x91960d59ae099b9b, + 0x04b4df56e3d7753f, + ])), + Felt252::new(BigInt([ + 0x5f1cf09eb5161ac4, + 0x66243534f30629fc, + 0x3ecae9fbd8ff06e4, + 0x005eecfa15a757dc, + ])), + Felt252::new(BigInt([ + 0x7f8448bda4279059, + 0x82e5a7cef81b1567, + 0x4659227634a1ec52, + 0x0680bfdd8b9680e0, + ])), + Felt252::new(BigInt([ + 0xb8877d97acd85053, + 0x5c17e10b1cedd791, + 0x14e2930794f7a306, + 0x01d0bf8fab0a1a7a, + ])), + Felt252::new(BigInt([ + 0x876701a37e32f464, + 0xc0fc11a610f14c48, + 0x54ba207053c0d412, + 0x02c2c8c79f808ace, + ])), + Felt252::new(BigInt([ + 0x630ad56c54afa562, + 0x74d8234c11ad7bce, + 0x52aae19a9b858d34, + 0x0354ec9ed01d20ec, + ])), + Felt252::new(BigInt([ + 0x94e6ea28deec1e55, + 0xe4136ac5892340e9, + 0xc38bb5d1a42287f4, + 0x030df20fcf6427ba, + ])), + Felt252::new(BigInt([ + 0x72eda296fc9c6778, + 0x41d99b424091e314, + 0x3040bafbdeff61e2, + 0x0528cf329c64e7ee, + ])), + Felt252::new(BigInt([ + 0xff6e757930bd1960, + 0xbf0c3e0c69e6c5b5, + 0x634789660df5435e, + 0x040416f24f623534, + ])), + Felt252::new(BigInt([ + 0xd5444435ccc9ea38, + 0x15ba21b11e88339c, + 0xfd488ae3bac7dce3, + 0x00380c8f936e2ed9, + ])), + Felt252::new(BigInt([ + 0x45e0e2291f255b75, + 0x03ad0541832829d2, + 0xf1a8e344392efd2d, + 0x01cc4f5d5603d176, + ])), + Felt252::new(BigInt([ + 0x23c502aa99c09752, + 0xe011d6c8e015ea54, + 0x9539310d99f5d142, + 0x05728917af5da91f, + ])), + Felt252::new(BigInt([ + 0xc788fecc17219aa1, + 0x90925107d17c56d7, + 0x46e295a348f0f235, + 0x00efb450a9e86e1a, + ])), + Felt252::new(BigInt([ + 0xa6c26693774dca99, + 0x84b8fcd977de6c53, + 0xe1a025616b342d07, + 0x02020d74d36c421a, + ])), + Felt252::new(BigInt([ + 0xa2b7b4f583989287, + 0x335050969f4bf84f, + 0x2705558ae511dc82, + 0x07cfb309b75fd3bf, + ])), + Felt252::new(BigInt([ + 0xc785a784812d75e9, + 0x9d7b7d02a617eb98, + 0x5365e009ece62680, + 0x04651e48b2e9349a, + ])), + Felt252::new(BigInt([ + 0x7a3b5c8f71c0dcc7, + 0xcae822d9aad0f094, + 0x22d0269719da923c, + 0x00d77627b270f651, + ])), + Felt252::new(BigInt([ + 0xd3b7758c32908ea8, + 0x82b003377f0dd8b7, + 0xd571b3fe37773a8b, + 0x0199ad3d641b54c4, + ])), + Felt252::new(BigInt([ + 0x319e72d137cdfe6e, + 0x82b2d297be2da289, + 0x973e2e9172a73334, + 0x044f33640a8ecfd3, + ])), + Felt252::new(BigInt([ + 0x6b6f366b6701abf7, + 0x7f801234f5216eab, + 0x89d00a02dcf1e6be, + 0x07e4adf9894d9641, + ])), + Felt252::new(BigInt([ + 0xca559fb4e711ee90, + 0xa7c6aecfb5471dfd, + 0xf5ff808f8a9817ed, + 0x03641fa5b3c90452, + ])), + Felt252::new(BigInt([ + 0xd0eee2c2cc3f3533, + 0x306df32e6e2f0e02, + 0x897a49a78fa923fc, + 0x03de5729efd2fcbd, + ])), + Felt252::new(BigInt([ + 0xdb77bd2882d6c994, + 0x06563500c8f06c9b, + 0x7f622966ca0be20c, + 0x062691891a3fc1e2, + ])), + Felt252::new(BigInt([ + 0x86e96e0604baa0be, + 0x1590cc4f9885ae1d, + 0x688739f72205763d, + 0x06608d3bf11c18e4, + ])), + Felt252::new(BigInt([ + 0x98c25cbbf593a316, + 0x07249f51cbdda4fd, + 0x3419726ce779116d, + 0x011c9c9b39cac71e, + ])), + Felt252::new(BigInt([ + 0x4dd68c557c462ad7, + 0x748e3312ea40c684, + 0xaef0850f74da27b9, + 0x061e23b58203269c, + ])), + Felt252::new(BigInt([ + 0xce010855cf83bdc8, + 0xd9878440b25951e4, + 0xf870a572010bc2a3, + 0x04182cd9ab1d9488, + ])), + Felt252::new(BigInt([ + 0x65f6a59f4f3ecb71, + 0xf1df2fe89d306f99, + 0xf9055e6823116d15, + 0x0520fe6c4a096793, + ])), + Felt252::new(BigInt([ + 0x3fbe4d4e2fd4afa1, + 0x99ed6d71f47723ea, + 0x29e093093dcd3dfa, + 0x0346b2b2d6e58101, + ])), + Felt252::new(BigInt([ + 0xea72877ce9f7e6cf, + 0xe8b682c8e8e973ac, + 0x8ec1dd2a3684bee4, + 0x01359ca923e7f144, + ])), + Felt252::new(BigInt([ + 0x92420f37b95d9675, + 0xde9deadab145a1b3, + 0x00dfefdad24de86f, + 0x047c655f55cf3078, + ])), + Felt252::new(BigInt([ + 0xa38ad87dca8441a8, + 0x98efd925f2d58b7a, + 0xa968cd7c9c285a95, + 0x04ab291f16555fa8, + ])), + Felt252::new(BigInt([ + 0x2c9c7c5d17c629c5, + 0x22c44ef959510e39, + 0x223d1f6f7d86c21a, + 0x039f409c7c782101, + ])), + Felt252::new(BigInt([ + 0xbfacead0cafb6052, + 0xe1a2f9fb5587a3ba, + 0xd86eecb0cd6beb02, + 0x044be36b782f882a, + ])), + Felt252::new(BigInt([ + 0x107679a53a0d538b, + 0x3cd1ceb394c52ce7, + 0x2906db6eb5b50720, + 0x050a1dfde9b504ad, + ])), + Felt252::new(BigInt([ + 0x83e7aebbeab183ab, + 0x680bdd7f1017dae0, + 0x7b181c0dd11ac6c3, + 0x05c753c14da89e28, + ])), + Felt252::new(BigInt([ + 0xa57746525fc0520c, + 0x6eee93e15f7b4f4f, + 0x06c8015a3b180f38, + 0x02cf6306ed322321, + ])), + Felt252::new(BigInt([ + 0x4d7d8e502c1c3a09, + 0x1dfc6380689bd4f5, + 0x420873cf34742909, + 0x02c2014634d52e27, + ])), + Felt252::new(BigInt([ + 0x50fc09cdf86ed8a1, + 0x975c446345f010d8, + 0x2fdacde2058e33e5, + 0x03cfb9c5bd93e02b, + ])), + Felt252::new(BigInt([ + 0x9ea4e1281f6b0299, + 0x6e311e84f72cb50a, + 0x97933f1411fc5f80, + 0x0363fa71a383cf38, + ])), + Felt252::new(BigInt([ + 0xbcb960da91b05df8, + 0xb4901b2a3686cffe, + 0x6947b3fc76271676, + 0x0728199657067ee1, + ])), + Felt252::new(BigInt([ + 0x652a078d7e4ee021, + 0xc9bde34a9872df5a, + 0x4f0723b728e8921d, + 0x03fdfbd47d27f3d3, + ])), + Felt252::new(BigInt([ + 0x945c453398eff449, + 0xe53cc02ca7d24197, + 0x7dc0efbe7858eb7d, + 0x07f241379440cacd, + ])), + Felt252::new(BigInt([ + 0x04354e52a5c25f0b, + 0xcbb457a27574d5f1, + 0x4e3bf056f3727797, + 0x05b2e8771ea9a000, + ])), + Felt252::new(BigInt([ + 0xa057a081bda2e23e, + 0xe910245be6bf822e, + 0xa7e0b3b0333146e1, + 0x00a8ddbce708de44, + ])), + Felt252::new(BigInt([ + 0xedce2e19aa9b0f61, + 0xc12270e533835613, + 0x31aa47cd90a0f551, + 0x02d521e0daca24e4, + ])), + Felt252::new(BigInt([ + 0x41a6266c30e08ae6, + 0x03eef7b07aaee003, + 0xf7d5ac3b93f855af, + 0x06cdbc0f2aa54d2c, + ])), + Felt252::new(BigInt([ + 0x0941112b36ed9bf3, + 0x1ceee452cbe92c7a, + 0x4c5da3ad6794c096, + 0x03dd96a17111ec8f, + ])), + Felt252::new(BigInt([ + 0xc0c5e732c36687dc, + 0xa2cfb92196a65d9e, + 0x7ac07fdd06159344, + 0x05eafb1edeedc5c0, + ])), + Felt252::new(BigInt([ + 0x312cfcd065c207e6, + 0xbcec5a7b7c7f449b, + 0x324577b260feaebd, + 0x04ab038d7b09eda9, + ])), + Felt252::new(BigInt([ + 0x495fc80c7fdef220, + 0x463c58052570f68e, + 0x05d2b0d94e235608, + 0x04ca71981e4df6b5, + ])), + Felt252::new(BigInt([ + 0x573c15b77e413d2f, + 0x7e9b59d7e2759ffe, + 0x2aa419899c8ea813, + 0x06dee9c6da4617e3, + ])), + Felt252::new(BigInt([ + 0x1e625d0460c6f186, + 0x5b4a795a4770e454, + 0x4dcbe2396065a430, + 0x058f9e60b34ddab8, + ])), + Felt252::new(BigInt([ + 0xfcecef17fc9af632, + 0x2d290906f274bea8, + 0xe6c9c735db6c3404, + 0x047b7b4a802a10c1, + ])), + Felt252::new(BigInt([ + 0xb9463a06a2bd430c, + 0x084a074be0bfc0fb, + 0x096ecc936a186774, + 0x01849bcdb9ad7171, + ])), + Felt252::new(BigInt([ + 0xc4d699b1466736cc, + 0xea3b49b4217547de, + 0x8af5767bddaecd8a, + 0x041870fbe0443834, + ])), + Felt252::new(BigInt([ + 0x965029d284738b07, + 0xc0ec42e3d4da68d1, + 0xfa02aa64557daf28, + 0x0226c04e598076a9, + ])), + Felt252::new(BigInt([ + 0x5335b2a7d6dac0fb, + 0x475cec4371f269a9, + 0x42eb92d6655c3ddb, + 0x01f0e971f0485a5b, + ])), + Felt252::new(BigInt([ + 0x7b40dd3926431563, + 0xebdf3703f795047a, + 0xf994d35aa47ee3f4, + 0x009f31cc2907dccb, + ])), + Felt252::new(BigInt([ + 0xffe8cca4c64bd7d2, + 0xc22cfbc198c84451, + 0xe31ce4df58ce5a42, + 0x04b40cce78f3b641, + ])), + Felt252::new(BigInt([ + 0xf72cb93ce50f8b9f, + 0xf3ac736962fdfb70, + 0x3e4563173de4a226, + 0x0191660489e4bd8a, + ])), + Felt252::new(BigInt([ + 0x7ed8dd4c7b467410, + 0xa814b475103373dc, + 0xf74eb01f293f2dae, + 0x018c0919618db971, + ])), + Felt252::new(BigInt([ + 0xfb240bd57eadc803, + 0xef37002e941c3dc1, + 0x845c8753121577d0, + 0x035b60253848530e, + ])), + Felt252::new(BigInt([ + 0xfd029134957451d5, + 0x581ad9b413d97fa6, + 0xc8b43a9f71a5f362, + 0x01ae99db1575ae91, + ])), + Felt252::new(BigInt([ + 0xd1dfb357e172647b, + 0x7d7cb8feb58a37d2, + 0x28148ebcbd5d7d33, + 0x03e6e1d0f3f8a0f7, + ])), + Felt252::new(BigInt([ + 0xc38dd1f4a209b8f3, + 0x6ee3e9ad619e16f5, + 0x659e1a171b55d270, + 0x018bc36dffa8f96a, + ])), + Felt252::new(BigInt([ + 0x83fa5b64893de4ed, + 0x99a16efe9a1cc3ab, + 0x2b54afc3a107ff91, + 0x02c7a3ef1afb6a30, + ])), + Felt252::new(BigInt([ + 0x9856e94469de4bd7, + 0x5e4fe4e84b0c6dde, + 0xf5e27dd8e92f6ae8, + 0x053a7bd889bed07b, + ])), + Felt252::new(BigInt([ + 0xd3cc0cc2f03ccea9, + 0x6bec5a02ce9a0bf9, + 0xfda704aca35995f8, + 0x04d383ff7ffc6318, + ])), + Felt252::new(BigInt([ + 0xd1292519c326f5cd, + 0xa96e0b3503037710, + 0x3d07ef7e8a65b21c, + 0x04667b6762fb8ad5, + ])), + Felt252::new(BigInt([ + 0xb7fb536422e5921f, + 0x6055dccc9589f02e, + 0x42a93c39ea98bcd4, + 0x002cc8b43e75cf0b, + ])), + Felt252::new(BigInt([ + 0x4b2ce25582bf9c60, + 0xba4df0e7be59c55f, + 0x38751447bfd76086, + 0x06b32ee98680871d, + ])), + Felt252::new(BigInt([ + 0x2d635cb1387102a3, + 0x34efac1f0609f086, + 0xaa3b3c81358b82e7, + 0x03e907927c7182fa, + ])), + Felt252::new(BigInt([ + 0x93ea5e8424fbc6ea, + 0x8d2f437973f6a937, + 0x5f0253728e512af7, + 0x03f3a5057b3a0897, + ])), + Felt252::new(BigInt([ + 0x7a946bb6ca68d8f5, + 0x1c21e1017224726a, + 0xf8aa74b3fd8aa582, + 0x014b491d73724779, + ])), + Felt252::new(BigInt([ + 0x61695ea4abb814ef, + 0x7aca84c54ad13738, + 0xe7f60e514fe3b936, + 0x05c8278c7bbfc30a, + ])), + Felt252::new(BigInt([ + 0xba0b4502755c8074, + 0x67018a82ba3bf99b, + 0x5a08a7dde65e44b4, + 0x064851937f9836ee, + ])), + Felt252::new(BigInt([ + 0xf9ea5e73f1d971dc, + 0x882be77cb85f422f, + 0x9eca450ffb52b441, + 0x06a9ac8425129476, + ])), + Felt252::new(BigInt([ + 0x1884f5ca545064de, + 0xc6a81d991d27f0fc, + 0xc9a2b71f2f7bd098, + 0x037ec35b710b0d04, + ])), + Felt252::new(BigInt([ + 0xf46d6a242bfeb7a1, + 0x72c6d0a61538bdff, + 0x35119816883040da, + 0x005334f75b052c02, + ])), + Felt252::new(BigInt([ + 0xcd49d6dca50aa431, + 0x8f80ee4af2ec6547, + 0xc1020cca9d871ae6, + 0x05d0af4fcbd9e056, + ])), + Felt252::new(BigInt([ + 0x5ab99537901b1e65, + 0xb4699dc00f1d53ba, + 0x4114a19c46d24e00, + 0x030131bce2fba569, + ])), + Felt252::new(BigInt([ + 0x4957660f2e788965, + 0x538f93f13161be3c, + 0xb34c0750ed2e641c, + 0x05646a95a7c1ae86, + ])), + Felt252::new(BigInt([ + 0xc90df47b7d4ec01a, + 0x78581f5259692b52, + 0x9fac36230a11f43e, + 0x04b9f291d7b430c7, + ])), + Felt252::new(BigInt([ + 0xd890e74abae01a13, + 0x3e00becf6ceb4d73, + 0x1a98f19127072dc8, + 0x05006d393d3480f4, + ])), + Felt252::new(BigInt([ + 0x202dc3b26a679d80, + 0xacf4f702e6b346fd, + 0x0e7cb8a115143106, + 0x062c9d42199f3b26, + ])), + Felt252::new(BigInt([ + 0xbf1d9ac2dc5717a5, + 0x7606836eabd8af54, + 0xf180b1a8a13b7f2c, + 0x051274d092db5099, + ])), + Felt252::new(BigInt([ + 0x861a8db0bfff0c5b, + 0xf415e14f0d9cdbed, + 0x7ad0fb7aaa4ca528, + 0x061fc552b8eb75e1, + ])), +]; From d0de79c6c5571b9b8adde676e7f67ae6ca495546 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Mon, 22 Jul 2024 12:10:13 +0200 Subject: [PATCH 6/6] chore: remove old artifact --- poseidon/poseidon3.txt | 462 ----------------------------------------- 1 file changed, 462 deletions(-) delete mode 100644 poseidon/poseidon3.txt diff --git a/poseidon/poseidon3.txt b/poseidon/poseidon3.txt deleted file mode 100644 index 734a87b..0000000 --- a/poseidon/poseidon3.txt +++ /dev/null @@ -1,462 +0,0 @@ -Rate = 2 -Capacity = 1 -FullRounds = 8 -PartialRounds = 83 -MDS = [[3, 1, 1], [1, -1, 1], [1, 1, -2]] -RoundKeys = [ - [ - 2950795762459345168613727575620414179244544320470208355568817838579231751791, - 1587446564224215276866294500450702039420286416111469274423465069420553242820, - 1645965921169490687904413452218868659025437693527479459426157555728339600137, - ], - [ - 2782373324549879794752287702905278018819686065818504085638398966973694145741, - 3409172630025222641379726933524480516420204828329395644967085131392375707302, - 2379053116496905638239090788901387719228422033660130943198035907032739387135, - ], - [ - 2570819397480941104144008784293466051718826502582588529995520356691856497111, - 3546220846133880637977653625763703334841539452343273304410918449202580719746, - 2720682389492889709700489490056111332164748138023159726590726667539759963454, - ], - [ - 1899653471897224903834726250400246354200311275092866725547887381599836519005, - 2369443697923857319844855392163763375394720104106200469525915896159690979559, - 2354174693689535854311272135513626412848402744119855553970180659094265527996, - ], - [ - 2404084503073127963385083467393598147276436640877011103379112521338973185443, - 950320777137731763811524327595514151340412860090489448295239456547370725376, - 2121140748740143694053732746913428481442990369183417228688865837805149503386, - ], - [ - 2372065044800422557577242066480215868569521938346032514014152523102053709709, - 2618497439310693947058545060953893433487994458443568169824149550389484489896, - 3518297267402065742048564133910509847197496119850246255805075095266319996916, - ], - [ - 340529752683340505065238931581518232901634742162506851191464448040657139775, - 1954876811294863748406056845662382214841467408616109501720437541211031966538, - 813813157354633930267029888722341725864333883175521358739311868164460385261, - ], - [ - 71901595776070443337150458310956362034911936706490730914901986556638720031, - 2789761472166115462625363403490399263810962093264318361008954888847594113421, - 2628791615374802560074754031104384456692791616314774034906110098358135152410, - ], - [ - 3617032588734559635167557152518265808024917503198278888820567553943986939719, - 2624012360209966117322788103333497793082705816015202046036057821340914061980, - 149101987103211771991327927827692640556911620408176100290586418839323044234, - ], - [ - 1039927963829140138166373450440320262590862908847727961488297105916489431045, - 2213946951050724449162431068646025833746639391992751674082854766704900195669, - 2792724903541814965769131737117981991997031078369482697195201969174353468597, - ], - [ - 3212031629728871219804596347439383805499808476303618848198208101593976279441, - 3343514080098703935339621028041191631325798327656683100151836206557453199613, - 614054702436541219556958850933730254992710988573177298270089989048553060199, - ], - [ - 148148081026449726283933484730968827750202042869875329032965774667206931170, - 1158283532103191908366672518396366136968613180867652172211392033571980848414, - 1032400527342371389481069504520755916075559110755235773196747439146396688513, - ], - [ - 806900704622005851310078578853499250941978435851598088619290797134710613736, - 462498083559902778091095573017508352472262817904991134671058825705968404510, - 1003580119810278869589347418043095667699674425582646347949349245557449452503, - ], - [ - 619074932220101074089137133998298830285661916867732916607601635248249357793, - 2635090520059500019661864086615522409798872905401305311748231832709078452746, - 978252636251682252755279071140187792306115352460774007308726210405257135181, - ], - [ - 1766912167973123409669091967764158892111310474906691336473559256218048677083, - 1663265127259512472182980890707014969235283233442916350121860684522654120381, - 3532407621206959585000336211742670185380751515636605428496206887841428074250, - ], - [ - 2507023127157093845256722098502856938353143387711652912931112668310034975446, - 3321152907858462102434883844787153373036767230808678981306827073335525034593, - 3039253036806065280643845548147711477270022154459620569428286684179698125661, - ], - [ - 103480338868480851881924519768416587261556021758163719199282794248762465380, - 2394049781357087698434751577708655768465803975478348134669006211289636928495, - 2660531560345476340796109810821127229446538730404600368347902087220064379579, - ], - [ - 3603166934034556203649050570865466556260359798872408576857928196141785055563, - 1553799760191949768532188139643704561532896296986025007089826672890485412324, - 2744284717053657689091306578463476341218866418732695211367062598446038965164, - ], - [ - 320745764922149897598257794663594419839885234101078803811049904310835548856, - 979382242100682161589753881721708883681034024104145498709287731138044566302, - 1860426855810549882740147175136418997351054138609396651615467358416651354991, - ], - [ - 336173081054369235994909356892506146234495707857220254489443629387613956145, - 1632470326779699229772327605759783482411227247311431865655466227711078175883, - 921958250077481394074960433988881176409497663777043304881055317463712938502, - ], - [ - 3034358982193370602048539901033542101022185309652879937418114324899281842797, - 25626282149517463867572353922222474817434101087272320606729439087234878607, - 3002662261401575565838149305485737102400501329139562227180277188790091853682, - ], - [ - 2939684373453383817196521641512509179310654199629514917426341354023324109367, - 1076484609897998179434851570277297233169621096172424141759873688902355505136, - 2575095284833160494841112025725243274091830284746697961080467506739203605049, - ], - [ - 3565075264617591783581665711620369529657840830498005563542124551465195621851, - 2197016502533303822395077038351174326125210255869204501838837289716363437993, - 331415322883530754594261416546036195982886300052707474899691116664327869405, - ], - [ - 1935011233711290003793244296594669823169522055520303479680359990463281661839, - 3495901467168087413996941216661589517270845976538454329511167073314577412322, - 954195417117133246453562983448451025087661597543338750600301835944144520375, - ], - [ - 1271840477709992894995746871435810599280944810893784031132923384456797925777, - 2565310762274337662754531859505158700827688964841878141121196528015826671847, - 3365022288251637014588279139038152521653896670895105540140002607272936852513, - ], - [ - 1660592021628965529963974299647026602622092163312666588591285654477111176051, - 970104372286014048279296575474974982288801187216974504035759997141059513421, - 2617024574317953753849168721871770134225690844968986289121504184985993971227, - ], - [ - 999899815343607746071464113462778273556695659506865124478430189024755832262, - 2228536129413411161615629030408828764980855956560026807518714080003644769896, - 2701953891198001564547196795777701119629537795442025393867364730330476403227, - ], - [ - 837078355588159388741598313782044128527494922918203556465116291436461597853, - 2121749601840466143704862369657561429793951309962582099604848281796392359214, - 771812260179247428733132708063116523892339056677915387749121983038690154755, - ], - [ - 3317336423132806446086732225036532603224267214833263122557471741829060578219, - 481570067997721834712647566896657604857788523050900222145547508314620762046, - 242195042559343964206291740270858862066153636168162642380846129622127460192, - ], - [ - 2855462178889999218204481481614105202770810647859867354506557827319138379686, - 3525521107148375040131784770413887305850308357895464453970651672160034885202, - 1320839531502392535964065058804908871811967681250362364246430459003920305799, - ], - [ - 2514191518588387125173345107242226637171897291221681115249521904869763202419, - 2798335750958827619666318316247381695117827718387653874070218127140615157902, - 2808467767967035643407948058486565877867906577474361783201337540214875566395, - ], - [ - 3551834385992706206273955480294669176699286104229279436819137165202231595747, - 1219439673853113792340300173186247996249367102884530407862469123523013083971, - 761519904537984520554247997444508040636526566551719396202550009393012691157, - ], - [ - 3355402549169351700500518865338783382387571349497391475317206324155237401353, - 199541098009731541347317515995192175813554789571447733944970283654592727138, - 192100490643078165121235261796864975568292640203635147901612231594408079071, - ], - [ - 1187019357602953326192019968809486933768550466167033084944727938441427050581, - 189525349641911362389041124808934468936759383310282010671081989585219065700, - 2831653363992091308880573627558515686245403755586311978724025292003353336665, - ], - [ - 2052859812632218952608271535089179639890275494426396974475479657192657094698, - 1670756178709659908159049531058853320846231785448204274277900022176591811072, - 3538757242013734574731807289786598937548399719866320954894004830207085723125, - ], - [ - 710549042741321081781917034337800036872214466705318638023070812391485261299, - 2345013122330545298606028187653996682275206910242635100920038943391319595180, - 3528369671971445493932880023233332035122954362711876290904323783426765912206, - ], - [ - 1167120829038120978297497195837406760848728897181138760506162680655977700764, - 3073243357129146594530765548901087443775563058893907738967898816092270628884, - 378514724418106317738164464176041649567501099164061863402473942795977719726, - ], - [ - 333391138410406330127594722511180398159664250722328578952158227406762627796, - 1727570175639917398410201375510924114487348765559913502662122372848626931905, - 968312190621809249603425066974405725769739606059422769908547372904403793174, - ], - [ - 360659316299446405855194688051178331671817370423873014757323462844775818348, - 1386580151907705298970465943238806620109618995410132218037375811184684929291, - 3604888328937389309031638299660239238400230206645344173700074923133890528967, - ], - [ - 2496185632263372962152518155651824899299616724241852816983268163379540137546, - 486538168871046887467737983064272608432052269868418721234810979756540672990, - 1558415498960552213241704009433360128041672577274390114589014204605400783336, - ], - [ - 3512058327686147326577190314835092911156317204978509183234511559551181053926, - 2235429387083113882635494090887463486491842634403047716936833563914243946191, - 1290896777143878193192832813769470418518651727840187056683408155503813799882, - ], - [ - 1143310336918357319571079551779316654556781203013096026972411429993634080835, - 3235435208525081966062419599803346573407862428113723170955762956243193422118, - 1293239921425673430660897025143433077974838969258268884994339615096356996604, - ], - [ - 236252269127612784685426260840574970698541177557674806964960352572864382971, - 1733907592497266237374827232200506798207318263912423249709509725341212026275, - 302004309771755665128395814807589350526779835595021835389022325987048089868, - ], - [ - 3018926838139221755384801385583867283206879023218491758435446265703006270945, - 39701437664873825906031098349904330565195980985885489447836580931425171297, - 908381723021746969965674308809436059628307487140174335882627549095646509778, - ], - [ - 219062858908229855064136253265968615354041842047384625689776811853821594358, - 1283129863776453589317845316917890202859466483456216900835390291449830275503, - 418512623547417594896140369190919231877873410935689672661226540908900544012, - ], - [ - 1792181590047131972851015200157890246436013346535432437041535789841136268632, - 370546432987510607338044736824316856592558876687225326692366316978098770516, - 3323437805230586112013581113386626899534419826098235300155664022709435756946, - ], - [ - 910076621742039763058481476739499965761942516177975130656340375573185415877, - 1762188042455633427137702520675816545396284185254002959309669405982213803405, - 2186362253913140345102191078329764107619534641234549431429008219905315900520, - ], - [ - 2230647725927681765419218738218528849146504088716182944327179019215826045083, - 1069243907556644434301190076451112491469636357133398376850435321160857761825, - 2695241469149243992683268025359863087303400907336026926662328156934068747593, - ], - [ - 1361519681544413849831669554199151294308350560528931040264950307931824877035, - 1339116632207878730171031743761550901312154740800549632983325427035029084904, - 790593524918851401449292693473498591068920069246127392274811084156907468875, - ], - [ - 2723400368331924254840192318398326090089058735091724263333980290765736363637, - 3457180265095920471443772463283225391927927225993685928066766687141729456030, - 1483675376954327086153452545475557749815683871577400883707749788555424847954, - ], - [ - 2926303836265506736227240325795090239680154099205721426928300056982414025239, - 543969119775473768170832347411484329362572550684421616624136244239799475526, - 237401230683847084256617415614300816373730178313253487575312839074042461932, - ], - [ - 844568412840391587862072008674263874021460074878949862892685736454654414423, - 151922054871708336050647150237534498235916969120198637893731715254687336644, - 1299332034710622815055321547569101119597030148120309411086203580212105652312, - ], - [ - 487046922649899823989594814663418784068895385009696501386459462815688122993, - 1104883249092599185744249485896585912845784382683240114120846423960548576851, - 1458388705536282069567179348797334876446380557083422364875248475157495514484, - ], - [ - 850248109622750774031817200193861444623975329881731864752464222442574976566, - 2885843173858536690032695698009109793537724845140477446409245651176355435722, - 3027068551635372249579348422266406787688980506275086097330568993357835463816, - ], - [ - 3231892723647447539926175383213338123506134054432701323145045438168976970994, - 1719080830641935421242626784132692936776388194122314954558418655725251172826, - 1172253756541066126131022537343350498482225068791630219494878195815226839450, - ], - [ - 1619232269633026603732619978083169293258272967781186544174521481891163985093, - 3495680684841853175973173610562400042003100419811771341346135531754869014567, - 1576161515913099892951745452471618612307857113799539794680346855318958552758, - ], - [ - 2618326122974253423403350731396350223238201817594761152626832144510903048529, - 2696245132758436974032479782852265185094623165224532063951287925001108567649, - 930116505665110070247395429730201844026054810856263733273443066419816003444, - ], - [ - 2786389174502246248523918824488629229455088716707062764363111940462137404076, - 1555260846425735320214671887347115247546042526197895180675436886484523605116, - 2306241912153325247392671742757902161446877415586158295423293240351799505917, - ], - [ - 411529621724849932999694270803131456243889635467661223241617477462914950626, - 1542495485262286701469125140275904136434075186064076910329015697714211835205, - 1853045663799041100600825096887578544265580718909350942241802897995488264551, - ], - [ - 2963055259497271220202739837493041799968576111953080503132045092194513937286, - 2303806870349915764285872605046527036748108533406243381676768310692344456050, - 2622104986201990620910286730213140904984256464479840856728424375142929278875, - ], - [ - 2369987021925266811581727383184031736927816625797282287927222602539037105864, - 285070227712021899602056480426671736057274017903028992288878116056674401781, - 3034087076179360957800568733595959058628497428787907887933697691951454610691, - ], - [ - 469095854351700119980323115747590868855368701825706298740201488006320881056, - 360001976264385426746283365024817520563236378289230404095383746911725100012, - 3438709327109021347267562000879503009590697221730578667498351600602230296178, - ], - [ - 63573904800572228121671659287593650438456772568903228287754075619928214969, - 3470881855042989871434874691030920672110111605547839662680968354703074556970, - 724559311507950497340993415408274803001166693839947519425501269424891465492, - ], - [ - 880409284677518997550768549487344416321062350742831373397603704465823658986, - 6876255662475867703077362872097208259197756317287339941435193538565586230, - 2701916445133770775447884812906226786217969545216086200932273680400909154638, - ], - [ - 425152119158711585559310064242720816611629181537672850898056934507216982586, - 1475552998258917706756737045704649573088377604240716286977690565239187213744, - 2413772448122400684309006716414417978370152271397082147158000439863002593561, - ], - [ - 392160855822256520519339260245328807036619920858503984710539815951012864164, - 1075036996503791536261050742318169965707018400307026402939804424927087093987, - 2176439430328703902070742432016450246365760303014562857296722712989275658921, - ], - [ - 1413865976587623331051814207977382826721471106513581745229680113383908569693, - 4879283427490523253696177116563427032332223531862961281430108575019551814, - 3392583297537374046875199552977614390492290683707960975137418536812266544902, - ], - [ - 3600854486849487646325182927019642276644093512133907046667282144129939150983, - 2779924664161372134024229593301361846129279572186444474616319283535189797834, - 2722699960903170449291146429799738181514821447014433304730310678334403972040, - ], - [ - 819109815049226540285781191874507704729062681836086010078910930707209464699, - 3046121243742768013822760785918001632929744274211027071381357122228091333823, - 1339019590803056172509793134119156250729668216522001157582155155947567682278, - ], - [ - 1933279639657506214789316403763326578443023901555983256955812717638093967201, - 2138221547112520744699126051903811860205771600821672121643894708182292213541, - 2694713515543641924097704224170357995809887124438248292930846280951601597065, - ], - [ - 2471734202930133750093618989223585244499567111661178960753938272334153710615, - 504903761112092757611047718215309856203214372330635774577409639907729993533, - 1943979703748281357156510253941035712048221353507135074336243405478613241290, - ], - [ - 684525210957572142559049112233609445802004614280157992196913315652663518936, - 1705585400798782397786453706717059483604368413512485532079242223503960814508, - 192429517716023021556170942988476050278432319516032402725586427701913624665, - ], - [ - 1586493702243128040549584165333371192888583026298039652930372758731750166765, - 686072673323546915014972146032384917012218151266600268450347114036285993377, - 3464340397998075738891129996710075228740496767934137465519455338004332839215, - ], - [ - 2805249176617071054530589390406083958753103601524808155663551392362371834663, - 667746464250968521164727418691487653339733392025160477655836902744186489526, - 1131527712905109997177270289411406385352032457456054589588342450404257139778, - ], - [ - 1908969485750011212309284349900149072003218505891252313183123635318886241171, - 1025257076985551890132050019084873267454083056307650830147063480409707787695, - 2153175291918371429502545470578981828372846236838301412119329786849737957977, - ], - [ - 3410257749736714576487217882785226905621212230027780855361670645857085424384, - 3442969106887588154491488961893254739289120695377621434680934888062399029952, - 3029953900235731770255937704976720759948880815387104275525268727341390470237, - ], - [ - 85453456084781138713939104192561924536933417707871501802199311333127894466, - 2730629666577257820220329078741301754580009106438115341296453318350676425129, - 178242450661072967256438102630920745430303027840919213764087927763335940415, - ], - [ - 2844589222514708695700541363167856718216388819406388706818431442998498677557, - 3547876269219141094308889387292091231377253967587961309624916269569559952944, - 2525005406762984211707203144785482908331876505006839217175334833739957826850, - ], - [ - 3096397013555211396701910432830904669391580557191845136003938801598654871345, - 574424067119200181933992948252007230348512600107123873197603373898923821490, - 1714030696055067278349157346067719307863507310709155690164546226450579547098, - ], - [ - 2339895272202694698739231405357972261413383527237194045718815176814132612501, - 3562501318971895161271663840954705079797767042115717360959659475564651685069, - 69069358687197963617161747606993436483967992689488259107924379545671193749, - ], - [ - 2614502738369008850475068874731531583863538486212691941619835266611116051561, - 655247349763023251625727726218660142895322325659927266813592114640858573566, - 2305235672527595714255517865498269719545193172975330668070873705108690670678, - ], - [ - 926416070297755413261159098243058134401665060349723804040714357642180531931, - 866523735635840246543516964237513287099659681479228450791071595433217821460, - 2284334068466681424919271582037156124891004191915573957556691163266198707693, - ], - [ - 1812588309302477291425732810913354633465435706480768615104211305579383928792, - 2836899808619013605432050476764608707770404125005720004551836441247917488507, - 2989087789022865112405242078196235025698647423649950459911546051695688370523, - ], - [ - 68056284404189102136488263779598243992465747932368669388126367131855404486, - 505425339250887519581119854377342241317528319745596963584548343662758204398, - 2118963546856545068961709089296976921067035227488975882615462246481055679215, - ], - [ - 2253872596319969096156004495313034590996995209785432485705134570745135149681, - 1625090409149943603241183848936692198923183279116014478406452426158572703264, - 179139838844452470348634657368199622305888473747024389514258107503778442495, - ], - [ - 1567067018147735642071130442904093290030432522257811793540290101391210410341, - 2737301854006865242314806979738760349397411136469975337509958305470398783585, - 3002738216460904473515791428798860225499078134627026021350799206894618186256, - ], - [ - 374029488099466837453096950537275565120689146401077127482884887409712315162, - 973403256517481077805460710540468856199855789930951602150773500862180885363, - 2691967457038172130555117632010860984519926022632800605713473799739632878867, - ], - [ - 3515906794910381201365530594248181418811879320679684239326734893975752012109, - 148057579455448384062325089530558091463206199724854022070244924642222283388, - 1541588700238272710315890873051237741033408846596322948443180470429851502842, - ], - [ - 147013865879011936545137344076637170977925826031496203944786839068852795297, - 2630278389304735265620281704608245039972003761509102213752997636382302839857, - 1359048670759642844930007747955701205155822111403150159614453244477853867621, - ], - [ - 2438984569205812336319229336885480537793786558293523767186829418969842616677, - 2137792255841525507649318539501906353254503076308308692873313199435029594138, - 2262318076430740712267739371170174514379142884859595360065535117601097652755, - ], - [ - 2792703718581084537295613508201818489836796608902614779596544185252826291584, - 2294173715793292812015960640392421991604150133581218254866878921346561546149, - 2770011224727997178743274791849308200493823127651418989170761007078565678171, - ], -]