mirror of
https://github.com/getwax/wax.git
synced 2026-01-08 22:57:58 -05:00
anon-aadhaar version bump & fixed verifier
This commit is contained in:
@@ -15,8 +15,9 @@
|
||||
"devDependencies": {
|
||||
"@account-abstraction/contracts": "0.7.0",
|
||||
"@account-abstraction/utils": "^0.6.0",
|
||||
"@anon-aadhaar/contracts": "^2.0.3",
|
||||
"@anon-aadhaar/core": "^2.0.3",
|
||||
"@anon-aadhaar/contracts": "2.2.0",
|
||||
"@anon-aadhaar/core": "2.2.0",
|
||||
"@zk-email/helpers": "^6.1.1",
|
||||
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
|
||||
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
||||
@@ -33,7 +34,7 @@
|
||||
"@typescript-eslint/eslint-plugin": ">=6.0.0",
|
||||
"@typescript-eslint/parser": ">=6.0.0",
|
||||
"chai": "^4.2.0",
|
||||
"circomlibjs": "0.1.1",
|
||||
"circomlibjs": "0.1.7",
|
||||
"dotenv": "^16.3.1",
|
||||
"eslint": ">=8.0.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
@@ -51,4 +52,4 @@
|
||||
"typechain": "^8.1.0",
|
||||
"typescript": "^5.4.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ contract SafeAnonAadhaarFactory {
|
||||
address owner,
|
||||
uint256 saltNonce,
|
||||
address _anonAadhaarAddr,
|
||||
uint _userDataHash
|
||||
uint256 _userDataHash
|
||||
) external returns (SafeAnonAadhaarPlugin) {
|
||||
bytes32 salt = keccak256(abi.encodePacked(owner, saltNonce));
|
||||
|
||||
@@ -35,6 +35,7 @@ contract SafeAnonAadhaarFactory {
|
||||
SafeAnonAadhaarPlugin plugin = new SafeAnonAadhaarPlugin{salt: salt}(
|
||||
address(entryPoint),
|
||||
_anonAadhaarAddr,
|
||||
address(safe),
|
||||
_userDataHash
|
||||
);
|
||||
|
||||
@@ -42,7 +43,10 @@ contract SafeAnonAadhaarFactory {
|
||||
owners,
|
||||
1,
|
||||
address(plugin),
|
||||
abi.encodeCall(SafeAnonAadhaarPlugin.enableMyself, (owner)),
|
||||
abi.encodeCall(
|
||||
SafeAnonAadhaarPlugin.enableMyself,
|
||||
(owner, _userDataHash)
|
||||
),
|
||||
address(plugin),
|
||||
address(0),
|
||||
0,
|
||||
|
||||
@@ -5,7 +5,7 @@ pragma abicoder v2;
|
||||
import {Safe4337Base, SIG_VALIDATION_FAILED} from "./utils/Safe4337Base.sol";
|
||||
import {IEntryPoint, PackedUserOperation} from "account-abstraction/interfaces/IEntryPoint.sol";
|
||||
import {PackedUserOperation} from "account-abstraction/interfaces/IEntryPoint.sol";
|
||||
import {IAnonAadhaar} from "./utils/anonAadhaar/interfaces/IAnonAadhaar.sol";
|
||||
import {IAnonAadhaar} from "@anon-aadhaar/contracts/interfaces/IAnonAadhaar.sol";
|
||||
|
||||
interface ISafe {
|
||||
function enableModule(address module) external;
|
||||
@@ -20,6 +20,7 @@ interface ISafe {
|
||||
|
||||
struct AnonAadhaarOwnerStorage {
|
||||
address owner;
|
||||
uint256 userDataHash; // the hash of unique and private user data extracted from Aadhaar QR code
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
@@ -27,6 +28,8 @@ struct AnonAadhaarOwnerStorage {
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
// Should be made possible to enable this if not the last mapping
|
||||
// mapping(address => mapping(uint => bool)) public signalNullifiers;
|
||||
mapping(address => AnonAadhaarOwnerStorage) public anonAadhaarOwnerStorage;
|
||||
|
||||
address public immutable myAddress; // Module address
|
||||
@@ -34,18 +37,12 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
|
||||
address internal constant _SENTINEL_MODULES = address(0x1);
|
||||
|
||||
// Note: the following state variables `anonAadhaarAddr` and `userDataHash` are set to immutable
|
||||
// to immutable to bypass invalid storage access error and make it accessible via delegatecall.
|
||||
// And `signalNullifiers` is currently unused as it can't be immutable.
|
||||
|
||||
// external contract managed by Anon Aadhaar with verifyAnonAadhaarProof() method
|
||||
// set to immutable to bypass invalid storage access error and make it accessible via delegatecall.
|
||||
address public immutable anonAadhaarAddr;
|
||||
|
||||
// the hash of unique and private user data extracted from Aadhaar QR code
|
||||
uint public immutable userDataHash;
|
||||
|
||||
// nullifier for each signal(userOpHash) to prevent on-chain front-running
|
||||
mapping(uint => bool) public signalNullifiers;
|
||||
// mapping(uint => bool) public signalNullifiers;
|
||||
|
||||
event OWNER_UPDATED(
|
||||
address indexed safe,
|
||||
@@ -56,18 +53,25 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
constructor(
|
||||
address entryPointAddress,
|
||||
address _anonAadhaarAddr,
|
||||
uint _userDataHash
|
||||
address _safe,
|
||||
uint256 _userDataHash
|
||||
) {
|
||||
myAddress = address(this);
|
||||
_entryPoint = entryPointAddress;
|
||||
anonAadhaarAddr = _anonAadhaarAddr;
|
||||
userDataHash = _userDataHash;
|
||||
anonAadhaarOwnerStorage[_safe].userDataHash = _userDataHash;
|
||||
}
|
||||
|
||||
function getOwner(address safe) external view returns (address owner) {
|
||||
owner = anonAadhaarOwnerStorage[safe].owner;
|
||||
}
|
||||
|
||||
function getUserDataHash(
|
||||
address safe
|
||||
) external view returns (uint userDataHash) {
|
||||
userDataHash = anonAadhaarOwnerStorage[safe].userDataHash;
|
||||
}
|
||||
|
||||
function execTransaction(
|
||||
address to,
|
||||
uint256 value,
|
||||
@@ -85,14 +89,14 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
require(success, "tx failed");
|
||||
}
|
||||
|
||||
function enableMyself(address ownerKey) public {
|
||||
function enableMyself(address ownerKey, uint256 userDataHash) public {
|
||||
// Called during safe setup as a delegatecall. This is why we use `this`
|
||||
// to refer to the safe instead of `msg.sender` / _currentSafe().
|
||||
|
||||
ISafe(address(this)).enableModule(myAddress);
|
||||
|
||||
// Enable the safe address with the defined key
|
||||
bytes memory _data = abi.encodePacked(ownerKey);
|
||||
// bytes memory _data = abi.encodePacked(ownerKey, userDataHash);
|
||||
bytes memory _data = abi.encode(ownerKey, userDataHash);
|
||||
SafeAnonAadhaarPlugin(myAddress).enable(_data);
|
||||
}
|
||||
|
||||
@@ -101,9 +105,14 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
}
|
||||
|
||||
function enable(bytes calldata _data) external payable {
|
||||
address newOwner = address(bytes20(_data[0:20]));
|
||||
// address newOwner = address(bytes20(_data[0:20]));
|
||||
(address newOwner, uint256 userDataHash) = abi.decode(
|
||||
_data,
|
||||
(address, uint)
|
||||
);
|
||||
address oldOwner = anonAadhaarOwnerStorage[msg.sender].owner;
|
||||
anonAadhaarOwnerStorage[msg.sender].owner = newOwner;
|
||||
anonAadhaarOwnerStorage[msg.sender].userDataHash = userDataHash;
|
||||
emit OWNER_UPDATED(msg.sender, oldOwner, newOwner);
|
||||
}
|
||||
|
||||
@@ -120,9 +129,9 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
) internal view override returns (uint256 validationData) {
|
||||
// decode proof verification params
|
||||
(
|
||||
uint nullifierSeed,
|
||||
uint timestamp,
|
||||
uint signal,
|
||||
uint256 nullifierSeed,
|
||||
uint256 timestamp,
|
||||
uint256 signal,
|
||||
uint[4] memory revealArray,
|
||||
uint[8] memory groth16Proof
|
||||
) = abi.decode(userOp.signature, (uint, uint, uint, uint[4], uint[8]));
|
||||
@@ -141,7 +150,7 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
if (
|
||||
!IAnonAadhaar(anonAadhaarAddr).verifyAnonAadhaarProof(
|
||||
nullifierSeed,
|
||||
userDataHash,
|
||||
anonAadhaarOwnerStorage[userOp.sender].userDataHash,
|
||||
timestamp,
|
||||
signal,
|
||||
revealArray,
|
||||
@@ -151,7 +160,7 @@ contract SafeAnonAadhaarPlugin is Safe4337Base {
|
||||
return SIG_VALIDATION_FAILED;
|
||||
}
|
||||
|
||||
// signalNullifiers[signal] = true; // store nullifier
|
||||
// signalNullifiers[userOp.sender][signal] = true; // store nullifier
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//SPDX-License-Identifier: Unlicense
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "./interfaces/IAnonAadhaarGroth16Verifier.sol";
|
||||
import "./interfaces/IAnonAadhaar.sol";
|
||||
import "@anon-aadhaar/contracts/interfaces/IAnonAadhaarGroth16Verifier.sol";
|
||||
import "@anon-aadhaar/contracts/interfaces/IAnonAadhaar.sol";
|
||||
|
||||
// Note: This is a AnonAadhaar contract with a modification that made`verifier` state variable immutable
|
||||
// so that verification doesn't fail due to invalid storage access.
|
||||
// https://github.com/anon-aadhaar/anon-aadhaar/blob/main/packages/contracts/src/AnonAadhaar.sol
|
||||
// Note: This is a AnonAadhaar contract with modifications, where `verifier` and `storedPublicKeyHash` are not mutable
|
||||
// so that verification doesn't fail due to invalid storage access
|
||||
|
||||
contract AnonAadhaar is IAnonAadhaar {
|
||||
address public immutable verifier;
|
||||
@@ -72,6 +72,6 @@ contract AnonAadhaar is IAnonAadhaar {
|
||||
/// @param message: Message to be hashed.
|
||||
/// @return Message digest.
|
||||
function _hash(uint256 message) private pure returns (uint256) {
|
||||
return uint256(keccak256(abi.encodePacked(message))) >> 8;
|
||||
return uint256(keccak256(abi.encodePacked(message))) >> 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
along with snarkJS. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// https://github.com/anon-aadhaar/anon-aadhaar/blob/main/packages/contracts/src/Verifier.sol
|
||||
// Note: This Verifier contract has slight modifications that replace
|
||||
// `sub(gas(), 2000)` with `gas()` in each elliptic curve precompiles
|
||||
// so that it doesn't fail due to invalid opcode: the use of GAS
|
||||
|
||||
pragma solidity >=0.7.0 <0.9.0;
|
||||
|
||||
contract Verifier {
|
||||
@@ -55,63 +50,63 @@ contract Verifier {
|
||||
uint256 constant gammay2 =
|
||||
8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
||||
uint256 constant deltax1 =
|
||||
6071654364864117822716107678715164059368627655003446090945989955304467149837;
|
||||
4299544762320140490788925402007646552975895862668459356441621010020815213047;
|
||||
uint256 constant deltax2 =
|
||||
13072340564387245197081358962854142189492579581726328392485837679318594883337;
|
||||
17871422848268104931114959135211373177342070617197528523406495979941661483095;
|
||||
uint256 constant deltay1 =
|
||||
16129185200821936946192616352115510872942769319488962175576366786927733342036;
|
||||
15409138591596798216491700390363405976448424349216823319603684880497172470392;
|
||||
uint256 constant deltay2 =
|
||||
9836457315723936304363664004692049268022671903565158357714875289404248646887;
|
||||
6760351807715958749139905882704408015750124381329342019530380383696940656228;
|
||||
|
||||
uint256 constant IC0x =
|
||||
433034494523434914838102899254531846355204811401746992363532148649453851856;
|
||||
8193099715697298773004274364923775437331207408810138294417049334729397568044;
|
||||
uint256 constant IC0y =
|
||||
16185574754751233049810707218299416895262406359332203380500058501402789092067;
|
||||
16159858748150857247889758127444994458965923852898118281816624376217211565521;
|
||||
|
||||
uint256 constant IC1x =
|
||||
21179290673531710816687977342442120864089027091423249719403961326728385126112;
|
||||
13108625264357966313259920811838652543870024141705807775281772752705667110553;
|
||||
uint256 constant IC1y =
|
||||
21685817308918906303962846527488982719733648919047127372368322998248408686255;
|
||||
2544332662962865223088426787295310199726639257423304707272531378194627250471;
|
||||
|
||||
uint256 constant IC2x =
|
||||
16100345601521557134194855549484898410417807824858064135652678289345593201927;
|
||||
12195716830305360975540216000332921077692646069403551236428029555879142592435;
|
||||
uint256 constant IC2y =
|
||||
15869267152111393688788798630241758050473907203620223106987984095328251916473;
|
||||
13326636634666739773620233113286098727293935511084177100928164174534804438393;
|
||||
|
||||
uint256 constant IC3x =
|
||||
3661100149498521668411736359067392242407918494756591190087645099587667381975;
|
||||
2688577362875587400781907970343221084288450779702134055253900789420295472719;
|
||||
uint256 constant IC3y =
|
||||
5532193562576932112972421444049102557989670390519012070371880238868149535842;
|
||||
2113388700188757742720394931373303194111138693822901565764110433637094759188;
|
||||
|
||||
uint256 constant IC4x =
|
||||
15814298253537154024860920042546391625869188476066246152054757278826188069206;
|
||||
19945525246931746661643582268635665599397781283994833186263056491807948286051;
|
||||
uint256 constant IC4y =
|
||||
329319601839229691290147591339045066663286618419843056627123245234969319813;
|
||||
16073805640677310775936718905838964579449451142346916951664145755535936866626;
|
||||
|
||||
uint256 constant IC5x =
|
||||
13122061734022923252145656969204117801566730463244754086040826478704381808829;
|
||||
15285986370760482985887872526745945510369406463801327538950916850999926460800;
|
||||
uint256 constant IC5y =
|
||||
5051423751245794332768923801879261853063836733804734167893836203571890589014;
|
||||
11338735502852181248738133285261397537982982234234692816858010242555671562990;
|
||||
|
||||
uint256 constant IC6x =
|
||||
5695352610426489934721399411472928171685138239743965011184726148703568464482;
|
||||
16599939912082694861350909874825011692719127627200428021965770460961325896451;
|
||||
uint256 constant IC6y =
|
||||
19017397729221116094927376031010535791774099897418232523304761570408659474050;
|
||||
2023372250411688527623252878305455588947803700538403282505116393326811329911;
|
||||
|
||||
uint256 constant IC7x =
|
||||
20257142077231484125759557782723901546054059679085015952389946335748432164034;
|
||||
937704650640100783774452178387730049849091986214664695849468839894667227986;
|
||||
uint256 constant IC7y =
|
||||
19824425651126428710541555737047577915043071440220796465355399011013568905190;
|
||||
1528238522480536593837231193324408021036867916082543038928582346279983380311;
|
||||
|
||||
uint256 constant IC8x =
|
||||
14323907968731727282177352381162840302516308415708544090376415098456091244895;
|
||||
20307194658033847757064139044228229338386028222602331026142092196761205728977;
|
||||
uint256 constant IC8y =
|
||||
15548900963703170140527630250333660897322677891626101360609254760914596318310;
|
||||
20906962585416997063272305175664219300089590012260266224825000463561652784804;
|
||||
|
||||
uint256 constant IC9x =
|
||||
8644550155122380458782935101189632949180134684837399409015079657415766761673;
|
||||
765061429630449224592522816482257405186943062678395274581816041425416367436;
|
||||
uint256 constant IC9y =
|
||||
8313064741271336560028609756676039614638525915857937834013902691432501510836;
|
||||
2812008994701470589234587891573790293274884176359538091522378449656962019510;
|
||||
|
||||
// Memory data
|
||||
uint16 constant pVk = 0;
|
||||
@@ -127,7 +122,7 @@ contract Verifier {
|
||||
) public view returns (bool) {
|
||||
assembly {
|
||||
function checkField(v) {
|
||||
if iszero(lt(v, q)) {
|
||||
if iszero(lt(v, r)) {
|
||||
mstore(0, 0)
|
||||
return(0, 0x20)
|
||||
}
|
||||
@@ -141,6 +136,7 @@ contract Verifier {
|
||||
mstore(add(mIn, 32), y)
|
||||
mstore(add(mIn, 64), s)
|
||||
|
||||
// `sub(gas(), 2000` replaced with `gas()` to avoid invalid opcode usage
|
||||
// success := staticcall(sub(gas(), 2000), 7, mIn, 96, mIn, 64)
|
||||
success := staticcall(gas(), 7, mIn, 96, mIn, 64)
|
||||
|
||||
@@ -152,6 +148,7 @@ contract Verifier {
|
||||
mstore(add(mIn, 64), mload(pR))
|
||||
mstore(add(mIn, 96), mload(add(pR, 32)))
|
||||
|
||||
// `sub(gas(), 2000` replaced with `gas()` to avoid invalid opcode usage
|
||||
// success := staticcall(sub(gas(), 2000), 6, mIn, 128, pR, 64)
|
||||
success := staticcall(gas(), 6, mIn, 128, pR, 64)
|
||||
|
||||
@@ -231,17 +228,10 @@ contract Verifier {
|
||||
mstore(add(_pPairing, 704), deltay1)
|
||||
mstore(add(_pPairing, 736), deltay2)
|
||||
|
||||
// let success := staticcall(
|
||||
// sub(gas(), 2000),
|
||||
// 8,
|
||||
// _pPairing,
|
||||
// 768,
|
||||
// _pPairing,
|
||||
// 0x20
|
||||
// )
|
||||
// `sub(gas(), 2000` replaced with `gas()` to avoid invalid opcode usage
|
||||
// let success := staticcall(sub(gas(), 2000), 8, _pPairing, 768, _pPairing, 0x20)
|
||||
let success := staticcall(
|
||||
gas(),
|
||||
not(0),
|
||||
8,
|
||||
_pPairing,
|
||||
768,
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
interface IAnonAadhaar {
|
||||
function verifyAnonAadhaarProof(
|
||||
uint nullifierSeed,
|
||||
uint nullifier,
|
||||
uint timestamp,
|
||||
uint signal,
|
||||
uint[4] memory revealArray,
|
||||
uint[8] memory groth16Proof
|
||||
) external view returns (bool);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
interface IAnonAadhaarGroth16Verifier {
|
||||
function verifyProof(
|
||||
uint[2] calldata _pA,
|
||||
uint[2][2] calldata _pB,
|
||||
uint[2] calldata _pC,
|
||||
uint[9] calldata publicInputs
|
||||
) external view returns (bool);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/comma-dangle */
|
||||
/* eslint-disable prettier/prettier */
|
||||
import { expect } from "chai";
|
||||
import { JsonRpcProvider, NonceManager, Signer, ethers } from "ethers";
|
||||
import DeterministicDeployer from "../../lib-ts/deterministic-deployer/DeterministicDeployer";
|
||||
@@ -7,6 +9,7 @@ import {
|
||||
Verifier__factory,
|
||||
AnonAadhaar__factory,
|
||||
Safe,
|
||||
AnonAadhaar,
|
||||
} from "../../typechain-types";
|
||||
import receiptOf from "./utils/receiptOf";
|
||||
import { setupTests } from "./utils/setupTests";
|
||||
@@ -22,6 +25,7 @@ import {
|
||||
artifactUrls,
|
||||
packGroth16Proof,
|
||||
ArtifactsOrigin,
|
||||
verify,
|
||||
} from "@anon-aadhaar/core";
|
||||
import fs from "fs";
|
||||
import { getUserOpHash } from "./utils/userOpUtils";
|
||||
@@ -54,6 +58,7 @@ describe("SafeAnonAadhaarPlugin", () => {
|
||||
|
||||
let certificate: string;
|
||||
let anonAadhaarAddress: string;
|
||||
let anonAadhaar: AnonAadhaar;
|
||||
|
||||
before(async () => {
|
||||
const setup = await setupTests();
|
||||
@@ -73,7 +78,7 @@ describe("SafeAnonAadhaarPlugin", () => {
|
||||
const anonAadhaarVerifier = await new Verifier__factory(signer).deploy();
|
||||
|
||||
// Deploy AnonAadhaar contract
|
||||
const anonAadhaar = await new AnonAadhaar__factory(signer).deploy(
|
||||
anonAadhaar = await new AnonAadhaar__factory(signer).deploy(
|
||||
await anonAadhaarVerifier.getAddress(),
|
||||
BigInt(testPublicKeyHash).toString()
|
||||
);
|
||||
|
||||
@@ -20,4 +20,4 @@ YMW7uRmnajfEd0MzfrXIUKBwCeWTCyP/bcdlJOT4u24ngFnkUyWaEKnqH3YuI8cw
|
||||
BKWQ26Lq7ODq6e6Otxf0KOtWTeVSzlCL66MGBvQ36LF1g8PLEZ9hvvX06ieaE99W
|
||||
HDK9/pGSuobx6Fi7ufzqymirT/GOuxslquB4mleCu4ArCg2qAVC2wDjQymgvq8FS
|
||||
bVukYnC6XdwqYhvIuTPnEys4gGdeirY+UPGQeqxMrNm+ZpKPTS0NwzxHwlhutw==
|
||||
-----END CERTIFICATE-----
|
||||
-----END CERTIFICATE-----
|
||||
@@ -1,16 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/comma-dangle */
|
||||
/* eslint-disable @typescript-eslint/prefer-for-of */
|
||||
/* eslint-disable prettier/prettier */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import {
|
||||
convertBigIntToByteArray,
|
||||
decompressByteArray,
|
||||
extractPhoto,
|
||||
} from "@anon-aadhaar/core";
|
||||
import { sha256Pad } from "@zk-email/helpers/dist/sha-utils";
|
||||
import { buildPoseidon } from "circomlibjs";
|
||||
|
||||
// Method to extract a nullifier specific to each Aadhaar ID owner from Aadhaar QR code
|
||||
@@ -19,11 +12,15 @@ export async function copmuteUserNullifier(
|
||||
nullifierSeed: number,
|
||||
qrData: string
|
||||
): Promise<bigint> {
|
||||
const QRDataBytes = convertBigIntToByteArray(BigInt(qrData));
|
||||
const QRDataDecode = decompressByteArray(QRDataBytes);
|
||||
const signedData = QRDataDecode.slice(0, QRDataDecode.length - 256);
|
||||
const qrDataBytes = convertBigIntToByteArray(BigInt(qrData));
|
||||
const decodedData = decompressByteArray(qrDataBytes);
|
||||
const signedData = decodedData.slice(0, decodedData.length - 256);
|
||||
const [qrDataPadded, qrDataPaddedLen] = sha256Pad(signedData, 512 * 3);
|
||||
|
||||
const { bytes: photoBytes } = extractPhoto(Array.from(signedData));
|
||||
const { bytes: photoBytes } = extractPhoto(
|
||||
Array.from(qrDataPadded),
|
||||
qrDataPaddedLen
|
||||
);
|
||||
|
||||
const photoBytesPacked = padArrayWithZeros(
|
||||
bytesToIntChunks(new Uint8Array(photoBytes), 31),
|
||||
|
||||
@@ -211,8 +211,10 @@ export const createAnonAadhaarOperation = async (
|
||||
factoryData: undefined,
|
||||
callData: userOpCallData,
|
||||
callGasLimit: ethers.toBeHex(150000n),
|
||||
verificationGasLimit: ethers.toBeHex(1000000n),
|
||||
preVerificationGas: ethers.toBeHex(200000n),
|
||||
// verificationGasLimit: ethers.toBeHex(1000000n),
|
||||
// preVerificationGas: ethers.toBeHex(200000n),
|
||||
verificationGasLimit: ethers.toBeHex(1500000n),
|
||||
preVerificationGas: ethers.toBeHex(500000n),
|
||||
maxFeePerGas,
|
||||
maxPriorityFeePerGas,
|
||||
signature: "0x",
|
||||
|
||||
@@ -42,21 +42,21 @@
|
||||
resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069"
|
||||
integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==
|
||||
|
||||
"@anon-aadhaar/contracts@^2.0.3":
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@anon-aadhaar/contracts/-/contracts-2.0.3.tgz#ab7e2b5b2209d41465df7148f90c27224f46ffdb"
|
||||
integrity sha512-7Eqq7vdEDWcMy0tn5GWKk3uMntrnGztVBgve+ppuRqgZ1m2hol5OnDo9GTPe3eGfwaDiPY+11iQW9Xu8GIerSA==
|
||||
"@anon-aadhaar/contracts@2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@anon-aadhaar/contracts/-/contracts-2.2.0.tgz#028c3257a7721152a0b90cdc73408dd4403bcdcb"
|
||||
integrity sha512-sqrpK1KHPB/py1/3rE8dYDjTMMMhS4QwTk3S9aPd+iFeAeY0S7r9tu+StQK2x7UICKNzOV1TzIsWHLinrXEIRQ==
|
||||
|
||||
"@anon-aadhaar/core@^2.0.3":
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@anon-aadhaar/core/-/core-2.0.3.tgz#23b17f6687c7712579cfb8052aea7995093659a4"
|
||||
integrity sha512-8TLaRxuOiFoVf8Q6ipK2sduUlqpsWVfzWFsVz7Bai4XHnSUCF4rA0rksfQlB6bvugosE9OekzZA9BESE7NtDhQ==
|
||||
"@anon-aadhaar/core@2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@anon-aadhaar/core/-/core-2.2.0.tgz#d63ff8495f40f7418bced534c01fd2e650a8c2a3"
|
||||
integrity sha512-3WhZxksWFE0xaPsd9sn2KHM8PLLEbkqJgdS2jXkkV5U4jKNUAHU3dY0xXJrr58E89gtAXMdfrcb1AR1DD1pKlA==
|
||||
dependencies:
|
||||
"@pcd/pcd-types" "^0.10.0"
|
||||
"@pcd/tsconfig" "^0.6.0"
|
||||
"@types/node-forge" "^1.3.8"
|
||||
"@types/snarkjs" "^0.7.6"
|
||||
"@zk-email/helpers" "^3.1.3"
|
||||
"@zk-email/helpers" "^6.1.1"
|
||||
buffer "^6.0.3"
|
||||
json-bigint "^1.0.0"
|
||||
localforage "^1.10.0"
|
||||
@@ -1369,20 +1369,18 @@
|
||||
"@uniswap/v3-core" "^1.0.0"
|
||||
base64-sol "1.0.1"
|
||||
|
||||
"@zk-email/helpers@^3.1.3":
|
||||
version "3.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@zk-email/helpers/-/helpers-3.2.3.tgz#a31aa06f6fc97938cc6ae766233febb1f477298e"
|
||||
integrity sha512-jhHqRqnCkwg6a2k3OkNRUd99sO7zkG/H/Pd/HL4PHhtS17Lqby/btOu0W3y7AX7wWn13xhNdonjuMEsISYRpQg==
|
||||
"@zk-email/helpers@^6.1.1":
|
||||
version "6.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@zk-email/helpers/-/helpers-6.1.3.tgz#d763050757ff6a96c3973a00e0751a6710ca089f"
|
||||
integrity sha512-UVnd33qJGO1seisIfhIo5m5gMalmU2y0S5wLCwAO8h2TZ6YBWJnmSKy2KeY5qVxPZn+WschnKEbW23Em7cj5QA==
|
||||
dependencies:
|
||||
addressparser "^1.0.1"
|
||||
atob "^2.1.2"
|
||||
circomlibjs "^0.1.7"
|
||||
libmime "^5.2.1"
|
||||
localforage "^1.10.0"
|
||||
lodash "^4.17.21"
|
||||
node-forge "^1.3.1"
|
||||
pako "^2.1.0"
|
||||
pki "^1.1.0"
|
||||
psl "^1.9.0"
|
||||
snarkjs "https://github.com/sampritipanda/snarkjs.git#fef81fc51d17a734637555c6edbd585ecda02d9e"
|
||||
|
||||
@@ -2146,16 +2144,6 @@ circomlib@2.0.5:
|
||||
resolved "https://registry.npmjs.org/circomlib/-/circomlib-2.0.5.tgz#183c703e53ed7d011811842dbeeeb9819f4cc1d6"
|
||||
integrity sha512-O7NQ8OS+J4eshBuoy36z/TwQU0YHw8W3zxZcs4hVwpEll3e4hDm3mgkIPqItN8FDeLEKZFK3YeT/+k8TiLF3/A==
|
||||
|
||||
circomlibjs@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/circomlibjs/-/circomlibjs-0.1.1.tgz#00085017f6fa00072a13a2092f643cfd12b11f6b"
|
||||
integrity sha512-Bl7Mylf/VERdI5bRTIQ4hpi2EgbfIvEyJrn/MPh2pEqScbCkatX44RF8fuNGigoiQGdhItaIikgHKLTdlPPLPQ==
|
||||
dependencies:
|
||||
blake-hash "^2.0.0"
|
||||
blake2b "^2.1.3"
|
||||
ethers "^5.5.1"
|
||||
ffjavascript "^0.2.45"
|
||||
|
||||
circomlibjs@0.1.7, circomlibjs@^0.1.7:
|
||||
version "0.1.7"
|
||||
resolved "https://registry.npmjs.org/circomlibjs/-/circomlibjs-0.1.7.tgz#9f5a7d9a23323744b11ee456b05b0cd81f48b554"
|
||||
@@ -5415,11 +5403,6 @@ pify@^4.0.1:
|
||||
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
|
||||
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
|
||||
|
||||
pki@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/pki/-/pki-1.1.0.tgz#abd7c257816ceb2a0c0afef5642180227355d173"
|
||||
integrity sha512-OzMMXAo8sI7X3+EW46eIfGfOnuM0d0Cef0iVp7UUCsh2VV7RvsUztLTc6xacBwgsz16Vp6qQuQA8Lep5bxeuOA==
|
||||
|
||||
postcss-value-parser@^4.0.2:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514"
|
||||
|
||||
Reference in New Issue
Block a user