mirror of
https://github.com/logos-storage/rust-bn254-hash.git
synced 2026-01-02 13:53:09 +00:00
90 lines
5.1 KiB
Rust
90 lines
5.1 KiB
Rust
use std::str::FromStr;
|
|
use lazy_static::lazy_static;
|
|
use ark_bn254::Fr as F;
|
|
use ark_ff::BigInteger256;
|
|
|
|
|
|
/// enum for deciding which function (Square or Bar) to apply
|
|
#[derive(Clone, Copy, Debug)]
|
|
pub enum FunctionBlock {
|
|
Square,
|
|
Bar,
|
|
}
|
|
|
|
/// round schedule
|
|
pub static RF1: [FunctionBlock; 10] = [
|
|
FunctionBlock::Square, FunctionBlock::Square,
|
|
FunctionBlock::Bar, FunctionBlock::Bar,
|
|
FunctionBlock::Square, FunctionBlock::Square,
|
|
FunctionBlock::Bar, FunctionBlock::Bar,
|
|
FunctionBlock::Square, FunctionBlock::Square,
|
|
];
|
|
|
|
/// round constants - same as in:
|
|
/// https://extgit.isec.tugraz.at/krypto/zkfriendlyhashzoo/-/blob/master/plain_impls/src/skyscraper/skyscraper_instances.rs?ref_type=heads
|
|
static RC_STR: [&str; 24] = [
|
|
"17829420340877239108687448009732280677191990375576158938221412342251481978692",
|
|
"27740342931201890067831390843279536630457710544396725670188095857896839417202",
|
|
"17048088173265532689680903955395019356591870902241717143279822196003888806966",
|
|
"109512792282736997633398631034649037613028427788284511060520396554381700616124",
|
|
"23518768991468467328187394347260979305359711922005254253047385842741274989784",
|
|
"95360373645575887695357714105933674592754581048282220961740831584356266637451",
|
|
"57106046715138585370392400429108362862843547132381623658436718362793140581845",
|
|
"16971509144034029782226530622087626979814683266929655790026304723118124142299",
|
|
"8608910393531852188108777530736778805001620473682472554749734455948859886057",
|
|
"54566392379700209585884878067585451869449334062644668287971552334629853792764",
|
|
"18708129585851494907644197977764586873688181219062643217509404046560774277231",
|
|
"52159802752268413629255578890890486811485406260370834838036769779232029980820",
|
|
"98108525134123848500172941527936985409086875223276518679938863940387852105202",
|
|
"105831033594660236721345339515389948186304708551041643590872398526195732523291",
|
|
"53084450331558915295247017186532447841918727727492403087452333633170905880952",
|
|
"78730946611419899835403512890231154575719512053287438310527615801825503526967",
|
|
"62089842541186043938517187437087053794210809382724083686360536771123796704819",
|
|
"32303085017979849099049635709265581104054174293154472699090841350494692332148",
|
|
"19361794324495443451354916303398190341881571975219162871160427826227778850994",
|
|
"65021267664773559966759214868166670507376995901124257419858229816098767301789",
|
|
"94847021352352647235478120180321422709509900436733319635143815989658015262598",
|
|
"51591271359432809566841356156562526830388219805637947403945613063492005256674",
|
|
"44534956566050763472510245910556224585100739093572801527559057220740673520964",
|
|
"84085239597197409225577945757724209425761279846653606664394225962327262179862",
|
|
];
|
|
|
|
/// same as above but in raw representation (just for checking consistency)
|
|
static RC_STR_RAW: [&str; 24] = [
|
|
"17829420340877239108687448009732280677191990375576158938221412342251481978692",
|
|
"5852100059362614845584985098022261541909346143980691326489891671321030921585",
|
|
"17048088173265532689680903955395019356591870902241717143279822196003888806966",
|
|
"71577923540621522166602308362662170286605786204339342029375621502658138039",
|
|
"1630526119629192105940988602003704216811347521589219909349181656165466494167",
|
|
"7807402158218786806372091124904574238561123446618083586948014838053032654983",
|
|
"13329560971460034925899588938593812685746818331549554971040309989641523590611",
|
|
"16971509144034029782226530622087626979814683266929655790026304723118124142299",
|
|
"8608910393531852188108777530736778805001620473682472554749734455948859886057",
|
|
"10789906636021659141392066577070901692352605261812599600575143961478236801530",
|
|
"18708129585851494907644197977764586873688181219062643217509404046560774277231",
|
|
"8383317008589863184762767400375936634388677459538766150640361406080412989586",
|
|
"10555553646766747611187318546907885054893417621612381305146047194084618122734",
|
|
"18278062107303135832359716534360847832111250949377506216079581779892498540823",
|
|
"9307964587880364850754205696017897664821998926660334400055925260019288889718",
|
|
"13066217995902074168664295654459329310074418852039335279433003242098078040116",
|
|
"18313356797507493494024375946572503617114080581892014998964128397972179713585",
|
|
"10414842146140573876803229964008306015505809892738438355392637163918883836531",
|
|
"19361794324495443451354916303398190341881571975219162871160427826227778850994",
|
|
"21244781921095009522266403377652120330280267100292188732461821442947150310555",
|
|
"7294049864995546346492497199292322355316442835069182260350999243354781280130",
|
|
"7814785615754259122348544666047976653291491004805878716549204690340388265440",
|
|
"758470822372213028017434420041674408004010292740732840162648847589056529730",
|
|
"18420510981679583558838728521952384160116186645405503633299613402599836693011",
|
|
];
|
|
|
|
lazy_static! {
|
|
pub static ref RC: Vec<F> = RC_STR
|
|
.iter()
|
|
.map(|s| F::new_unchecked(BigInteger256::from_str(s).unwrap()))
|
|
.collect();
|
|
|
|
pub static ref RC_RAW: Vec<F> = RC_STR_RAW
|
|
.iter()
|
|
.map(|s| F::new_unchecked(BigInteger256::from_str(s).unwrap()))
|
|
.collect();
|
|
} |