Skip to content

Commit

Permalink
fixing encryption for output utxos
Browse files Browse the repository at this point in the history
Signed-off-by: Chengxuan Xing <chengxuan.xing@kaleido.io>
  • Loading branch information
Chengxuan committed Oct 2, 2024
1 parent 759c610 commit 63979e9
Show file tree
Hide file tree
Showing 29 changed files with 1,728 additions and 1,141 deletions.
69 changes: 38 additions & 31 deletions solidity/contracts/lib/verifier_anon_enc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,53 @@ contract Groth16Verifier_AnonEnc {
uint256 constant deltay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;


uint256 constant IC0x = 19738436812852754138717560068465488575650466935897866784235851363188283681055;
uint256 constant IC0y = 20276710811895297863478242769429631408343958016139841779904405850032032045827;
uint256 constant IC0x = 6079617742568787541094179325682887909945808244704810735243959827192832415778;
uint256 constant IC0y = 16787571520225799670519045007682168421960853837217519526390259473913021713340;

uint256 constant IC1x = 12004009131111215646999120161880487388502192413854826301881504538550543450502;
uint256 constant IC1y = 5034584841161295539588326933292197987831538710023697101766083868565246659218;
uint256 constant IC1x = 2505991522311752156778455090661523584559854297926222384064524634600878278709;
uint256 constant IC1y = 8255748774878977400056431504849025092327157890018362555157613902790081047915;

uint256 constant IC2x = 11744025093458990804167237970026144007871637967897648400215565295861061328335;
uint256 constant IC2y = 2248857409928028413263909113804746755226258898653477806239821342300643857095;
uint256 constant IC2x = 3236965350244914412491796468123964009504328184224919569631341853652111094664;
uint256 constant IC2y = 5018817446917809174563002251706876062136577540211251783213972233922309257208;

uint256 constant IC3x = 1027866460885921739427963398134501038455918532796341088945078011511621442676;
uint256 constant IC3y = 5958883990350165479676838573621528879534261429892979129692820679034946644717;
uint256 constant IC3x = 20635473822198152490889178203795297168128816692310934597308737609178622412295;
uint256 constant IC3y = 21686381794875901264921303819775850606785172748503700974135282319021418270312;

uint256 constant IC4x = 21477343731350881336427671728879526073055001513676414044100634074555163654487;
uint256 constant IC4y = 975839980071906751516077094474212502568600329809457289967004593943814041533;
uint256 constant IC4x = 1802657464311138049888005009951146706506829170163571227091060253925154095179;
uint256 constant IC4y = 6464223263536811410457882731522205111712402908223512049836366029568020386091;

uint256 constant IC5x = 10745395673337059701699795673419720732231823654131369713589820865994307217089;
uint256 constant IC5y = 991956397633440927392694166348862131981180374714009247953939276179698863313;
uint256 constant IC5x = 19683038061393177247346161878002523504516242525587093858171051169964965175309;
uint256 constant IC5y = 11941559534567530881898628022677745180708901756040014021900468886305142561737;

uint256 constant IC6x = 1672993394090581484120407360563051967903199184399912366269853108749767520052;
uint256 constant IC6y = 2164345873917124991571819758981721198425688586574947724181752888003788143824;
uint256 constant IC6x = 15831016304560225046433682948470755223605261989966252819923716158997718599877;
uint256 constant IC6y = 10152669751914951883087310745426443490134580294923111749465612194458531720480;

uint256 constant IC7x = 12851905556792884689855342999140438817587827047283740173600609203898826077791;
uint256 constant IC7y = 2928106356023086030701978715110626259062951617739902988557680022327927922648;
uint256 constant IC7x = 9223895744540988597347383517954906051269131434601393127779914476155588638987;
uint256 constant IC7y = 4057097817924275113774337560125840582168668507218738756759091312261450180548;

uint256 constant IC8x = 1706366517711033642836339515106072692739807158278497001454479300738236232683;
uint256 constant IC8y = 16700903182897452990475040323204325018874215917926885692984146211640664248939;
uint256 constant IC8x = 21887069730271477339395447000828431935392336781494270340838992528947889565081;
uint256 constant IC8y = 2844201003524278672997973600529290000831521001613305325326949178045719277021;

uint256 constant IC9x = 19101508791113451928961082481025527911094003843281774332989233416940984939257;
uint256 constant IC9y = 21697565471392202731806697866311578445068434145060675485941899096932688363780;
uint256 constant IC9x = 4808414835523320523628320681520047895479955081528791196030370521667222450937;
uint256 constant IC9y = 7797923313705195871120077961543496501027976338844390403835230583395399970416;

uint256 constant IC10x = 19730275336196180738068616492761799716598666564420842355043346059462631887595;
uint256 constant IC10y = 16685285536790785249111663346085181130998577327076396224848784078816064185361;
uint256 constant IC10x = 16211172993626747621391823991207229208028328331008628770505605774793950633700;
uint256 constant IC10y = 1746841007064125740967254557870472532226722619400114330227028935555178320068;

uint256 constant IC11x = 7617913501130858003386168099320868449737268059133253154619134544472248055105;
uint256 constant IC11y = 7972962376779726951865679647174563612838286095297842951560535589126110704430;
uint256 constant IC11x = 16227183149439187186179102228002824287668616602328858751082873976570526170116;
uint256 constant IC11y = 9130539427162880676961016387612035890807345274623521216630692667632198253838;

uint256 constant IC12x = 12544403142863928402358237586570057011271857580491825726062907284786959213913;
uint256 constant IC12y = 6822386508465769764381472926650183520080357052212751223638195245287957269971;
uint256 constant IC12x = 21716508817418550410875346202260448235027234519728647013970503004924891373972;
uint256 constant IC12y = 17548855966889182106362129512160022419387113158178611749412734874189761681682;

uint256 constant IC13x = 18940507486165234508918415676788929441013178061873512240392411069614035082362;
uint256 constant IC13y = 16781396210596043591429632308560467689975084335009897683626466396650016291114;
uint256 constant IC13x = 4196241592017627542929377456411216126324404517576014546207377205111904423400;
uint256 constant IC13y = 15225817043451991271351666619621568203461001025671068346305503483918132477767;

uint256 constant IC14x = 558712144346877070501655608109394614280454755351878785357769476496746188097;
uint256 constant IC14y = 11446848258088708077539993154875274206911247468515662688034438075323420564863;
uint256 constant IC14x = 19892615000249065498152255196451223590291375775646942741981105696311293768977;
uint256 constant IC14y = 8090737511599560169511450830471484005709823693720459500304471799924206103331;

uint256 constant IC15x = 8663346001839375986622551340093804693770355108507981331683176599016183492970;
uint256 constant IC15y = 16427003456838313815469615381585105215654274650877521404992073085959518425353;


// Memory data
Expand All @@ -95,7 +98,7 @@ contract Groth16Verifier_AnonEnc {

uint16 constant pLastMem = 896;

function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[14] calldata _pubSignals) public view returns (bool) {
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[15] calldata _pubSignals) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
Expand Down Expand Up @@ -167,6 +170,8 @@ contract Groth16Verifier_AnonEnc {

g1_mulAccC(_pVk, IC14x, IC14y, calldataload(add(pubSignals, 416)))

g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))


// -A
mstore(_pPairing, calldataload(pA))
Expand Down Expand Up @@ -250,6 +255,8 @@ contract Groth16Verifier_AnonEnc {

checkField(calldataload(add(_pubSignals, 448)))

checkField(calldataload(add(_pubSignals, 480)))


// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
Expand Down
Loading

0 comments on commit 63979e9

Please sign in to comment.