From 24467cec7048bb22ed5189a050da400adaaa6bf4 Mon Sep 17 00:00:00 2001 From: Artem Chystiakov Date: Fri, 5 Apr 2024 13:35:02 +0300 Subject: [PATCH] quick bl update --- contracts/registration/Registration.sol | 16 ++++++++++++---- deploy/1_setup.migration.ts | 5 +---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/contracts/registration/Registration.sol b/contracts/registration/Registration.sol index b0481f3..90d2221 100644 --- a/contracts/registration/Registration.sol +++ b/contracts/registration/Registration.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.16; -import {PoseidonUnit1L, PoseidonUnit2L, PoseidonUnit5L} from "@iden3/contracts/lib/Poseidon.sol"; +import {PoseidonUnit1L, PoseidonUnit2L, PoseidonUnit3L, PoseidonUnit5L} from "@iden3/contracts/lib/Poseidon.sol"; import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; @@ -23,6 +23,9 @@ contract Registration is PoseidonSMT, Initializable { mapping(bytes32 => bytes32) public hashedRSAKeyToInternalKey; mapping(bytes32 => bytes32) public internalKeyToHashedRSAKey; + mapping(bytes32 => uint256) public passportIdentitiesCounter; + mapping(bytes32 => uint256) public identityCreationTimestamps; + mapping(bytes32 => bool) internal _usedSignatures; event Registered(bytes32 hashedRSAKey, bytes32 hashedInternalKey); @@ -78,14 +81,19 @@ contract Registration is PoseidonSMT, Initializable { require(verifier.verifyProof(pubSignals_, zkPoints_), "Registration: invalid zk proof"); - uint256 index_ = PoseidonUnit2L.poseidon([hashedRSAKey_, hashedInternalKey_]); - _usedSignatures[sigHash_] = true; hashedRSAKeyToInternalKey[bytes32(hashedRSAKey_)] = bytes32(hashedInternalKey_); internalKeyToHashedRSAKey[bytes32(hashedInternalKey_)] = bytes32(hashedRSAKey_); - _add(bytes32(index_), bytes32(PoseidonUnit2L.poseidon([index_, group1Hash_]))); + identityCreationTimestamps[bytes32(hashedInternalKey_)] = block.timestamp; + + uint256 index_ = PoseidonUnit2L.poseidon([hashedRSAKey_, hashedInternalKey_]); + uint256 value_ = PoseidonUnit3L.poseidon( + [group1Hash_, passportIdentitiesCounter[bytes32(hashedRSAKey_)], block.timestamp] + ); + + _add(bytes32(index_), bytes32(value_)); emit Registered(bytes32(hashedRSAKey_), bytes32(hashedInternalKey_)); } diff --git a/deploy/1_setup.migration.ts b/deploy/1_setup.migration.ts index 32250d3..6c21f44 100644 --- a/deploy/1_setup.migration.ts +++ b/deploy/1_setup.migration.ts @@ -8,10 +8,7 @@ const treeHeight = 80; const icaoMasterTreeMerkleRoot = "0x2c50ce3aa92bc3dd0351a89970b02630415547ea83c487befbc8b1795ea90c45"; export = async (deployer: Deployer) => { - await deployPoseidons( - deployer, - new Array(6).fill(6).map((_, i) => i + 1), - ); + await deployPoseidons(deployer, [2, 3, 5]); const registration = await deployer.deploy(Registration__factory); const registrationVerifier = await deployer.deploy(RegistrationVerifier__factory);