Skip to content

Commit

Permalink
quick bl update
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvolear committed Apr 5, 2024
1 parent 0559276 commit 24467ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 12 additions & 4 deletions contracts/registration/Registration.sol
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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);
Expand Down Expand Up @@ -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_));
}
Expand Down
5 changes: 1 addition & 4 deletions deploy/1_setup.migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 24467ce

Please sign in to comment.