pragma solidity >= 0.6.0; import { RollUpTree } from "../library/RollUpTree.sol"; library Poseidon { /** * @dev This is a dummy implementation for contract compilation * We'll use a generated library by circomlib instead of this dummy library * Please see * 1. migrations/3_deploy_poseidon.js * 2. https://github.com/iden3/circomlib/blob/master/src/poseidon_gencontract.js */ function poseidon(uint256[] calldata) external pure returns(uint256) { return 0; } } contract PoseidonTree is RollUpTree { function parentOf(uint256 left, uint256 right) public override pure returns (uint256) { uint[] memory res = new uint[](2); res[0] = left; res[1] = right; try Poseidon.poseidon(res) returns (uint val) { return val; } catch { revert("poseidon hash error"); } } function preHashedZero() public override pure returns (uint[] memory preHashed) { preHashed = new uint[](32); preHashed[0] = 0; preHashed[1] = 951383894958571821976060584138905353883650994872035011055912076785884444545; preHashed[2] = 20622346557934808217011721426661266483227782601688308996572323237868248378218; preHashed[3] = 9824383624068251658076004948987922624579386843373418302611235390446333218543; preHashed[4] = 18231051098028563566680291532078429851434716680352819569730767461390496150778; preHashed[5] = 3353212758970507511129878484465451720398128800239371146311683143363228006106; preHashed[6] = 11217981488147314489933157152414929198080353151522289497544152685671318494641; preHashed[7] = 15036778088095722022055958830077231912659267101273997428998619074916612435352; preHashed[8] = 13902072967731839344862497510839651364835012530289392251474510732102392496571; preHashed[9] = 11544666763895735667784949329006117565540509653060441453303165109269815573544; preHashed[10] = 21510646961350375150419802995301138938521651775264825801359130949650284310444; preHashed[11] = 8352951083833165756052596980166442098457751367763718836446899882180191056793; preHashed[12] = 15343731119332398035690133781878944808098758389875899387389032483608612201975; preHashed[13] = 17859889065964874059806749716671767294095122942218003054680455600278721682760; preHashed[14] = 13005683751955859646895222251347854050150102883725283511471451046875989680212; preHashed[15] = 4205649174226986356930070553187886804719468302164503100263635377186950831036; preHashed[16] = 19750306022602824334621751540444602941877212564617012384779890110940631499479; preHashed[17] = 13787449475998321194796333585929859822964379810621858297650445681317735049751; preHashed[18] = 19352660058382111833333563403449037513106549759599458573918161511424572551829; preHashed[19] = 3737777351960466472975103209621270470022655814871527857722759823396260075061; preHashed[20] = 20943234782302513461017727952568639683644580199489397255626110226440291401339; preHashed[21] = 5795708929007238426530181738408577219198201357778748765541563020248457323168; preHashed[22] = 8016801324339516904819330350066760814239094671519336277388286173855806999806; preHashed[23] = 5884199066691509831812513915574160689494297229511099310637152935955369731711; preHashed[24] = 3250655938939174689654559750315833136967841599319866612728223815985686816858; preHashed[25] = 14114218770778246664749017784964222075721417858412398618644650029333437797933; preHashed[26] = 2401943160580347625744978340544385888105785851018239049483997691518521960245; preHashed[27] = 9134780783526471460351764774308554035095817103500494344324917691105479502643; preHashed[28] = 758381646748944873489189316588017438483718171776336982948905935306261589091; preHashed[29] = 9437629125854872304659557622300510437290759503293331002065135264046317502539; preHashed[30] = 16058676910022686140116540147895265761026624401884559485184012755053971681997; preHashed[31] = 16436245448658037421414193783997917891680762875933787844005157653665438384766; } }