Files
self/contracts/ignition/modules/upgrade/deployNewHubAndUpgrade.ts
Nesopie e77247f372 Feat/kyc (#1623)
* feat: selfrica circuit and tests

* chore: remove unused code

* feat: test for ofac,date and olderthan

* fix: public signal constant

* feat: add contract tests

* feat: helper function to gen TEE input

* feat: gen circuit inputs with signature

* feat: seralized base64

* fix: DateIsLessFullYear componenet

* feat: register circuit for selfrica

* feat: selfrica disclose circuit and test

* fix: common module error

* feat: add more test and fix constant

* fix: commitment calculation

* feat: selfrica contracts

* test: selfrica register using unified circuit

* feat: register persona and selfrica circuit

* feat: selfrica circuit and tests

* chore: remove unused code

* feat: test for ofac,date and olderthan

* fix: public signal constant

* feat: add contract tests

* feat: helper function to gen TEE input

* feat: gen circuit inputs with signature

* feat: seralized base64

* fix: DateIsLessFullYear componenet

* feat: register circuit for selfrica

* feat: selfrica disclose circuit and test

* fix: common module error

* feat: add more test and fix constant

* fix: commitment calculation

* feat: selfrica contracts

* test: selfrica register using unified circuit

* feat: register persona and selfrica circuit

* refactor: contract size reduction for IdentityVerificationHubImplV2

export function logic to external libs, reduce compiler runs to 200, update deploy scripts to link new libs

* feat: disclose circuit for persona

* feat: update  persona ofac trees

* feat; register circuit for selfper

* feat: disclose test for selfper

* chore: refactor

* chore : remove unused circuits

* chore: rename selfper to kyc

* chore: update comments

* feat: constrain s to be 251 bit

* feat: add range check on majority ASCII and comments

* feat: range check on neg_r_inv

* chore: remove is pk zero constrain

* merge dev

* feat: add registerPubkey function to Selfrica with GCPJWT Verification

* test: add testing for GCPJWT verification on Selfrica

* fix: script that calls register_selfrica circuits (ptau:14 -> ptau:15)

* fix: get remaining Selfrica tests working with proper import paths

* refactor: store pubkeys as string

also add some comment code for registerPubkey function

* refactor: remove registerPubkeyCommitment function

some tests now skipped as awaiting changes to how pubkeys are stored (string instead of uint256)

* feat: use hex decoding for the pubkey commitment

* test: adjust tests for pubkey being string again

* fix: remove old references to registerPubkey

* docs: add full natspec for IdentityRegistrySelfricaImplV1

* docs: update files in rest of the repo for Selfrica attestation type

* test: fix broken tests

* fix: builds and move to kyc from selfrica

* fix: constrain r_inv, Rx, s, T

* feat: eddsa

* feat: add onlyTEE check to registerPubkeyCommitment

onlyOwner is able to change onlyTEE

* refactor: update gcpRootCAPubkeyHash to be changeable by owner

* feat: add events for update functions

* style: move functions to be near other similar functions

* fix: kyc happy flow

* fix: all contract tests passing

| fix: timestamp conversion with Date(), migrate to V2 for endToEnd test, scope formatting, fix register aadhaar issue by using block.timestamp instead of Date.now(), fix changed getter function name, enable MockGCPJWTVerifier with updated file paths, add missing LeanIMT import, fix user identifier format

* audit: bind key offset-value offset and ensure image_digest only occurs once in the payload

* fix: constrain bracket

* chore: update comment

* audit: hardcode attestation id

* audit: make sure R and pubkey are on the curve

* audit: ensure pubkey is within bounds

* fix: all contract tests passing

* feat: change max length to 99 from 74

* audit: don't check sha256 padding

* audit: check the last window as well

* audit: single occurance for eat_nonce and image_digest

* audit: check if the certs are expired

* audit: add the timestamp check to the contract

* audit: make sure the person is less than 255 years of age

* audit fixes

* chore: yarn.lock

* fix: build fixes

* fix: aadhaar timestamp

* lint

* fix: types

* format

---------

Co-authored-by: vishal <vishalkoolkarni0045@gmail.com>
Co-authored-by: Evi Nova <tranquil_flow@protonmail.com>
2026-01-19 15:54:37 +05:30

65 lines
2.5 KiB
TypeScript

import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
import { artifacts, ethers } from "hardhat";
import hre from "hardhat";
import { readFileSync } from "fs";
import path from "path";
function getHubImplV2InitializeData() {
const hubArtifact = artifacts.readArtifactSync("IdentityVerificationHubImplV2");
return new ethers.Interface(hubArtifact.abi);
}
export default buildModule("DeployNewHubAndUpgradee", (m) => {
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(readFileSync(deployedAddressesPath, "utf8"));
const hubProxyAddress = deployedAddresses["DeployHubV2#IdentityVerificationHub"];
if (!hubProxyAddress) {
throw new Error("Hub proxy address not found in deployed_addresses.json");
}
// Deploy all required libraries
const customVerifier = m.library("CustomVerifier");
const outputFormatterLib = m.library("OutputFormatterLib");
const proofVerifierLib = m.library("ProofVerifierLib");
const registerProofVerifierLib = m.library("RegisterProofVerifierLib");
const dscProofVerifierLib = m.library("DscProofVerifierLib");
const rootCheckLib = m.library("RootCheckLib");
const ofacCheckLib = m.library("OfacCheckLib");
// Deploy new implementation with all library linkages
const identityVerificationHubImplV2 = m.contract("IdentityVerificationHubImplV2", [], {
libraries: {
CustomVerifier: customVerifier,
OutputFormatterLib: outputFormatterLib,
ProofVerifierLib: proofVerifierLib,
RegisterProofVerifierLib: registerProofVerifierLib,
DscProofVerifierLib: dscProofVerifierLib,
RootCheckLib: rootCheckLib,
OfacCheckLib: ofacCheckLib,
},
});
// Get the interface to encode the initialize function call
const hubInterface = getHubImplV2InitializeData();
// The V2 initialize function takes no parameters (unlike V1)
// It automatically sets circuit version to 2 and emits HubInitializedV2 event
const initializeData = hubInterface.encodeFunctionData("initialize", []);
const hubProxy = m.contractAt("IdentityVerificationHubImplV2", hubProxyAddress, { id: "IdentityVerificationHubV2" });
const a = m.call(hubProxy, "upgradeToAndCall", [identityVerificationHubImplV2, initializeData], {
after: [identityVerificationHubImplV2],
});
m.call(hubProxy, "setAadhaarRegistrationWindow", [120], { after: [a] });
return {
identityVerificationHubImplV2,
hubProxy,
};
});