Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion contracts/contracts/tests/TestSelfVerificationRoot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ contract TestSelfVerificationRoot is SelfVerificationRoot {
ISelfVerificationRoot.GenericDiscloseOutputV2 public lastOutput;
bytes public lastUserData;
SelfStructs.VerificationConfigV2 public verificationConfig;
bytes32 public verificationConfigId;

// Events for testing
event VerificationCompleted(ISelfVerificationRoot.GenericDiscloseOutputV2 output, bytes userData);
Expand Down Expand Up @@ -87,12 +88,16 @@ contract TestSelfVerificationRoot is SelfVerificationRoot {
verificationConfig = config;
}

function setConfigId(bytes32 configId) external {
verificationConfigId = configId;
}

function getConfigId(
bytes32 destinationChainId,
bytes32 userIdentifier,
bytes memory userDefinedData
) public view override returns (bytes32) {
return _identityVerificationHubV2.generateConfigId(verificationConfig);
return verificationConfigId;
}

/**
Expand Down
133 changes: 67 additions & 66 deletions contracts/contracts/verifiers/disclose/Verifier_vc_and_disclose.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,104 +22,101 @@ pragma solidity >=0.7.0 <0.9.0;

contract Verifier_vc_and_disclose {
// Scalar field size
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
uint256 constant r = 21888242871839275222246405745257275088548364400416034343698204186575808495617;
// Base field size
uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;

// Verification Key data
uint256 constant alphax = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant alphax = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
uint256 constant deltax1 = 4208242267248789053828092105678707152810727302421704805417689166806500057546;
uint256 constant deltax2 = 5271221976433221763304741528380840580903119658570165237480182570804501659558;
uint256 constant deltay1 = 11327385974519668968032322736085307141713806429709421661182708424466117238997;
uint256 constant deltay2 = 10012305292867396754099447814288164358641801402945324446509796861150789568449;
uint256 constant deltax1 = 5795368240936503596335549456158425883051420682995876933341852062275599013650;
uint256 constant deltax2 = 12938463399522443086457477933600092669254764041774786514417181251292512660714;
uint256 constant deltay1 = 12540010325641881371116121450209835663869183125485844650454127657458562657135;
uint256 constant deltay2 = 5745831082153426833961839903205936221609761549734057076333858241059465478539;
Comment on lines +25 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

❓ Verification inconclusive

Critical: Verify the updated cryptographic constants are correct.

The verification key constants (scalar/base field sizes, alpha, beta, delta points) have been updated with new values. These constants are critical for the security and correctness of zero-knowledge proof verification.

Ensure these constants were generated by a trusted setup ceremony and match the expected circuit configuration.


🏁 Script executed:

#!/bin/bash
# Verify the cryptographic constants format and basic validation
echo "Checking field sizes..."
r_value="21888242871839275222246405745257275088548364400416034343698204186575808495617"
q_value="21888242871839275222246405745257275088696311157297823662689037894645226208583"

# These should be the BN254 curve parameters
echo "Scalar field (r): $r_value"
echo "Base field (q): $q_value"

# Check if the constants are within the valid field ranges
python3 << EOF
r = $r_value
q = $q_value

# Verify these are the correct BN254 parameters
expected_r = 21888242871839275222246405745257275088548364400416034343698204186575808495617
expected_q = 21888242871839275222246405745257275088696311157297823662689037894645226208583

print(f"r matches BN254 scalar field: {r == expected_r}")
print(f"q matches BN254 base field: {q == expected_q}")
EOF

Length of output: 708


Critical: Verify the updated cryptographic constants are correct.

The verification key constants (scalar/base field sizes, alpha, beta, delta points) have been updated with new values. These constants are critical for the security and correctness of zero-knowledge proof verification.

#!/bin/bash
# Verify the cryptographic constants format and basic validation
echo "Checking field sizes..."
r_value="21888242871839275222246405745257275088548364400416034343698204186575808495617"
q_value="21888242871839275222246405745257275088696311157297823662689037894645226208583"

# These should be the BN254 curve parameters
echo "Scalar field (r): $r_value"
echo "Base field (q): $q_value"

# Check if the constants are within the valid field ranges
python3 << EOF
r = $r_value
q = $q_value

# Verify these are the correct BN254 parameters
expected_r = 21888242871839275222246405745257275088548364400416034343698204186575808495617
expected_q = 21888242871839275222246405745257275088696311157297823662689037894645226208583

print(f"r matches BN254 scalar field: {r == expected_r}")
print(f"q matches BN254 base field: {q == expected_q}")
EOF

Ensure these constants were generated by a trusted setup ceremony and match the expected circuit configuration.

🤖 Prompt for AI Agents
In contracts/contracts/verifiers/disclose/Verifier_vc_and_disclose.sol between
lines 25 and 43, the cryptographic constants for the verification key have been
updated. You need to verify that these constants exactly match the expected
BN254 curve parameters and were generated by a trusted setup ceremony. To fix
this, cross-check each constant against the official trusted setup values for
the circuit you are using, confirm the scalar field (r) and base field (q)
values are correct, and ensure all alpha, beta, gamma, and delta points
correspond to the verified trusted setup data before merging.


uint256 constant IC0x = 5645809423132108234526155064520926563161700247800213537205723921444703247217;
uint256 constant IC0y = 19273662370473753554670561090991166814029325379251212873103161241607581584566;

uint256 constant IC1x = 1797669655256453130371220220781770764170539267531220862021381942885591828064;
uint256 constant IC1y = 7001586812758904198735882543207168343594801214486108350714954778228545102578;
uint256 constant IC0x = 1327643666632315025512187418817023630780563184758021455663314119872437463145;
uint256 constant IC0y = 2622893971724901828914047259052067392447274440848954417614321746778812751881;

uint256 constant IC2x = 16151498656936517849109903512557528108224465357388552905088955276567940069352;
uint256 constant IC2y = 21290383973737261995392203381388245229530591066391887542266051339172122980610;
uint256 constant IC1x = 20927011517723457008102782318397010921983294435880612972153120487747261995333;
uint256 constant IC1y = 18649509350577586920402079427241751583571095028055506078542019996865511703564;

uint256 constant IC3x = 13594306613618663328469180492848909213054943576045786330757072453957461211429;
uint256 constant IC3y = 17106191422608317011071228510210313119098258902423951406450677354622457559954;
uint256 constant IC2x = 18223545039205454783148203870836982137410477518180720119480480153635557174304;
uint256 constant IC2y = 14354250107099459449970545617224325946145147040253960693477698870437037762909;

uint256 constant IC4x = 10540562137042439306820327362182488961461252811713311037793556389563213988367;
uint256 constant IC4y = 13390475227407915257414653696902926958379562466610252657969000491800379839832;
uint256 constant IC3x = 2173758372018833803307650315845499838285851237592930252028174525580546546212;
uint256 constant IC3y = 11484957593605555554581664590508364277322965026091620635584632890824112335330;

uint256 constant IC5x = 14047770242565207987849727178067237797960577221760083987091292937338321362192;
uint256 constant IC5y = 4607949095956681151208754684340954434065140599773002127904735754740923457290;
uint256 constant IC4x = 7157190044841716686091632308502737011979099809606870421939953854408747856731;
uint256 constant IC4y = 18315602217937620885107757034463661543707738397425161578650110819142660670372;

uint256 constant IC6x = 533605635141604091468837890450980097899976907187175033882725759869648895139;
uint256 constant IC6y = 5121343922882143859016572020277997629769211588320816684559275427523086391260;
uint256 constant IC5x = 6260667805546381923858902471892397126243269313854577708606218376521908362565;
uint256 constant IC5y = 13716486493605237311926465265255870345358784266311689841198776426559442954137;

uint256 constant IC7x = 20950810023595074636645188401126777396931698429970632510329364260508114254649;
uint256 constant IC7y = 15363004416976419598006096303962722739509622870059250392680729963552585027821;
uint256 constant IC6x = 18606363599559637061941956230491916987222537133370229590923171484462919701227;
uint256 constant IC6y = 2433361506657306508828144447793032310343955443449067717401403184301651823995;

uint256 constant IC8x = 21141369375300299590026264437282327654307650673045833038665014396619386405360;
uint256 constant IC8y = 13568060724977289928853639950012597657294256347073414147013319159524409681097;
uint256 constant IC7x = 19280866248824868201853947527606978917049858969164646547147582117900910165818;
uint256 constant IC7y = 12004989744914315761708669577255110696291165332282234776831447906508334174065;

uint256 constant IC9x = 12070388761580959399164669209709461362321643934983690375125147552128464963953;
uint256 constant IC9y = 13122752493285998578654222539640165097582774244857666169217998263040175338511;
uint256 constant IC8x = 9499667142250207864939084997366463919158967968217947947452929384485105655483;
uint256 constant IC8y = 7934640485738501605809283862245180894070081349952179321671898117937450554978;

uint256 constant IC10x = 3155043394395334396684505740101602478801121319174204325455833353483450426603;
uint256 constant IC10y = 4001903316495741471727515697485538626849994288595198286197670853000376952608;
uint256 constant IC9x = 20248101600931458686357220379631192702866178668147896841612695942649039306904;
uint256 constant IC9y = 17146962363094782772160475831653226068881596057834124050728488367347134754895;

uint256 constant IC11x = 11580817845413390940484294910470637940735781669534450285058891649231298055438;
uint256 constant IC11y = 11745932694467884175811632165252866594271326601859010100723177984958589451650;
uint256 constant IC10x = 7698102871102525311081154517506621927872860404243843030208612865041171291679;
uint256 constant IC10y = 17451440288940059901172619610591057928798945050984287918189963973980684490936;

uint256 constant IC12x = 2881070016945796223001080172114503185514285867729144217331063554991484954126;
uint256 constant IC12y = 14167304337176286668786874852785788018624401891816801704956527547500195848883;
uint256 constant IC11x = 15522722806663355688859428499986250804296589439746832906847538630162245728449;
uint256 constant IC11y = 17731443422876322849401673846065881492578186542336670047706150379276239434736;

uint256 constant IC13x = 18883405056778717265600091502443498671078474036444505009504491224347768060512;
uint256 constant IC13y = 14812978301212555409657902542346841425786957827465950093762300162318026670295;
uint256 constant IC12x = 12339816027317431982064382456180166106960325372245286406655416854868988899703;
uint256 constant IC12y = 1623004256251937705099896843572191766950534593682479744120770181852683481461;

uint256 constant IC14x = 6577157458950343654298030929658788314638268827611749219037795310784295524862;
uint256 constant IC14y = 8429244719525290744211189219610479430815666050697340325468837559505312383856;
uint256 constant IC13x = 16216101416188390585624804230286907502888542435957249996363202481890837436823;
uint256 constant IC13y = 19792033164136600401729520568052979301967100486751550563922332851674279231879;

uint256 constant IC15x = 16374040167465027877148927308323868423523506482577951143585975183285308096400;
uint256 constant IC15y = 19848062855727074979497070827222518475377208981773894131613945308293152037386;
uint256 constant IC14x = 9526823787561424517694409522408689943116198117932113165892430928752383410927;
uint256 constant IC14y = 15425544394205620802764497690404474607132882651029664273449118268473325168573;

uint256 constant IC16x = 5369066939278676378968646518060321291123419641615507226693819438606229259727;
uint256 constant IC16y = 16729550092204417517172374565729920596490405185877796985933449527255634235308;
uint256 constant IC15x = 21379552168442334118192987128570335250484225781188878794769111112730685255680;
uint256 constant IC15y = 11413252397601154464320301772186050681727031323285046472485957139652053961337;

uint256 constant IC17x = 14649963317278229594447647740414141466603479012579221101904384047636220514768;
uint256 constant IC17y = 14247491789479084970737272226075028063019925997471420682570205007884944759477;
uint256 constant IC16x = 20428162085801543636385155875246864224732967575559765504978908153515749149989;
uint256 constant IC16y = 18815283633327124443616880398781266901051625797588830712455957697615424697685;

uint256 constant IC18x = 11902572680644837317532839083230381253517912078611490650871537384207738042092;
uint256 constant IC18y = 20016771317149607035640286896673339585314902815531231665552693497445627584165;
uint256 constant IC17x = 14469038019687287252080675455019765736968071520512741147009183358330281848192;
uint256 constant IC17y = 2254410426995330112169610023372576019626185925041252653212723256001596932807;

uint256 constant IC19x = 13662298766996950339241997202544532479906071787308616133742838930447382591478;
uint256 constant IC19y = 20739438792451670425639845258461859578645504245239453508387345820702014104428;
uint256 constant IC18x = 6646738351527040290587708010640343681780304778150763218965087230163505094741;
uint256 constant IC18y = 7224595387826330922504236191632797623787710821043271778727414843835083051307;

uint256 constant IC20x = 11743378744218879600087835709388165328591499404152675849147563493614332998904;
uint256 constant IC20y = 4541034768018638352186080395830990298417361588467317129716290912950603785160;
uint256 constant IC19x = 13930005350988118664410913458609814475220380700610122956318720762892362913810;
uint256 constant IC19y = 1510210795288547564147036133366552832970234430196908175239728458476685653344;

uint256 constant IC20x = 19395101085598768787243131602792145650244700025278061861975309911987787383833;
uint256 constant IC20y = 19593647464319651444688400549955086154512565325512427576174534610645336455682;

uint256 constant IC21x = 6877461228082443111890464295830127588035564773913061145705260000890224419695;
uint256 constant IC21y = 13729662662934324858332564018609296055385187918293000684588750857191114304504;

uint256 constant IC21x = 11482551398584236834849590479781862497389279604940066814152820783286286153167;
uint256 constant IC21y = 12585642819692696296358219602072676911890723261269077558436703827603489236308;

// Memory data
uint16 constant pVk = 0;
uint16 constant pPairing = 128;

uint16 constant pLastMem = 896;

function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[21] calldata _pubSignals
) public view returns (bool) {
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[21] calldata _pubSignals) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
Expand Down Expand Up @@ -205,6 +202,7 @@ contract Verifier_vc_and_disclose {

g1_mulAccC(_pVk, IC21x, IC21y, calldataload(add(pubSignals, 640)))


// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
Expand All @@ -229,6 +227,7 @@ contract Verifier_vc_and_disclose {
mstore(add(_pPairing, 384), mload(add(pMem, pVk)))
mstore(add(_pPairing, 416), mload(add(pMem, add(pVk, 32))))


// gamma2
mstore(add(_pPairing, 448), gammax1)
mstore(add(_pPairing, 480), gammax2)
Expand All @@ -245,6 +244,7 @@ contract Verifier_vc_and_disclose {
mstore(add(_pPairing, 704), deltay1)
mstore(add(_pPairing, 736), deltay2)


let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)

isOk := and(success, mload(_pPairing))
Expand Down Expand Up @@ -297,11 +297,12 @@ contract Verifier_vc_and_disclose {

checkField(calldataload(add(_pubSignals, 640)))


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

mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}
2 changes: 1 addition & 1 deletion contracts/error-selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,4 @@
"file": "contracts/IdentityVerificationHubImplV2.sol",
"line": 106
}
]
]
7 changes: 1 addition & 6 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ const config: HardhatUserConfig = {
},
},
etherscan: {
apiKey: {
sepolia: process.env.ETHERSCAN_API_KEY as string,
ethereum: process.env.ETHERSCAN_API_KEY as string,
celo: process.env.CELOSCAN_API_KEY as string,
alfajores: process.env.CELOSCAN_API_KEY as string,
},
apiKey: process.env.CELOSCAN_API_KEY as string,
customChains: [
{
network: "celo",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
"DeployAllVerifiers#Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1": "0xCab0632d19d387218d68b026e9b1A62f2C0866dA",
"DeployAllVerifiers#Verifier_register_sha512_sha512_sha512_rsa_65537_4096": "0xFad583ccE9B8Ff9131eA09308E423C6A16b255b0",
"DeployAllVerifiers#Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048": "0xA3d7F6c891DaF8e036c92c92Df174c9E3a390f86",
"DeployAllVerifiers#Verifier_vc_and_disclose": "0x34e0d12F100e8fBaFb3d7c2605c53684a38bA3dD",
"DeployAllVerifiers#Verifier_vc_and_disclose": "0xddC2376F60F79b19e1C43297E481CeB551330076",
"DeployAllVerifiers#Verifier_vc_and_disclose_id": "0xC59B0E8525DedF2D64CA8f60c930279c871Aa3cc",
"UpdateRegistryHubV2#IdentityRegistryIdCardImplV1": "0xF77Be82318F11392Efb5F1062D954911d6086537",
"UpdateRegistryHubV2#IdentityRegistryImplV1": "0xE1A05bbee7D8DF2ee2A81dEE8FB22e07B07D1084",
"DeployAllVerifiers#Verifier_register_id_sha256_sha256_sha256_rsa_65537_4096": "0x05D1043F88aeA207f5a450597c5ABA8cCe8Dc874"
}
5 changes: 3 additions & 2 deletions contracts/ignition/modules/deployTestSelfVerificationRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
export default buildModule("DeployTestSelfVerificationRoot", (m) => {
const identityVerificationHubV2Address = m.getParameter(
"identityVerificationHubV2Address",
"0x3e2487a250e2A7b56c7ef5307Fb591Cc8C83623D",
"0x68c931C9a534D37aa78094877F46fE46a49F1A51",
);
const scopeValue = m.getParameter("scopeValue", 12345);

console.log("identityVerificationHubV2Address", identityVerificationHubV2Address);
console.log("scopeValue", scopeValue);
const testSelfVerificationRoot = m.contract("TestSelfVerificationRoot", [
identityVerificationHubV2Address,
scopeValue,
Expand Down
Loading