Feature/add prettier formatter (#568)

* Add Prettier configuration and ignore files for code formatting

- Created .prettierignore to exclude specific directories and files from formatting.
- Added .prettierrc.yml with custom settings for print width and trailing commas.
- Updated package.json to include Prettier and its Solidity plugin as dependencies, along with scripts for formatting and checking code.

* Run prettier formatting
This commit is contained in:
Kevin Lin
2025-05-23 14:52:59 +08:00
committed by GitHub
parent 5fa10dba79
commit 5a3bd28e7b
162 changed files with 12328 additions and 15107 deletions

17
contracts/.prettierignore Normal file
View File

@@ -0,0 +1,17 @@
# directories
broadcast
cache
coverage
node_modules
out
# files
*.env
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock

View File

@@ -0,0 +1,8 @@
printWidth: 120
trailingComma: "all"
overrides:
- files: "*.md"
options:
proseWrap: "always"
plugins:
- prettier-plugin-solidity

View File

@@ -7,11 +7,14 @@ This is the implementation of contracts for verification and management of ident
## ⚠Cautions⚠
When you do the upgrade, be careful with this storage patterns
- You can not change the order in which the contract state variables are declared, nor their type.
Pls see this page for more details: https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable#modifying-your-contracts
Pls see this page for more details:
https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable#modifying-your-contracts
## Integration Guide
In the npm package, you'll find the following directory structure:
```bash
@@ -37,53 +40,60 @@ In the npm package, you'll find the following directory structure:
If you want to integrate SelfVerificationRoot.sol into your contract, you should also import these files.
```solidity
import {SelfVerificationRoot} from "@selfxyz/contracts/contracts/abstract/SelfVerificationRoot.sol";
import { SelfVerificationRoot } from "@selfxyz/contracts/contracts/abstract/SelfVerificationRoot.sol";
import {IVcAndDiscloseCircuitVerifier} from "@selfxyz/contracts/contracts/interfaces/IVcAndDiscloseCircuitVerifier.sol";
import {
IVcAndDiscloseCircuitVerifier
} from "@selfxyz/contracts/contracts/interfaces/IVcAndDiscloseCircuitVerifier.sol";
import {IIdentityVerificationHubV1} from "@selfxyz/contracts/contracts/interfaces/IIdentityVerificationHubV1.sol";
import { IIdentityVerificationHubV1 } from "@selfxyz/contracts/contracts/interfaces/IIdentityVerificationHubV1.sol";
import {CircuitConstants} from "@selfxyz/contracts/contracts/constants/CircuitConstants.sol";
import { CircuitConstants } from "@selfxyz/contracts/contracts/constants/CircuitConstants.sol";
```
And override verifySelfProof function and write your own logic.
You can take a look at these examples.
And override verifySelfProof function and write your own logic. You can take a look at these examples.
- [Airdrop](https://github.com/selfxyz/self/blob/main/contracts/contracts/example/Airdrop.sol)
- [HappyBirthday](https://github.com/selfxyz/happy-birthday/blob/main/contracts/contracts/HappyBirthday.sol)
In the verifySelfProof function, you should add these validations
- Mandatory
- scope validation
- attestation id validation
- scope validation
- attestation id validation
- Optional
- nullifier validation
- user id validation
- age verification with olderThan
- forbidden countries validation
- ofac validation
- nullifier validation
- user id validation
- age verification with olderThan
- forbidden countries validation
- ofac validation
Also, if you want to play with some attributes in the passport, you should import these libraries.
``` solidity
import {CircuitAttributeHandler} from "@selfxyz/contracts/contracts/libraries/CircuitAttributeHandler.sol";
import {Formatter} from "@selfxyz/contracts/contracts/libraries/Formatter.sol";
```solidity
import { CircuitAttributeHandler } from "@selfxyz/contracts/contracts/libraries/CircuitAttributeHandler.sol";
import { Formatter } from "@selfxyz/contracts/contracts/libraries/Formatter.sol";
```
CircuitAttributeHandler is the library to extract readable attributes in the passport from public signals.
The formatter is responsible for converting other data included in the public signals.
Use it when you want to validate information related to birthdays or the time when the proof was generated.
CircuitAttributeHandler is the library to extract readable attributes in the passport from public signals. The formatter
is responsible for converting other data included in the public signals. Use it when you want to validate information
related to birthdays or the time when the proof was generated.
As an example, please refer to the following contract.
- [HappyBirthday](https://github.com/selfxyz/happy-birthday/blob/main/contracts/contracts/HappyBirthday.sol)
- [getReadableRevealedData function in the hub contract](https://github.com/selfxyz/self/blob/bdcf9537b01570b2197ae378815adbcc9c8747e8/contracts/contracts/IdentityVerificationHubImplV1.sol#L313-L357)
## Building Contracts
1. Install dependencies:
```bash
yarn install
```
2. Compile the contracts:
```bash
yarn run compile
```
@@ -91,21 +101,25 @@ yarn run compile
## Deployments
1. Deploy verifiers
```bash
yarn run deploy:allverifiers:celo
```
2. Deploy registry proxy and impl
```bash
yarn run deploy:registry:celo
```
3. Deploy hub proxy and impl
```bash
yarn run deploy:hub:celo
```
4. Update csca, ofac and hub address in registry
```bash
yarn run update:cscaroot:celo
yarn run update:ofacroot:celo
@@ -115,11 +129,11 @@ yarn run update:hub:celo
## Testing
When you compile the circuits, make sure you set the build flag to true for these circuits:
- register_sha256_sha256_sha256_rsa_65537_4096
- dsc_sha256_rsa_65537_4096
- vc_and_disclose
Go to ../circuits/scripts/build/ and change false to true for these circuits.
Then you can run the following command to see the coverage.
- vc_and_disclose Go to ../circuits/scripts/build/ and change false to true for these circuits. Then you can run the
following command to see the coverage.
```shell
cd ../circuits
@@ -130,45 +144,45 @@ yarn run test:coverage:local
## Deployed Contract Addresses
| Contract | Address |
|----------|---------|
| Verifier_dsc_sha1_ecdsa_brainpoolP256r1 | 0xE7B4A70fc1d96D3Fb6577206c932eF1e634Cf2d0 |
| Verifier_dsc_sha1_rsa_65537_4096 | 0x19E25a5772df0D7D6Db59D94a4d6FBd7098a3012 |
| Verifier_dsc_sha256_ecdsa_brainpoolP256r1 | 0x1F3afAe85992B1B8CF6946B091225dAF8307675d |
| Verifier_dsc_sha256_ecdsa_brainpoolP384r1 | 0x52A6EF39655D662A8Cf8eB56CD853883fe43eb2b |
| Verifier_dsc_sha256_ecdsa_secp256r1 | 0x643735Cd44F8b2BDa47b4a7962c8BDf12E6CDdf8 |
| Verifier_dsc_sha256_ecdsa_secp384r1 | 0x00F0D1A32Def293DAB78100A6569ebb4EC035F82 |
| Verifier_dsc_sha256_rsa_65537_4096 | 0x711e655c43410fB985c4EDB48E9bCBdDb770368d |
| Verifier_dsc_sha256_rsapss_3_32_3072 | 0xDAFF470e561F3f96C7410AeF02196913E981fF1B |
| Verifier_dsc_sha256_rsapss_65537_32_3072 | 0x07B6C2FFB098B131eAD104396d399177014ae15f |
| Verifier_dsc_sha256_rsapss_65537_32_4096 | 0xFBDDADb864b24B2c4336081A22f41D04E7b35DA9 |
| Verifier_dsc_sha384_ecdsa_brainpoolP384r1 | 0x6a40dfa6f99FA178aB6cc88928Bf30661e917A76 |
| Verifier_dsc_sha384_ecdsa_secp384r1 | 0x1719430107E66717d8b34d4190838dfABAf810e6 |
| Verifier_dsc_sha512_rsa_65537_4096 | 0xf5eE920d6D50a8A83C22f548bf406fCBcD558751 |
| Verifier_dsc_sha512_rsapss_65537_64_4096 | 0x5438C4ebFD8Fcce6eb54542e3A5C192B22227f70 |
| Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 | 0x8588e473428cf415F10AC96CAa701F6Cd1C8641F |
| Verifier_register_sha1_sha1_sha1_rsa_65537_4096 | 0x15fd0d58cfF9DaA4A60105c0DAC73659530BB7f7 |
| Verifier_register_sha1_sha256_sha256_rsa_65537_4096 | 0xaC5166A01Aee75A10703177896122F4d6e3836d1 |
| Contract | Address |
| ------------------------------------------------------------ | ------------------------------------------ |
| Verifier_dsc_sha1_ecdsa_brainpoolP256r1 | 0xE7B4A70fc1d96D3Fb6577206c932eF1e634Cf2d0 |
| Verifier_dsc_sha1_rsa_65537_4096 | 0x19E25a5772df0D7D6Db59D94a4d6FBd7098a3012 |
| Verifier_dsc_sha256_ecdsa_brainpoolP256r1 | 0x1F3afAe85992B1B8CF6946B091225dAF8307675d |
| Verifier_dsc_sha256_ecdsa_brainpoolP384r1 | 0x52A6EF39655D662A8Cf8eB56CD853883fe43eb2b |
| Verifier_dsc_sha256_ecdsa_secp256r1 | 0x643735Cd44F8b2BDa47b4a7962c8BDf12E6CDdf8 |
| Verifier_dsc_sha256_ecdsa_secp384r1 | 0x00F0D1A32Def293DAB78100A6569ebb4EC035F82 |
| Verifier_dsc_sha256_rsa_65537_4096 | 0x711e655c43410fB985c4EDB48E9bCBdDb770368d |
| Verifier_dsc_sha256_rsapss_3_32_3072 | 0xDAFF470e561F3f96C7410AeF02196913E981fF1B |
| Verifier_dsc_sha256_rsapss_65537_32_3072 | 0x07B6C2FFB098B131eAD104396d399177014ae15f |
| Verifier_dsc_sha256_rsapss_65537_32_4096 | 0xFBDDADb864b24B2c4336081A22f41D04E7b35DA9 |
| Verifier_dsc_sha384_ecdsa_brainpoolP384r1 | 0x6a40dfa6f99FA178aB6cc88928Bf30661e917A76 |
| Verifier_dsc_sha384_ecdsa_secp384r1 | 0x1719430107E66717d8b34d4190838dfABAf810e6 |
| Verifier_dsc_sha512_rsa_65537_4096 | 0xf5eE920d6D50a8A83C22f548bf406fCBcD558751 |
| Verifier_dsc_sha512_rsapss_65537_64_4096 | 0x5438C4ebFD8Fcce6eb54542e3A5C192B22227f70 |
| Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 | 0x8588e473428cf415F10AC96CAa701F6Cd1C8641F |
| Verifier_register_sha1_sha1_sha1_rsa_65537_4096 | 0x15fd0d58cfF9DaA4A60105c0DAC73659530BB7f7 |
| Verifier_register_sha1_sha256_sha256_rsa_65537_4096 | 0xaC5166A01Aee75A10703177896122F4d6e3836d1 |
| Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 | 0x7d9b7D2A95541b50CECDB44d82c0570a818111Ac |
| Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 | 0x48cEc90de8d746efD316968Ea65417e74C6A1a74 |
| Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 | 0x48cEc90de8d746efD316968Ea65417e74C6A1a74 |
| Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 | 0x9C5Af0FC9A32b457e300905929A05356D3C0DB25 |
| Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 | 0x5286E20745A0d4C35E6D97832D56e30A28303BD6 |
| Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 | 0xaC861bf9FC8B44ccbAde8E2A39C851bbCf38c392 |
| Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 | 0x03FCc979cf2d69275647095E4079A3389F24525D |
| Verifier_register_sha256_sha256_sha256_rsa_3_4096 | 0xbE036B26317F013D2c6cB092Aa1fa903220be846 |
| Verifier_register_sha256_sha256_sha256_rsa_65537_4096 | 0xE80537B3399bd405e40136D08e24c250397c09F1 |
| Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 | 0xe063BD3188341B2D17d96cE38FD31584147d3219 |
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 | 0xe93Be9382868f30150cAF77793aF384905c2C7E4 |
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 | 0xD39E5eAfb6d266E3c4AC8255578F23a514fd8B36 |
| Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 | 0xaC861bf9FC8B44ccbAde8E2A39C851bbCf38c392 |
| Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 | 0x03FCc979cf2d69275647095E4079A3389F24525D |
| Verifier_register_sha256_sha256_sha256_rsa_3_4096 | 0xbE036B26317F013D2c6cB092Aa1fa903220be846 |
| Verifier_register_sha256_sha256_sha256_rsa_65537_4096 | 0xE80537B3399bd405e40136D08e24c250397c09F1 |
| Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 | 0xe063BD3188341B2D17d96cE38FD31584147d3219 |
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 | 0xe93Be9382868f30150cAF77793aF384905c2C7E4 |
| Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 | 0xD39E5eAfb6d266E3c4AC8255578F23a514fd8B36 |
| Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 | 0xd2F65a76A10f5E0e7aE9d18826ab463f4CEb33C9 |
| Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 | 0xC33E6A04b7296A3062Cf438C33dc8D8157c3916d |
| Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 | 0xa7A5A581C2Eb8dF39f486e9ABBc4898546D70C3e |
| Verifier_register_sha512_sha512_sha512_rsa_65537_4096 | 0x6C88A6Afc38cA2859e157532b1b872EcC1ED0424 |
| Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 | 0x04A1D0d51Bc078CB137088424b2ec569699dd7A5 |
| Verifier_vc_and_disclose | 0x44d314c2F9b3690735808d26d17dFCc9F906A9B4 |
| PoseidonT3 | 0xF134707a4C4a3a76b8410fC0294d620A7c341581 |
| IdentityRegistryImplV1 | 0xC473d5F784e424A70Bf7aCf887E33448E64F8798 |
| IdentityRegistry | 0x37F5CB8cB1f6B00aa768D8aA99F1A9289802A968 |
| IdentityVerificationHubImplV1 | 0x85FD004B2312a6703F1ce293242Dc15B719772b1 |
| IdentityVerificationHub | 0x77117D60eaB7C044e785D68edB6C7E0e134970Ea |
| VerifyAll | 0xe6D61680A6ED381bb5A0dB5cF4E9Cc933cF43915 |
| Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 | 0xC33E6A04b7296A3062Cf438C33dc8D8157c3916d |
| Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 | 0xa7A5A581C2Eb8dF39f486e9ABBc4898546D70C3e |
| Verifier_register_sha512_sha512_sha512_rsa_65537_4096 | 0x6C88A6Afc38cA2859e157532b1b872EcC1ED0424 |
| Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 | 0x04A1D0d51Bc078CB137088424b2ec569699dd7A5 |
| Verifier_vc_and_disclose | 0x44d314c2F9b3690735808d26d17dFCc9F906A9B4 |
| PoseidonT3 | 0xF134707a4C4a3a76b8410fC0294d620A7c341581 |
| IdentityRegistryImplV1 | 0xC473d5F784e424A70Bf7aCf887E33448E64F8798 |
| IdentityRegistry | 0x37F5CB8cB1f6B00aa768D8aA99F1A9289802A968 |
| IdentityVerificationHubImplV1 | 0x85FD004B2312a6703F1ce293242Dc15B719772b1 |
| IdentityVerificationHub | 0x77117D60eaB7C044e785D68edB6C7E0e134970Ea |
| VerifyAll | 0xe6D61680A6ED381bb5A0dB5cF4E9Cc933cF43915 |

View File

@@ -45,9 +45,7 @@ import {ImplRoot} from "./upgradeable/ImplRoot.sol";
* @notice Storage contract for IdentityVerificationHubImplV1.
* @dev Inherits from ImplRoot to include upgradeability functionality.
*/
abstract contract IdentityVerificationHubStorageV1 is
ImplRoot
{
abstract contract IdentityVerificationHubStorageV1 is ImplRoot {
// ====================================================
// Storage Variables
// ====================================================
@@ -70,10 +68,7 @@ abstract contract IdentityVerificationHubStorageV1 is
* @notice Implementation contract for the Identity Verification Hub.
* @dev Provides functions for registering commitments and verifying groth16 proofs and inclusion proofs.
*/
contract IdentityVerificationHubImplV1 is
IdentityVerificationHubStorageV1,
IIdentityVerificationHubV1
{
contract IdentityVerificationHubImplV1 is IdentityVerificationHubStorageV1, IIdentityVerificationHubV1 {
using Formatter for uint256;
uint256 constant MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH = 40;
@@ -245,13 +240,7 @@ contract IdentityVerificationHubImplV1 is
* @notice Retrieves the registry address.
* @return The address of the Identity Registry.
*/
function registry()
external
virtual
onlyProxy
view
returns (address)
{
function registry() external view virtual onlyProxy returns (address) {
return _registry;
}
@@ -259,13 +248,7 @@ contract IdentityVerificationHubImplV1 is
* @notice Retrieves the VC and Disclose circuit verifier address.
* @return The address of the VC and Disclose circuit verifier.
*/
function vcAndDiscloseCircuitVerifier()
external
virtual
onlyProxy
view
returns (address)
{
function vcAndDiscloseCircuitVerifier() external view virtual onlyProxy returns (address) {
return _vcAndDiscloseCircuitVerifier;
}
@@ -274,15 +257,7 @@ contract IdentityVerificationHubImplV1 is
* @param typeId The signature type identifier.
* @return The register circuit verifier address.
*/
function sigTypeToRegisterCircuitVerifiers(
uint256 typeId
)
external
virtual
onlyProxy
view
returns (address)
{
function sigTypeToRegisterCircuitVerifiers(uint256 typeId) external view virtual onlyProxy returns (address) {
return _sigTypeToRegisterCircuitVerifiers[typeId];
}
@@ -291,15 +266,7 @@ contract IdentityVerificationHubImplV1 is
* @param typeId The signature type identifier.
* @return The DSC circuit verifier address.
*/
function sigTypeToDscCircuitVerifiers(
uint256 typeId
)
external
virtual
onlyProxy
view
returns (address)
{
function sigTypeToDscCircuitVerifiers(uint256 typeId) external view virtual onlyProxy returns (address) {
return _sigTypeToDscCircuitVerifiers[typeId];
}
@@ -313,16 +280,8 @@ contract IdentityVerificationHubImplV1 is
function getReadableRevealedData(
uint256[3] memory revealedDataPacked,
RevealedDataType[] memory types
)
external
virtual
onlyProxy
view
returns (ReadableRevealedData memory)
{
bytes memory charcodes = Formatter.fieldElementsToBytes(
revealedDataPacked
);
) external view virtual onlyProxy returns (ReadableRevealedData memory) {
bytes memory charcodes = Formatter.fieldElementsToBytes(revealedDataPacked);
ReadableRevealedData memory attrs;
@@ -363,13 +322,7 @@ contract IdentityVerificationHubImplV1 is
*/
function getReadableForbiddenCountries(
uint256[4] memory forbiddenCountriesListPacked
)
external
virtual
onlyProxy
view
returns (string[MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH] memory)
{
) external view virtual onlyProxy returns (string[MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH] memory) {
return Formatter.extractForbiddenCountriesFromPacked(forbiddenCountriesListPacked);
}
@@ -381,26 +334,28 @@ contract IdentityVerificationHubImplV1 is
*/
function verifyVcAndDisclose(
VcAndDiscloseHubProof memory proof
)
external
virtual
view
onlyProxy
returns (VcAndDiscloseVerificationResult memory)
{
) external view virtual onlyProxy returns (VcAndDiscloseVerificationResult memory) {
VcAndDiscloseVerificationResult memory result;
result.identityCommitmentRoot = _verifyVcAndDiscloseProof(proof);
for (uint256 i = 0; i < 3; i++) {
result.revealedDataPacked[i] = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_REVEALED_DATA_PACKED_INDEX + i];
result.revealedDataPacked[i] = proof.vcAndDiscloseProof.pubSignals[
CircuitConstants.VC_AND_DISCLOSE_REVEALED_DATA_PACKED_INDEX + i
];
}
for (uint256 i = 0; i < 4; i++) {
result.forbiddenCountriesListPacked[i] = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX + i];
result.forbiddenCountriesListPacked[i] = proof.vcAndDiscloseProof.pubSignals[
CircuitConstants.VC_AND_DISCLOSE_FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX + i
];
}
result.nullifier = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_NULLIFIER_INDEX];
result.attestationId = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX];
result.userIdentifier = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX];
result.attestationId = proof.vcAndDiscloseProof.pubSignals[
CircuitConstants.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX
];
result.userIdentifier = proof.vcAndDiscloseProof.pubSignals[
CircuitConstants.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX
];
result.scope = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_SCOPE_INDEX];
return result;
}
@@ -418,11 +373,7 @@ contract IdentityVerificationHubImplV1 is
function registerPassportCommitment(
uint256 registerCircuitVerifierId,
IRegisterCircuitVerifier.RegisterCircuitProof memory registerCircuitProof
)
external
virtual
onlyProxy
{
) external virtual onlyProxy {
_verifyPassportRegisterProof(registerCircuitVerifierId, registerCircuitProof);
IIdentityRegistryV1(_registry).registerCommitment(
AttestationId.E_PASSPORT,
@@ -440,18 +391,13 @@ contract IdentityVerificationHubImplV1 is
function registerDscKeyCommitment(
uint256 dscCircuitVerifierId,
IDscCircuitVerifier.DscCircuitProof memory dscCircuitProof
)
external
virtual
onlyProxy
{
) external virtual onlyProxy {
_verifyPassportDscProof(dscCircuitVerifierId, dscCircuitProof);
IIdentityRegistryV1(_registry).registerDscKeyCommitment(
dscCircuitProof.pubSignals[CircuitConstants.DSC_TREE_LEAF_INDEX]
);
}
// ====================================================
// External Functions - Only Owner
// ====================================================
@@ -460,14 +406,7 @@ contract IdentityVerificationHubImplV1 is
* @notice Updates the registry address.
* @param registryAddress The new registry address.
*/
function updateRegistry(
address registryAddress
)
external
virtual
onlyProxy
onlyOwner
{
function updateRegistry(address registryAddress) external virtual onlyProxy onlyOwner {
_registry = registryAddress;
emit RegistryUpdated(registryAddress);
}
@@ -478,12 +417,7 @@ contract IdentityVerificationHubImplV1 is
*/
function updateVcAndDiscloseCircuit(
address vcAndDiscloseCircuitVerifierAddress
)
external
virtual
onlyProxy
onlyOwner
{
) external virtual onlyProxy onlyOwner {
_vcAndDiscloseCircuitVerifier = vcAndDiscloseCircuitVerifierAddress;
emit VcAndDiscloseCircuitUpdated(vcAndDiscloseCircuitVerifierAddress);
}
@@ -496,12 +430,7 @@ contract IdentityVerificationHubImplV1 is
function updateRegisterCircuitVerifier(
uint256 typeId,
address verifierAddress
)
external
virtual
onlyProxy
onlyOwner
{
) external virtual onlyProxy onlyOwner {
_sigTypeToRegisterCircuitVerifiers[typeId] = verifierAddress;
emit RegisterCircuitVerifierUpdated(typeId, verifierAddress);
}
@@ -511,15 +440,7 @@ contract IdentityVerificationHubImplV1 is
* @param typeId The signature type identifier.
* @param verifierAddress The new DSC circuit verifier address.
*/
function updateDscVerifier(
uint256 typeId,
address verifierAddress
)
external
virtual
onlyProxy
onlyOwner
{
function updateDscVerifier(uint256 typeId, address verifierAddress) external virtual onlyProxy onlyOwner {
_sigTypeToDscCircuitVerifiers[typeId] = verifierAddress;
emit DscCircuitVerifierUpdated(typeId, verifierAddress);
}
@@ -532,12 +453,7 @@ contract IdentityVerificationHubImplV1 is
function batchUpdateRegisterCircuitVerifiers(
uint256[] calldata typeIds,
address[] calldata verifierAddresses
)
external
virtual
onlyProxy
onlyOwner
{
) external virtual onlyProxy onlyOwner {
if (typeIds.length != verifierAddresses.length) {
revert LENGTH_MISMATCH();
}
@@ -555,12 +471,7 @@ contract IdentityVerificationHubImplV1 is
function batchUpdateDscCircuitVerifiers(
uint256[] calldata typeIds,
address[] calldata verifierAddresses
)
external
virtual
onlyProxy
onlyOwner
{
) external virtual onlyProxy onlyOwner {
if (typeIds.length != verifierAddresses.length) {
revert LENGTH_MISMATCH();
}
@@ -582,13 +493,13 @@ contract IdentityVerificationHubImplV1 is
*/
function _verifyVcAndDiscloseProof(
VcAndDiscloseHubProof memory proof
)
internal
view
returns (uint256 identityCommitmentRoot)
{
) internal view returns (uint256 identityCommitmentRoot) {
// verify identity commitment root
if (!IIdentityRegistryV1(_registry).checkIdentityCommitmentRoot(proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX])) {
if (
!IIdentityRegistryV1(_registry).checkIdentityCommitmentRoot(
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX]
)
) {
revert INVALID_COMMITMENT_ROOT();
}
@@ -599,7 +510,7 @@ contract IdentityVerificationHubImplV1 is
}
uint currentTimestamp = Formatter.proofDateToUnixTimestamp(dateNum);
if(
if (
currentTimestamp < _getStartOfDayTimestamp() - 1 days + 1 ||
currentTimestamp > _getStartOfDayTimestamp() + 1 days - 1
) {
@@ -609,34 +520,48 @@ contract IdentityVerificationHubImplV1 is
// verify attributes
uint256[3] memory revealedDataPacked;
for (uint256 i = 0; i < 3; i++) {
revealedDataPacked[i] = proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_REVEALED_DATA_PACKED_INDEX + i];
revealedDataPacked[i] = proof.vcAndDiscloseProof.pubSignals[
CircuitConstants.VC_AND_DISCLOSE_REVEALED_DATA_PACKED_INDEX + i
];
}
if (proof.olderThanEnabled) {
if (!CircuitAttributeHandler.compareOlderThan(Formatter.fieldElementsToBytes(revealedDataPacked), proof.olderThan)) {
if (
!CircuitAttributeHandler.compareOlderThan(
Formatter.fieldElementsToBytes(revealedDataPacked),
proof.olderThan
)
) {
revert INVALID_OLDER_THAN();
}
}
if (proof.ofacEnabled[0] || proof.ofacEnabled[1] || proof.ofacEnabled[2]) {
if (!CircuitAttributeHandler.compareOfac(
Formatter.fieldElementsToBytes(revealedDataPacked),
proof.ofacEnabled[0],
proof.ofacEnabled[1],
proof.ofacEnabled[2]
)) {
if (
!CircuitAttributeHandler.compareOfac(
Formatter.fieldElementsToBytes(revealedDataPacked),
proof.ofacEnabled[0],
proof.ofacEnabled[1],
proof.ofacEnabled[2]
)
) {
revert INVALID_OFAC();
}
if (!IIdentityRegistryV1(_registry).checkOfacRoots(
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_PASSPORT_NO_SMT_ROOT_INDEX],
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_NAME_DOB_SMT_ROOT_INDEX],
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_NAME_YOB_SMT_ROOT_INDEX]
)) {
if (
!IIdentityRegistryV1(_registry).checkOfacRoots(
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_PASSPORT_NO_SMT_ROOT_INDEX],
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_NAME_DOB_SMT_ROOT_INDEX],
proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_NAME_YOB_SMT_ROOT_INDEX]
)
) {
revert INVALID_OFAC_ROOT();
}
}
if (proof.forbiddenCountriesEnabled) {
for (uint256 i = 0; i < 4; i++) {
if (
proof.forbiddenCountriesListPacked[i] != proof.vcAndDiscloseProof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX + i]
proof.forbiddenCountriesListPacked[i] !=
proof.vcAndDiscloseProof.pubSignals[
CircuitConstants.VC_AND_DISCLOSE_FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX + i
]
) {
revert INVALID_FORBIDDEN_COUNTRIES();
}
@@ -644,7 +569,14 @@ contract IdentityVerificationHubImplV1 is
}
// verify the proof using the VC and Disclose circuit verifier
if (!IVcAndDiscloseCircuitVerifier(_vcAndDiscloseCircuitVerifier).verifyProof(proof.vcAndDiscloseProof.a, proof.vcAndDiscloseProof.b, proof.vcAndDiscloseProof.c, proof.vcAndDiscloseProof.pubSignals)) {
if (
!IVcAndDiscloseCircuitVerifier(_vcAndDiscloseCircuitVerifier).verifyProof(
proof.vcAndDiscloseProof.a,
proof.vcAndDiscloseProof.b,
proof.vcAndDiscloseProof.c,
proof.vcAndDiscloseProof.pubSignals
)
) {
revert INVALID_VC_AND_DISCLOSE_PROOF();
}
@@ -660,25 +592,28 @@ contract IdentityVerificationHubImplV1 is
function _verifyPassportRegisterProof(
uint256 registerCircuitVerifierId,
IRegisterCircuitVerifier.RegisterCircuitProof memory registerCircuitProof
)
internal
view
{
) internal view {
address verifier = _sigTypeToRegisterCircuitVerifiers[registerCircuitVerifierId];
if (verifier == address(0)) {
revert NO_VERIFIER_SET();
}
if (!IIdentityRegistryV1(_registry).checkDscKeyCommitmentMerkleRoot(registerCircuitProof.pubSignals[CircuitConstants.REGISTER_MERKLE_ROOT_INDEX])) {
if (
!IIdentityRegistryV1(_registry).checkDscKeyCommitmentMerkleRoot(
registerCircuitProof.pubSignals[CircuitConstants.REGISTER_MERKLE_ROOT_INDEX]
)
) {
revert INVALID_COMMITMENT_ROOT();
}
if(!IRegisterCircuitVerifier(verifier).verifyProof(
registerCircuitProof.a,
registerCircuitProof.b,
registerCircuitProof.c,
registerCircuitProof.pubSignals
)) {
if (
!IRegisterCircuitVerifier(verifier).verifyProof(
registerCircuitProof.a,
registerCircuitProof.b,
registerCircuitProof.c,
registerCircuitProof.pubSignals
)
) {
revert INVALID_REGISTER_PROOF();
}
}
@@ -692,25 +627,28 @@ contract IdentityVerificationHubImplV1 is
function _verifyPassportDscProof(
uint256 dscCircuitVerifierId,
IDscCircuitVerifier.DscCircuitProof memory dscCircuitProof
)
internal
view
{
) internal view {
address verifier = _sigTypeToDscCircuitVerifiers[dscCircuitVerifierId];
if (verifier == address(0)) {
revert NO_VERIFIER_SET();
}
if (!IIdentityRegistryV1(_registry).checkCscaRoot(dscCircuitProof.pubSignals[CircuitConstants.DSC_CSCA_ROOT_INDEX])) {
if (
!IIdentityRegistryV1(_registry).checkCscaRoot(
dscCircuitProof.pubSignals[CircuitConstants.DSC_CSCA_ROOT_INDEX]
)
) {
revert INVALID_CSCA_ROOT();
}
if(!IDscCircuitVerifier(verifier).verifyProof(
dscCircuitProof.a,
dscCircuitProof.b,
dscCircuitProof.c,
dscCircuitProof.pubSignals
)) {
if (
!IDscCircuitVerifier(verifier).verifyProof(
dscCircuitProof.a,
dscCircuitProof.b,
dscCircuitProof.c,
dscCircuitProof.pubSignals
)
) {
revert INVALID_DSC_PROOF();
}
}

View File

@@ -13,7 +13,6 @@ import {AttestationId} from "../constants/AttestationId.sol";
* @dev Provides base functionality for verifying and disclosing identity credentials
*/
abstract contract SelfVerificationRoot is ISelfVerificationRoot {
// ====================================================
// Storage Variables
// ====================================================
@@ -40,7 +39,8 @@ abstract contract SelfVerificationRoot is ISelfVerificationRoot {
// Make CircuitConstants available to inheriting contracts
uint256 internal constant REVEALED_DATA_PACKED_INDEX = CircuitConstants.VC_AND_DISCLOSE_REVEALED_DATA_PACKED_INDEX;
uint256 internal constant FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX = CircuitConstants.VC_AND_DISCLOSE_FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX;
uint256 internal constant FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX =
CircuitConstants.VC_AND_DISCLOSE_FORBIDDEN_COUNTRIES_LIST_PACKED_INDEX;
uint256 internal constant NULLIFIER_INDEX = CircuitConstants.VC_AND_DISCLOSE_NULLIFIER_INDEX;
uint256 internal constant ATTESTATION_ID_INDEX = CircuitConstants.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX;
uint256 internal constant MERKLE_ROOT_INDEX = CircuitConstants.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX;
@@ -75,11 +75,7 @@ abstract contract SelfVerificationRoot is ISelfVerificationRoot {
* @param scope The expected proof scope for user registration.
* @param attestationIds The expected attestation identifiers required in proofs.
*/
constructor(
address identityVerificationHub,
uint256 scope,
uint256[] memory attestationIds
) {
constructor(address identityVerificationHub, uint256 scope, uint256[] memory attestationIds) {
_identityVerificationHub = IIdentityVerificationHubV1(identityVerificationHub);
_scope = scope;
for (uint256 i = 0; i < attestationIds.length; i++) {
@@ -92,9 +88,7 @@ abstract contract SelfVerificationRoot is ISelfVerificationRoot {
* @dev Used to set or update verification parameters after contract deployment
* @param verificationConfig The new verification configuration to apply
*/
function _setVerificationConfig(
ISelfVerificationRoot.VerificationConfig memory verificationConfig
) internal {
function _setVerificationConfig(ISelfVerificationRoot.VerificationConfig memory verificationConfig) internal {
_verificationConfig = verificationConfig;
}
@@ -140,7 +134,9 @@ abstract contract SelfVerificationRoot is ISelfVerificationRoot {
* @param pubSignals The proof's public signals
* @return revealedDataPacked Array of the three packed revealed data values
*/
function getRevealedDataPacked(uint256[21] memory pubSignals) internal pure returns (uint256[3] memory revealedDataPacked) {
function getRevealedDataPacked(
uint256[21] memory pubSignals
) internal pure returns (uint256[3] memory revealedDataPacked) {
revealedDataPacked[0] = pubSignals[REVEALED_DATA_PACKED_INDEX];
revealedDataPacked[1] = pubSignals[REVEALED_DATA_PACKED_INDEX + 1];
revealedDataPacked[2] = pubSignals[REVEALED_DATA_PACKED_INDEX + 2];
@@ -152,12 +148,7 @@ abstract contract SelfVerificationRoot is ISelfVerificationRoot {
* @dev Validates scope and attestation ID before performing verification through the identity hub
* @param proof The proof data for verification and disclosure
*/
function verifySelfProof(
ISelfVerificationRoot.DiscloseCircuitProof memory proof
)
public
virtual
{
function verifySelfProof(ISelfVerificationRoot.DiscloseCircuitProof memory proof) public virtual {
if (_scope != proof.pubSignals[CircuitConstants.VC_AND_DISCLOSE_SCOPE_INDEX]) {
revert InvalidScope();
}

View File

@@ -8,7 +8,6 @@ pragma solidity 0.8.28;
* @dev These indices map directly to specific data fields in the corresponding circuits proofs.
*/
library CircuitConstants {
// ---------------------------
// Register Circuit Constants
// ---------------------------

View File

@@ -99,14 +99,7 @@ contract Airdrop is SelfVerificationRoot, Ownable {
uint256 _scope,
uint256[] memory _attestationIds,
address _token
)
SelfVerificationRoot(
_identityVerificationHub,
_scope,
_attestationIds
)
Ownable(_msgSender())
{
) SelfVerificationRoot(_identityVerificationHub, _scope, _attestationIds) Ownable(_msgSender()) {
token = IERC20(_token);
}
@@ -205,13 +198,7 @@ contract Airdrop is SelfVerificationRoot, Ownable {
* @dev Reverts if the registration phase is not open.
* @param proof The VC and Disclose proof data used to verify and register the user.
*/
function verifySelfProof(
ISelfVerificationRoot.DiscloseCircuitProof memory proof
)
public
override
{
function verifySelfProof(ISelfVerificationRoot.DiscloseCircuitProof memory proof) public override {
if (!isRegistrationOpen) {
revert RegistrationNotOpen();
}
@@ -283,11 +270,7 @@ contract Airdrop is SelfVerificationRoot, Ownable {
* @param amount The amount of tokens to be claimed.
* @param merkleProof The Merkle proof verifying the claim.
*/
function claim(
uint256 index,
uint256 amount,
bytes32[] memory merkleProof
) external {
function claim(uint256 index, uint256 amount, bytes32[] memory merkleProof) external {
if (isRegistrationOpen) {
revert RegistrationNotClosed();
}

View File

@@ -32,11 +32,7 @@ contract SelfPassportERC721 is SelfVerificationRoot, ERC721, Ownable {
// Events
// ====================================================
event PassportNFTMinted(
uint256 indexed tokenId,
address indexed owner,
SelfCircuitLibrary.PassportData attributes
);
event PassportNFTMinted(uint256 indexed tokenId, address indexed owner, SelfCircuitLibrary.PassportData attributes);
/// @notice Emitted when the scope is updated
event ScopeUpdated(uint256 newScope);
@@ -73,11 +69,7 @@ contract SelfPassportERC721 is SelfVerificationRoot, ERC721, Ownable {
uint256[] memory attestationIds,
string memory name,
string memory symbol
)
SelfVerificationRoot(identityVerificationHub, scope, attestationIds)
ERC721(name, symbol)
Ownable(_msgSender())
{}
) SelfVerificationRoot(identityVerificationHub, scope, attestationIds) ERC721(name, symbol) Ownable(_msgSender()) {}
// ====================================================
// External/Public Functions
@@ -128,9 +120,7 @@ contract SelfPassportERC721 is SelfVerificationRoot, ERC721, Ownable {
* @notice Verifies a self-proof and mints an NFT with passport attributes
* @param proof The VC and Disclose proof data used to verify and register the user
*/
function verifySelfProof(
ISelfVerificationRoot.DiscloseCircuitProof memory proof
) public override {
function verifySelfProof(ISelfVerificationRoot.DiscloseCircuitProof memory proof) public override {
if (_usedNullifiers[proof.pubSignals[NULLIFIER_INDEX]]) {
revert NullifierAlreadyUsed();
}

View File

@@ -7,7 +7,6 @@ pragma solidity 0.8.28;
* @dev This interface defines the structure of a DSC circuit proof and exposes a function to verify such proofs.
*/
interface IDscCircuitVerifier {
/**
* @notice Represents a DSC circuit proof.
* @param a An array of two unsigned integers representing the proof component 'a'.
@@ -31,7 +30,7 @@ interface IDscCircuitVerifier {
* @param _pubSignals The public signals associated with the proof.
* @return A boolean value indicating whether the provided proof is valid (true) or not (false).
*/
function verifyProof (
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,

View File

@@ -20,19 +20,14 @@ interface IIdentityRegistryV1 {
* @param nullifier The nullifier to check.
* @return True if the nullifier is registered; otherwise, false.
*/
function nullifiers(
bytes32 attestationId,
uint256 nullifier
) external view returns (bool);
function nullifiers(bytes32 attestationId, uint256 nullifier) external view returns (bool);
/**
* @notice Checks whether a DSC key commitment is registered.
* @param commitment The DSC key commitment to check.
* @return True if the commitment is registered, false otherwise.
*/
function isRegisteredDscKeyCommitment(
uint256 commitment
) external view returns (bool);
function isRegisteredDscKeyCommitment(uint256 commitment) external view returns (bool);
/**
* @notice Retrieves the timestamp at which a given Merkle tree root was created.
@@ -46,9 +41,7 @@ interface IIdentityRegistryV1 {
* @param root The Merkle tree root to check.
* @return True if the root exists in the tree, false otherwise.
*/
function checkIdentityCommitmentRoot(
uint256 root
) external view returns (bool);
function checkIdentityCommitmentRoot(uint256 root) external view returns (bool);
/**
* @notice Retrieves the total number of identity commitments in the Merkle tree.
@@ -67,9 +60,7 @@ interface IIdentityRegistryV1 {
* @param commitment The identity commitment to locate.
* @return The index position of the provided commitment.
*/
function getIdentityCommitmentIndex(
uint256 commitment
) external view returns (uint256);
function getIdentityCommitmentIndex(uint256 commitment) external view returns (uint256);
/**
* @notice Retrieves the current passport number OFAC root.
@@ -113,9 +104,7 @@ interface IIdentityRegistryV1 {
* @param root The CSCA root to verify.
* @return True if the given root equals the stored CSCA root, otherwise false.
*/
function checkCscaRoot(
uint256 root
) external view returns (bool);
function checkCscaRoot(uint256 root) external view returns (bool);
/**
* @notice Retrieves the current Merkle root of the DSC key commitments.
@@ -128,9 +117,7 @@ interface IIdentityRegistryV1 {
* @param root The root to check.
* @return True if it matches the current root, false otherwise.
*/
function checkDscKeyCommitmentMerkleRoot(
uint256 root
) external view returns (bool);
function checkDscKeyCommitmentMerkleRoot(uint256 root) external view returns (bool);
/**
* @notice Retrieves the total number of DSC key commitments in the Merkle tree.
@@ -143,9 +130,7 @@ interface IIdentityRegistryV1 {
* @param commitment The DSC key commitment to locate.
* @return The index of the provided commitment.
*/
function getDscKeyCommitmentIndex(
uint256 commitment
) external view returns (uint256);
function getDscKeyCommitmentIndex(uint256 commitment) external view returns (uint256);
/**
* @notice Registers a new identity commitment.
@@ -154,18 +139,12 @@ interface IIdentityRegistryV1 {
* @param nullifier A unique nullifier to prevent double registration.
* @param commitment The identity commitment to register.
*/
function registerCommitment(
bytes32 attestationId,
uint256 nullifier,
uint256 commitment
) external;
function registerCommitment(bytes32 attestationId, uint256 nullifier, uint256 commitment) external;
/**
* @notice Registers a new DSC key commitment.
* @dev Must be called by the identity verification hub. Reverts if the DSC key commitment is already registered.
* @param dscCommitment The DSC key commitment to register.
*/
function registerDscKeyCommitment(
uint256 dscCommitment
) external;
function registerDscKeyCommitment(uint256 dscCommitment) external;
}

View File

@@ -12,22 +12,21 @@ import {CircuitConstants} from "../constants/CircuitConstants.sol";
* @dev Defines data structures and external functions for verifying proofs and recovering human-readable data.
*/
interface IIdentityVerificationHubV1 {
/**
* @notice Enum representing types of data that may be revealed.
*/
enum RevealedDataType {
ISSUING_STATE, // The issuing state of the passport.
NAME, // The full name of the passport holder.
PASSPORT_NUMBER, // The passport number.
NATIONALITY, // The nationality.
DATE_OF_BIRTH, // The date of birth.
GENDER, // The gender.
EXPIRY_DATE, // The passport expiry date.
OLDER_THAN, // The "older than" age verification value.
PASSPORT_NO_OFAC, // The passport number OFAC status.
ISSUING_STATE, // The issuing state of the passport.
NAME, // The full name of the passport holder.
PASSPORT_NUMBER, // The passport number.
NATIONALITY, // The nationality.
DATE_OF_BIRTH, // The date of birth.
GENDER, // The gender.
EXPIRY_DATE, // The passport expiry date.
OLDER_THAN, // The "older than" age verification value.
PASSPORT_NO_OFAC, // The passport number OFAC status.
NAME_AND_DOB_OFAC, // The name and date of birth OFAC verification result.
NAME_AND_YOB_OFAC // The name and year of birth OFAC verification result.
NAME_AND_YOB_OFAC // The name and year of birth OFAC verification result.
}
/**
@@ -104,10 +103,7 @@ interface IIdentityVerificationHubV1 {
*/
function verifyVcAndDisclose(
VcAndDiscloseHubProof memory proof
)
external
view
returns (VcAndDiscloseVerificationResult memory result);
) external view returns (VcAndDiscloseVerificationResult memory result);
/**
* @notice Converts packed revealed data into a human-readable format.
@@ -119,10 +115,7 @@ interface IIdentityVerificationHubV1 {
function getReadableRevealedData(
uint256[3] memory revealedDataPacked,
RevealedDataType[] memory types
)
external
view
returns (ReadableRevealedData memory readableData);
) external view returns (ReadableRevealedData memory readableData);
/**
* @notice Retrieves a human-readable list of forbidden countries.
@@ -132,10 +125,7 @@ interface IIdentityVerificationHubV1 {
*/
function getReadableForbiddenCountries(
uint256[4] memory forbiddenCountriesListPacked
)
external
view
returns (string[40] memory forbiddenCountries);
) external view returns (string[40] memory forbiddenCountries);
/**
* @notice Registers a passport commitment using a register circuit proof.
@@ -146,8 +136,7 @@ interface IIdentityVerificationHubV1 {
function registerPassportCommitment(
uint256 registerCircuitVerifierId,
IRegisterCircuitVerifier.RegisterCircuitProof memory registerCircuitProof
)
external;
) external;
/**
* @notice Registers a DSC key commitment using a DSC circuit proof.
@@ -158,8 +147,7 @@ interface IIdentityVerificationHubV1 {
function registerDscKeyCommitment(
uint256 dscCircuitVerifierId,
IDscCircuitVerifier.DscCircuitProof memory dscCircuitProof
)
external;
) external;
/**
* @notice Returns the address of the Identity Registry.
@@ -178,22 +166,12 @@ interface IIdentityVerificationHubV1 {
* @param typeId The signature type identifier.
* @return verifier The address of the register circuit verifier.
*/
function sigTypeToRegisterCircuitVerifiers(
uint256 typeId
)
external
view
returns (address verifier);
function sigTypeToRegisterCircuitVerifiers(uint256 typeId) external view returns (address verifier);
/**
* @notice Retrieves the DSC circuit verifier for a given signature type.
* @param typeId The signature type identifier.
* @return verifier The address of the DSC circuit verifier.
*/
function sigTypeToDscCircuitVerifiers(
uint256 typeId
)
external
view
returns (address verifier);
function sigTypeToDscCircuitVerifiers(uint256 typeId) external view returns (address verifier);
}

View File

@@ -8,7 +8,6 @@ pragma solidity 0.8.28;
* the verification process during passport airdrop registration.
*/
interface IPassportAirdropRoot {
/**
* @notice Configuration settings for the verification process.
* @dev These settings determine which attributes are enabled for verification and the expected values.
@@ -25,5 +24,4 @@ interface IPassportAirdropRoot {
uint256[4] forbiddenCountriesListPacked;
bool[3] ofacEnabled;
}
}

View File

@@ -6,7 +6,6 @@ pragma solidity 0.8.28;
* @dev This interface defines the structure of a register circuit proof and exposes a function to verify such proofs.
*/
interface IRegisterCircuitVerifier {
/**
* @notice Represents a register circuit proof.
* @dev This structure encapsulates the required proof elements.
@@ -31,7 +30,7 @@ interface IRegisterCircuitVerifier {
* @param pubSignals The public signals associated with the proof.
* @return isValid A boolean value indicating whether the provided proof is valid (true) or not (false).
*/
function verifyProof (
function verifyProof(
uint[2] calldata a,
uint[2][2] calldata b,
uint[2] calldata c,

View File

@@ -4,7 +4,6 @@ pragma solidity 0.8.28;
import {IVcAndDiscloseCircuitVerifier} from "./IVcAndDiscloseCircuitVerifier.sol";
interface ISelfVerificationRoot {
struct VerificationConfig {
bool olderThanEnabled;
uint256 olderThan;
@@ -24,8 +23,5 @@ interface ISelfVerificationRoot {
* @notice Verifies a self-proof
* @param proof The proof data for verification and disclosure
*/
function verifySelfProof(
DiscloseCircuitProof memory proof
) external;
function verifySelfProof(DiscloseCircuitProof memory proof) external;
}

View File

@@ -7,7 +7,6 @@ pragma solidity 0.8.28;
* @dev This interface defines the structure of a VC and Disclose proof and a function to verify such proofs.
*/
interface IVcAndDiscloseCircuitVerifier {
/**
* @notice Represents a VC and Disclose proof.
* @param a An array of two unsigned integers representing the proof component 'a'.
@@ -31,7 +30,7 @@ interface IVcAndDiscloseCircuitVerifier {
* @param pubSignals The public signals associated with the proof.
* @return A boolean value indicating whether the proof is valid (true) or not (false).
*/
function verifyProof (
function verifyProof(
uint[2] calldata a,
uint[2][2] calldata b,
uint[2] calldata c,

View File

@@ -10,7 +10,6 @@ import {Formatter} from "./Formatter.sol";
* @dev Utilizes the Formatter library for converting and formatting specific fields.
*/
library CircuitAttributeHandler {
/**
* @dev Reverts when the provided character codes array does not contain enough data to extract an attribute.
*/
@@ -114,8 +113,10 @@ library CircuitAttributeHandler {
* @return The extracted age as a uint256.
*/
function getOlderThan(bytes memory charcodes) internal pure returns (uint256) {
return Formatter.numAsciiToUint(uint8(charcodes[OLDER_THAN_START])) * 10
+ Formatter.numAsciiToUint(uint8(charcodes[OLDER_THAN_START + 1]));
return
Formatter.numAsciiToUint(uint8(charcodes[OLDER_THAN_START])) *
10 +
Formatter.numAsciiToUint(uint8(charcodes[OLDER_THAN_START + 1]));
}
/**
@@ -161,9 +162,10 @@ library CircuitAttributeHandler {
bool checkNameAndDob,
bool checkNameAndYob
) internal pure returns (bool) {
return (!checkPassportNo || getPassportNoOfac(charcodes) == 1) &&
(!checkNameAndDob || getNameAndDobOfac(charcodes) == 1) &&
(!checkNameAndYob || getNameAndYobOfac(charcodes) == 1);
return
(!checkPassportNo || getPassportNoOfac(charcodes) == 1) &&
(!checkNameAndDob || getNameAndDobOfac(charcodes) == 1) &&
(!checkNameAndYob || getNameAndYobOfac(charcodes) == 1);
}
/**
@@ -172,10 +174,7 @@ library CircuitAttributeHandler {
* @param olderThan The threshold value to compare against.
* @return True if the extracted age is greater than or equal to the threshold, false otherwise.
*/
function compareOlderThan(
bytes memory charcodes,
uint256 olderThan
) internal pure returns (bool) {
function compareOlderThan(bytes memory charcodes, uint256 olderThan) internal pure returns (bool) {
return getOlderThan(charcodes) >= olderThan;
}
@@ -187,7 +186,11 @@ library CircuitAttributeHandler {
* @param end The ending index (inclusive) of the attribute in the byte array.
* @return The extracted attribute as a string.
*/
function extractStringAttribute(bytes memory charcodes, uint256 start, uint256 end) internal pure returns (string memory) {
function extractStringAttribute(
bytes memory charcodes,
uint256 start,
uint256 end
) internal pure returns (string memory) {
if (charcodes.length <= end) {
revert INSUFFICIENT_CHARCODE_LEN();
}
@@ -197,5 +200,4 @@ library CircuitAttributeHandler {
}
return string(attributeBytes);
}
}

View File

@@ -23,9 +23,7 @@ library Formatter {
* @param input The input string structured as "lastName<<firstName(s)".
* @return names An array of two strings: [firstName(s), lastName].
*/
function formatName(
string memory input
) internal pure returns (string[] memory) {
function formatName(string memory input) internal pure returns (string[] memory) {
bytes memory inputBytes = bytes(input);
bytes memory firstNameBytes;
bytes memory lastNameBytes;
@@ -49,10 +47,7 @@ library Formatter {
}
firstNameBytes = abi.encodePacked(firstNameBytes, " ");
} else {
firstNameBytes = abi.encodePacked(
firstNameBytes,
inputBytes[i]
);
firstNameBytes = abi.encodePacked(firstNameBytes, inputBytes[i]);
}
i++;
}
@@ -69,19 +64,17 @@ library Formatter {
* @param date A string representing the date in YYMMDD format.
* @return A formatted date string in the format "DD-MM-YY".
*/
function formatDate(
string memory date
) internal pure returns (string memory) {
function formatDate(string memory date) internal pure returns (string memory) {
bytes memory dateBytes = bytes(date);
if (dateBytes.length != 6) {
revert InvalidDateLength();
}
if (dateBytes[2] > '1' || (dateBytes[2] == '1' && dateBytes[3] > '2')) {
if (dateBytes[2] > "1" || (dateBytes[2] == "1" && dateBytes[3] > "2")) {
revert InvalidMonthRange();
}
if (dateBytes[4] > '3' || (dateBytes[4] == '3' && dateBytes[5] > '1')) {
if (dateBytes[4] > "3" || (dateBytes[4] == "3" && dateBytes[5] > "1")) {
revert InvalidDayRange();
}
@@ -109,9 +102,7 @@ library Formatter {
* @param publicSignals An array of three unsigned integers representing field elements.
* @return bytesArray A bytes array of total length 93 that encodes the three field elements.
*/
function fieldElementsToBytes(
uint256[3] memory publicSignals
) internal pure returns (bytes memory) {
function fieldElementsToBytes(uint256[3] memory publicSignals) internal pure returns (bytes memory) {
if (
publicSignals[0] >= SNARK_SCALAR_FIELD ||
publicSignals[1] >= SNARK_SCALAR_FIELD ||
@@ -142,13 +133,7 @@ library Formatter {
*/
function extractForbiddenCountriesFromPacked(
uint256[4] memory publicSignals
)
internal
pure
returns (
string[MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH] memory forbiddenCountries
)
{
) internal pure returns (string[MAX_FORBIDDEN_COUNTRIES_LIST_LENGTH] memory forbiddenCountries) {
for (uint256 i = 0; i < 4; i++) {
if (publicSignals[i] >= SNARK_SCALAR_FIELD) {
revert InvalidFieldElement();
@@ -187,7 +172,6 @@ library Formatter {
}
return forbiddenCountries;
}
/**
@@ -198,19 +182,15 @@ library Formatter {
* @param dateNum An array of 6 unsigned integers representing a date in YYMMDD format.
* @return timestamp The Unix timestamp corresponding to the provided date.
*/
function proofDateToUnixTimestamp(
uint256[6] memory dateNum
) internal pure returns (uint256) {
function proofDateToUnixTimestamp(uint256[6] memory dateNum) internal pure returns (uint256) {
for (uint256 i = 0; i < 6; i++) {
if (dateNum[i] > 9) {
revert InvalidDateDigit();
if (dateNum[i] > 9) {
revert InvalidDateDigit();
}
}
string memory date = "";
for (uint256 i = 0; i < 6; i++) {
date = string(
abi.encodePacked(date, bytes1(uint8(48 + (dateNum[i] % 10))))
);
date = string(abi.encodePacked(date, bytes1(uint8(48 + (dateNum[i] % 10)))));
}
uint256 currentTimestamp = dateToUnixTimestamp(date);
return currentTimestamp;
@@ -224,19 +204,17 @@ library Formatter {
* @param date A 6-character string representing the date in YYMMDD format.
* @return timestamp The Unix timestamp corresponding to the input date.
*/
function dateToUnixTimestamp(
string memory date
) internal pure returns (uint256) {
function dateToUnixTimestamp(string memory date) internal pure returns (uint256) {
bytes memory dateBytes = bytes(date);
if (dateBytes.length != 6) {
revert InvalidDateLength();
}
if (dateBytes[2] > '1' || (dateBytes[2] == '1' && dateBytes[3] > '2')) {
if (dateBytes[2] > "1" || (dateBytes[2] == "1" && dateBytes[3] > "2")) {
revert InvalidMonthRange();
}
if (dateBytes[4] > '3' || (dateBytes[4] == '3' && dateBytes[5] > '1')) {
if (dateBytes[4] > "3" || (dateBytes[4] == "3" && dateBytes[5] > "1")) {
revert InvalidDayRange();
}
@@ -255,11 +233,7 @@ library Formatter {
* @param endIndex The ending index of the substring (exclusive).
* @return The resulting substring.
*/
function substring(
string memory str,
uint startIndex,
uint endIndex
) internal pure returns (string memory) {
function substring(string memory str, uint startIndex, uint endIndex) internal pure returns (string memory) {
bytes memory strBytes = bytes(str);
bytes memory result = new bytes(endIndex - startIndex);
@@ -300,11 +274,7 @@ library Formatter {
* @param day The day of the month.
* @return timestamp The Unix timestamp corresponding to the given date.
*/
function toTimestamp(
uint256 year,
uint256 month,
uint256 day
) internal pure returns (uint timestamp) {
function toTimestamp(uint256 year, uint256 month, uint256 day) internal pure returns (uint timestamp) {
uint16 i;
if (year < 1970 || year > 2100) {
@@ -377,5 +347,4 @@ library Formatter {
return true;
}
}
}

View File

@@ -35,19 +35,20 @@ library SelfCircuitLibrary {
function extractPassportData(uint256[3] memory revealedDataPacked) internal pure returns (PassportData memory) {
bytes memory charcodes = Formatter.fieldElementsToBytes(revealedDataPacked);
return PassportData({
issuingState: CircuitAttributeHandler.getIssuingState(charcodes),
name: CircuitAttributeHandler.getName(charcodes),
passportNumber: CircuitAttributeHandler.getPassportNumber(charcodes),
nationality: CircuitAttributeHandler.getNationality(charcodes),
dateOfBirth: CircuitAttributeHandler.getDateOfBirth(charcodes),
gender: CircuitAttributeHandler.getGender(charcodes),
expiryDate: CircuitAttributeHandler.getExpiryDate(charcodes),
olderThan: CircuitAttributeHandler.getOlderThan(charcodes),
passportNoOfac: CircuitAttributeHandler.getPassportNoOfac(charcodes) == 1,
nameAndDobOfac: CircuitAttributeHandler.getNameAndDobOfac(charcodes) == 1,
nameAndYobOfac: CircuitAttributeHandler.getNameAndYobOfac(charcodes) == 1
});
return
PassportData({
issuingState: CircuitAttributeHandler.getIssuingState(charcodes),
name: CircuitAttributeHandler.getName(charcodes),
passportNumber: CircuitAttributeHandler.getPassportNumber(charcodes),
nationality: CircuitAttributeHandler.getNationality(charcodes),
dateOfBirth: CircuitAttributeHandler.getDateOfBirth(charcodes),
gender: CircuitAttributeHandler.getGender(charcodes),
expiryDate: CircuitAttributeHandler.getExpiryDate(charcodes),
olderThan: CircuitAttributeHandler.getOlderThan(charcodes),
passportNoOfac: CircuitAttributeHandler.getPassportNoOfac(charcodes) == 1,
nameAndDobOfac: CircuitAttributeHandler.getNameAndDobOfac(charcodes) == 1,
nameAndYobOfac: CircuitAttributeHandler.getNameAndYobOfac(charcodes) == 1
});
}
/**
@@ -186,12 +187,7 @@ library SelfCircuitLibrary {
bool checkNameAndYob
) internal pure returns (bool) {
bytes memory charcodes = Formatter.fieldElementsToBytes(revealedDataPacked);
return CircuitAttributeHandler.compareOfac(
charcodes,
checkPassportNo,
checkNameAndDob,
checkNameAndYob
);
return CircuitAttributeHandler.compareOfac(charcodes, checkPassportNo, checkNameAndDob, checkNameAndYob);
}
/**

View File

@@ -4,7 +4,7 @@ pragma solidity 0.8.28;
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import { InternalLeanIMT, LeanIMTData } from "@zk-kit/imt.sol/internal/InternalLeanIMT.sol";
import {InternalLeanIMT, LeanIMTData} from "@zk-kit/imt.sol/internal/InternalLeanIMT.sol";
import {IIdentityRegistryV1} from "../interfaces/IIdentityRegistryV1.sol";
import {IIdentityVerificationHubV1} from "../interfaces/IIdentityVerificationHubV1.sol";
import {ImplRoot} from "../upgradeable/ImplRoot.sol";
@@ -41,9 +41,7 @@ import {ImplRoot} from "../upgradeable/ImplRoot.sol";
* @dev Abstract contract for storage layout of IdentityRegistryImplV1.
* Inherits from ImplRoot to provide upgradeable functionality.
*/
abstract contract IdentityRegistryStorageV1 is
ImplRoot
{
abstract contract IdentityRegistryStorageV1 is ImplRoot {
// ====================================================
// Storage Variables
// ====================================================
@@ -85,10 +83,7 @@ abstract contract IdentityRegistryStorageV1 is
* @notice Provides functions to register and manage identity commitments using a Merkle tree structure.
* @dev Inherits from IdentityRegistryStorageV1 and implements IIdentityRegistryV1.
*/
contract IdentityRegistryImplV1 is
IdentityRegistryStorageV1,
IIdentityRegistryV1
{
contract IdentityRegistryImplV1 is IdentityRegistryStorageV1, IIdentityRegistryV1 {
using InternalLeanIMT for LeanIMTData;
// ====================================================
@@ -108,11 +103,25 @@ contract IdentityRegistryImplV1 is
/// @notice Emitted when the name and year of birth OFAC root is updated.
event NameAndYobOfacRootUpdated(uint256 nameAndYobOfacRoot);
/// @notice Emitted when an identity commitment is successfully registered.
event CommitmentRegistered(bytes32 indexed attestationId, uint256 indexed nullifier, uint256 indexed commitment, uint256 timestamp, uint256 imtRoot, uint256 imtIndex);
event CommitmentRegistered(
bytes32 indexed attestationId,
uint256 indexed nullifier,
uint256 indexed commitment,
uint256 timestamp,
uint256 imtRoot,
uint256 imtIndex
);
/// @notice Emitted when a DSC key commitment is successfully registered.
event DscKeyCommitmentRegistered(uint256 indexed commitment, uint256 timestamp, uint256 imtRoot, uint256 imtIndex);
/// @notice Emitted when a identity commitment is added by dev team.
event DevCommitmentRegistered(bytes32 indexed attestationId, uint256 indexed nullifier, uint256 indexed commitment, uint256 timestamp, uint256 imtRoot, uint256 imtIndex);
event DevCommitmentRegistered(
bytes32 indexed attestationId,
uint256 indexed nullifier,
uint256 indexed commitment,
uint256 timestamp,
uint256 imtRoot,
uint256 imtIndex
);
/// @notice Emitted when a identity commitment is updated by dev team.
event DevCommitmentUpdated(uint256 indexed oldLeaf, uint256 indexed newLeaf, uint256 imtRoot, uint256 timestamp);
/// @notice Emitted when a identity commitment is removed by dev team.
@@ -173,12 +182,7 @@ contract IdentityRegistryImplV1 is
* @dev Sets the hub address and initializes the UUPS upgradeable feature.
* @param _hub The address of the identity verification hub.
*/
function initialize(
address _hub
)
external
initializer
{
function initialize(address _hub) external initializer {
__ImplRoot_init();
_hub = _hub;
emit RegistryInitialized(_hub);
@@ -192,13 +196,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the hub address.
* @return The current identity verification hub address.
*/
function hub()
external
virtual
onlyProxy
view
returns (address)
{
function hub() external view virtual onlyProxy returns (address) {
return _hub;
}
@@ -208,16 +206,7 @@ contract IdentityRegistryImplV1 is
* @param nullifier The nullifier to be checked.
* @return True if the nullifier has been registered, false otherwise.
*/
function nullifiers(
bytes32 attestationId,
uint256 nullifier
)
external
virtual
onlyProxy
view
returns (bool)
{
function nullifiers(bytes32 attestationId, uint256 nullifier) external view virtual onlyProxy returns (bool) {
return _nullifiers[attestationId][nullifier];
}
@@ -226,15 +215,7 @@ contract IdentityRegistryImplV1 is
* @param commitment The DSC key commitment.
* @return True if the DSC key commitment is registered, false otherwise.
*/
function isRegisteredDscKeyCommitment(
uint256 commitment
)
external
virtual
onlyProxy
view
returns (bool)
{
function isRegisteredDscKeyCommitment(uint256 commitment) external view virtual onlyProxy returns (bool) {
return _isRegisteredDscKeyCommitment[commitment];
}
@@ -243,15 +224,7 @@ contract IdentityRegistryImplV1 is
* @param root The Merkle tree root.
* @return The timestamp corresponding to the given root.
*/
function rootTimestamps(
uint256 root
)
external
virtual
onlyProxy
view
returns (uint256)
{
function rootTimestamps(uint256 root) external view virtual onlyProxy returns (uint256) {
return _rootTimestamps[root];
}
@@ -260,14 +233,7 @@ contract IdentityRegistryImplV1 is
* @param root The Merkle tree root.
* @return True if the root exists, false otherwise.
*/
function checkIdentityCommitmentRoot(
uint256 root
)
external
onlyProxy
view
returns (bool)
{
function checkIdentityCommitmentRoot(uint256 root) external view onlyProxy returns (bool) {
return _rootTimestamps[root] != 0;
}
@@ -275,12 +241,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the number of identity commitments in the Merkle tree.
* @return The size of the identity commitment Merkle tree.
*/
function getIdentityCommitmentMerkleTreeSize()
external
onlyProxy
view
returns (uint256)
{
function getIdentityCommitmentMerkleTreeSize() external view onlyProxy returns (uint256) {
return _identityCommitmentIMT.size;
}
@@ -288,12 +249,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the current Merkle root of the identity commitments.
* @return The current identity commitment Merkle root.
*/
function getIdentityCommitmentMerkleRoot()
external
onlyProxy
view
returns (uint256)
{
function getIdentityCommitmentMerkleRoot() external view onlyProxy returns (uint256) {
return _identityCommitmentIMT._root();
}
@@ -302,14 +258,7 @@ contract IdentityRegistryImplV1 is
* @param commitment The identity commitment to locate.
* @return The index of the provided commitment within the Merkle tree.
*/
function getIdentityCommitmentIndex(
uint256 commitment
)
external
onlyProxy
view
returns (uint256)
{
function getIdentityCommitmentIndex(uint256 commitment) external view onlyProxy returns (uint256) {
return _identityCommitmentIMT._indexOf(commitment);
}
@@ -317,12 +266,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the current passport number OFAC root.
* @return The stored passport number OFAC root.
*/
function getPassportNoOfacRoot()
external
onlyProxy
view
returns (uint256)
{
function getPassportNoOfacRoot() external view onlyProxy returns (uint256) {
return _passportNoOfacRoot;
}
@@ -330,12 +274,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the current name and date of birth OFAC root.
* @return The stored name and date of birth OFAC root.
*/
function getNameAndDobOfacRoot()
external
onlyProxy
view
returns (uint256)
{
function getNameAndDobOfacRoot() external view onlyProxy returns (uint256) {
return _nameAndDobOfacRoot;
}
@@ -343,12 +282,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the current name and year of birth OFAC root.
* @return The stored name and year of birth OFAC root.
*/
function getNameAndYobOfacRoot()
external
onlyProxy
view
returns (uint256)
{
function getNameAndYobOfacRoot() external view onlyProxy returns (uint256) {
return _nameAndYobOfacRoot;
}
@@ -363,27 +297,18 @@ contract IdentityRegistryImplV1 is
uint256 passportNoRoot,
uint256 nameAndDobRoot,
uint256 nameAndYobRoot
)
external
onlyProxy
view
returns (bool)
{
return _passportNoOfacRoot == passportNoRoot
&& _nameAndDobOfacRoot == nameAndDobRoot
&& _nameAndYobOfacRoot == nameAndYobRoot;
) external view onlyProxy returns (bool) {
return
_passportNoOfacRoot == passportNoRoot &&
_nameAndDobOfacRoot == nameAndDobRoot &&
_nameAndYobOfacRoot == nameAndYobRoot;
}
/**
* @notice Retrieves the current CSCA root.
* @return The stored CSCA root.
*/
function getCscaRoot()
external
onlyProxy
view
returns (uint256)
{
function getCscaRoot() external view onlyProxy returns (uint256) {
return _cscaRoot;
}
@@ -392,14 +317,7 @@ contract IdentityRegistryImplV1 is
* @param root The CSCA root to validate.
* @return True if the provided root is equal to the stored CSCA root, false otherwise.
*/
function checkCscaRoot(
uint256 root
)
external
onlyProxy
view
returns (bool)
{
function checkCscaRoot(uint256 root) external view onlyProxy returns (bool) {
return _cscaRoot == root;
}
@@ -407,12 +325,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the current Merkle root of the DSC key commitments.
* @return The current DSC key commitment Merkle root.
*/
function getDscKeyCommitmentMerkleRoot()
external
onlyProxy
view
returns (uint256)
{
function getDscKeyCommitmentMerkleRoot() external view onlyProxy returns (uint256) {
return _dscKeyCommitmentIMT._root();
}
@@ -421,14 +334,7 @@ contract IdentityRegistryImplV1 is
* @param root The root to validate.
* @return True if the roots match, false otherwise.
*/
function checkDscKeyCommitmentMerkleRoot(
uint256 root
)
external
onlyProxy
view
returns (bool)
{
function checkDscKeyCommitmentMerkleRoot(uint256 root) external view onlyProxy returns (bool) {
return _dscKeyCommitmentIMT._root() == root;
}
@@ -436,12 +342,7 @@ contract IdentityRegistryImplV1 is
* @notice Retrieves the number of DSC key commitments in the Merkle tree.
* @return The DSC key commitment Merkle tree size.
*/
function getDscKeyCommitmentTreeSize()
external
onlyProxy
view
returns (uint256)
{
function getDscKeyCommitmentTreeSize() external view onlyProxy returns (uint256) {
return _dscKeyCommitmentIMT.size;
}
@@ -450,14 +351,7 @@ contract IdentityRegistryImplV1 is
* @param commitment The DSC key commitment to locate.
* @return The index of the provided commitment within the DSC key commitment Merkle tree.
*/
function getDscKeyCommitmentIndex(
uint256 commitment
)
external
onlyProxy
view
returns (uint256)
{
function getDscKeyCommitmentIndex(uint256 commitment) external view onlyProxy returns (uint256) {
return _dscKeyCommitmentIMT._indexOf(commitment);
}
@@ -476,11 +370,7 @@ contract IdentityRegistryImplV1 is
bytes32 attestationId,
uint256 nullifier,
uint256 commitment
)
external
onlyProxy
onlyHub
{
) external onlyProxy onlyHub {
if (_nullifiers[attestationId][nullifier]) revert REGISTERED_COMMITMENT();
_nullifiers[attestationId][nullifier] = true;
@@ -495,13 +385,7 @@ contract IdentityRegistryImplV1 is
* @dev Caller must be the hub. Reverts if the commitment has already been registered.
* @param dscCommitment The DSC key commitment to register.
*/
function registerDscKeyCommitment(
uint256 dscCommitment
)
external
onlyProxy
onlyHub
{
function registerDscKeyCommitment(uint256 dscCommitment) external onlyProxy onlyHub {
if (_isRegisteredDscKeyCommitment[dscCommitment]) revert REGISTERED_COMMITMENT();
_isRegisteredDscKeyCommitment[dscCommitment] = true;
@@ -519,13 +403,7 @@ contract IdentityRegistryImplV1 is
* @dev Callable only via a proxy and restricted to the contract owner.
* @param newHubAddress The new address of the hub.
*/
function updateHub(
address newHubAddress
)
external
onlyProxy
onlyOwner
{
function updateHub(address newHubAddress) external onlyProxy onlyOwner {
_hub = newHubAddress;
emit HubUpdated(newHubAddress);
}
@@ -535,13 +413,7 @@ contract IdentityRegistryImplV1 is
* @dev Callable only via a proxy and restricted to the contract owner.
* @param newPassportNoOfacRoot The new passport number OFAC root value.
*/
function updatePassportNoOfacRoot(
uint256 newPassportNoOfacRoot
)
external
onlyProxy
onlyOwner
{
function updatePassportNoOfacRoot(uint256 newPassportNoOfacRoot) external onlyProxy onlyOwner {
_passportNoOfacRoot = newPassportNoOfacRoot;
emit PassportNoOfacRootUpdated(newPassportNoOfacRoot);
}
@@ -551,13 +423,7 @@ contract IdentityRegistryImplV1 is
* @dev Callable only via a proxy and restricted to the contract owner.
* @param newNameAndDobOfacRoot The new name and date of birth OFAC root value.
*/
function updateNameAndDobOfacRoot(
uint256 newNameAndDobOfacRoot
)
external
onlyProxy
onlyOwner
{
function updateNameAndDobOfacRoot(uint256 newNameAndDobOfacRoot) external onlyProxy onlyOwner {
_nameAndDobOfacRoot = newNameAndDobOfacRoot;
emit NameAndDobOfacRootUpdated(newNameAndDobOfacRoot);
}
@@ -567,13 +433,7 @@ contract IdentityRegistryImplV1 is
* @dev Callable only via a proxy and restricted to the contract owner.
* @param newNameAndYobOfacRoot The new name and year of birth OFAC root value.
*/
function updateNameAndYobOfacRoot(
uint256 newNameAndYobOfacRoot
)
external
onlyProxy
onlyOwner
{
function updateNameAndYobOfacRoot(uint256 newNameAndYobOfacRoot) external onlyProxy onlyOwner {
_nameAndYobOfacRoot = newNameAndYobOfacRoot;
emit NameAndYobOfacRootUpdated(newNameAndYobOfacRoot);
}
@@ -583,18 +443,11 @@ contract IdentityRegistryImplV1 is
* @dev Callable only via a proxy and restricted to the contract owner.
* @param newCscaRoot The new CSCA root value.
*/
function updateCscaRoot(
uint256 newCscaRoot
)
external
onlyProxy
onlyOwner
{
function updateCscaRoot(uint256 newCscaRoot) external onlyProxy onlyOwner {
_cscaRoot = newCscaRoot;
emit CscaRootUpdated(newCscaRoot);
}
/**
* @notice (DEV) Force-adds an identity commitment.
* @dev Callable only by the owner for testing or administration.
@@ -606,11 +459,7 @@ contract IdentityRegistryImplV1 is
bytes32 attestationId,
uint256 nullifier,
uint256 commitment
)
external
onlyProxy
onlyOwner
{
) external onlyProxy onlyOwner {
_nullifiers[attestationId][nullifier] = true;
uint256 imt_root = _addCommitment(_identityCommitmentIMT, commitment);
_rootTimestamps[imt_root] = block.timestamp;
@@ -629,11 +478,7 @@ contract IdentityRegistryImplV1 is
uint256 oldLeaf,
uint256 newLeaf,
uint256[] calldata siblingNodes
)
external
onlyProxy
onlyOwner
{
) external onlyProxy onlyOwner {
uint256 imt_root = _updateCommitment(_identityCommitmentIMT, oldLeaf, newLeaf, siblingNodes);
_rootTimestamps[imt_root] = block.timestamp;
emit DevCommitmentUpdated(oldLeaf, newLeaf, imt_root, block.timestamp);
@@ -645,14 +490,7 @@ contract IdentityRegistryImplV1 is
* @param oldLeaf The identity commitment to remove.
* @param siblingNodes An array of sibling nodes for Merkle proof generation.
*/
function devRemoveCommitment(
uint256 oldLeaf,
uint256[] calldata siblingNodes
)
external
onlyProxy
onlyOwner
{
function devRemoveCommitment(uint256 oldLeaf, uint256[] calldata siblingNodes) external onlyProxy onlyOwner {
uint256 imt_root = _removeCommitment(_identityCommitmentIMT, oldLeaf, siblingNodes);
_rootTimestamps[imt_root] = block.timestamp;
emit DevCommitmentRemoved(oldLeaf, imt_root, block.timestamp);
@@ -663,13 +501,7 @@ contract IdentityRegistryImplV1 is
* @dev Callable only by the owner for testing or administration.
* @param dscCommitment The DSC key commitment to add.
*/
function devAddDscKeyCommitment(
uint256 dscCommitment
)
external
onlyProxy
onlyOwner
{
function devAddDscKeyCommitment(uint256 dscCommitment) external onlyProxy onlyOwner {
_isRegisteredDscKeyCommitment[dscCommitment] = true;
uint256 imt_root = _addCommitment(_dscKeyCommitmentIMT, dscCommitment);
uint256 index = _dscKeyCommitmentIMT._indexOf(dscCommitment);
@@ -687,11 +519,7 @@ contract IdentityRegistryImplV1 is
uint256 oldLeaf,
uint256 newLeaf,
uint256[] calldata siblingNodes
)
external
onlyProxy
onlyOwner
{
) external onlyProxy onlyOwner {
uint256 imt_root = _updateCommitment(_dscKeyCommitmentIMT, oldLeaf, newLeaf, siblingNodes);
emit DevDscKeyCommitmentUpdated(oldLeaf, newLeaf, imt_root);
}
@@ -702,14 +530,7 @@ contract IdentityRegistryImplV1 is
* @param oldLeaf The DSC key commitment to remove.
* @param siblingNodes An array of sibling nodes for Merkle proof generation.
*/
function devRemoveDscKeyCommitment(
uint256 oldLeaf,
uint256[] calldata siblingNodes
)
external
onlyProxy
onlyOwner
{
function devRemoveDscKeyCommitment(uint256 oldLeaf, uint256[] calldata siblingNodes) external onlyProxy onlyOwner {
uint256 imt_root = _removeCommitment(_dscKeyCommitmentIMT, oldLeaf, siblingNodes);
emit DevDscKeyCommitmentRemoved(oldLeaf, imt_root);
}
@@ -725,11 +546,7 @@ contract IdentityRegistryImplV1 is
bytes32 attestationId,
uint256 nullifier,
bool state
)
external
onlyProxy
onlyOwner
{
) external onlyProxy onlyOwner {
_nullifiers[attestationId][nullifier] = state;
emit DevNullifierStateChanged(attestationId, nullifier, state);
}
@@ -740,14 +557,7 @@ contract IdentityRegistryImplV1 is
* @param dscCommitment The DSC key commitment.
* @param state The new state of the DSC key commitment (true for registered, false for not registered).
*/
function devChangeDscKeyCommitmentState(
uint256 dscCommitment,
bool state
)
external
onlyProxy
onlyOwner
{
function devChangeDscKeyCommitmentState(uint256 dscCommitment, bool state) external onlyProxy onlyOwner {
_isRegisteredDscKeyCommitment[dscCommitment] = state;
emit DevDscKeyCommitmentStateChanged(dscCommitment, state);
}
@@ -763,13 +573,7 @@ contract IdentityRegistryImplV1 is
* @param commitment The commitment to add.
* @return imt_root The new Merkle tree root after insertion.
*/
function _addCommitment(
LeanIMTData storage imt,
uint256 commitment
)
internal
returns(uint256 imt_root)
{
function _addCommitment(LeanIMTData storage imt, uint256 commitment) internal returns (uint256 imt_root) {
imt_root = imt._insert(commitment);
}
@@ -787,10 +591,7 @@ contract IdentityRegistryImplV1 is
uint256 oldLeaf,
uint256 newLeaf,
uint256[] calldata siblingNodes
)
internal
returns(uint256 imt_root)
{
) internal returns (uint256 imt_root) {
imt_root = imt._update(oldLeaf, newLeaf, siblingNodes);
}
@@ -806,10 +607,7 @@ contract IdentityRegistryImplV1 is
LeanIMTData storage imt,
uint256 oldLeaf,
uint256[] calldata siblingNodes
)
internal
returns(uint256 imt_root)
{
) internal returns (uint256 imt_root) {
imt_root = imt._remove(oldLeaf, siblingNodes);
}
}

View File

@@ -10,17 +10,13 @@ import {CircuitConstants} from "../constants/CircuitConstants.sol";
/// @notice A contract for verifying identity proofs and revealing selected data
/// @dev This contract interacts with IdentityVerificationHub and IdentityRegistry
contract VerifyAll is Ownable {
IIdentityVerificationHubV1 public hub;
IIdentityRegistryV1 public registry;
/// @notice Initializes the contract with hub and registry addresses
/// @param hubAddress The address of the IdentityVerificationHub contract
/// @param registryAddress The address of the IdentityRegistry contract
constructor(
address hubAddress,
address registryAddress
) Ownable(msg.sender) {
constructor(address hubAddress, address registryAddress) Ownable(msg.sender) {
hub = IIdentityVerificationHubV1(hubAddress);
registry = IIdentityRegistryV1(registryAddress);
}
@@ -31,22 +27,15 @@ contract VerifyAll is Ownable {
/// @param types Array of data types to reveal
/// @return readableData The revealed data in readable format
/// @return success Whether the verification was successful
function verifyAll (
function verifyAll(
uint256 targetRootTimestamp,
IIdentityVerificationHubV1.VcAndDiscloseHubProof memory proof,
IIdentityVerificationHubV1.RevealedDataType[] memory types
)
external
view
returns (
IIdentityVerificationHubV1.ReadableRevealedData memory,
bool,
string memory
)
{
) external view returns (IIdentityVerificationHubV1.ReadableRevealedData memory, bool, string memory) {
IIdentityVerificationHubV1.VcAndDiscloseVerificationResult memory result;
try hub.verifyVcAndDisclose(proof) returns (IIdentityVerificationHubV1.VcAndDiscloseVerificationResult memory _result) {
try hub.verifyVcAndDisclose(proof) returns (
IIdentityVerificationHubV1.VcAndDiscloseVerificationResult memory _result
) {
result = _result;
} catch (bytes memory lowLevelData) {
string memory errorCode;
@@ -71,25 +60,8 @@ contract VerifyAll is Ownable {
errorCode = "INVALID_VC_AND_DISCLOSE_PROOF";
}
}
IIdentityVerificationHubV1.ReadableRevealedData memory emptyData = IIdentityVerificationHubV1.ReadableRevealedData({
issuingState: "",
name: new string[](0),
passportNumber: "",
nationality: "",
dateOfBirth: "",
gender: "",
expiryDate: "",
olderThan: 0,
passportNoOfac: 1,
nameAndDobOfac: 1,
nameAndYobOfac: 1
});
return (emptyData, false, errorCode);
}
if (targetRootTimestamp != 0) {
if (registry.rootTimestamps(result.identityCommitmentRoot) != targetRootTimestamp) {
IIdentityVerificationHubV1.ReadableRevealedData memory emptyData = IIdentityVerificationHubV1.ReadableRevealedData({
IIdentityVerificationHubV1.ReadableRevealedData memory emptyData = IIdentityVerificationHubV1
.ReadableRevealedData({
issuingState: "",
name: new string[](0),
passportNumber: "",
@@ -102,12 +74,33 @@ contract VerifyAll is Ownable {
nameAndDobOfac: 1,
nameAndYobOfac: 1
});
return (emptyData, false, errorCode);
}
if (targetRootTimestamp != 0) {
if (registry.rootTimestamps(result.identityCommitmentRoot) != targetRootTimestamp) {
IIdentityVerificationHubV1.ReadableRevealedData memory emptyData = IIdentityVerificationHubV1
.ReadableRevealedData({
issuingState: "",
name: new string[](0),
passportNumber: "",
nationality: "",
dateOfBirth: "",
gender: "",
expiryDate: "",
olderThan: 0,
passportNoOfac: 1,
nameAndDobOfac: 1,
nameAndYobOfac: 1
});
return (emptyData, false, "INVALID_TIMESTAMP");
}
}
uint256[3] memory revealedDataPacked = result.revealedDataPacked;
IIdentityVerificationHubV1.ReadableRevealedData memory readableData = hub.getReadableRevealedData(revealedDataPacked, types);
IIdentityVerificationHubV1.ReadableRevealedData memory readableData = hub.getReadableRevealedData(
revealedDataPacked,
types
);
return (readableData, true, "");
}
@@ -125,5 +118,4 @@ contract VerifyAll is Ownable {
function setRegistry(address registryAddress) external onlyOwner {
registry = IIdentityRegistryV1(registryAddress);
}
}

View File

@@ -58,15 +58,14 @@ contract TestCircuitAttributeHandler {
bool checkNameAndDob,
bool checkNameAndYob
) external pure returns (bool) {
return CircuitAttributeHandler.compareOfac(
charcodes,
checkPassportNo,
checkNameAndDob,
checkNameAndYob
);
return CircuitAttributeHandler.compareOfac(charcodes, checkPassportNo, checkNameAndDob, checkNameAndYob);
}
function testExtractStringAttribute(bytes memory charcodes, uint256 start, uint256 end) external pure returns (string memory) {
function testExtractStringAttribute(
bytes memory charcodes,
uint256 start,
uint256 end
) external pure returns (string memory) {
return CircuitAttributeHandler.extractStringAttribute(charcodes, start, end);
}
}

View File

@@ -20,11 +20,9 @@ contract TestFormatter {
return Formatter.fieldElementsToBytes(publicSignals);
}
function testExtractForbiddenCountriesFromPacked(uint256[4] memory publicSignals)
external
pure
returns (string[40] memory)
{
function testExtractForbiddenCountriesFromPacked(
uint256[4] memory publicSignals
) external pure returns (string[40] memory) {
return Formatter.extractForbiddenCountriesFromPacked(publicSignals);
}

View File

@@ -4,12 +4,11 @@ pragma solidity 0.8.28;
import {ImplRoot} from "../../contracts/upgradeable/ImplRoot.sol";
contract MockImplRoot is ImplRoot {
function exposed__ImplRoot_init() external {
__ImplRoot_init();
}
function exposed__Ownable_init(address initialOwner) external initializer() {
function exposed__Ownable_init(address initialOwner) external initializer {
__Ownable_init(initialOwner);
}

View File

@@ -2,15 +2,14 @@
pragma solidity 0.8.28;
import {IdentityRegistryStorageV1} from "../registry/IdentityRegistryImplV1.sol";
import { InternalLeanIMT, LeanIMTData } from "@zk-kit/imt.sol/internal/InternalLeanIMT.sol";
import {InternalLeanIMT, LeanIMTData} from "@zk-kit/imt.sol/internal/InternalLeanIMT.sol";
/**
* @title IdentityRegistryStorageV1
* @dev Abstract contract for storage layout of IdentityRegistryImplV1.
* Inherits from ImplRoot to provide upgradeable functionality.
*/
abstract contract UpgradedIdentityRegistryStorageV1
{
abstract contract UpgradedIdentityRegistryStorageV1 {
bool internal _isTest;
}
@@ -19,10 +18,7 @@ abstract contract UpgradedIdentityRegistryStorageV1
* @notice Provides functions to register and manage identity commitments using a Merkle tree structure.
* @dev Inherits from IdentityRegistryStorageV1 and implements IIdentityRegistryV1.
*/
contract testUpgradedIdentityRegistryImplV1 is
IdentityRegistryStorageV1,
UpgradedIdentityRegistryStorageV1
{
contract testUpgradedIdentityRegistryImplV1 is IdentityRegistryStorageV1, UpgradedIdentityRegistryStorageV1 {
using InternalLeanIMT for LeanIMTData;
// ====================================================
@@ -54,12 +50,7 @@ contract testUpgradedIdentityRegistryImplV1 is
* @dev Sets the hub address and initializes the UUPS upgradeable feature.
* @param isTestInput The address of the identity verification hub.
*/
function initialize(
bool isTestInput
)
external
reinitializer(2)
{
function initialize(bool isTestInput) external reinitializer(2) {
__ImplRoot_init();
_isTest = isTestInput;
emit TestRegistryInitialized();
@@ -69,127 +60,51 @@ contract testUpgradedIdentityRegistryImplV1 is
// External Functions - View & Checks
// ====================================================
function isTest()
external
virtual
onlyProxy
view
returns (bool)
{
function isTest() external view virtual onlyProxy returns (bool) {
return _isTest;
}
function hub()
external
virtual
onlyProxy
view
returns (address)
{
function hub() external view virtual onlyProxy returns (address) {
return _hub;
}
function nullifiers(
bytes32 attestationId,
uint256 nullifier
)
external
virtual
onlyProxy
view
returns (bool)
{
function nullifiers(bytes32 attestationId, uint256 nullifier) external view virtual onlyProxy returns (bool) {
return _nullifiers[attestationId][nullifier];
}
function isRegisteredDscKeyCommitment(
uint256 commitment
)
external
virtual
onlyProxy
view
returns (bool)
{
function isRegisteredDscKeyCommitment(uint256 commitment) external view virtual onlyProxy returns (bool) {
return _isRegisteredDscKeyCommitment[commitment];
}
function rootTimestamps(
uint256 root
)
external
virtual
onlyProxy
view
returns (uint256)
{
function rootTimestamps(uint256 root) external view virtual onlyProxy returns (uint256) {
return _rootTimestamps[root];
}
function checkIdentityCommitmentRoot(
uint256 root
)
external
onlyProxy
view
returns (bool)
{
function checkIdentityCommitmentRoot(uint256 root) external view onlyProxy returns (bool) {
return _rootTimestamps[root] != 0;
}
function getIdentityCommitmentMerkleTreeSize()
external
onlyProxy
view
returns (uint256)
{
function getIdentityCommitmentMerkleTreeSize() external view onlyProxy returns (uint256) {
return _identityCommitmentIMT.size;
}
function getIdentityCommitmentMerkleRoot()
external
onlyProxy
view
returns (uint256)
{
function getIdentityCommitmentMerkleRoot() external view onlyProxy returns (uint256) {
return _identityCommitmentIMT._root();
}
function getIdentityCommitmentIndex(
uint256 commitment
)
external
onlyProxy
view
returns (uint256)
{
function getIdentityCommitmentIndex(uint256 commitment) external view onlyProxy returns (uint256) {
return _identityCommitmentIMT._indexOf(commitment);
}
function getPassportNoOfacRoot()
external
onlyProxy
view
returns (uint256)
{
function getPassportNoOfacRoot() external view onlyProxy returns (uint256) {
return _passportNoOfacRoot;
}
function getNameAndDobOfacRoot()
external
onlyProxy
view
returns (uint256)
{
function getNameAndDobOfacRoot() external view onlyProxy returns (uint256) {
return _nameAndDobOfacRoot;
}
function getNameAndYobOfacRoot()
external
onlyProxy
view
returns (uint256)
{
function getNameAndYobOfacRoot() external view onlyProxy returns (uint256) {
return _nameAndYobOfacRoot;
}
@@ -197,75 +112,34 @@ contract testUpgradedIdentityRegistryImplV1 is
uint256 passportNoRoot,
uint256 nameAndDobRoot,
uint256 nameAndYobRoot
)
external
onlyProxy
view
returns (bool)
{
return _passportNoOfacRoot == passportNoRoot
&& _nameAndDobOfacRoot == nameAndDobRoot
&& _nameAndYobOfacRoot == nameAndYobRoot;
) external view onlyProxy returns (bool) {
return
_passportNoOfacRoot == passportNoRoot &&
_nameAndDobOfacRoot == nameAndDobRoot &&
_nameAndYobOfacRoot == nameAndYobRoot;
}
function getCscaRoot()
external
onlyProxy
view
returns (uint256)
{
function getCscaRoot() external view onlyProxy returns (uint256) {
return _cscaRoot;
}
function checkCscaRoot(
uint256 root
)
external
onlyProxy
view
returns (bool)
{
function checkCscaRoot(uint256 root) external view onlyProxy returns (bool) {
return _cscaRoot == root;
}
function getDscKeyCommitmentMerkleRoot()
external
onlyProxy
view
returns (uint256)
{
function getDscKeyCommitmentMerkleRoot() external view onlyProxy returns (uint256) {
return _dscKeyCommitmentIMT._root();
}
function checkDscKeyCommitmentMerkleRoot(
uint256 root
)
external
onlyProxy
view
returns (bool)
{
function checkDscKeyCommitmentMerkleRoot(uint256 root) external view onlyProxy returns (bool) {
return _dscKeyCommitmentIMT._root() == root;
}
function getDscKeyCommitmentTreeSize()
external
onlyProxy
view
returns (uint256)
{
function getDscKeyCommitmentTreeSize() external view onlyProxy returns (uint256) {
return _dscKeyCommitmentIMT.size;
}
function getDscKeyCommitmentIndex(
uint256 commitment
)
external
onlyProxy
view
returns (uint256)
{
function getDscKeyCommitmentIndex(uint256 commitment) external view onlyProxy returns (uint256) {
return _dscKeyCommitmentIMT._indexOf(commitment);
}
}

View File

@@ -3,8 +3,7 @@ pragma solidity 0.8.28;
import {IdentityVerificationHubStorageV1} from "../IdentityVerificationHubImplV1.sol";
abstract contract UpgradedIdentityVerificationHubStorageV1
{
abstract contract UpgradedIdentityVerificationHubStorageV1 {
bool internal _isTest;
}
@@ -17,7 +16,6 @@ contract testUpgradedIdentityVerificationHubImplV1 is
IdentityVerificationHubStorageV1,
UpgradedIdentityVerificationHubStorageV1
{
// ====================================================
// Events
// ====================================================
@@ -48,12 +46,7 @@ contract testUpgradedIdentityVerificationHubImplV1 is
* @dev Sets the registry, VC and Disclose circuit verifier address, register circuit verifiers, and DSC circuit verifiers.
* @param isTestInput Boolean value which shows it is test or not
*/
function initialize(
bool isTestInput
)
external
reinitializer(3)
{
function initialize(bool isTestInput) external reinitializer(3) {
__ImplRoot_init();
_isTest = isTestInput;
emit TestHubInitialized();
@@ -63,58 +56,23 @@ contract testUpgradedIdentityVerificationHubImplV1 is
// External View Functions
// ====================================================
function isTest()
external
virtual
onlyProxy
view
returns (bool)
{
function isTest() external view virtual onlyProxy returns (bool) {
return _isTest;
}
function registry()
external
virtual
onlyProxy
view
returns (address)
{
function registry() external view virtual onlyProxy returns (address) {
return _registry;
}
function vcAndDiscloseCircuitVerifier()
external
virtual
onlyProxy
view
returns (address)
{
function vcAndDiscloseCircuitVerifier() external view virtual onlyProxy returns (address) {
return _vcAndDiscloseCircuitVerifier;
}
function sigTypeToRegisterCircuitVerifiers(
uint256 typeId
)
external
virtual
onlyProxy
view
returns (address)
{
function sigTypeToRegisterCircuitVerifiers(uint256 typeId) external view virtual onlyProxy returns (address) {
return _sigTypeToRegisterCircuitVerifiers[typeId];
}
function sigTypeToDscCircuitVerifiers(
uint256 typeId
)
external
virtual
onlyProxy
view
returns (address)
{
function sigTypeToDscCircuitVerifiers(uint256 typeId) external view virtual onlyProxy returns (address) {
return _sigTypeToDscCircuitVerifiers[typeId];
}
}

View File

@@ -11,7 +11,6 @@ import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/acces
* Serves as a base for upgradeable implementations.
*/
abstract contract ImplRoot is UUPSUpgradeable, Ownable2StepUpgradeable {
// Reserved storage space to allow for layout changes in the future.
uint256[50] private __gap;
@@ -34,11 +33,5 @@ abstract contract ImplRoot is UUPSUpgradeable, Ownable2StepUpgradeable {
*
* @param newImplementation The address of the new implementation contract.
*/
function _authorizeUpgrade(address newImplementation)
internal
virtual
override
onlyProxy
onlyOwner
{}
function _authorizeUpgrade(address newImplementation) internal virtual override onlyProxy onlyOwner {}
}

View File

@@ -56,9 +56,7 @@ contract PCR0Manager is Ownable {
* @param pcr0 The PCR0 value (must be exactly 48 bytes).
* @return exists True if the PCR0 entry is set, false otherwise.
*/
function isPCR0Set(
bytes calldata pcr0
) external view returns (bool exists) {
function isPCR0Set(bytes calldata pcr0) external view returns (bool exists) {
require(pcr0.length == 48, "PCR0 must be 48 bytes");
bytes32 key = keccak256(pcr0);
return pcr0Mapping[key];

View File

@@ -22,17 +22,17 @@ 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_vc_and_disclose {
uint256 constant deltay1 = 11327385974519668968032322736085307141713806429709421661182708424466117238997;
uint256 constant deltay2 = 10012305292867396754099447814288164358641801402945324446509796861150789568449;
uint256 constant IC0x = 5645809423132108234526155064520926563161700247800213537205723921444703247217;
uint256 constant IC0y = 19273662370473753554670561090991166814029325379251212873103161241607581584566;
@@ -109,14 +108,18 @@ contract Verifier_vc_and_disclose {
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)) {
@@ -202,7 +205,6 @@ 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))
@@ -227,7 +229,6 @@ 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)
@@ -244,7 +245,6 @@ 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))
@@ -297,12 +297,11 @@ 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)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
uint256 constant deltay1 = 17358074359516820567886963253083730754218121289514382698389644314857108532365;
uint256 constant deltay2 = 17847472407947487752691527368222893047739716651050784182328983734421006293675;
uint256 constant IC0x = 5393250947825600017034594097684527686937701214367414304055479197751874088030;
uint256 constant IC0y = 12743141085881515208211444893873526784081968137100496383444454251322551211985;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
uint256 constant IC2x = 13643299466840868611336555216971795865784486256260896870186827756722920150974;
uint256 constant IC2y = 20031729898069918506238105181470744579329641989307020151184529733341690802885;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha1_ecdsa_brainpoolP256r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha1_ecdsa_secp256r1 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha1_ecdsa_secp256r1 {
uint256 constant deltay1 = 3390456600443455506302148812517000321496337766593349757273547140119846451145;
uint256 constant deltay2 = 2683709453415812541600943744993443543337313128850472580051355886800639784468;
uint256 constant IC0x = 12675676047730170209192964659628979792421583884835081061924340503292148118580;
uint256 constant IC0y = 8005429490912458496906425839158171340037163354900427604245368710533256420277;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha1_ecdsa_secp256r1 {
uint256 constant IC2x = 3886285320844557718123920951668542008337481352970679360571120460620571049685;
uint256 constant IC2y = 17415151548883447323439745357012235200330074749013787777992538418692677126646;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha1_ecdsa_secp256r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha1_ecdsa_secp256r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha1_ecdsa_secp256r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha1_ecdsa_secp256r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha1_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha1_rsa_65537_4096 {
uint256 constant deltay1 = 12386861633939357897311726220181767463730553921920146231142618441123850504498;
uint256 constant deltay2 = 20674470883201731689984003870617302131050815771343007030459371218911924891868;
uint256 constant IC0x = 19441255926750545468944197116731261414848766598030018894405396352503089003164;
uint256 constant IC0y = 15758814426349860038201583006832227885235721848718900437115777674827804990280;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha1_rsa_65537_4096 {
uint256 constant IC2x = 4394258923847165352620826784124810658800222064222876328666862381090940769588;
uint256 constant IC2y = 19075507518746698810956333568507654968578908476359054856477836730424433683865;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha1_rsa_65537_4096 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha1_rsa_65537_4096 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha1_rsa_65537_4096 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha1_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
uint256 constant deltay1 = 10676263205742724055795903745183410124676856230246162639796185570871828571842;
uint256 constant deltay2 = 5765951428532505799282159403858152905631348236021397710413408355430143979177;
uint256 constant IC0x = 15367206121839955762011823176432875107209278826038812451160502020912672517809;
uint256 constant IC0y = 21041512010143355829864892490387365789381441587680866631795817779631552157379;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
uint256 constant IC2x = 13658331438879300214497268120729163368666540297060972204419000979008026097718;
uint256 constant IC2y = 20379908478303656704441112836919060185289193632233027919281111997672857211682;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP256r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
uint256 constant deltay1 = 6889184159765420951789007505474196844250709203374834149407655944002134144724;
uint256 constant deltay2 = 1966263721788283447467356361246921957144249784577408980069297668772679638312;
uint256 constant IC0x = 659580088998578070030981389513074306430378313664542931151252973393681626386;
uint256 constant IC0y = 15847497078695440584225276689193018348032687730924578011825150388408764804768;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
uint256 constant IC2x = 19337579933634766979148936619938139523936041901664035344355521113670520489071;
uint256 constant IC2y = 20973272345953147783510881552260259207464823597684557274545396051166816559680;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_ecdsa_brainpoolP384r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_ecdsa_secp256r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_ecdsa_secp256r1 {
uint256 constant deltay1 = 1379990108520784981499684190353513521686894359798300105485844449527113172532;
uint256 constant deltay2 = 16032227002624596941901664869778919446531437354171143943844739013887015790377;
uint256 constant IC0x = 12230279487075355588146232877411380641395694907111257837299763475907667270301;
uint256 constant IC0y = 6665239488894449502473370954745820351617517323389685182308103006269196795762;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_ecdsa_secp256r1 {
uint256 constant IC2x = 13658331438879300214497268120729163368666540297060972204419000979008026097718;
uint256 constant IC2y = 20379908478303656704441112836919060185289193632233027919281111997672857211682;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_ecdsa_secp256r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_ecdsa_secp256r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_ecdsa_secp256r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_ecdsa_secp256r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_ecdsa_secp384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_ecdsa_secp384r1 {
uint256 constant deltay1 = 13512628501729381786391242403503084146555269333604181607408712699616544867996;
uint256 constant deltay2 = 16722612627662957493583650570582460390230415127323126464445453467663398955195;
uint256 constant IC0x = 18191126408084701504224562638938466976633511856094029564921061288421096529536;
uint256 constant IC0y = 7874170387655554596704243322916448411301165813842964589259974876466852751248;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_ecdsa_secp384r1 {
uint256 constant IC2x = 19337579933634766979148936619938139523936041901664035344355521113670520489071;
uint256 constant IC2y = 20973272345953147783510881552260259207464823597684557274545396051166816559680;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_ecdsa_secp384r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_ecdsa_secp384r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_ecdsa_secp384r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_ecdsa_secp384r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_ecdsa_secp521r1 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_ecdsa_secp521r1 {
uint256 constant deltay1 = 968125866770846796808710939585846643817058108093372960570701629910784318864;
uint256 constant deltay2 = 12216864206212511235315976798082889872627544441390643890886155153587471762186;
uint256 constant IC0x = 11198407869990430604822080005647844132231169087019364625207841772083886082756;
uint256 constant IC0y = 13774799428851210074159336555321647634507660666641475242236156913076712041741;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_ecdsa_secp521r1 {
uint256 constant IC2x = 7608609333225637846753797474786477234041135378858688651993341996547239218662;
uint256 constant IC2y = 13036970020621774119816858757427303597665775583602766779799942821487978394693;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_ecdsa_secp521r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_ecdsa_secp521r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_ecdsa_secp521r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_ecdsa_secp521r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_rsa_65537_4096 {
uint256 constant deltay1 = 661501627404154996169608794002694935021757801103289852114117015566911946329;
uint256 constant deltay2 = 16567452430156862387837146752441453364293918383742739848718397860115822800064;
uint256 constant IC0x = 16241005142482247661355611805985713223142625546320321652729411817292725880336;
uint256 constant IC0y = 3849621357564233957000975509069645451659363466776730319973246136787524980317;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_rsa_65537_4096 {
uint256 constant IC2x = 17687125118780526381226454443022323594075307431677202777564475001260807144360;
uint256 constant IC2y = 14674940982284194393439442374112009934497090740281796410892352815734408931543;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_rsa_65537_4096 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_rsa_65537_4096 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_rsa_65537_4096 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_rsapss_3_32_3072 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_rsapss_3_32_3072 {
uint256 constant deltay1 = 232140573053947840553411220443388261235372949489202414188606995434296840450;
uint256 constant deltay2 = 8130092547923778131965928343347244161930368940161259856055262342565208619784;
uint256 constant IC0x = 12620464585052290819007856763660336208940278196659572856453355517783047375742;
uint256 constant IC0y = 3390602569146793076585074263480269117585089933082768513956969996350087851372;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_rsapss_3_32_3072 {
uint256 constant IC2x = 2489498112724333902281234525518992117856181811211455677336589248443139008958;
uint256 constant IC2y = 10377122056032769734282101693368444643449184346801692898595672266480707718599;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_rsapss_3_32_3072 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_rsapss_3_32_3072 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_rsapss_3_32_3072 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_rsapss_3_32_3072 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
uint256 constant deltay1 = 3452760924868488115787557603097061457224840730939685141249091937251492206223;
uint256 constant deltay2 = 9423633604022314255524124098880883774245557038013638234906364773514027500607;
uint256 constant IC0x = 14813474503207570046610982310967746269243544059234641765135216737888053804829;
uint256 constant IC0y = 9154691151039599375957188306571890456577516100636751566387645654267738411601;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
uint256 constant IC2x = 10526229662163874368857932991034397082279427227544621549031532129140736236429;
uint256 constant IC2y = 3011706903789493036487088756766963655549402409867173019894262834743320055985;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_rsapss_65537_32_3072 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
uint256 constant deltay1 = 2589398613433727282285672702070166671377906963271015685181070150452765350638;
uint256 constant deltay2 = 4549130548838856553572072257366600539979637374865368325817346592762994580325;
uint256 constant IC0x = 10777640084867471361146393097597090893654888869164898377029432359502626112469;
uint256 constant IC0y = 20494567130868896678721094122076931742895456629840331660690065277736751914622;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
uint256 constant IC2x = 4784178454546895061300143369090412817442880785841947337501409752122515197376;
uint256 constant IC2y = 9279502414267368124275170396046179750616701209127504670483264465302019374739;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha256_rsapss_65537_32_4096 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
uint256 constant deltay1 = 2069564818639872727764109028571692796079865136168643667520460726036679827340;
uint256 constant deltay2 = 10931236091611661445812279018578580556292434706798406928566475215591616175333;
uint256 constant IC0x = 3078796548910792124867521966471565765478476660809266356296707871992775959653;
uint256 constant IC0y = 6800666731786189648626735200695616790848337999099082477128772951414448347754;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
uint256 constant IC2x = 6135759906556602512033221677791515863312102500467760742997691814407836834208;
uint256 constant IC2y = 8340907402047374494050668129923237269291489014758614848102437858941083505729;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP384r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
uint256 constant deltay1 = 16047974943909860300676356846359424106067013301701903269259394127906204387924;
uint256 constant deltay2 = 19121513428213240116044362882588137076351549644308466259528321350439646572263;
uint256 constant IC0x = 7873767668004917131331802256306079363018497214917800406656003818258696939352;
uint256 constant IC0y = 14912976041983106474346819001420266588695308519687724079672778493226556096333;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
uint256 constant IC2x = 8747441738906818716672964476834702185117504770235935488924766630345322944183;
uint256 constant IC2y = 18164498138633665708832988193754261643195939997946514564956248753295561758554;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha384_ecdsa_brainpoolP512r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha384_ecdsa_secp384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha384_ecdsa_secp384r1 {
uint256 constant deltay1 = 3439375804488391682047032793111742890384740981260877667704217117698837635540;
uint256 constant deltay2 = 10922495998532240778177754781915017080119363533174316459909222472814843353831;
uint256 constant IC0x = 15428527398346470570204225423347884116167911703577531010770592316532112978289;
uint256 constant IC0y = 11394444257441940827867166510282185266944605704751191013112365153909119560219;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha384_ecdsa_secp384r1 {
uint256 constant IC2x = 6135759906556602512033221677791515863312102500467760742997691814407836834208;
uint256 constant IC2y = 8340907402047374494050668129923237269291489014758614848102437858941083505729;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha384_ecdsa_secp384r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha384_ecdsa_secp384r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha384_ecdsa_secp384r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha384_ecdsa_secp384r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
uint256 constant deltay1 = 12369278861826334826775785697613986489421427981532861159941565055302380388435;
uint256 constant deltay2 = 268218501938740843576755870688043856015430017503150289273886004818951340211;
uint256 constant IC0x = 2854580057122758363137747486193301686434303619633504875611831707366593193268;
uint256 constant IC0y = 161152799478229153815090373143900568223205432805517132728553706296506229632;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
uint256 constant IC2x = 6535621112246865230629050883801747388199012560026269297051551123854305849670;
uint256 constant IC2y = 12613639586408767324115549737218218464694013359987071410410390868145511841392;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha512_ecdsa_brainpoolP512r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha512_ecdsa_secp521r1 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha512_ecdsa_secp521r1 {
uint256 constant deltay1 = 12112251966035714986038310379728868813344813567575772425184620994375435183493;
uint256 constant deltay2 = 541069664758689108623530630690631010640418421812375414721343442872115937402;
uint256 constant IC0x = 136910311248568363820473562407939112717019551412068446334589064796761238234;
uint256 constant IC0y = 14761093221964254612087739097195844172438739963995752455378640347842923505631;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha512_ecdsa_secp521r1 {
uint256 constant IC2x = 14358689694998711607953028013988003416714328323807188343803787983254880315583;
uint256 constant IC2y = 11617460142005906950398539783051988683143041496653951656062385487051296621592;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha512_ecdsa_secp521r1 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha512_ecdsa_secp521r1 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha512_ecdsa_secp521r1 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha512_ecdsa_secp521r1 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha512_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha512_rsa_65537_4096 {
uint256 constant deltay1 = 21428515931464385620730182368968406916666024874675101194599111378408011047428;
uint256 constant deltay2 = 1558724681363422124783587676312168410700012697885378202020602107711575601861;
uint256 constant IC0x = 8095362675719160713631337478379784798399194783598795655898223841598252282668;
uint256 constant IC0y = 6439154585539636799954577345503253289769574438600314903172693070772761377678;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha512_rsa_65537_4096 {
uint256 constant IC2x = 3599149666568952753127446987051032893129278914420714886060131651834276339909;
uint256 constant IC2y = 15474376648113943403208232183870381739764572044602735134638863326991559807772;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha512_rsa_65537_4096 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha512_rsa_65537_4096 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha512_rsa_65537_4096 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha512_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
uint256 constant deltay1 = 14143847869780845305359522342602190877307021059040613866307785597405878613945;
uint256 constant deltay2 = 11794579662045030403362807154209218712532002665441792443688263863248294733806;
uint256 constant IC0x = 9696026138342026395279592597616245033004914829363120240538663976676310016503;
uint256 constant IC0y = 1041019786294196872070965112981064093687515225465385286539234086481491269678;
@@ -52,14 +51,18 @@ contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
uint256 constant IC2x = 10054837955581817730135713476914697791847601592942603989577247562800734740144;
uint256 constant IC2y = 20016446798323781782121888846141370599179508808492367607695725852906963635076;
// 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[2] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[2] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -107,7 +110,6 @@ contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
g1_mulAccC(_pVk, IC2x, IC2y, calldataload(add(pubSignals, 32)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -132,7 +134,6 @@ contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
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)
@@ -149,7 +150,6 @@ contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
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))
@@ -164,12 +164,11 @@ contract Verifier_dsc_sha512_rsapss_65537_64_4096 {
checkField(calldataload(add(_pubSignals, 32)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
uint256 constant deltay1 = 18031898897154963414025141677622297401219665295749636217410864667281772000433;
uint256 constant deltay2 = 21831540883730035301413733264718453236289248639488942882934948388586980962845;
uint256 constant IC0x = 19509572610092207288670808612793005292427088225084923989481790232834691421218;
uint256 constant IC0y = 20981186445151391222764194225178707477545220084289882124966253025319330386716;
@@ -55,14 +54,18 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
uint256 constant IC3x = 11911512511832804727234578540995600437810078524965709720308124945378582921495;
uint256 constant IC3y = 20562189586897282263315939558507913305487143843850828495916004211153189021293;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_brainpoolP224r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
uint256 constant deltay1 = 9448382163867444066295328702218988975263374023667830442650604436203430718782;
uint256 constant deltay2 = 3390587171884285909512991075541156150549390244719272045010214315075006407592;
uint256 constant IC0x = 16450632745264405183134879933548836357522771992781381371437352893044233134089;
uint256 constant IC0y = 7406049893990952623098067634432868719037604070795933670159207846811098380152;
@@ -55,14 +54,18 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
uint256 constant IC3x = 3590539162724376220252043367439687121476794060909776981340467603542696454783;
uint256 constant IC3y = 9817658469812892944717716328749390598728625285115805840044120011595137437624;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
uint256 constant deltay1 = 3665741634116606936489770677276959138129221741447229704587025783098245795085;
uint256 constant deltay2 = 403539896334743856854319107138699105727408472499380778544123756001283833378;
uint256 constant IC0x = 20756451814539478249751219749430622694437886828255681030901283599531849607563;
uint256 constant IC0y = 10515539338155791301560829975566985059585726032052087045959182102863044641627;
@@ -55,14 +54,18 @@ contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
uint256 constant IC3x = 21371077966007684491944419706317642834377204594723191303711655277642289355259;
uint256 constant IC3y = 6514391881814533347944634607795370652611541523264920880959575958638411648255;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha1_sha1_sha1_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
uint256 constant deltay1 = 12314715100513663962818487492216029300388813419191267519828806049674208132775;
uint256 constant deltay2 = 10470523697438015174056330463148535375729117776768240109864817806935384204557;
uint256 constant IC0x = 12361539322653261021360066647549205546373574859480447523007571711209362191471;
uint256 constant IC0y = 3753815764472092148426692365780053324411980063589958862133181479142352994780;
@@ -55,14 +54,18 @@ contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
uint256 constant IC3x = 1197590734606895962055154260828783141953061515173288377871991535662924617440;
uint256 constant IC3y = 18942239486191169122929828442458072434935876596191455341626876659481393360346;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha1_sha256_sha256_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
uint256 constant deltay1 = 6309979045282778302942056209768770834937974278704411556356240326005027775108;
uint256 constant deltay2 = 14431014253712863614953101637194770902839088329362669949449976361594501871386;
uint256 constant IC0x = 7049014070845704797398804006160076365072552113538832823116300666708052900140;
uint256 constant IC0y = 21442947750272735435847899362570529914949459321795987895055133600218265935805;
@@ -55,14 +54,18 @@ contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
uint256 constant IC3x = 2664951959234114136071060711363539347386341588709135442596514957836669271965;
uint256 constant IC3y = 13235160485529120155109991361721968247548273207835323315920567269912250240966;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha224_sha224_sha224_ecdsa_brainpoolP224r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
uint256 constant deltay1 = 17922238729206820258777005538508696344640087041630861737277811527798956341174;
uint256 constant deltay2 = 19343082958961494620437916048299672564753840210138542937948538284994282503556;
uint256 constant IC0x = 12521316718902993678296712934793473287690901468560324816920939082278543579014;
uint256 constant IC0y = 8478119979955946440850520514866248107612719142562088893016150154822941492437;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
uint256 constant IC3x = 20913259597347413901976782093989664830906159344929838301034406870827489688402;
uint256 constant IC3y = 3901488944428160131651382851952512860695104361610472292838012573652157077746;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha224_sha224_ecdsa_secp224r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
uint256 constant deltay1 = 13063167950997764554295715260649179775160121935115344843116270981460011515045;
uint256 constant deltay2 = 10894079596870145113454476183498886773244865923585175354140797804801878633159;
uint256 constant IC0x = 8762998664314077566541074231125849912115544729350659715286518613692697344232;
uint256 constant IC0y = 14001271104843473296871506767615367200344646326139246066177383985774884134036;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
uint256 constant IC3x = 12489076924452947445650770949126936558633478532726739743575890534382634119788;
uint256 constant IC3y = 19184068330904123630217755441256337303398437062402964032554713882869223121187;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
uint256 constant deltay1 = 9264189429064603261584419178333938947647064896232842698148291477622205695991;
uint256 constant deltay2 = 6456822800838506843976332735258220771655353543944505822268251880234958843589;
uint256 constant IC0x = 14329212318534927524909414573593840658332088808690549054063025133267761199977;
uint256 constant IC0y = 6891575372982448157919314834426319637097322770954014095842802433794534683954;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
uint256 constant IC3x = 4770022706913284022426246361926495635078904750741043214268956075109086834012;
uint256 constant IC3y = 15234126863934255697594075887866757176470841009005326054002736760043901137869;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP384r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
uint256 constant deltay1 = 20799323163784559718261914492858317118523130378150092434435613338572110196932;
uint256 constant deltay2 = 14990446910847906685728734892794375678795805883652589172884763012806420930819;
uint256 constant IC0x = 15279862456791935189899436182918029011971810980820636137503798281596332644431;
uint256 constant IC0y = 5875594256869355615925003865805275481889149778767531026103030843188849163042;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
uint256 constant IC3x = 12489076924452947445650770949126936558633478532726739743575890534382634119788;
uint256 constant IC3y = 19184068330904123630217755441256337303398437062402964032554713882869223121187;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp256r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
uint256 constant deltay1 = 20268971577229545954706935167010616285735836507513920429223288718088929943995;
uint256 constant deltay2 = 21144325406167384882393518756777912265383436408998666310107848365852496419102;
uint256 constant IC0x = 9442411342865165006604779210847282499145964678682843678247134860374634735655;
uint256 constant IC0y = 19908889975223200197374227870824078479476658997752221093587493678364256098150;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
uint256 constant IC3x = 4770022706913284022426246361926495635078904750741043214268956075109086834012;
uint256 constant IC3y = 15234126863934255697594075887866757176470841009005326054002736760043901137869;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_ecdsa_secp384r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
uint256 constant deltay1 = 16912060044718566958760186965832621985233174684202860901065771441595930661;
uint256 constant deltay2 = 6990904920712329146370660837771595296060103589737805809718454732421937412911;
uint256 constant IC0x = 7147662374664978178528564902578191592241162703662598471403516878430958623540;
uint256 constant IC0y = 20742545882978583745317608766583437072418450203393459898749008422742542408017;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
uint256 constant IC3x = 5040162780305494203626900935364986325906575444438264986007662724745613060233;
uint256 constant IC3y = 3489728127071850413957238637352781132171576211336681477809188287120783210919;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_rsa_3_4096 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
uint256 constant deltay1 = 21774177102224165726668027860055379505695373535738271243426634930654955477900;
uint256 constant deltay2 = 1048058787444696992441125463798305262557229676029701658299423124050556506165;
uint256 constant IC0x = 4203584187689189016146966776511744493003920506375581844626620523492362207984;
uint256 constant IC0y = 9052081284249212023426781620778265204219325827617666210271990635080730218503;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
uint256 constant IC3x = 5708146574768159438095373888198192859966167122713346603306758508855474255629;
uint256 constant IC3y = 7392468767845842343202171561885901283557240289513003767394888152058209685110;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
uint256 constant deltay1 = 8857763070540994305951412539908926535830206116302473035781309933327417423895;
uint256 constant deltay2 = 16039701702536735810439617038019650947776334461700333220779823591886420216383;
uint256 constant IC0x = 19023325689133548863703657224526039088381457377965323696245245439046610747144;
uint256 constant IC0y = 18495120018510107318032766424788517531904003435620141063237139509825730519;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
uint256 constant IC3x = 1024972951926569974358687494937065172122524805144782023419355129238334286556;
uint256 constant IC3y = 15440423366153868217034969510027375825542972135674805344487214674699015498714;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_3_32_2048 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
uint256 constant deltay1 = 17855601415401520282357849469203244544868276435666994083788576252104715952889;
uint256 constant deltay2 = 20700679607291376795241183042865543121940947546969076159179984252908604602623;
uint256 constant IC0x = 20650047058132213809662993089573414062005281673402818277748734247805350329312;
uint256 constant IC0y = 8346431023551893201844483416096699802966095060511235070842889654340760885421;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
uint256 constant IC3x = 17317044777633640299119455114281927115644331466688145265926488556620349221911;
uint256 constant IC3y = 8772760877485816523867159264654349840312402751202686541010425679352093361796;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_2048 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
uint256 constant deltay1 = 10335149737728562397961334902612175311030426856662020462832946982440475945403;
uint256 constant deltay2 = 7725990003319491530270603256668676379344028381959299917586866031204349994841;
uint256 constant IC0x = 20273694991424696222089865695164764916021146867149536913591135292403542949895;
uint256 constant IC0y = 12236098091629357084243416615405919483831387116612844842890607315845386223990;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
uint256 constant IC3x = 12127347857146364994262050450136225135590745112775230995746041695314807204647;
uint256 constant IC3y = 12605180488335893175829332325219421676947049720195349132644638356539735606902;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_32_3072 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
uint256 constant deltay1 = 21417331860517620213853557801012932528265294825667483000398760394460342854150;
uint256 constant deltay2 = 3521621565182312756026882025146971753553266652119142711524309069960835034217;
uint256 constant IC0x = 2650232139950799889519964811076582312005955772764804225189429907947120413540;
uint256 constant IC0y = 657051112223451016707929555981496025456893729703484208440844641832356601238;
@@ -55,14 +54,18 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
uint256 constant IC3x = 20322713313159424926274301577889437312884792230033252132502625130351424539432;
uint256 constant IC3y = 1436142875889436717857447601847861561066309444586720002288236204838004201424;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
uint256 constant deltay1 = 2655964634947877199609996494191289594643875256682371211458883798917414765294;
uint256 constant deltay2 = 6529830897474966572891697442914666184318854305774824529178321388222091805665;
uint256 constant IC0x = 14180127463576949511430389406985338707938226442458612272287141032641097433282;
uint256 constant IC0y = 18520340001081201681341628889445882751413799061044855626444262669475231575998;
@@ -55,14 +54,18 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
uint256 constant IC3x = 15983604734716803811176175475868936955531879564011132812169690299787697608343;
uint256 constant IC3y = 5433234915278424150573590364928224011999313701986627480961475623393357074963;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP384r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
uint256 constant deltay1 = 14873387777512603238202291899184271790755514580527473327518246092956340721506;
uint256 constant deltay2 = 14390611362883461355955787694696658528915413320294561035084608364017878919822;
uint256 constant IC0x = 8735192185444852843909796464662622311966954494624979798830494437573487040586;
uint256 constant IC0y = 6050735154878376107549186154135524222506843051956047858431384872560380356975;
@@ -55,14 +54,18 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
uint256 constant IC3x = 15777780268455716462763947803251713833182250613008125174940265570223026085835;
uint256 constant IC3y = 4875711447580581709474407572392202914066259658604550614725631006355405476979;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
uint256 constant deltay1 = 5455169250604385419795219345075582044299579949122066670985590123551840944964;
uint256 constant deltay2 = 10104015913070532250676370268025611554945382148400238036849663790115734541142;
uint256 constant IC0x = 7908093383721926775469240343078448363521575177109101592873710160262939359547;
uint256 constant IC0y = 15740067290358963763952194191806517899082061979771944799240661001956270328137;
@@ -55,14 +54,18 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
uint256 constant IC3x = 15983604734716803811176175475868936955531879564011132812169690299787697608343;
uint256 constant IC3y = 5433234915278424150573590364928224011999313701986627480961475623393357074963;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha384_sha384_sha384_ecdsa_secp384r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
uint256 constant deltay1 = 8782002948712706591692122892777769887858927924877222024302273449842068580687;
uint256 constant deltay2 = 9352362274075683037351887254389845200972649164871915897438615446650841042777;
uint256 constant IC0x = 8544184508155231574977970852113755830620175462799939787804984445958495214999;
uint256 constant IC0y = 18216913274830099676167841484944957272042369395734546840643108051729478468281;
@@ -55,14 +54,18 @@ contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
uint256 constant IC3x = 17925609596845562960145662666722247162134174553832555607981758300339142868368;
uint256 constant IC3y = 1711339344858919485507118159910992082861313712569300995440460052671927530290;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha384_sha384_sha384_rsapss_65537_48_2048 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
uint256 constant deltay1 = 11939697202187053508707510976290905199551499409672263761474391291658710514837;
uint256 constant deltay2 = 7404233723661255839394438230729423120454040735018080878441518168933906765047;
uint256 constant IC0x = 1522312918359803988788512091755329622787453581365817416344334969305501826763;
uint256 constant IC0y = 15103489129488920195567010010842048345426549759697537037237072176139672140741;
@@ -55,14 +54,18 @@ contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
uint256 constant IC3x = 9284316895527342666880616834392865785293585993469843715065175921767468731647;
uint256 constant IC3y = 12546994336269880385565077660652394363324080564977267049945074848375882704903;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha512_sha512_sha256_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
uint256 constant deltay1 = 18166959287221332415767368018929503078315106563710994156348604460979714762741;
uint256 constant deltay2 = 14908064929580417939168737694833933618386052899840219036224614307551672747916;
uint256 constant IC0x = 18710498748220767227705003302977305323071337506522987320895689013754828757421;
uint256 constant IC0y = 16102011319913061201700546418800139175766194462922175370869548963760320631597;
@@ -55,14 +54,18 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
uint256 constant IC3x = 6342858539600635210736844370527058585508847306654018171123849143234084040487;
uint256 constant IC3y = 8189602452833790560637976876815510209304393905453779032446627471985274992928;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
// 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 = 20491192805390485299153009773594534940189261866228447918068658471970481763042;
uint256 constant alphay = 9383485363053290200918347156157836566562967994039712273449902621266178545958;
uint256 constant betax1 = 4252822878758300859123897981450591353533073413197771768651442665752259397132;
uint256 constant betax2 = 6375614351688725206403948262868962793625744043794305715222011528459656738731;
uint256 constant betay1 = 21847035105528745403288232691147584728191162732299865338377159692350059136679;
uint256 constant betay2 = 10505242626370262277552901082094356697409835680220590971873171140371331206856;
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;
@@ -42,7 +42,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
uint256 constant deltay1 = 6418076645836420671059748997176292536327596475671797721341469567563945325034;
uint256 constant deltay2 = 20047489905314554657229962814302565457277706277614625796219965705986733016400;
uint256 constant IC0x = 8213850473044923644372922865138955448896302402477327581557948020399125562390;
uint256 constant IC0y = 7127144729850972239443830705584255154725231438062233874024536757991585918868;
@@ -55,14 +54,18 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
uint256 constant IC3x = 2412093987228821900950564577698223430910769162690133525007020355167634696396;
uint256 constant IC3y = 19260582347247453329893161917118325457388005792864770063050983236893723593026;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
uint256 constant deltay1 = 8016323471157868097210555378021863771129239692256048285686953910097496901175;
uint256 constant deltay2 = 1268442858174232798041320890040058302231282153658837795419767784404409812927;
uint256 constant IC0x = 788662153977020047487908440060519636608025586441517269900106807901228230078;
uint256 constant IC0y = 20904598284048198472069371874145875403624827652749070067699932239193561364800;
@@ -55,14 +54,18 @@ contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
uint256 constant IC3x = 16582908753421460384147547461147864816075691546275678778406809963905097757166;
uint256 constant IC3y = 6430293998872124339560152168701504895975370254752408653634784744388236898330;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha512_sha512_sha512_rsa_65537_4096 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -22,17 +22,17 @@ pragma solidity >=0.7.0 <0.9.0;
contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
// 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 = 16428432848801857252194528405604668803277877773566238944394625302971855135431;
uint256 constant alphay = 16846502678714586896801519656441059708016666274385668027902869494772365009666;
uint256 constant betax1 = 3182164110458002340215786955198810119980427837186618912744689678939861918171;
uint256 constant betax2 = 16348171800823588416173124589066524623406261996681292662100840445103873053252;
uint256 constant betay1 = 4920802715848186258981584729175884379674325733638798907835771393452862684714;
uint256 constant betay2 = 19687132236965066906216944365591810874384658708175106803089633851114028275753;
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
@@ -42,7 +42,6 @@ contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
uint256 constant deltay1 = 15928828060852996611567735126472583606210784067107216934749365960478255705284;
uint256 constant deltay2 = 15523148677555090064002432817799049564835503366137479497726812725171445608393;
uint256 constant IC0x = 14970850053554520917871936978877373592008600599218183137399879767770614013397;
uint256 constant IC0y = 4687518326098445506883764869131479730374051909081414100859780026635333412365;
@@ -55,14 +54,18 @@ contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
uint256 constant IC3x = 6401225548848035306725692880264920393627384820763938963945560767378047631985;
uint256 constant IC3y = 3976547394444563928321174757780585113046713922808426955124252186710066806205;
// 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[3] calldata _pubSignals) public view returns (bool) {
function verifyProof(
uint[2] calldata _pA,
uint[2][2] calldata _pB,
uint[2] calldata _pC,
uint[3] calldata _pubSignals
) public view returns (bool) {
assembly {
function checkField(v) {
if iszero(lt(v, r)) {
@@ -112,7 +115,6 @@ contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
g1_mulAccC(_pVk, IC3x, IC3y, calldataload(add(pubSignals, 64)))
// -A
mstore(_pPairing, calldataload(pA))
mstore(add(_pPairing, 32), mod(sub(q, calldataload(add(pA, 32))), q))
@@ -137,7 +139,6 @@ contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
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)
@@ -154,7 +155,6 @@ contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
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))
@@ -171,12 +171,11 @@ contract Verifier_register_sha512_sha512_sha512_rsapss_65537_64_2048 {
checkField(calldataload(add(_pubSignals, 64)))
// Validate all evaluations
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
mstore(0, isValid)
return(0, 0x20)
}
}
}
return(0, 0x20)
}
}
}

View File

@@ -3,7 +3,7 @@ import "@nomicfoundation/hardhat-toolbox";
require("dotenv").config();
import "hardhat-contract-sizer";
import "@nomicfoundation/hardhat-ignition-ethers";
import 'solidity-coverage';
import "solidity-coverage";
import "hardhat-gas-reporter";
import "hardhat-contract-sizer";
@@ -15,11 +15,11 @@ const config: HardhatUserConfig = {
enabled: true,
runs: 200,
details: {
yul: true
}
yul: true,
},
},
metadata: {
bytecodeHash: "none"
bytecodeHash: "none",
},
viaIR: false,
},
@@ -31,7 +31,7 @@ const config: HardhatUserConfig = {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
artifacts: "./artifacts",
},
defaultNetwork: "hardhat",
networks: {
@@ -40,8 +40,8 @@ const config: HardhatUserConfig = {
url: "http://127.0.0.1:8545",
accounts: {
mnemonic: "test test test test test test test test test test test test",
count: 20
}
count: 20,
},
},
mainnet: {
chainId: 1,
@@ -81,11 +81,11 @@ const config: HardhatUserConfig = {
chainId: 42220,
urls: {
apiURL: "https://api.celoscan.io/api",
browserURL: "https://celoscan.io"
}
}
]
}
browserURL: "https://celoscan.io",
},
},
],
},
};
export default config;

View File

@@ -1,23 +1,20 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
import {
DEPLOYED_CIRCUITS_REGISTER,
DEPLOYED_CIRCUITS_DSC
} from "../../../common/src/constants/constants";
import { DEPLOYED_CIRCUITS_REGISTER, DEPLOYED_CIRCUITS_DSC } from "../../../common/src/constants/constants";
export default buildModule("DeployAllVerifiers", (m) => {
const deployedContracts: Record<string, any> = {};
const deployedContracts: Record<string, any> = {};
deployedContracts.vcAndDiscloseVerifier = m.contract("Verifier_vc_and_disclose");
deployedContracts.vcAndDiscloseVerifier = m.contract("Verifier_vc_and_disclose");
DEPLOYED_CIRCUITS_REGISTER.forEach(circuit => {
const contractName = `Verifier_${circuit}`;
deployedContracts[circuit] = m.contract(contractName);
});
DEPLOYED_CIRCUITS_REGISTER.forEach((circuit) => {
const contractName = `Verifier_${circuit}`;
deployedContracts[circuit] = m.contract(contractName);
});
DEPLOYED_CIRCUITS_DSC.forEach(circuit => {
const contractName = `Verifier_${circuit}`;
deployedContracts[circuit] = m.contract(contractName);
});
DEPLOYED_CIRCUITS_DSC.forEach((circuit) => {
const contractName = `Verifier_${circuit}`;
deployedContracts[circuit] = m.contract(contractName);
});
return deployedContracts;
return deployedContracts;
});

View File

@@ -5,38 +5,35 @@ import fs from "fs";
import path from "path";
function getHubInitializeData() {
const hubArtifact = artifacts.readArtifactSync("IdentityVerificationHubImplV1");
return new ethers.Interface(hubArtifact.abi);
const hubArtifact = artifacts.readArtifactSync("IdentityVerificationHubImplV1");
return new ethers.Interface(hubArtifact.abi);
}
export default buildModule("DeployHub", (m) => {
const networkName = hre.network.config.chainId;
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
const vcAndDiscloseVerifierAddress = deployedAddresses["DeployAllVerifiers#Verifier_vc_and_disclose"];
const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
const vcAndDiscloseVerifierAddress = deployedAddresses["DeployAllVerifiers#Verifier_vc_and_disclose"];
const identityVerificationHubImpl = m.contract("IdentityVerificationHubImplV1");
const identityVerificationHubImpl = m.contract("IdentityVerificationHubImplV1");
const hubInterface = getHubInitializeData();
const initializeData = hubInterface.encodeFunctionData("initialize", [
registryAddress,
vcAndDiscloseVerifierAddress,
[],
[],
[],
[]
]);
const hubInterface = getHubInitializeData();
const initializeData = hubInterface.encodeFunctionData("initialize", [
registryAddress,
vcAndDiscloseVerifierAddress,
[],
[],
[],
[],
]);
const hub = m.contract("IdentityVerificationHub", [
identityVerificationHubImpl,
initializeData
]);
const hub = m.contract("IdentityVerificationHub", [identityVerificationHubImpl, initializeData]);
return {
hub,
identityVerificationHubImpl,
};
return {
hub,
identityVerificationHubImpl,
};
});

View File

@@ -5,37 +5,32 @@ import fs from "fs";
import path from "path";
function getTestHubInitializeData() {
const hubArtifact = artifacts.readArtifactSync("testUpgradedIdentityVerificationHubImplV1");
return new ethers.Interface(hubArtifact.abi);
const hubArtifact = artifacts.readArtifactSync("testUpgradedIdentityVerificationHubImplV1");
return new ethers.Interface(hubArtifact.abi);
}
export default buildModule("DeployNewHubAndUpgrade", (m) => {
const networkName = hre.network.config.chainId;
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const hubProxyAddress = deployedAddresses["DeployHub#IdentityVerificationHub"];
if (!hubProxyAddress) {
throw new Error("Hub proxy address not found in deployed_addresses.json");
}
const hubProxyAddress = deployedAddresses["DeployHub#IdentityVerificationHub"];
if (!hubProxyAddress) {
throw new Error("Hub proxy address not found in deployed_addresses.json");
}
const newHubImpl = m.contract("testUpgradedIdentityVerificationHubImplV1");
const newHubImpl = m.contract("testUpgradedIdentityVerificationHubImplV1");
const testHubInterface = getTestHubInitializeData();
const initializeData = testHubInterface.encodeFunctionData("initialize", [
true
]);
const testHubInterface = getTestHubInitializeData();
const initializeData = testHubInterface.encodeFunctionData("initialize", [true]);
const hubProxy = m.contractAt("IdentityVerificationHubImplV1", hubProxyAddress);
const hubProxy = m.contractAt("IdentityVerificationHubImplV1", hubProxyAddress);
m.call(hubProxy, "upgradeToAndCall", [
newHubImpl,
initializeData
]);
m.call(hubProxy, "upgradeToAndCall", [newHubImpl, initializeData]);
return {
newHubImpl,
hubProxy
};
return {
newHubImpl,
hubProxy,
};
});

View File

@@ -5,37 +5,32 @@ import fs from "fs";
import path from "path";
function getTestRegistryInitializeData() {
const registryArtifact = artifacts.readArtifactSync("testUpgradedIdentityRegistryImplV1");
return new ethers.Interface(registryArtifact.abi);
const registryArtifact = artifacts.readArtifactSync("testUpgradedIdentityRegistryImplV1");
return new ethers.Interface(registryArtifact.abi);
}
export default buildModule("DeployNewHubAndUpgrade", (m) => {
const networkName = hre.network.config.chainId;
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const registryProxyAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
if (!registryProxyAddress) {
throw new Error("Registry proxy address not found in deployed_addresses.json");
}
const registryProxyAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
if (!registryProxyAddress) {
throw new Error("Registry proxy address not found in deployed_addresses.json");
}
const newRegistryImpl = m.contract("testUpgradedIdentityVerificationHubImplV1");
const newRegistryImpl = m.contract("testUpgradedIdentityVerificationHubImplV1");
const testRegistryInterface = getTestRegistryInitializeData();
const initializeData = testRegistryInterface.encodeFunctionData("initialize", [
true
]);
const testRegistryInterface = getTestRegistryInitializeData();
const initializeData = testRegistryInterface.encodeFunctionData("initialize", [true]);
const registryProxy = m.contractAt("IdentityRegistryImplV1", registryProxyAddress);
const registryProxy = m.contractAt("IdentityRegistryImplV1", registryProxyAddress);
m.call(registryProxy, "upgradeToAndCall", [
newRegistryImpl,
initializeData
]);
m.call(registryProxy, "upgradeToAndCall", [newRegistryImpl, initializeData]);
return {
newRegistryImpl,
registryProxy
};
return {
newRegistryImpl,
registryProxy,
};
});

View File

@@ -4,12 +4,12 @@ import fs from "fs";
import path from "path";
export default buildModule("DeployPCR0", (m) => {
const networkName = hre.network.config.chainId;
const networkName = hre.network.config.chainId;
// Deploy the PCR0Manager contract (implementation from PCR0.sol)
const pcr0Manager = m.contract("PCR0Manager");
// Deploy the PCR0Manager contract (implementation from PCR0.sol)
const pcr0Manager = m.contract("PCR0Manager");
return {
pcr0Manager,
};
return {
pcr0Manager,
};
});

View File

@@ -3,34 +3,31 @@ import { artifacts } from "hardhat";
import { ethers } from "ethers";
export default buildModule("DeployRegistryModule", (m) => {
// Deploy PoseidonT3
const poseidonT3 = m.library("PoseidonT3");
// Deploy PoseidonT3
const poseidonT3 = m.library("PoseidonT3");
// Deploy IdentityRegistryImplV1
const identityRegistryImpl = m.contract("IdentityRegistryImplV1", [], {
libraries: { PoseidonT3: poseidonT3 },
});
// Deploy IdentityRegistryImplV1
const identityRegistryImpl = m.contract("IdentityRegistryImplV1", [], {
libraries: { PoseidonT3: poseidonT3 },
});
// Deploy registry with temporary hub address
const registryInterface = getRegistryInitializeData();
const registryInitData = registryInterface.encodeFunctionData("initialize", [
"0x0000000000000000000000000000000000000000"
]);
const registry = m.contract("IdentityRegistry", [
identityRegistryImpl,
registryInitData
]);
// Deploy registry with temporary hub address
const registryInterface = getRegistryInitializeData();
const registryInitData = registryInterface.encodeFunctionData("initialize", [
"0x0000000000000000000000000000000000000000",
]);
const registry = m.contract("IdentityRegistry", [identityRegistryImpl, registryInitData]);
// Return deployed contracts
return {
poseidonT3,
identityRegistryImpl,
registry
};
// Return deployed contracts
return {
poseidonT3,
identityRegistryImpl,
registry,
};
});
function getRegistryInitializeData() {
const registryArtifact = artifacts.readArtifactSync("IdentityRegistryImplV1");
const registryInterface = new ethers.Interface(registryArtifact.abi);
return registryInterface;
const registryArtifact = artifacts.readArtifactSync("IdentityRegistryImplV1");
const registryInterface = new ethers.Interface(registryArtifact.abi);
return registryInterface;
}

View File

@@ -1,37 +1,36 @@
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";
export default buildModule("DeployVerifiers", (m) => {
// const vcAndDiscloseVerifier = m.contract("Verifier_vc_and_disclose");
// const vcAndDiscloseVerifier = m.contract("Verifier_vc_and_disclose");
// const registerVerifier = m.contract("Verifier_register_sha1_sha256_sha256_rsa_65537_4096");
// const registerVerifier2 = m.contract("Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1");
// const registerVerifier3 = m.contract("Verifier_register_sha256_sha256_sha256_rsa_65537_4096");
const verifier1 = m.contract("Verifier_dsc_sha1_ecdsa_secp256r1");
const verifier2 = m.contract("Verifier_dsc_sha256_ecdsa_secp521r1");
const verifier3 = m.contract("Verifier_dsc_sha384_ecdsa_brainpoolP512r1");
const verifier4 = m.contract("Verifier_dsc_sha512_ecdsa_brainpoolP512r1");
const verifier5 = m.contract("Verifier_dsc_sha512_ecdsa_secp521r1");
const verifier6 = m.contract("Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1");
const verifier7 = m.contract("Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048");
const verifier8 = m.contract("Verifier_register_sha512_sha512_sha256_rsa_65537_4096");
const verifier9 = m.contract("Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1");
const verifier10 = m.contract("Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1");
const verifier11 = m.contract("Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1");
// const registerVerifier = m.contract("Verifier_register_sha1_sha256_sha256_rsa_65537_4096");
// const registerVerifier2 = m.contract("Verifier_register_sha256_sha256_sha256_ecdsa_brainpoolP256r1");
// const registerVerifier3 = m.contract("Verifier_register_sha256_sha256_sha256_rsa_65537_4096");
const verifier1 = m.contract("Verifier_dsc_sha1_ecdsa_secp256r1");
const verifier2 = m.contract("Verifier_dsc_sha256_ecdsa_secp521r1");
const verifier3 = m.contract("Verifier_dsc_sha384_ecdsa_brainpoolP512r1");
const verifier4= m.contract("Verifier_dsc_sha512_ecdsa_brainpoolP512r1");
const verifier5 = m.contract("Verifier_dsc_sha512_ecdsa_secp521r1");
const verifier6 = m.contract("Verifier_register_sha1_sha1_sha1_ecdsa_secp256r1");
const verifier7 = m.contract("Verifier_register_sha256_sha256_sha256_rsapss_65537_64_2048");
const verifier8 = m.contract("Verifier_register_sha512_sha512_sha256_rsa_65537_4096");
const verifier9 = m.contract("Verifier_register_sha512_sha512_sha512_ecdsa_secp521r1");
const verifier10 = m.contract("Verifier_register_sha512_sha512_sha512_ecdsa_brainpoolP512r1");
const verifier11 = m.contract("Verifier_register_sha384_sha384_sha384_ecdsa_brainpoolP512r1");
// const dscVerifier = m.contract("Verifier_dsc_sha256_rsa_65537_4096");
// const dscVerifier = m.contract("Verifier_dsc_sha256_rsa_65537_4096");
return {
verifier1,
verifier2,
verifier3,
verifier4,
verifier5,
verifier6,
verifier7,
verifier8,
verifier9,
verifier10,
verifier11
};
return {
verifier1,
verifier2,
verifier3,
verifier4,
verifier5,
verifier6,
verifier7,
verifier8,
verifier9,
verifier10,
verifier11,
};
});

View File

@@ -4,15 +4,15 @@ import fs from "fs";
import path from "path";
export default buildModule("DeployVerifyAll", (m) => {
const networkName = hre.network.config.chainId;
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const hubAddress = deployedAddresses["DeployHub#IdentityVerificationHub"];
const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
const deployedAddressesPath = path.join(__dirname, `../deployments/chain-${networkName}/deployed_addresses.json`);
const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
const hubAddress = deployedAddresses["DeployHub#IdentityVerificationHub"];
const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
const verifyAll = m.contract("VerifyAll", [hubAddress, registryAddress]);
return {
verifyAll,
};
const verifyAll = m.contract("VerifyAll", [hubAddress, registryAddress]);
return {
verifyAll,
};
});

View File

@@ -5,36 +5,36 @@ import path from "path";
import { ethers } from "ethers";
export default buildModule("UpdatePCR0", (m) => {
const networkName = hre.network.config.chainId;
const journalPath = path.join(__dirname, "../../deployments", `chain-${networkName}`, "journal.jsonl");
const networkName = hre.network.config.chainId;
const journalPath = path.join(__dirname, "../../deployments", `chain-${networkName}`, "journal.jsonl");
// Read and parse the journal file
const journal = fs.readFileSync(journalPath, "utf8")
.split('\n')
.filter(Boolean)
.map(line => JSON.parse(line));
// Read and parse the journal file
const journal = fs
.readFileSync(journalPath, "utf8")
.split("\n")
.filter(Boolean)
.map((line) => JSON.parse(line));
// Find the deployment result entry
const deploymentResult = journal.find(entry =>
entry.type === "DEPLOYMENT_EXECUTION_STATE_COMPLETE" &&
entry.futureId === "DeployPCR0#PCR0Manager"
);
// Find the deployment result entry
const deploymentResult = journal.find(
(entry) => entry.type === "DEPLOYMENT_EXECUTION_STATE_COMPLETE" && entry.futureId === "DeployPCR0#PCR0Manager",
);
if (!deploymentResult?.result?.address) {
throw new Error("PCR0Manager address not found in journal. Please deploy PCR0Manager first.");
}
if (!deploymentResult?.result?.address) {
throw new Error("PCR0Manager address not found in journal. Please deploy PCR0Manager first.");
}
const pcr0Address = deploymentResult.result.address;
const pcr0Manager = m.contractAt("PCR0Manager", pcr0Address);
const pcr0Hash = "002991b83537ca49d9cfcd3375d9148151121470eef8e84cac087d789af9d200bcc6582fb53e0e273aeddc83943c4def";
if (pcr0Hash.length !== 96) {
throw new Error(`Invalid PCR0 hash length: expected 96 hex characters, got ${pcr0Hash.length}`);
}
const pcr0Bytes = "0x" + pcr0Hash;
// Create a zero-filled hex string
const pcr0Address = deploymentResult.result.address;
const pcr0Manager = m.contractAt("PCR0Manager", pcr0Address);
const pcr0Hash = "002991b83537ca49d9cfcd3375d9148151121470eef8e84cac087d789af9d200bcc6582fb53e0e273aeddc83943c4def";
if (pcr0Hash.length !== 96) {
throw new Error(`Invalid PCR0 hash length: expected 96 hex characters, got ${pcr0Hash.length}`);
}
const pcr0Bytes = "0x" + pcr0Hash;
// Create a zero-filled hex string
// Add the zero PCR0 value
m.call(pcr0Manager, "addPCR0", [pcr0Bytes]);
// Add the zero PCR0 value
m.call(pcr0Manager, "addPCR0", [pcr0Bytes]);
return {};
return {};
});

View File

@@ -6,7 +6,6 @@ import { getCscaTreeRoot } from "../../../../common/src/utils/trees";
import serialized_csca_tree from "../../../../common/pubkeys/serialized_csca_tree.json";
module.exports = buildModule("UpdateRegistryCscaRoot", (m) => {
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../../deployments/chain-${networkName}/deployed_addresses.json`);

View File

@@ -4,7 +4,6 @@ import fs from "fs";
import path from "path";
module.exports = buildModule("UpdateRegistryHub", (m) => {
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../../deployments/chain-${networkName}/deployed_addresses.json`);

View File

@@ -5,7 +5,6 @@ import path from "path";
import { getSMTs } from "../../../test/utils/generateProof";
module.exports = buildModule("UpdateRegistryOfacRoot", (m) => {
const networkName = hre.network.config.chainId;
const deployedAddressesPath = path.join(__dirname, `../../deployments/chain-${networkName}/deployed_addresses.json`);
@@ -16,11 +15,7 @@ module.exports = buildModule("UpdateRegistryOfacRoot", (m) => {
const deployedRegistryInstance = m.contractAt("IdentityRegistryImplV1", registryAddress);
console.log("Deployed registry instance", deployedRegistryInstance);
const {
passportNo_smt,
nameAndDob_smt,
nameAndYob_smt
} = getSMTs();
const { passportNo_smt, nameAndDob_smt, nameAndYob_smt } = getSMTs();
m.call(deployedRegistryInstance, "updatePassportNoOfacRoot", [passportNo_smt.root]);
m.call(deployedRegistryInstance, "updateNameAndDobOfacRoot", [nameAndDob_smt.root]);

View File

@@ -4,18 +4,18 @@ import fs from "fs";
import path from "path";
module.exports = buildModule("UpdateVerifyAllAddresses", (m) => {
// const networkName = hre.network.config.chainId;
// const networkName = hre.network.config.chainId;
// const deployedAddressesPath = path.join(__dirname, `../../deployments/chain-${networkName}/deployed_addresses.json`);
// const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
// const deployedAddressesPath = path.join(__dirname, `../../deployments/chain-${networkName}/deployed_addresses.json`);
// const deployedAddresses = JSON.parse(fs.readFileSync(deployedAddressesPath, "utf8"));
// Get the addresses from the deployed_addresses.json file
// const verifyAllAddress = deployedAddresses["DeployVerifyAllModule#VerifyAll"];
// const hubAddress = deployedAddresses["DeployHubModule#IdentityVerificationHub"];
// const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
const verifyAllAddress = "0x03237E7b4c2b1AdEBdBC33d91478Eaef05D0fF85";
const hubAddress = "0x3e2487a250e2A7b56c7ef5307Fb591Cc8C83623D";
const registryAddress = "0xD961B67B35739cCF16326B087C9aD2c0095cCc4E";
// const verifyAllAddress = deployedAddresses["DeployVerifyAllModule#VerifyAll"];
// const hubAddress = deployedAddresses["DeployHubModule#IdentityVerificationHub"];
// const registryAddress = deployedAddresses["DeployRegistryModule#IdentityRegistry"];
const verifyAllAddress = "0x03237E7b4c2b1AdEBdBC33d91478Eaef05D0fF85";
const hubAddress = "0x3e2487a250e2A7b56c7ef5307Fb591Cc8C83623D";
const registryAddress = "0xD961B67B35739cCF16326B087C9aD2c0095cCc4E";
// Get the deployed VerifyAll contract instance
const deployedVerifyAllInstance = m.contractAt("VerifyAll", verifyAllAddress);

View File

@@ -65,7 +65,9 @@
"update:hub:celo": "npx hardhat ignition deploy ignition/modules/scripts/updateRegistryHub.ts --network celo --verify",
"update:ofacroot:celo": "npx hardhat ignition deploy ignition/modules/scripts/updateRegistryOfacRoot.ts --network celo --verify",
"deploy:pcr0:celo": "npx hardhat ignition deploy ignition/modules/deployPCR0.ts --network celo --verify",
"update:pcr0:celo": "PCR0_ACTION=add PCR0_KEY=123 npx hardhat ignition deploy ignition/modules/scripts/updatePCR0.ts --network celo --reset"
"update:pcr0:celo": "PCR0_ACTION=add PCR0_KEY=123 npx hardhat ignition deploy ignition/modules/scripts/updatePCR0.ts --network celo --reset",
"prettier:write": "prettier --write '**/*.{json,md,yml,sol,ts}'",
"prettier:check": "prettier --list-different '**/*.{json,md,yml,sol,ts}'"
},
"dependencies": {
"@ashpect/smt": "https://github.com/ashpect/smt#main",
@@ -109,6 +111,8 @@
"hardhat": "^2.22.6",
"hardhat-gas-reporter": "^1.0.10",
"mochawesome": "^7.1.3",
"prettier": "3.5.3",
"prettier-plugin-solidity": "^2.0.0",
"solidity-coverage": "^0.8.14",
"ts-node": "^10.9.1",
"typechain": "^8.3.2",

View File

@@ -41,84 +41,87 @@ const dscTree = new LeanIMT<bigint>(hashFunction);
// Function to initialize the tree with all commitments
function initializeTree() {
console.log("Initializing DSC tree...");
// The first array in serialized_dsc_tree[0] contains the leaf nodes
for (let i = 0; i < serialized_dsc_tree[0].length; i++) {
dscTree.insert(BigInt(serialized_dsc_tree[0][i]));
}
console.log(`Initialized DSC tree with ${dscTree.size} commitments. Root: ${dscTree.root}`);
console.log("Initializing DSC tree...");
// The first array in serialized_dsc_tree[0] contains the leaf nodes
for (let i = 0; i < serialized_dsc_tree[0].length; i++) {
dscTree.insert(BigInt(serialized_dsc_tree[0][i]));
}
console.log(`Initialized DSC tree with ${dscTree.size} commitments. Root: ${dscTree.root}`);
}
async function main() {
try {
// Set up connection to blockchain
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL as string);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider);
try {
// Set up connection to blockchain
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL as string);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider);
// Load the registry contract
const registryAbiFile = fs.readFileSync(path.join(__dirname, "../ignition/deployments/chain-11155111/artifacts/DeployRegistryModule#IdentityRegistryImplV1.json"), "utf-8");
const registryAbi = JSON.parse(registryAbiFile).abi;
const registryAddress = "0xD961B67B35739cCF16326B087C9aD2c0095cCc4E"; // Update with your contract address
const registry = new ethers.Contract(registryAddress, registryAbi, wallet);
// Load the registry contract
const registryAbiFile = fs.readFileSync(
path.join(
__dirname,
"../ignition/deployments/chain-11155111/artifacts/DeployRegistryModule#IdentityRegistryImplV1.json",
),
"utf-8",
);
const registryAbi = JSON.parse(registryAbiFile).abi;
const registryAddress = "0xD961B67B35739cCF16326B087C9aD2c0095cCc4E"; // Update with your contract address
const registry = new ethers.Contract(registryAddress, registryAbi, wallet);
// Initialize our tree with all the DSC key commitments
initializeTree();
// Initialize our tree with all the DSC key commitments
initializeTree();
// Get all commitments to delete
const commitments = serialized_dsc_tree[0];
console.log(`Total commitments to delete: ${commitments.length}`);
// Get all commitments to delete
const commitments = serialized_dsc_tree[0];
console.log(`Total commitments to delete: ${commitments.length}`);
// Delete each commitment one by one
for (let i = 0; i < commitments.length; i++) {
try {
const commitment = BigInt(commitments[i]);
console.log(`Processing commitment ${i+1}/${commitments.length}: ${commitment.toString()}`);
// Delete each commitment one by one
for (let i = 0; i < commitments.length; i++) {
try {
const commitment = BigInt(commitments[i]);
console.log(`Processing commitment ${i + 1}/${commitments.length}: ${commitment.toString()}`);
// Find the index of the commitment in the tree
const index = dscTree.indexOf(commitment);
if (index === -1) {
console.warn(`Commitment ${commitment.toString()} not found in the tree, skipping...`);
continue;
}
// Generate the proof for the current commitment
const { siblings } = dscTree.generateProof(index);
// Convert siblings to string array for contract call
const siblingNodes = siblings.map(s => s.toString());
// Call the contract to remove the commitment
console.log(`Removing commitment from contract...`);
const tx = await registry.devRemoveDscKeyCommitment(
commitment.toString(),
siblingNodes
);
console.log(`Transaction sent. Waiting for confirmation...`);
const receipt = await tx.wait();
console.log(`Transaction confirmed! Hash: ${receipt.hash}`);
// Update the commitment in our local tree to keep it in sync with the contract
// According to documentation, update takes index and new value
dscTree.update(index, BigInt(0)); // Update to zero, effectively "removing" it
console.log(`Removed commitment ${i+1}. New tree root: ${dscTree.root}`);
// Small delay to avoid spamming the network
await new Promise(resolve => setTimeout(resolve, 1000));
} catch (error) {
console.error(`Error processing commitment ${i+1}:`, error);
// Continue with the next commitment
}
// Find the index of the commitment in the tree
const index = dscTree.indexOf(commitment);
if (index === -1) {
console.warn(`Commitment ${commitment.toString()} not found in the tree, skipping...`);
continue;
}
console.log("All DSC key commitments have been removed.");
} catch (error) {
console.error("Error in main function:", error);
process.exitCode = 1;
// Generate the proof for the current commitment
const { siblings } = dscTree.generateProof(index);
// Convert siblings to string array for contract call
const siblingNodes = siblings.map((s) => s.toString());
// Call the contract to remove the commitment
console.log(`Removing commitment from contract...`);
const tx = await registry.devRemoveDscKeyCommitment(commitment.toString(), siblingNodes);
console.log(`Transaction sent. Waiting for confirmation...`);
const receipt = await tx.wait();
console.log(`Transaction confirmed! Hash: ${receipt.hash}`);
// Update the commitment in our local tree to keep it in sync with the contract
// According to documentation, update takes index and new value
dscTree.update(index, BigInt(0)); // Update to zero, effectively "removing" it
console.log(`Removed commitment ${i + 1}. New tree root: ${dscTree.root}`);
// Small delay to avoid spamming the network
await new Promise((resolve) => setTimeout(resolve, 1000));
} catch (error) {
console.error(`Error processing commitment ${i + 1}:`, error);
// Continue with the next commitment
}
}
console.log("All DSC key commitments have been removed.");
} catch (error) {
console.error("Error in main function:", error);
process.exitCode = 1;
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
console.error(error);
process.exitCode = 1;
});

View File

@@ -1,4 +1,4 @@
import { ethers } from 'ethers';
import { ethers } from "ethers";
// Error Signatures and their Selectors:
// =====================================
@@ -34,42 +34,42 @@ import { ethers } from 'ethers';
// 0x034acfcc - REGISTERED_COMMITMENT()
const errorSignatures = [
'InvalidProof()',
'AlreadyClaimed()',
'NotRegistered(address nonRegisteredAddress)',
'RegistrationNotOpen()',
'RegistrationNotClosed()',
'ClaimNotOpen()',
'INSUFFICIENT_CHARCODE_LEN()',
'InvalidDateLength()',
'InvalidAsciiCode()',
'InvalidYearRange()',
'InvalidMonthRange()',
'InvalidDayRange()',
'InvalidFieldElement()',
'InvalidDateDigit()',
'LENGTH_MISMATCH()',
'NO_VERIFIER_SET()',
'CURRENT_DATE_NOT_IN_VALID_RANGE()',
'INVALID_OLDER_THAN()',
'INVALID_FORBIDDEN_COUNTRIES()',
'INVALID_OFAC()',
'INVALID_REGISTER_PROOF()',
'INVALID_DSC_PROOF()',
'INVALID_VC_AND_DISCLOSE_PROOF()',
'INVALID_COMMITMENT_ROOT()',
'INVALID_OFAC_ROOT()',
'INVALID_CSCA_ROOT()',
'INVALID_REVEALED_DATA_TYPE()',
'HUB_NOT_SET()',
'ONLY_HUB_CAN_ACCESS()',
'REGISTERED_COMMITMENT()',
'RegisteredNullifier()'
"InvalidProof()",
"AlreadyClaimed()",
"NotRegistered(address nonRegisteredAddress)",
"RegistrationNotOpen()",
"RegistrationNotClosed()",
"ClaimNotOpen()",
"INSUFFICIENT_CHARCODE_LEN()",
"InvalidDateLength()",
"InvalidAsciiCode()",
"InvalidYearRange()",
"InvalidMonthRange()",
"InvalidDayRange()",
"InvalidFieldElement()",
"InvalidDateDigit()",
"LENGTH_MISMATCH()",
"NO_VERIFIER_SET()",
"CURRENT_DATE_NOT_IN_VALID_RANGE()",
"INVALID_OLDER_THAN()",
"INVALID_FORBIDDEN_COUNTRIES()",
"INVALID_OFAC()",
"INVALID_REGISTER_PROOF()",
"INVALID_DSC_PROOF()",
"INVALID_VC_AND_DISCLOSE_PROOF()",
"INVALID_COMMITMENT_ROOT()",
"INVALID_OFAC_ROOT()",
"INVALID_CSCA_ROOT()",
"INVALID_REVEALED_DATA_TYPE()",
"HUB_NOT_SET()",
"ONLY_HUB_CAN_ACCESS()",
"REGISTERED_COMMITMENT()",
"RegisteredNullifier()",
];
errorSignatures.forEach(sig => {
errorSignatures.forEach((sig) => {
// Pls input the error code
const errorCode = '0x22cbc6a2';
const errorCode = "0x22cbc6a2";
const selector = ethers.id(sig).slice(0, 10);
if (selector === errorCode) {
console.log(`Found matching error: ${sig}`);

View File

@@ -6,42 +6,46 @@ import { RegisterVerifierId, DscVerifierId } from "../../common/src/constants/co
dotenv.config();
const deployedAddresses = JSON.parse(fs.readFileSync(path.join(__dirname, "../ignition/deployments/chain-42220/deployed_addresses.json"), "utf-8"));
const deployedAddresses = JSON.parse(
fs.readFileSync(path.join(__dirname, "../ignition/deployments/chain-42220/deployed_addresses.json"), "utf-8"),
);
const contractAbiPath = path.join(__dirname, "../ignition/deployments/chain-11155111/artifacts");
const serializedDscTreePath = path.join(__dirname, "../../registry/outputs/serialized_dsc_tree.json");
const serialized_dsc_tree = JSON.parse(JSON.parse(fs.readFileSync(serializedDscTreePath, "utf-8")));
function getContractAddressByPartialName(partialName: string): string | unknown {
for (const [key, value] of Object.entries(deployedAddresses)) {
if (key.includes(partialName)) {
return value;
}
for (const [key, value] of Object.entries(deployedAddresses)) {
if (key.includes(partialName)) {
return value;
}
return undefined;
}
return undefined;
}
async function main() {
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL as string);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider);
const registryAbiFile = fs.readFileSync(
path.join(
__dirname,
"../ignition/deployments/chain-11155111/artifacts/DeployRegistryModule#IdentityRegistryImplV1.json",
),
"utf-8",
);
const registryAbi = JSON.parse(registryAbiFile).abi;
const registry = new ethers.Contract("0x66916bc86F761a11587B99c474dB9051f8262478", registryAbi, wallet);
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL as string);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string, provider);
const registryAbiFile = fs.readFileSync(path.join(__dirname, "../ignition/deployments/chain-11155111/artifacts/DeployRegistryModule#IdentityRegistryImplV1.json"), "utf-8");
const registryAbi = JSON.parse(registryAbiFile).abi;
const registry = new ethers.Contract("0x66916bc86F761a11587B99c474dB9051f8262478", registryAbi, wallet);
console.log("serialized dsc tree: ", serialized_dsc_tree[0]);
console.log("lenght: ", serialized_dsc_tree[0].length);
for (let i = 395; i < serialized_dsc_tree[0].length; i++) {
const tx = await registry.devAddDscKeyCommitment(
serialized_dsc_tree[0][i]
);
const receipt = await tx.wait();
console.log(`${i} th tx hash: `, receipt.hash);
}
console.log("serialized dsc tree: ", serialized_dsc_tree[0]);
console.log("lenght: ", serialized_dsc_tree[0].length);
for (let i = 395; i < serialized_dsc_tree[0].length; i++) {
const tx = await registry.devAddDscKeyCommitment(serialized_dsc_tree[0][i]);
const receipt = await tx.wait();
console.log(`${i} th tx hash: `, receipt.hash);
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
console.error(error);
process.exitCode = 1;
});

View File

@@ -8,111 +8,111 @@ dotenv.config();
// Debug logs for paths and files
console.log("Current directory:", __dirname);
console.log("Deployed addresses path:", path.join(__dirname, "../ignition/deployments/chain-42220/deployed_addresses.json"));
console.log("Contract ABI path:", path.join(__dirname, "../ignition/deployments/chain-42220/artifacts/DeployHub#IdentityVerificationHubImplV1.json"));
console.log(
"Deployed addresses path:",
path.join(__dirname, "../ignition/deployments/chain-42220/deployed_addresses.json"),
);
console.log(
"Contract ABI path:",
path.join(__dirname, "../ignition/deployments/chain-42220/artifacts/DeployHub#IdentityVerificationHubImplV1.json"),
);
// Debug logs for environment variables (redacted for security)
console.log("CELO_RPC_URL configured:", !!process.env.CELO_RPC_URL);
console.log("CELO_KEY configured:", !!process.env.CELO_KEY);
try {
const deployedAddresses = JSON.parse(fs.readFileSync(path.join(__dirname, "../ignition/deployments/chain-42220/deployed_addresses.json"), "utf-8"));
console.log("Deployed addresses loaded:", deployedAddresses);
const deployedAddresses = JSON.parse(
fs.readFileSync(path.join(__dirname, "../ignition/deployments/chain-42220/deployed_addresses.json"), "utf-8"),
);
console.log("Deployed addresses loaded:", deployedAddresses);
const identityVerificationHubAbiFile = fs.readFileSync(path.join(__dirname, "../ignition/deployments/prod/artifacts/DeployHub#IdentityVerificationHubImplV1.json"), "utf-8");
console.log("ABI file loaded");
const identityVerificationHubAbiFile = fs.readFileSync(
path.join(__dirname, "../ignition/deployments/prod/artifacts/DeployHub#IdentityVerificationHubImplV1.json"),
"utf-8",
);
console.log("ABI file loaded");
const identityVerificationHubAbi = JSON.parse(identityVerificationHubAbiFile).abi;
console.log("ABI parsed");
const identityVerificationHubAbi = JSON.parse(identityVerificationHubAbiFile).abi;
console.log("ABI parsed");
const contractAbiPath = path.join(__dirname, "../ignition/deployments/chain-11155111/artifacts");
const contractAbiPath = path.join(__dirname, "../ignition/deployments/chain-11155111/artifacts");
function getContractAddressByPartialName(partialName: string): string | unknown {
for (const [key, value] of Object.entries(deployedAddresses)) {
if (key.includes(partialName)) {
return value;
}
}
return undefined;
function getContractAddressByPartialName(partialName: string): string | unknown {
for (const [key, value] of Object.entries(deployedAddresses)) {
if (key.includes(partialName)) {
return value;
}
}
return undefined;
}
async function main() {
const provider = new ethers.JsonRpcProvider(process.env.CELO_RPC_URL as string);
console.log("Provider created");
const wallet = new ethers.Wallet(process.env.CELO_KEY as string, provider);
console.log("Wallet created");
// const hubAddress = deployedAddresses["DeployHub#IdentityVerificationHub"];
const hubAddress = "0x77117D60eaB7C044e785D68edB6C7E0e134970Ea";
console.log("Hub address:", hubAddress);
if (!hubAddress) {
throw new Error("Hub address not found in deployed_addresses.json");
}
async function main() {
const provider = new ethers.JsonRpcProvider(process.env.CELO_RPC_URL as string);
console.log("Provider created");
const identityVerificationHub = new ethers.Contract(hubAddress, identityVerificationHubAbi, wallet);
console.log("Contract instance created");
const wallet = new ethers.Wallet(process.env.CELO_KEY as string, provider);
console.log("Wallet created");
// const hubAddress = deployedAddresses["DeployHub#IdentityVerificationHub"];
const hubAddress = "0x77117D60eaB7C044e785D68edB6C7E0e134970Ea";
console.log("Hub address:", hubAddress);
if (!hubAddress) {
throw new Error("Hub address not found in deployed_addresses.json");
}
const identityVerificationHub = new ethers.Contract(
hubAddress,
identityVerificationHubAbi,
wallet
);
console.log("Contract instance created");
// Debug verifier addresses before updating
const registerVerifierKeys = Object.keys(RegisterVerifierId).filter(key => isNaN(Number(key)));
for (const key of registerVerifierKeys) {
const verifierName = `Verifier_${key}`;
const verifierAddress = getContractAddressByPartialName(verifierName);
console.log(`${verifierName} address:`, verifierAddress);
}
for (const key of registerVerifierKeys) {
const verifierName = `Verifier_${key}`;
const verifierAddress = getContractAddressByPartialName(verifierName);
if (!verifierAddress) {
console.log(`Skipping ${verifierName} because no deployed address was found.`);
continue;
}
console.log(`Updating for ${verifierName}`);
const verifierId = RegisterVerifierId[key as keyof typeof RegisterVerifierId];
try {
const tx = await identityVerificationHub.updateRegisterCircuitVerifier(
verifierId,
verifierAddress
);
const receipt = await tx.wait();
console.log(`${verifierName} is updated with tx: ${receipt.hash}`);
} catch (error) {
console.error(`Error updating ${verifierName}:`, error);
}
}
const dscKeys = Object.keys(DscVerifierId).filter(key => isNaN(Number(key)));
for (const key of dscKeys) {
const verifierName = `Verifier_${key}`;
const verifierAddress = getContractAddressByPartialName(verifierName);
if (!verifierAddress) {
console.log(`Skipping ${verifierName} because no deployed address was found.`);
continue;
}
const verifierId = DscVerifierId[key as keyof typeof DscVerifierId];
const tx = await identityVerificationHub.updateDscVerifier(
verifierId,
verifierAddress
);
const receipt = await tx.wait();
console.log(`${verifierName} is updated wit this tx: ${receipt.hash}`);
}
// Debug verifier addresses before updating
const registerVerifierKeys = Object.keys(RegisterVerifierId).filter((key) => isNaN(Number(key)));
for (const key of registerVerifierKeys) {
const verifierName = `Verifier_${key}`;
const verifierAddress = getContractAddressByPartialName(verifierName);
console.log(`${verifierName} address:`, verifierAddress);
}
main().catch((error) => {
console.error("Execution error:", error);
process.exitCode = 1;
});
for (const key of registerVerifierKeys) {
const verifierName = `Verifier_${key}`;
const verifierAddress = getContractAddressByPartialName(verifierName);
if (!verifierAddress) {
console.log(`Skipping ${verifierName} because no deployed address was found.`);
continue;
}
console.log(`Updating for ${verifierName}`);
const verifierId = RegisterVerifierId[key as keyof typeof RegisterVerifierId];
} catch (error) {
console.error("Initial setup error:", error);
try {
const tx = await identityVerificationHub.updateRegisterCircuitVerifier(verifierId, verifierAddress);
const receipt = await tx.wait();
console.log(`${verifierName} is updated with tx: ${receipt.hash}`);
} catch (error) {
console.error(`Error updating ${verifierName}:`, error);
}
}
const dscKeys = Object.keys(DscVerifierId).filter((key) => isNaN(Number(key)));
for (const key of dscKeys) {
const verifierName = `Verifier_${key}`;
const verifierAddress = getContractAddressByPartialName(verifierName);
if (!verifierAddress) {
console.log(`Skipping ${verifierName} because no deployed address was found.`);
continue;
}
const verifierId = DscVerifierId[key as keyof typeof DscVerifierId];
const tx = await identityVerificationHub.updateDscVerifier(verifierId, verifierAddress);
const receipt = await tx.wait();
console.log(`${verifierName} is updated wit this tx: ${receipt.hash}`);
}
}
main().catch((error) => {
console.error("Execution error:", error);
process.exitCode = 1;
});
} catch (error) {
console.error("Initial setup error:", error);
process.exitCode = 1;
}

File diff suppressed because it is too large Load Diff

View File

@@ -7,441 +7,401 @@ import { CIRCUIT_CONSTANTS, DscVerifierId, RegisterVerifierId } from "../../../c
import { ATTESTATION_ID } from "../utils/constants";
import { deploySystemFixtures } from "../utils/deployment";
import { generateDscProof, generateRegisterProof } from "../utils/generateProof";
import serialized_dsc_tree from '../utils/pubkeys/serialized_dsc_tree.json';
import serialized_dsc_tree from "../utils/pubkeys/serialized_dsc_tree.json";
import { DeployedActors } from "../utils/types";
import { generateRandomFieldElement } from "../utils/utils";
describe("Commitment Registration Tests", function () {
this.timeout(0);
this.timeout(0);
let deployedActors: DeployedActors;
let snapshotId: string;
let baseDscProof: any;
let baseRegisterProof: any;
let dscProof: any;
let registerProof: any;
let registerSecret: any;
let deployedActors: DeployedActors;
let snapshotId: string;
let baseDscProof: any;
let baseRegisterProof: any;
let dscProof: any;
let registerProof: any;
let registerSecret: any;
before(async () => {
deployedActors = await deploySystemFixtures();
registerSecret = generateRandomFieldElement();
baseDscProof = await generateDscProof(
deployedActors.mockPassport,
before(async () => {
deployedActors = await deploySystemFixtures();
registerSecret = generateRandomFieldElement();
baseDscProof = await generateDscProof(deployedActors.mockPassport);
baseRegisterProof = await generateRegisterProof(registerSecret, deployedActors.mockPassport);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
beforeEach(async () => {
dscProof = structuredClone(baseDscProof);
registerProof = structuredClone(baseRegisterProof);
});
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
describe("Register Commitment", () => {
describe("Initialization", () => {
it("should have consistent addresses between registry and hub", async () => {
const { hub, registry } = deployedActors;
expect(await registry.hub()).to.equal(hub.target);
expect(await hub.registry()).to.equal(registry.target);
});
});
describe("Register DSC Pubkey", async () => {
it("Should register DSC key commitment successfully", async () => {
const { hub, registry } = deployedActors;
const previousRoot = await registry.getDscKeyCommitmentMerkleRoot();
const previousSize = await registry.getDscKeyCommitmentTreeSize();
const tx = await hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof);
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
const imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]));
const receipt = (await tx.wait()) as TransactionReceipt;
const event = receipt?.logs.find(
(log) => log.topics[0] === registry.interface.getEvent("DscKeyCommitmentRegistered").topicHash,
);
baseRegisterProof = await generateRegisterProof(
registerSecret,
deployedActors.mockPassport
const eventArgs = event
? registry.interface.decodeEventLog("DscKeyCommitmentRegistered", event.data, event.topics)
: null;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getDscKeyCommitmentMerkleRoot();
const index = await registry.getDscKeyCommitmentIndex(
dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX],
);
expect(eventArgs?.commitment).to.equal(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(index);
// Check state
expect(currentRoot).to.not.equal(previousRoot);
expect(currentRoot).to.be.equal(imt.root);
expect(await registry.getDscKeyCommitmentTreeSize()).to.equal(previousSize + 1n);
expect(
await registry.getDscKeyCommitmentIndex(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]),
).to.equal(index);
expect(
await registry.isRegisteredDscKeyCommitment(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]),
).to.equal(true);
});
it("Should fail when called by proxy address", async () => {
const { hubImpl } = deployedActors;
await expect(
hubImpl.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("Should fail when the verifier is not set", async () => {
const { hub } = deployedActors;
await expect(
hub.registerDscKeyCommitment(DscVerifierId.dsc_sha1_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(hub, "NO_VERIFIER_SET");
});
it("Should fail when the csca root is invalid", async () => {
const { hub } = deployedActors;
dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_CSCA_ROOT_INDEX] = generateRandomFieldElement();
await expect(
hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(hub, "INVALID_CSCA_ROOT");
});
it("Should fail when the proof is invalid", async () => {
const { hub } = deployedActors;
dscProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(hub, "INVALID_DSC_PROOF");
});
it("Should fail when registerDscKeyCommitment is called directly on implementation", async () => {
const { registryImpl } = deployedActors;
await expect(registryImpl.registerDscKeyCommitment(generateRandomFieldElement())).to.be.revertedWithCustomError(
registryImpl,
"UUPSUnauthorizedCallContext",
);
});
it("Should fail when the registerDscKeyCommitment is called by non-hub address", async () => {
const { registry, vcAndDisclose, register, dsc, owner } = deployedActors;
const IdentityVerificationHubImplFactory = await ethers.getContractFactory(
"IdentityVerificationHubImplV1",
owner,
);
const hubImpl2 = await IdentityVerificationHubImplFactory.deploy();
await hubImpl2.waitForDeployment();
const initializeData = hubImpl2.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[register.target],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dsc.target],
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
const hub2Proxy = await hubFactory.deploy(hubImpl2.target, initializeData);
await hub2Proxy.waitForDeployment();
const hub2 = await ethers.getContractAt("IdentityVerificationHubImplV1", hub2Proxy.target);
await expect(
hub2.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(registry, "ONLY_HUB_CAN_ACCESS");
});
it("should fail registerDscKeyCommitment when hub address is not set", async () => {
const { hub, registry } = deployedActors;
await registry.updateHub(ZeroAddress);
await expect(
hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(registry, "HUB_NOT_SET");
});
it("should fail when the dsc key commitment is already registered", async () => {
const { hub, registry } = deployedActors;
await hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof);
await expect(
hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(registry, "REGISTERED_COMMITMENT");
});
it("should fail when getDscKeyCommitmentMerkleRoot is called by non-proxy", async () => {
const { registryImpl } = deployedActors;
await expect(registryImpl.getDscKeyCommitmentMerkleRoot()).to.be.revertedWithCustomError(
registryImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should fail when checkDscKeyCommitmentMerkleRoot is called by non-proxy", async () => {
const { registryImpl } = deployedActors;
const root = generateRandomFieldElement();
await expect(registryImpl.checkDscKeyCommitmentMerkleRoot(root)).to.be.revertedWithCustomError(
registryImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should fail when getDscKeyCommitmentTreeSize is called by non-proxy", async () => {
const { registryImpl } = deployedActors;
await expect(registryImpl.getDscKeyCommitmentTreeSize()).to.be.revertedWithCustomError(
registryImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should fail when getDscKeyCommitmentIndex is called by non-proxy", async () => {
const { registryImpl } = deployedActors;
const commitment = generateRandomFieldElement();
await expect(registryImpl.getDscKeyCommitmentIndex(commitment)).to.be.revertedWithCustomError(
registryImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should fail when registerDscKeyCommitment is called by non-proxy address", async () => {
const { hubImpl } = deployedActors;
await expect(
hubImpl.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof),
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
});
describe("Register Passport Commitment", () => {
before(async () => {
const { registry } = deployedActors;
const dscKeys = JSON.parse(serialized_dsc_tree);
for (let i = 0; i < dscKeys[0].length; i++) {
await registry.devAddDscKeyCommitment(BigInt(dscKeys[0][i]));
}
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
});
beforeEach(async () => {
dscProof = structuredClone(baseDscProof);
registerProof = structuredClone(baseRegisterProof);
});
afterEach(async () => {
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
it("should register passport commitment successfully", async () => {
const { hub, registry, mockPassport } = deployedActors;
const registerProof = await generateRegisterProof(registerSecret, mockPassport);
const previousRoot = await registry.getIdentityCommitmentMerkleRoot();
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
const imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]));
const tx = await hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
);
const receipt = (await tx.wait()) as TransactionReceipt;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getIdentityCommitmentMerkleRoot();
const size = await registry.getIdentityCommitmentMerkleTreeSize();
const rootTimestamp = await registry.rootTimestamps(currentRoot);
const index = await registry.getIdentityCommitmentIndex(
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX],
);
const nullifier = await registry.nullifiers(
ATTESTATION_ID.E_PASSPORT,
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX],
);
const event = receipt?.logs.find(
(log) => log.topics[0] === registry.interface.getEvent("CommitmentRegistered").topicHash,
);
const eventArgs = event
? registry.interface.decodeEventLog("CommitmentRegistered", event.data, event.topics)
: null;
expect(eventArgs?.attestationId).to.equal(ATTESTATION_ID.E_PASSPORT);
expect(eventArgs?.nullifier).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX]);
expect(eventArgs?.commitment).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(0);
expect(currentRoot).to.not.equal(previousRoot);
expect(currentRoot).to.be.equal(imt.root);
expect(size).to.equal(1);
expect(rootTimestamp).to.equal(blockTimestamp);
expect(index).to.equal(0);
expect(nullifier).to.equal(true);
});
it("should fail when verifier is not set", async () => {
const { hub } = deployedActors;
registerProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerPassportCommitment(RegisterVerifierId.register_sha256_sha256_sha256_rsa_3_4096, registerProof),
).to.be.revertedWithCustomError(hub, "NO_VERIFIER_SET");
});
it("should fail when commitment root is invalid", async () => {
const { hub } = deployedActors;
const invalidCommitmentRoot = generateRandomFieldElement();
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_MERKLE_ROOT_INDEX] = invalidCommitmentRoot;
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
),
).to.be.revertedWithCustomError(hub, "INVALID_COMMITMENT_ROOT");
});
it("should fail when register proof verification fails", async () => {
const { hub } = deployedActors;
registerProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
),
).to.be.revertedWithCustomError(hub, "INVALID_REGISTER_PROOF");
});
it("should fail when nullifier is already used", async () => {
const { hub, registry, mockPassport } = deployedActors;
const registerProof = await generateRegisterProof(registerSecret, mockPassport);
await hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
);
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
),
).to.be.revertedWithCustomError(registry, "REGISTERED_COMMITMENT");
});
it("should fail when registerPassportCommitment is called by non-proxy address", async () => {
const { hubImpl } = deployedActors;
await expect(
hubImpl.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
),
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should fail when registerCommitment is called by non-hub address", async () => {
const { registry, vcAndDisclose, register, dsc, owner } = deployedActors;
const IdentityVerificationHubImplFactory = await ethers.getContractFactory(
"IdentityVerificationHubImplV1",
owner,
);
const hubImpl2 = await IdentityVerificationHubImplFactory.deploy();
await hubImpl2.waitForDeployment();
const initializeData = hubImpl2.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[register.target],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dsc.target],
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
const hub2Proxy = await hubFactory.deploy(hubImpl2.target, initializeData);
await hub2Proxy.waitForDeployment();
const hub2 = await ethers.getContractAt("IdentityVerificationHubImplV1", hub2Proxy.target);
await expect(
hub2.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
),
).to.be.revertedWithCustomError(registry, "ONLY_HUB_CAN_ACCESS");
});
it("should fail registerCommitment when hub address is not set", async () => {
const { hub, registry } = deployedActors;
await registry.updateHub(ZeroAddress);
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
),
).to.be.revertedWithCustomError(registry, "HUB_NOT_SET");
});
it("should fail when registerCommitment is called by non-proxy address", async () => {
const { registryImpl } = deployedActors;
const nullifier = generateRandomFieldElement();
const commitment = generateRandomFieldElement();
await expect(
registryImpl.registerCommitment(ATTESTATION_ID.E_PASSPORT, nullifier, commitment),
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
});
describe("Register Commitment", () => {
describe("Initialization", () => {
it("should have consistent addresses between registry and hub", async () => {
const {hub, registry} = deployedActors;
expect(await registry.hub()).to.equal(hub.target);
expect(await hub.registry()).to.equal(registry.target);
});
});
describe("Register DSC Pubkey", async () => {
it("Should register DSC key commitment successfully", async () => {
const {hub, registry} = deployedActors;
const previousRoot = await registry.getDscKeyCommitmentMerkleRoot();
const previousSize = await registry.getDscKeyCommitmentTreeSize();
const tx = await hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
);
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
const imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]));
const receipt = await tx.wait() as TransactionReceipt;
const event = receipt?.logs.find(
log => log.topics[0] === registry.interface.getEvent("DscKeyCommitmentRegistered").topicHash
);
const eventArgs = event ? registry.interface.decodeEventLog(
"DscKeyCommitmentRegistered",
event.data,
event.topics
) : null;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getDscKeyCommitmentMerkleRoot();
const index = await registry.getDscKeyCommitmentIndex(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]);
expect(eventArgs?.commitment).to.equal(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(index);
// Check state
expect(currentRoot).to.not.equal(previousRoot);
expect(currentRoot).to.be.equal(imt.root);
expect(await registry.getDscKeyCommitmentTreeSize()).to.equal(previousSize + 1n);
expect(await registry.getDscKeyCommitmentIndex(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX])).to.equal(index);
expect(await registry.isRegisteredDscKeyCommitment(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX])).to.equal(true);
});
it("Should fail when called by proxy address", async () => {
const {hubImpl} = deployedActors;
await expect(
hubImpl.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("Should fail when the verifier is not set", async () => {
const {hub} = deployedActors;
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha1_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hub, "NO_VERIFIER_SET");
});
it("Should fail when the csca root is invalid", async() => {
const {hub} = deployedActors;
dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_CSCA_ROOT_INDEX] = generateRandomFieldElement();
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hub, "INVALID_CSCA_ROOT");
});
it("Should fail when the proof is invalid", async () => {
const {hub} = deployedActors;
dscProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hub, "INVALID_DSC_PROOF");
});
it("Should fail when registerDscKeyCommitment is called directly on implementation", async () => {
const {registryImpl} = deployedActors;
await expect(
registryImpl.registerDscKeyCommitment(
generateRandomFieldElement()
)
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
it("Should fail when the registerDscKeyCommitment is called by non-hub address", async () => {
const {registry,vcAndDisclose,register,dsc, owner} = deployedActors;
const IdentityVerificationHubImplFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl2 = await IdentityVerificationHubImplFactory.deploy();
await hubImpl2.waitForDeployment();
const initializeData = hubImpl2.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[register.target],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dsc.target]
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
const hub2Proxy = await hubFactory.deploy(hubImpl2.target, initializeData);
await hub2Proxy.waitForDeployment();
const hub2 = await ethers.getContractAt("IdentityVerificationHubImplV1", hub2Proxy.target);
await expect(
hub2.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(registry, "ONLY_HUB_CAN_ACCESS");
});
it("should fail registerDscKeyCommitment when hub address is not set", async () => {
const {hub, registry} = deployedActors;
await registry.updateHub(ZeroAddress);
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(registry, "HUB_NOT_SET");
});
it("should fail when the dsc key commitment is already registered", async () => {
const {hub, registry} = deployedActors;
await hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
);
await expect(
hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(registry, "REGISTERED_COMMITMENT");
});
it("should fail when getDscKeyCommitmentMerkleRoot is called by non-proxy", async () => {
const {registryImpl} = deployedActors;
await expect(
registryImpl.getDscKeyCommitmentMerkleRoot()
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
it("should fail when checkDscKeyCommitmentMerkleRoot is called by non-proxy", async () => {
const {registryImpl} = deployedActors;
const root = generateRandomFieldElement();
await expect(
registryImpl.checkDscKeyCommitmentMerkleRoot(root)
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
it("should fail when getDscKeyCommitmentTreeSize is called by non-proxy", async () => {
const {registryImpl} = deployedActors;
await expect(
registryImpl.getDscKeyCommitmentTreeSize()
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
it("should fail when getDscKeyCommitmentIndex is called by non-proxy", async () => {
const {registryImpl} = deployedActors;
const commitment =generateRandomFieldElement();
await expect(
registryImpl.getDscKeyCommitmentIndex(commitment)
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
it("should fail when registerDscKeyCommitment is called by non-proxy address", async () => {
const { hubImpl } = deployedActors;
await expect(
hubImpl.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
)
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
});
describe("Register Passport Commitment", () => {
before(async () => {
const {registry} = deployedActors;
const dscKeys = JSON.parse(serialized_dsc_tree);
for (let i = 0; i < dscKeys[0].length; i++) {
await registry.devAddDscKeyCommitment(BigInt(dscKeys[0][i]));
}
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
it("should register passport commitment successfully", async () => {
const {hub, registry, mockPassport} = deployedActors;
const registerProof = await generateRegisterProof(
registerSecret,
mockPassport
);
const previousRoot = await registry.getIdentityCommitmentMerkleRoot();
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
const imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]));
const tx = await hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
);
const receipt = await tx.wait() as TransactionReceipt;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getIdentityCommitmentMerkleRoot();
const size = await registry.getIdentityCommitmentMerkleTreeSize();
const rootTimestamp = await registry.rootTimestamps(currentRoot);
const index = await registry.getIdentityCommitmentIndex(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]);
const nullifier = await registry.nullifiers(
ATTESTATION_ID.E_PASSPORT,
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX]
);
const event = receipt?.logs.find(
log => log.topics[0] === registry.interface.getEvent("CommitmentRegistered").topicHash
);
const eventArgs = event ? registry.interface.decodeEventLog(
"CommitmentRegistered",
event.data,
event.topics
) : null;
expect(eventArgs?.attestationId).to.equal(ATTESTATION_ID.E_PASSPORT);
expect(eventArgs?.nullifier).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX]);
expect(eventArgs?.commitment).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(0);
expect(currentRoot).to.not.equal(previousRoot);
expect(currentRoot).to.be.equal(imt.root);
expect(size).to.equal(1);
expect(rootTimestamp).to.equal(blockTimestamp);
expect(index).to.equal(0);
expect(nullifier).to.equal(true);
});
it("should fail when verifier is not set", async () => {
const {hub} = deployedActors;
registerProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_3_4096,
registerProof
)
).to.be.revertedWithCustomError(hub, "NO_VERIFIER_SET");
});
it("should fail when commitment root is invalid", async () => {
const {hub} = deployedActors;
const invalidCommitmentRoot = generateRandomFieldElement();
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_MERKLE_ROOT_INDEX] = invalidCommitmentRoot;
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
)
).to.be.revertedWithCustomError(hub, "INVALID_COMMITMENT_ROOT");
});
it("should fail when register proof verification fails", async () => {
const {hub} = deployedActors;
registerProof.a[0] = generateRandomFieldElement();
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
)
).to.be.revertedWithCustomError(hub, "INVALID_REGISTER_PROOF");
});
it("should fail when nullifier is already used", async () => {
const {hub, registry, mockPassport} = deployedActors;
const registerProof = await generateRegisterProof(
registerSecret,
mockPassport
);
await hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
);
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
)
).to.be.revertedWithCustomError(registry, "REGISTERED_COMMITMENT");
});
it("should fail when registerPassportCommitment is called by non-proxy address", async () => {
const {hubImpl} = deployedActors;
await expect(
hubImpl.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
)
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should fail when registerCommitment is called by non-hub address", async () => {
const {registry, vcAndDisclose, register, dsc, owner} = deployedActors;
const IdentityVerificationHubImplFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl2 = await IdentityVerificationHubImplFactory.deploy();
await hubImpl2.waitForDeployment();
const initializeData = hubImpl2.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096],
[register.target],
[DscVerifierId.dsc_sha256_rsa_65537_4096],
[dsc.target]
]);
const hubFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
const hub2Proxy = await hubFactory.deploy(hubImpl2.target, initializeData);
await hub2Proxy.waitForDeployment();
const hub2 = await ethers.getContractAt("IdentityVerificationHubImplV1", hub2Proxy.target);
await expect(
hub2.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
)
).to.be.revertedWithCustomError(registry, "ONLY_HUB_CAN_ACCESS");
});
it("should fail registerCommitment when hub address is not set", async () => {
const {hub, registry} = deployedActors;
await registry.updateHub(ZeroAddress);
await expect(
hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
)
).to.be.revertedWithCustomError(registry, "HUB_NOT_SET");
});
it("should fail when registerCommitment is called by non-proxy address", async() => {
const {registryImpl} = deployedActors;
const nullifier = generateRandomFieldElement();
const commitment = generateRandomFieldElement();
await expect(
registryImpl.registerCommitment(
ATTESTATION_ID.E_PASSPORT,
nullifier,
commitment
)
).to.be.revertedWithCustomError(registryImpl, "UUPSUnauthorizedCallContext");
});
});
});
});
});

View File

@@ -11,241 +11,235 @@ import { deploySystemFixtures } from "../utils/deployment";
import BalanceTree from "../utils/example/balance-tree";
import { Formatter } from "../utils/formatter";
import { generateDscProof, generateRegisterProof, generateVcAndDiscloseProof } from "../utils/generateProof";
import serialized_dsc_tree from '../utils/pubkeys/serialized_dsc_tree.json';
import serialized_dsc_tree from "../utils/pubkeys/serialized_dsc_tree.json";
import { DeployedActors } from "../utils/types";
import { generateRandomFieldElement, splitHexFromBack } from "../utils/utils";
describe("End to End Tests", function () {
this.timeout(0);
this.timeout(0);
let deployedActors: DeployedActors;
let snapshotId: string;
let deployedActors: DeployedActors;
let snapshotId: string;
before(async () => {
deployedActors = await deploySystemFixtures();
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
before(async () => {
deployedActors = await deploySystemFixtures();
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
it("register dsc key commitment, register identity commitment, verify commitment and disclose attrs and claim airdrop", async () => {
const { hub, registry, mockPassport, owner, user1 } = deployedActors;
// register dsc key
// To increase test performance, we will just set one dsc key with groth16 proof
// Other commitments are registered by dev function
const dscKeys = JSON.parse(serialized_dsc_tree);
let registerDscTx;
const dscProof = await generateDscProof(
mockPassport,
);
const registerSecret = generateRandomFieldElement();
for (let i = 0; i < dscKeys[0].length; i++) {
if (BigInt(dscKeys[0][i]) == dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]) {
const previousRoot = await registry.getDscKeyCommitmentMerkleRoot();
const previousSize = await registry.getDscKeyCommitmentTreeSize();
registerDscTx = await hub.registerDscKeyCommitment(
DscVerifierId.dsc_sha256_rsa_65537_4096,
dscProof
);
const receipt = await registerDscTx.wait() as TransactionReceipt;
const event = receipt?.logs.find(
log => log.topics[0] === registry.interface.getEvent("DscKeyCommitmentRegistered").topicHash
);
const eventArgs = event ? registry.interface.decodeEventLog(
"DscKeyCommitmentRegistered",
event.data,
event.topics
) : null;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getDscKeyCommitmentMerkleRoot();
const index = await registry.getDscKeyCommitmentIndex(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]);
expect(eventArgs?.commitment).to.equal(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(index);
// Check state
expect(currentRoot).to.not.equal(previousRoot);
expect(await registry.getDscKeyCommitmentTreeSize()).to.equal(previousSize + 1n);
expect(await registry.getDscKeyCommitmentIndex(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX])).to.equal(index);
expect(await registry.isRegisteredDscKeyCommitment(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX])).to.equal(true);
} else {
await registry.devAddDscKeyCommitment(BigInt(dscKeys[0][i]));
}
};
// register identity commitment
const registerProof = await generateRegisterProof(
registerSecret,
mockPassport
);
const previousRoot = await registry.getIdentityCommitmentMerkleRoot();
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
const imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]));
const tx = await hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof
);
const receipt = await tx.wait() as TransactionReceipt;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getIdentityCommitmentMerkleRoot();
const size = await registry.getIdentityCommitmentMerkleTreeSize();
const rootTimestamp = await registry.rootTimestamps(currentRoot);
const index = await registry.getIdentityCommitmentIndex(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]);
const identityNullifier = await registry.nullifiers(
ATTESTATION_ID.E_PASSPORT,
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX]
);
it("register dsc key commitment, register identity commitment, verify commitment and disclose attrs and claim airdrop", async () => {
const { hub, registry, mockPassport, owner, user1 } = deployedActors;
// register dsc key
// To increase test performance, we will just set one dsc key with groth16 proof
// Other commitments are registered by dev function
const dscKeys = JSON.parse(serialized_dsc_tree);
let registerDscTx;
const dscProof = await generateDscProof(mockPassport);
const registerSecret = generateRandomFieldElement();
for (let i = 0; i < dscKeys[0].length; i++) {
if (BigInt(dscKeys[0][i]) == dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]) {
const previousRoot = await registry.getDscKeyCommitmentMerkleRoot();
const previousSize = await registry.getDscKeyCommitmentTreeSize();
registerDscTx = await hub.registerDscKeyCommitment(DscVerifierId.dsc_sha256_rsa_65537_4096, dscProof);
const receipt = (await registerDscTx.wait()) as TransactionReceipt;
const event = receipt?.logs.find(
log => log.topics[0] === registry.interface.getEvent("CommitmentRegistered").topicHash
(log) => log.topics[0] === registry.interface.getEvent("DscKeyCommitmentRegistered").topicHash,
);
const eventArgs = event ? registry.interface.decodeEventLog(
"CommitmentRegistered",
event.data,
event.topics
) : null;
const eventArgs = event
? registry.interface.decodeEventLog("DscKeyCommitmentRegistered", event.data, event.topics)
: null;
expect(eventArgs?.attestationId).to.equal(ATTESTATION_ID.E_PASSPORT);
expect(eventArgs?.nullifier).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX]);
expect(eventArgs?.commitment).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]);
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
const currentRoot = await registry.getDscKeyCommitmentMerkleRoot();
const index = await registry.getDscKeyCommitmentIndex(
dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX],
);
expect(eventArgs?.commitment).to.equal(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(0);
expect(eventArgs?.imtIndex).to.equal(index);
// Check state
expect(currentRoot).to.not.equal(previousRoot);
expect(currentRoot).to.be.equal(imt.root);
expect(size).to.equal(1);
expect(rootTimestamp).to.equal(blockTimestamp);
expect(index).to.equal(0);
expect(identityNullifier).to.equal(true);
expect(await registry.getDscKeyCommitmentTreeSize()).to.equal(previousSize + 1n);
expect(
await registry.getDscKeyCommitmentIndex(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]),
).to.equal(index);
expect(
await registry.isRegisteredDscKeyCommitment(dscProof.pubSignals[CIRCUIT_CONSTANTS.DSC_TREE_LEAF_INDEX]),
).to.equal(true);
} else {
await registry.devAddDscKeyCommitment(BigInt(dscKeys[0][i]));
}
}
const forbiddenCountriesList = ['AAA', 'ABC', 'CBA'];
const countriesListPacked = splitHexFromBack(reverseBytes(Formatter.bytesToHexString(new Uint8Array(formatCountriesList(forbiddenCountriesList)))));
// register identity commitment
const registerProof = await generateRegisterProof(registerSecret, mockPassport);
const vcAndDiscloseProof = await generateVcAndDiscloseProof(
registerSecret,
BigInt(ATTESTATION_ID.E_PASSPORT).toString(),
mockPassport,
"test-scope",
new Array(88).fill("1"),
"1",
imt,
"20",
undefined,
undefined,
undefined,
undefined,
forbiddenCountriesList,
(await user1.getAddress()).slice(2)
);
const previousRoot = await registry.getIdentityCommitmentMerkleRoot();
const vcAndDiscloseHubProof = {
olderThanEnabled: true,
olderThan: "20",
forbiddenCountriesEnabled: true,
forbiddenCountriesListPacked: countriesListPacked,
ofacEnabled: [true, true, true] as [boolean, boolean, boolean],
vcAndDiscloseProof: vcAndDiscloseProof
}
const hashFunction = (a: bigint, b: bigint) => poseidon2([a, b]);
const imt = new LeanIMT<bigint>(hashFunction);
await imt.insert(BigInt(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]));
const result = await hub.verifyVcAndDisclose(vcAndDiscloseHubProof);
const tx = await hub.registerPassportCommitment(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
registerProof,
);
const receipt = (await tx.wait()) as TransactionReceipt;
const blockTimestamp = (await ethers.provider.getBlock(receipt.blockNumber))!.timestamp;
expect(result.identityCommitmentRoot).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX]);
expect(result.revealedDataPacked).to.have.lengthOf(3);
expect(result.nullifier).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX]);
expect(result.attestationId).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX]);
expect(result.userIdentifier).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX]);
expect(result.scope).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX]);
for (let i = 0; i < 4; i++) {
expect(result.forbiddenCountriesListPacked[i]).to.equal(BigInt(countriesListPacked[i]));
}
const currentRoot = await registry.getIdentityCommitmentMerkleRoot();
const size = await registry.getIdentityCommitmentMerkleTreeSize();
const rootTimestamp = await registry.rootTimestamps(currentRoot);
const index = await registry.getIdentityCommitmentIndex(
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX],
);
const identityNullifier = await registry.nullifiers(
ATTESTATION_ID.E_PASSPORT,
registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX],
);
const tokenFactory = await ethers.getContractFactory("AirdropToken");
const token = await tokenFactory.connect(owner).deploy();
await token.waitForDeployment();
const event = receipt?.logs.find(
(log) => log.topics[0] === registry.interface.getEvent("CommitmentRegistered").topicHash,
);
const eventArgs = event
? registry.interface.decodeEventLog("CommitmentRegistered", event.data, event.topics)
: null;
const airdropFactory = await ethers.getContractFactory("Airdrop");
const airdrop = await airdropFactory.connect(owner).deploy(
hub.target,
castFromScope("test-scope"),
ATTESTATION_ID.E_PASSPORT,
token.target,
true,
20,
true,
countriesListPacked as [BigNumberish, BigNumberish, BigNumberish, BigNumberish],
[true, true, true],
);
await airdrop.waitForDeployment();
expect(eventArgs?.attestationId).to.equal(ATTESTATION_ID.E_PASSPORT);
expect(eventArgs?.nullifier).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_NULLIFIER_INDEX]);
expect(eventArgs?.commitment).to.equal(registerProof.pubSignals[CIRCUIT_CONSTANTS.REGISTER_COMMITMENT_INDEX]);
expect(eventArgs?.timestamp).to.equal(blockTimestamp);
expect(eventArgs?.imtRoot).to.equal(currentRoot);
expect(eventArgs?.imtIndex).to.equal(0);
await token.connect(owner).mint(airdrop.target, BigInt(1000000000000000000));
expect(currentRoot).to.not.equal(previousRoot);
expect(currentRoot).to.be.equal(imt.root);
expect(size).to.equal(1);
expect(rootTimestamp).to.equal(blockTimestamp);
expect(index).to.equal(0);
expect(identityNullifier).to.equal(true);
await airdrop.connect(owner).openRegistration();
await airdrop.connect(user1).verifySelfProof(vcAndDiscloseProof);
await airdrop.connect(owner).closeRegistration();
const forbiddenCountriesList = ["AAA", "ABC", "CBA"];
const countriesListPacked = splitHexFromBack(
reverseBytes(Formatter.bytesToHexString(new Uint8Array(formatCountriesList(forbiddenCountriesList)))),
);
const tree = new BalanceTree([
{ account: await user1.getAddress(), amount: BigInt(1000000000000000000) }
]);
const merkleRoot = tree.getHexRoot();
await airdrop.connect(owner).setMerkleRoot(merkleRoot);
await airdrop.connect(owner).openClaim();
const merkleProof = tree.getProof(0, await user1.getAddress(), BigInt(1000000000000000000));
const claimTx = await airdrop.connect(user1).claim(
0,
BigInt(1000000000000000000),
merkleProof
);
const claimReceipt = await claimTx.wait() as TransactionReceipt;
const vcAndDiscloseProof = await generateVcAndDiscloseProof(
registerSecret,
BigInt(ATTESTATION_ID.E_PASSPORT).toString(),
mockPassport,
"test-scope",
new Array(88).fill("1"),
"1",
imt,
"20",
undefined,
undefined,
undefined,
undefined,
forbiddenCountriesList,
(await user1.getAddress()).slice(2),
);
const claimEvent = claimReceipt?.logs.find(
log => log.topics[0] === airdrop.interface.getEvent("Claimed").topicHash
);
const claimEventArgs = claimEvent ? airdrop.interface.decodeEventLog(
"Claimed",
claimEvent.data,
claimEvent.topics
) : null;
const vcAndDiscloseHubProof = {
olderThanEnabled: true,
olderThan: "20",
forbiddenCountriesEnabled: true,
forbiddenCountriesListPacked: countriesListPacked,
ofacEnabled: [true, true, true] as [boolean, boolean, boolean],
vcAndDiscloseProof: vcAndDiscloseProof,
};
expect(claimEventArgs?.index).to.equal(0);
expect(claimEventArgs?.amount).to.equal(BigInt(1000000000000000000));
expect(claimEventArgs?.account).to.equal(await user1.getAddress());
const result = await hub.verifyVcAndDisclose(vcAndDiscloseHubProof);
const balance = await token.balanceOf(await user1.getAddress());
expect(balance).to.equal(BigInt(1000000000000000000));
expect(result.identityCommitmentRoot).to.equal(
vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_MERKLE_ROOT_INDEX],
);
expect(result.revealedDataPacked).to.have.lengthOf(3);
expect(result.nullifier).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_NULLIFIER_INDEX]);
expect(result.attestationId).to.equal(
vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_ATTESTATION_ID_INDEX],
);
expect(result.userIdentifier).to.equal(
vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_USER_IDENTIFIER_INDEX],
);
expect(result.scope).to.equal(vcAndDiscloseProof.pubSignals[CIRCUIT_CONSTANTS.VC_AND_DISCLOSE_SCOPE_INDEX]);
for (let i = 0; i < 4; i++) {
expect(result.forbiddenCountriesListPacked[i]).to.equal(BigInt(countriesListPacked[i]));
}
const isClaimed = await airdrop.claimed(await user1.getAddress());
expect(isClaimed).to.be.true;
const tokenFactory = await ethers.getContractFactory("AirdropToken");
const token = await tokenFactory.connect(owner).deploy();
await token.waitForDeployment();
const readableData = await hub.getReadableRevealedData(
[
result.revealedDataPacked[0],
result.revealedDataPacked[1],
result.revealedDataPacked[2]
],
['0', '1', '2', '3', '4', '5', '6', '7', '8']
);
const airdropFactory = await ethers.getContractFactory("Airdrop");
const airdrop = await airdropFactory
.connect(owner)
.deploy(
hub.target,
castFromScope("test-scope"),
ATTESTATION_ID.E_PASSPORT,
token.target,
true,
20,
true,
countriesListPacked as [BigNumberish, BigNumberish, BigNumberish, BigNumberish],
[true, true, true],
);
await airdrop.waitForDeployment();
expect(readableData[0]).to.equal('FRA');
expect(readableData[1]).to.deep.equal([ 'ALPHONSE HUGHUES ALBERT', 'DUPONT' ]);
expect(readableData[2]).to.equal('15AA81234');
expect(readableData[3]).to.equal('FRA');
expect(readableData[4]).to.equal('31-01-94');
expect(readableData[5]).to.equal('M');
expect(readableData[6]).to.equal('31-10-40');
expect(readableData[7]).to.equal(20n);
expect(readableData[8]).to.equal(1n);
});
await token.connect(owner).mint(airdrop.target, BigInt(1000000000000000000));
await airdrop.connect(owner).openRegistration();
await airdrop.connect(user1).verifySelfProof(vcAndDiscloseProof);
await airdrop.connect(owner).closeRegistration();
const tree = new BalanceTree([{ account: await user1.getAddress(), amount: BigInt(1000000000000000000) }]);
const merkleRoot = tree.getHexRoot();
await airdrop.connect(owner).setMerkleRoot(merkleRoot);
await airdrop.connect(owner).openClaim();
const merkleProof = tree.getProof(0, await user1.getAddress(), BigInt(1000000000000000000));
const claimTx = await airdrop.connect(user1).claim(0, BigInt(1000000000000000000), merkleProof);
const claimReceipt = (await claimTx.wait()) as TransactionReceipt;
const claimEvent = claimReceipt?.logs.find(
(log) => log.topics[0] === airdrop.interface.getEvent("Claimed").topicHash,
);
const claimEventArgs = claimEvent
? airdrop.interface.decodeEventLog("Claimed", claimEvent.data, claimEvent.topics)
: null;
expect(claimEventArgs?.index).to.equal(0);
expect(claimEventArgs?.amount).to.equal(BigInt(1000000000000000000));
expect(claimEventArgs?.account).to.equal(await user1.getAddress());
const balance = await token.balanceOf(await user1.getAddress());
expect(balance).to.equal(BigInt(1000000000000000000));
const isClaimed = await airdrop.claimed(await user1.getAddress());
expect(isClaimed).to.be.true;
const readableData = await hub.getReadableRevealedData(
[result.revealedDataPacked[0], result.revealedDataPacked[1], result.revealedDataPacked[2]],
["0", "1", "2", "3", "4", "5", "6", "7", "8"],
);
expect(readableData[0]).to.equal("FRA");
expect(readableData[1]).to.deep.equal(["ALPHONSE HUGHUES ALBERT", "DUPONT"]);
expect(readableData[2]).to.equal("15AA81234");
expect(readableData[3]).to.equal("FRA");
expect(readableData[4]).to.equal("31-01-94");
expect(readableData[5]).to.equal("M");
expect(readableData[6]).to.equal("31-10-40");
expect(readableData[7]).to.equal(20n);
expect(readableData[8]).to.equal(1n);
});
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,198 +4,192 @@ import { TestCircuitAttributeHandler } from "../../typechain-types";
import { CircuitAttributeHandler } from "../utils/formatter";
describe("CircuitAttributeHandler", function () {
let testHandler: TestCircuitAttributeHandler;
let testHandler: TestCircuitAttributeHandler;
before(async function () {
const TestHandlerFactory = await ethers.getContractFactory("TestCircuitAttributeHandler");
testHandler = await TestHandlerFactory.deploy();
await testHandler.waitForDeployment();
before(async function () {
const TestHandlerFactory = await ethers.getContractFactory("TestCircuitAttributeHandler");
testHandler = await TestHandlerFactory.deploy();
await testHandler.waitForDeployment();
});
const mrz = ethers.toUtf8Bytes(
"P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<" + "L898902C36UTO7408122F1204159ZE184226B<<<<<1018",
);
const sampleMRZ = new Uint8Array([...mrz, 1, 1, 1]);
describe("getIssuingState", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetIssuingState(sampleMRZ);
const tsResult = CircuitAttributeHandler.getIssuingState(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("UTO");
});
});
describe("getName", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetName(sampleMRZ);
const tsResult = CircuitAttributeHandler.getName(sampleMRZ);
expect(contractResult[0]).to.equal(tsResult[0]);
expect(contractResult[1]).to.equal(tsResult[1]);
expect(contractResult[0]).to.equal("ANNA MARIA");
expect(contractResult[1]).to.equal("ERIKSSON");
});
});
describe("getPassportNumber", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetPassportNumber(sampleMRZ);
const tsResult = CircuitAttributeHandler.getPassportNumber(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("L898902C3");
});
});
describe("getNationality", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetNationality(sampleMRZ);
const tsResult = CircuitAttributeHandler.getNationality(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("UTO");
});
});
describe("getDateOfBirth", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetDateOfBirth(sampleMRZ);
const tsResult = CircuitAttributeHandler.getDateOfBirth(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("12-08-74");
});
});
describe("getGender", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetGender(sampleMRZ);
const tsResult = CircuitAttributeHandler.getGender(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("F");
});
});
describe("getExpiryDate", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetExpiryDate(sampleMRZ);
const tsResult = CircuitAttributeHandler.getExpiryDate(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("15-04-12");
});
});
describe("getOlderThan and compareOlderThan", function () {
it("should match contract and ts implementation for getOlderThan", async function () {
const contractResult = await testHandler.testGetOlderThan(sampleMRZ);
const tsResult = CircuitAttributeHandler.getOlderThan(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal(18);
});
const mrz = ethers.toUtf8Bytes(
"P<UTOERIKSSON<<ANNA<MARIA<<<<<<<<<<<<<<<<<<<" +
"L898902C36UTO7408122F1204159ZE184226B<<<<<1018"
);
const sampleMRZ = new Uint8Array([...mrz, 1, 1, 1]);
it("should match contract and ts implementation for compareOlderThan", async function () {
const contractResult = await testHandler.testCompareOlderThan(sampleMRZ, 18);
const tsResult = CircuitAttributeHandler.compareOlderThan(sampleMRZ, 18);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.be.true;
describe("getIssuingState", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetIssuingState(sampleMRZ);
const tsResult = CircuitAttributeHandler.getIssuingState(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("UTO");
});
const contractResultFalse = await testHandler.testCompareOlderThan(sampleMRZ, 19);
const tsResultFalse = CircuitAttributeHandler.compareOlderThan(sampleMRZ, 19);
expect(contractResultFalse).to.equal(tsResultFalse);
expect(contractResultFalse).to.be.false;
});
});
describe("getPassportNoOfac, getNameAndDobOfac, getNameAndYobOfac and compareOfac", function () {
it("should match contract and ts implementation for getPassportNoOfac, getNameAndDobOfac, getNameAndYobOfac", async function () {
const contractResult = await testHandler.testGetPassportNoOfac(sampleMRZ);
const tsResult = CircuitAttributeHandler.getPassportNoOfac(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal(1);
const contractResult2 = await testHandler.testGetNameAndDobOfac(sampleMRZ);
const tsResult2 = CircuitAttributeHandler.getNameAndDobOfac(sampleMRZ);
expect(contractResult2).to.equal(tsResult2);
expect(contractResult2).to.equal(1);
const contractResult3 = await testHandler.testGetNameAndYobOfac(sampleMRZ);
const tsResult3 = CircuitAttributeHandler.getNameAndYobOfac(sampleMRZ);
expect(contractResult3).to.equal(tsResult3);
expect(contractResult3).to.equal(1);
});
describe("getName", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetName(sampleMRZ);
const tsResult = CircuitAttributeHandler.getName(sampleMRZ);
expect(contractResult[0]).to.equal(tsResult[0]);
expect(contractResult[1]).to.equal(tsResult[1]);
expect(contractResult[0]).to.equal("ANNA MARIA");
expect(contractResult[1]).to.equal("ERIKSSON");
});
it("should match contract and ts implementation for individual OFAC checks using flags", async function () {
// Test passport number check
const contractPassportNo = await testHandler.testCompareOfac(sampleMRZ, true, false, false);
const tsPassportNo = CircuitAttributeHandler.compareOfac(sampleMRZ, true, false, false);
expect(contractPassportNo).to.equal(tsPassportNo);
expect(contractPassportNo).to.be.true;
// Test name and DOB check
const contractNameDob = await testHandler.testCompareOfac(sampleMRZ, false, true, false);
const tsNameDob = CircuitAttributeHandler.compareOfac(sampleMRZ, false, true, false);
expect(contractNameDob).to.equal(tsNameDob);
expect(contractNameDob).to.be.true;
// Test name and YOB check
const contractNameYob = await testHandler.testCompareOfac(sampleMRZ, false, false, true);
const tsNameYob = CircuitAttributeHandler.compareOfac(sampleMRZ, false, false, true);
expect(contractNameYob).to.equal(tsNameYob);
expect(contractNameYob).to.be.true;
});
describe("getPassportNumber", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetPassportNumber(sampleMRZ);
const tsResult = CircuitAttributeHandler.getPassportNumber(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("L898902C3");
});
it("should match contract and ts implementation for compareOfac", async function () {
// Test with all flags true
const contractAllTrue = await testHandler.testCompareOfac(sampleMRZ, true, true, true);
const tsAllTrue = CircuitAttributeHandler.compareOfac(sampleMRZ, true, true, true);
expect(contractAllTrue).to.equal(tsAllTrue);
expect(contractAllTrue).to.be.true;
// Test with some flags false
const contractSomeTrue = await testHandler.testCompareOfac(sampleMRZ, true, false, true);
const tsSomeTrue = CircuitAttributeHandler.compareOfac(sampleMRZ, true, false, true);
expect(contractSomeTrue).to.equal(tsSomeTrue);
expect(contractSomeTrue).to.be.true;
});
});
describe("extractStringAttribute", function () {
it("should match contract and ts implementation for different positions", async function () {
const testCases = [
{ start: 2, end: 4, expected: "UTO" },
{ start: 44, end: 52, expected: "L898902C3" },
{ start: 54, end: 56, expected: "UTO" },
{ start: 64, end: 64, expected: "F" },
];
for (const testCase of testCases) {
const contractResult = await testHandler.testExtractStringAttribute(sampleMRZ, testCase.start, testCase.end);
const tsResult = CircuitAttributeHandler.extractStringAttribute(sampleMRZ, testCase.start, testCase.end);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal(testCase.expected);
}
});
describe("getNationality", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetNationality(sampleMRZ);
const tsResult = CircuitAttributeHandler.getNationality(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("UTO");
});
it("should handle errors consistently between contract and ts", async function () {
const shortMRZ = ethers.toUtf8Bytes("ABC");
await expect(testHandler.testExtractStringAttribute(shortMRZ, 0, 5)).to.be.revertedWithCustomError(
testHandler,
"INSUFFICIENT_CHARCODE_LEN",
);
expect(() => CircuitAttributeHandler.extractStringAttribute(shortMRZ, 0, 5)).to.throw(
"INSUFFICIENT_CHARCODE_LEN",
);
});
describe("getDateOfBirth", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetDateOfBirth(sampleMRZ);
const tsResult = CircuitAttributeHandler.getDateOfBirth(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("12-08-74");
});
});
describe("getGender", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetGender(sampleMRZ);
const tsResult = CircuitAttributeHandler.getGender(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("F");
});
});
describe("getExpiryDate", function () {
it("should match contract and ts implementation", async function () {
const contractResult = await testHandler.testGetExpiryDate(sampleMRZ);
const tsResult = CircuitAttributeHandler.getExpiryDate(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("15-04-12");
});
});
describe("getOlderThan and compareOlderThan", function () {
it("should match contract and ts implementation for getOlderThan", async function () {
const contractResult = await testHandler.testGetOlderThan(sampleMRZ);
const tsResult = CircuitAttributeHandler.getOlderThan(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal(18);
});
it("should match contract and ts implementation for compareOlderThan", async function () {
const contractResult = await testHandler.testCompareOlderThan(sampleMRZ, 18);
const tsResult = CircuitAttributeHandler.compareOlderThan(sampleMRZ, 18);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.be.true;
const contractResultFalse = await testHandler.testCompareOlderThan(sampleMRZ, 19);
const tsResultFalse = CircuitAttributeHandler.compareOlderThan(sampleMRZ, 19);
expect(contractResultFalse).to.equal(tsResultFalse);
expect(contractResultFalse).to.be.false;
});
});
describe("getPassportNoOfac, getNameAndDobOfac, getNameAndYobOfac and compareOfac", function () {
it("should match contract and ts implementation for getPassportNoOfac, getNameAndDobOfac, getNameAndYobOfac", async function () {
const contractResult = await testHandler.testGetPassportNoOfac(sampleMRZ);
const tsResult = CircuitAttributeHandler.getPassportNoOfac(sampleMRZ);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal(1);
const contractResult2 = await testHandler.testGetNameAndDobOfac(sampleMRZ);
const tsResult2 = CircuitAttributeHandler.getNameAndDobOfac(sampleMRZ);
expect(contractResult2).to.equal(tsResult2);
expect(contractResult2).to.equal(1);
const contractResult3 = await testHandler.testGetNameAndYobOfac(sampleMRZ);
const tsResult3 = CircuitAttributeHandler.getNameAndYobOfac(sampleMRZ);
expect(contractResult3).to.equal(tsResult3);
expect(contractResult3).to.equal(1);
});
it("should match contract and ts implementation for individual OFAC checks using flags", async function () {
// Test passport number check
const contractPassportNo = await testHandler.testCompareOfac(sampleMRZ, true, false, false);
const tsPassportNo = CircuitAttributeHandler.compareOfac(sampleMRZ, true, false, false);
expect(contractPassportNo).to.equal(tsPassportNo);
expect(contractPassportNo).to.be.true;
// Test name and DOB check
const contractNameDob = await testHandler.testCompareOfac(sampleMRZ, false, true, false);
const tsNameDob = CircuitAttributeHandler.compareOfac(sampleMRZ, false, true, false);
expect(contractNameDob).to.equal(tsNameDob);
expect(contractNameDob).to.be.true;
// Test name and YOB check
const contractNameYob = await testHandler.testCompareOfac(sampleMRZ, false, false, true);
const tsNameYob = CircuitAttributeHandler.compareOfac(sampleMRZ, false, false, true);
expect(contractNameYob).to.equal(tsNameYob);
expect(contractNameYob).to.be.true;
});
it("should match contract and ts implementation for compareOfac", async function () {
// Test with all flags true
const contractAllTrue = await testHandler.testCompareOfac(sampleMRZ, true, true, true);
const tsAllTrue = CircuitAttributeHandler.compareOfac(sampleMRZ, true, true, true);
expect(contractAllTrue).to.equal(tsAllTrue);
expect(contractAllTrue).to.be.true;
// Test with some flags false
const contractSomeTrue = await testHandler.testCompareOfac(sampleMRZ, true, false, true);
const tsSomeTrue = CircuitAttributeHandler.compareOfac(sampleMRZ, true, false, true);
expect(contractSomeTrue).to.equal(tsSomeTrue);
expect(contractSomeTrue).to.be.true;
});
});
describe("extractStringAttribute", function () {
it("should match contract and ts implementation for different positions", async function () {
const testCases = [
{ start: 2, end: 4, expected: "UTO" },
{ start: 44, end: 52, expected: "L898902C3" },
{ start: 54, end: 56, expected: "UTO" },
{ start: 64, end: 64, expected: "F" }
];
for (const testCase of testCases) {
const contractResult = await testHandler.testExtractStringAttribute(
sampleMRZ,
testCase.start,
testCase.end
);
const tsResult = CircuitAttributeHandler.extractStringAttribute(
sampleMRZ,
testCase.start,
testCase.end
);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal(testCase.expected);
}
});
it("should handle errors consistently between contract and ts", async function () {
const shortMRZ = ethers.toUtf8Bytes("ABC");
await expect(testHandler.testExtractStringAttribute(shortMRZ, 0, 5))
.to.be.revertedWithCustomError(testHandler, "INSUFFICIENT_CHARCODE_LEN");
expect(() => CircuitAttributeHandler.extractStringAttribute(shortMRZ, 0, 5))
.to.throw("INSUFFICIENT_CHARCODE_LEN");
});
it("should match contract and ts implementation for empty range", async function () {
const contractResult = await testHandler.testExtractStringAttribute(sampleMRZ, 2, 2);
const tsResult = CircuitAttributeHandler.extractStringAttribute(sampleMRZ, 2, 2);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("U");
});
it("should match contract and ts implementation for empty range", async function () {
const contractResult = await testHandler.testExtractStringAttribute(sampleMRZ, 2, 2);
const tsResult = CircuitAttributeHandler.extractStringAttribute(sampleMRZ, 2, 2);
expect(contractResult).to.equal(tsResult);
expect(contractResult).to.equal("U");
});
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -5,478 +5,494 @@ import { ethers } from "hardhat";
import { RegisterVerifierId, DscVerifierId } from "../../../common/src/constants/constants";
describe("Unit Tests for IdentityVerificationHub", () => {
let deployedActors: DeployedActors;
let snapshotId: string;
let deployedActors: DeployedActors;
let snapshotId: string;
before(async () => {
deployedActors = await deploySystemFixtures();
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
before(async () => {
deployedActors = await deploySystemFixtures();
snapshotId = await ethers.provider.send("evm_snapshot", []);
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
});
describe("Initialization", () => {
it("should initialize hub with correct parameters", async () => {
const { hub, registry, vcAndDisclose, register, dsc } = deployedActors;
// Check initial state
expect(await hub.registry()).to.equal(registry.target);
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDisclose.target);
const registerId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const dscId = DscVerifierId.dsc_sha256_rsa_65537_4096;
expect(await hub.sigTypeToRegisterCircuitVerifiers(registerId)).to.equal(register.target);
expect(await hub.sigTypeToDscCircuitVerifiers(dscId)).to.equal(dsc.target);
const filter = hub.filters.HubInitialized;
const hubInitializedEvents = await hub.queryFilter(filter);
expect(hubInitializedEvents.length).to.equal(1);
const hubInitializedEvent = hubInitializedEvents[0];
expect(hubInitializedEvent.args.registry).to.equal(registry.target);
expect(hubInitializedEvent.args.vcAndDiscloseCircuitVerifier).to.equal(vcAndDisclose.target);
expect(hubInitializedEvent.args.registerCircuitVerifierIds).to.deep.equal([registerId]);
expect(hubInitializedEvent.args.registerCircuitVerifiers).to.deep.equal([register.target]);
expect(hubInitializedEvent.args.dscCircuitVerifierIds).to.deep.equal([dscId]);
expect(hubInitializedEvent.args.dscCircuitVerifiers).to.deep.equal([dsc.target]);
const initFilter = hub.filters.Initialized;
const initEvents = await hub.queryFilter(initFilter);
expect(initEvents.length).to.equal(1);
const initEvent = initEvents[0];
expect(initEvent.args.version).to.equal(1);
});
afterEach(async () => {
await ethers.provider.send("evm_revert", [snapshotId]);
snapshotId = await ethers.provider.send("evm_snapshot", []);
it("should not allow direct initialization of hub implementation", async () => {
const { owner, registry, vcAndDisclose } = deployedActors;
const HubFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl = await HubFactory.deploy();
await expect(
hubImpl.initialize(registry.target, vcAndDisclose.target, [], [], [], []),
).to.be.revertedWithCustomError(hubImpl, "InvalidInitialization");
});
describe("Initialization", () => {
it("should initialize hub with correct parameters", async () => {
const {hub, registry, vcAndDisclose, register, dsc} = deployedActors;
it("should revert when register circuit verifier arrays length mismatch", async () => {
const { owner, registry, vcAndDisclose } = deployedActors;
// Check initial state
expect(await hub.registry()).to.equal(registry.target);
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDisclose.target);
const HubFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl = await HubFactory.deploy();
await hubImpl.waitForDeployment();
const registerId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const dscId = DscVerifierId.dsc_sha256_rsa_65537_4096;
expect(await hub.sigTypeToRegisterCircuitVerifiers(registerId)).to.equal(register.target);
expect(await hub.sigTypeToDscCircuitVerifiers(dscId)).to.equal(dsc.target);
const initializeData = hubImpl.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[1],
[],
[],
[],
]);
const hubProxyFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
const filter = hub.filters.HubInitialized;
const hubInitializedEvents = await hub.queryFilter(filter);
expect(hubInitializedEvents.length).to.equal(1);
const hubInitializedEvent = hubInitializedEvents[0];
expect(hubInitializedEvent.args.registry).to.equal(registry.target);
expect(hubInitializedEvent.args.vcAndDiscloseCircuitVerifier).to.equal(vcAndDisclose.target);
expect(hubInitializedEvent.args.registerCircuitVerifierIds).to.deep.equal([registerId]);
expect(hubInitializedEvent.args.registerCircuitVerifiers).to.deep.equal([register.target]);
expect(hubInitializedEvent.args.dscCircuitVerifierIds).to.deep.equal([dscId]);
expect(hubInitializedEvent.args.dscCircuitVerifiers).to.deep.equal([dsc.target]);
const initFilter = hub.filters.Initialized;
const initEvents = await hub.queryFilter(initFilter);
expect(initEvents.length).to.equal(1);
const initEvent = initEvents[0];
expect(initEvent.args.version).to.equal(1);
});
it("should not allow direct initialization of hub implementation", async () => {
const {owner, registry, vcAndDisclose} = deployedActors;
const HubFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl = await HubFactory.deploy();
await expect(
hubImpl.initialize(
registry.target,
vcAndDisclose.target,
[],
[],
[],
[]
)
).to.be.revertedWithCustomError(hubImpl, "InvalidInitialization");
});
it("should revert when register circuit verifier arrays length mismatch", async () => {
const {owner, registry, vcAndDisclose} = deployedActors;
const HubFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl = await HubFactory.deploy();
await hubImpl.waitForDeployment();
const initializeData = hubImpl.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[1],
[],
[],
[]
]);
const hubProxyFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
await expect(
hubProxyFactory.deploy(hubImpl.target, initializeData)
).to.be.revertedWithCustomError(hubImpl, "LENGTH_MISMATCH");
});
it("should revert when DSC circuit verifier arrays length mismatch", async () => {
const {owner, registry, vcAndDisclose} = deployedActors;
const HubFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl = await HubFactory.deploy();
await hubImpl.waitForDeployment();
const initializeData = hubImpl.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[],
[],
[1],
[]
]);
const hubProxyFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
await expect(
hubProxyFactory.deploy(hubImpl.target, initializeData)
).to.be.revertedWithCustomError(hubImpl, "LENGTH_MISMATCH");
});
it("should not allow initialization after initialized", async () => {
const { hub, registry, vcAndDisclose } = deployedActors;
await expect(
hub.initialize(
registry.target,
vcAndDisclose.target,
[],
[],
[],
[]
)
).to.be.revertedWithCustomError(hub, "InvalidInitialization");
});
await expect(hubProxyFactory.deploy(hubImpl.target, initializeData)).to.be.revertedWithCustomError(
hubImpl,
"LENGTH_MISMATCH",
);
});
describe("Update functions", () => {
it("should update registry address", async () => {
const { hub, user1 } = deployedActors;
const newRegistryAddress = await user1.getAddress();
it("should revert when DSC circuit verifier arrays length mismatch", async () => {
const { owner, registry, vcAndDisclose } = deployedActors;
await expect(hub.updateRegistry(newRegistryAddress))
.to.emit(hub, "RegistryUpdated")
.withArgs(newRegistryAddress);
const HubFactory = await ethers.getContractFactory("IdentityVerificationHubImplV1", owner);
const hubImpl = await HubFactory.deploy();
await hubImpl.waitForDeployment();
expect(await hub.registry()).to.equal(newRegistryAddress);
});
const initializeData = hubImpl.interface.encodeFunctionData("initialize", [
registry.target,
vcAndDisclose.target,
[],
[],
[1],
[],
]);
const hubProxyFactory = await ethers.getContractFactory("IdentityVerificationHub", owner);
it("should not update registry address if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const newRegistryAddress = await user1.getAddress();
await expect(hub.connect(user1).updateRegistry(newRegistryAddress)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it ("should not update registry address if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const newRegistryAddress = await user1.getAddress();
await expect(hubImpl.updateRegistry(newRegistryAddress)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should update vc and disclose circuit verifier", async () => {
const { hub, user1 } = deployedActors;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateVcAndDiscloseCircuit(newVerifierAddress))
.to.emit(hub, "VcAndDiscloseCircuitUpdated")
.withArgs(newVerifierAddress);
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(newVerifierAddress);
});
it("should not update vc and disclose circuit verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const newVerifierAddress = await user1.getAddress();
await expect(hub.connect(user1).updateVcAndDiscloseCircuit(newVerifierAddress)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not update vc and disclose circuit verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateVcAndDiscloseCircuit(newVerifierAddress)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should update register circuit verifier", async () => {
const { hub, user1 } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateRegisterCircuitVerifier(verifierId, newVerifierAddress))
.to.emit(hub, "RegisterCircuitVerifierUpdated")
.withArgs(verifierId, newVerifierAddress);
expect(await hub.sigTypeToRegisterCircuitVerifiers(verifierId)).to.equal(newVerifierAddress);
});
it("should not update register circuit verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.connect(user1).updateRegisterCircuitVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not update register circuit verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateRegisterCircuitVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should update DSC verifier", async () => {
const { hub, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateDscVerifier(verifierId, newVerifierAddress))
.to.emit(hub, "DscCircuitVerifierUpdated")
.withArgs(verifierId, newVerifierAddress);
expect(await hub.sigTypeToDscCircuitVerifiers(verifierId)).to.equal(newVerifierAddress);
});
it("should not update DSC verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.connect(user1).updateDscVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not update DSC verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateDscVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should batch update register circuit verifiers", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses))
.to.emit(hub, "RegisterCircuitVerifierUpdated")
.withArgs(verifierIds[0], newVerifierAddresses[0])
.to.emit(hub, "RegisterCircuitVerifierUpdated")
.withArgs(verifierIds[1], newVerifierAddresses[1]);
for (let i = 0; i < verifierIds.length; i++) {
expect(await hub.sigTypeToRegisterCircuitVerifiers(verifierIds[i]))
.to.equal(newVerifierAddresses[i]);
}
});
it("should not batch update register circuit verifiers if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.connect(user1).batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not batch update register circuit verifiers if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hubImpl.batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses))
.to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should not batch update register verifiers if length is not the same", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hub.batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses)
).to.be.revertedWithCustomError(hub, "LENGTH_MISMATCH");
});
it("should batch update DSC circuit verifiers", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses))
.to.emit(hub, "DscCircuitVerifierUpdated")
.withArgs(verifierIds[0], newVerifierAddresses[0])
.to.emit(hub, "DscCircuitVerifierUpdated")
.withArgs(verifierIds[1], newVerifierAddresses[1]);
for (let i = 0; i < verifierIds.length; i++) {
expect(await hub.sigTypeToDscCircuitVerifiers(verifierIds[i]))
.to.equal(newVerifierAddresses[i]);
}
});
it("should not batch update DSC circuit verifiers if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.connect(user1).batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses)).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not batch update DSC circuit verifiers if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hubImpl.batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses))
.to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should not batch update dsc verifiers if length is not the same", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hub.batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses)
).to.be.revertedWithCustomError(hub, "LENGTH_MISMATCH");
});
await expect(hubProxyFactory.deploy(hubImpl.target, initializeData)).to.be.revertedWithCustomError(
hubImpl,
"LENGTH_MISMATCH",
);
});
describe("View functions", () => {
it("should return correct registry address", async () => {
const { hub, registry } = deployedActors;
expect(await hub.registry()).to.equal(registry.target);
});
it("should not allow initialization after initialized", async () => {
const { hub, registry, vcAndDisclose } = deployedActors;
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.registry()).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
await expect(hub.initialize(registry.target, vcAndDisclose.target, [], [], [], [])).to.be.revertedWithCustomError(
hub,
"InvalidInitialization",
);
});
});
it("should return correct vcAndDiscloseCircuitVerifier address", async () => {
const { hub, vcAndDisclose } = deployedActors;
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDisclose.target);
});
describe("Update functions", () => {
it("should update registry address", async () => {
const { hub, user1 } = deployedActors;
const newRegistryAddress = await user1.getAddress();
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.vcAndDiscloseCircuitVerifier()).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should return correct register circuit verifier address", async () => {
const { hub, register } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
expect(await hub.sigTypeToRegisterCircuitVerifiers(verifierId)).to.equal(register.target);
});
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.sigTypeToRegisterCircuitVerifiers(1)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should return correct dsc circuit verifier address", async () => {
const { hub, dsc } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
expect(await hub.sigTypeToDscCircuitVerifiers(verifierId)).to.equal(dsc.target);
});
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.sigTypeToDscCircuitVerifiers(1)).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
await expect(hub.updateRegistry(newRegistryAddress)).to.emit(hub, "RegistryUpdated").withArgs(newRegistryAddress);
expect(await hub.registry()).to.equal(newRegistryAddress);
});
describe("Upgradeabilitiy", () => {
it("should preserve state after upgrade", async () => {
const {hub, owner} = deployedActors;
it("should not update registry address if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const newRegistryAddress = await user1.getAddress();
const registryAddressBefore = await hub.registry();
const vcAndDiscloseCircuitVerifierBefore = await hub.vcAndDiscloseCircuitVerifier();
const registerCircuitVerifierIdsBefore = await hub.sigTypeToRegisterCircuitVerifiers(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096
);
const dscCircuitVerifierIdsBefore = await hub.sigTypeToDscCircuitVerifiers(
DscVerifierId.dsc_sha256_rsa_65537_4096
);
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
const hubAsImpl = await ethers.getContractAt(
"testUpgradedIdentityVerificationHubImplV1",
hub.target
);
await hubAsImpl.connect(owner).upgradeToAndCall(
hubV2Implementation.target,
HubV2Factory.interface.encodeFunctionData("initialize", [true])
);
const hubV2 = await ethers.getContractAt("testUpgradedIdentityVerificationHubImplV1", hub.target);
expect(await hubV2.isTest()).to.equal(true);
expect(await hubV2.registry()).to.equal(registryAddressBefore);
expect(await hubV2.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDiscloseCircuitVerifierBefore);
expect(await hubV2.sigTypeToRegisterCircuitVerifiers(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096
)).to.equal(registerCircuitVerifierIdsBefore);
expect(await hubV2.sigTypeToDscCircuitVerifiers(
DscVerifierId.dsc_sha256_rsa_65537_4096
)).to.equal(dscCircuitVerifierIdsBefore);
const implementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
const implementationAddress = await ethers.provider.getStorage(hub.target, implementationSlot);
expect(ethers.zeroPadValue(implementationAddress, 32))
.to.equal(ethers.zeroPadValue(hubV2Implementation.target.toString(), 32));
});
it("should not allow non-proxy to upgrade implementation", async() => {
const {hub, hubImpl, owner} = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
const hubAsImpl = await ethers.getContractAt(
"testUpgradedIdentityVerificationHubImplV1",
hub.target
);
await expect(
hubImpl.connect(owner).upgradeToAndCall(
hubV2Implementation.target,
HubV2Factory.interface.encodeFunctionData("initialize", [true])
)
).to.be.revertedWithCustomError(hubAsImpl, "UUPSUnauthorizedCallContext");
});
it("should not allow non-owner to upgrade implementation", async () => {
const {hub, owner, user1} = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
const hubAsImpl = await ethers.getContractAt(
"testUpgradedIdentityVerificationHubImplV1",
hub.target
);
await expect(
hubAsImpl.connect(user1).upgradeToAndCall(
hubV2Implementation.target,
HubV2Factory.interface.encodeFunctionData("initialize", [true])
)
).to.be.revertedWithCustomError(hubAsImpl, "OwnableUnauthorizedAccount");
});
it("should not allow implementation contract to be initialized directly", async () => {
const {hub, owner} = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
await expect(
hubV2Implementation.initialize(true)
).to.be.revertedWithCustomError(hub, "InvalidInitialization");
});
it("should not allow direct calls to implementation contract", async () => {
const {hub, owner} = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
await expect(
hubV2Implementation.isTest()
).to.be.revertedWithCustomError(hubV2Implementation, "UUPSUnauthorizedCallContext");
});
await expect(hub.connect(user1).updateRegistry(newRegistryAddress)).to.be.revertedWithCustomError(
hub,
"OwnableUnauthorizedAccount",
);
});
it("should not update registry address if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const newRegistryAddress = await user1.getAddress();
await expect(hubImpl.updateRegistry(newRegistryAddress)).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should update vc and disclose circuit verifier", async () => {
const { hub, user1 } = deployedActors;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateVcAndDiscloseCircuit(newVerifierAddress))
.to.emit(hub, "VcAndDiscloseCircuitUpdated")
.withArgs(newVerifierAddress);
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(newVerifierAddress);
});
it("should not update vc and disclose circuit verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const newVerifierAddress = await user1.getAddress();
await expect(hub.connect(user1).updateVcAndDiscloseCircuit(newVerifierAddress)).to.be.revertedWithCustomError(
hub,
"OwnableUnauthorizedAccount",
);
});
it("should not update vc and disclose circuit verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateVcAndDiscloseCircuit(newVerifierAddress)).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should update register circuit verifier", async () => {
const { hub, user1 } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateRegisterCircuitVerifier(verifierId, newVerifierAddress))
.to.emit(hub, "RegisterCircuitVerifierUpdated")
.withArgs(verifierId, newVerifierAddress);
expect(await hub.sigTypeToRegisterCircuitVerifiers(verifierId)).to.equal(newVerifierAddress);
});
it("should not update register circuit verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(
hub.connect(user1).updateRegisterCircuitVerifier(verifierId, newVerifierAddress),
).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not update register circuit verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateRegisterCircuitVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should update DSC verifier", async () => {
const { hub, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.updateDscVerifier(verifierId, newVerifierAddress))
.to.emit(hub, "DscCircuitVerifierUpdated")
.withArgs(verifierId, newVerifierAddress);
expect(await hub.sigTypeToDscCircuitVerifiers(verifierId)).to.equal(newVerifierAddress);
});
it("should not update DSC verifier if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hub.connect(user1).updateDscVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(
hub,
"OwnableUnauthorizedAccount",
);
});
it("should not update DSC verifier if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
const newVerifierAddress = await user1.getAddress();
await expect(hubImpl.updateDscVerifier(verifierId, newVerifierAddress)).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should batch update register circuit verifiers", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses))
.to.emit(hub, "RegisterCircuitVerifierUpdated")
.withArgs(verifierIds[0], newVerifierAddresses[0])
.to.emit(hub, "RegisterCircuitVerifierUpdated")
.withArgs(verifierIds[1], newVerifierAddresses[1]);
for (let i = 0; i < verifierIds.length; i++) {
expect(await hub.sigTypeToRegisterCircuitVerifiers(verifierIds[i])).to.equal(newVerifierAddresses[i]);
}
});
it("should not batch update register circuit verifiers if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hub.connect(user1).batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses),
).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not batch update register circuit verifiers if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hubImpl.batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses),
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should not batch update register verifiers if length is not the same", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hub.batchUpdateRegisterCircuitVerifiers(verifierIds, newVerifierAddresses),
).to.be.revertedWithCustomError(hub, "LENGTH_MISMATCH");
});
it("should batch update DSC circuit verifiers", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses))
.to.emit(hub, "DscCircuitVerifierUpdated")
.withArgs(verifierIds[0], newVerifierAddresses[0])
.to.emit(hub, "DscCircuitVerifierUpdated")
.withArgs(verifierIds[1], newVerifierAddresses[1]);
for (let i = 0; i < verifierIds.length; i++) {
expect(await hub.sigTypeToDscCircuitVerifiers(verifierIds[i])).to.equal(newVerifierAddresses[i]);
}
});
it("should not batch update DSC circuit verifiers if caller is not owner", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hub.connect(user1).batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses),
).to.be.revertedWithCustomError(hub, "OwnableUnauthorizedAccount");
});
it("should not batch update DSC circuit verifiers if caller is not proxy", async () => {
const { hubImpl, user1 } = deployedActors;
const verifierIds = [1, 2];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(
hubImpl.batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses),
).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should not batch update dsc verifiers if length is not the same", async () => {
const { hub, user1 } = deployedActors;
const verifierIds = [1];
const newVerifierAddresses = [await user1.getAddress(), await user1.getAddress()];
await expect(hub.batchUpdateDscCircuitVerifiers(verifierIds, newVerifierAddresses)).to.be.revertedWithCustomError(
hub,
"LENGTH_MISMATCH",
);
});
});
describe("View functions", () => {
it("should return correct registry address", async () => {
const { hub, registry } = deployedActors;
expect(await hub.registry()).to.equal(registry.target);
});
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.registry()).to.be.revertedWithCustomError(hubImpl, "UUPSUnauthorizedCallContext");
});
it("should return correct vcAndDiscloseCircuitVerifier address", async () => {
const { hub, vcAndDisclose } = deployedActors;
expect(await hub.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDisclose.target);
});
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.vcAndDiscloseCircuitVerifier()).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should return correct register circuit verifier address", async () => {
const { hub, register } = deployedActors;
const verifierId = RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096;
expect(await hub.sigTypeToRegisterCircuitVerifiers(verifierId)).to.equal(register.target);
});
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.sigTypeToRegisterCircuitVerifiers(1)).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
it("should return correct dsc circuit verifier address", async () => {
const { hub, dsc } = deployedActors;
const verifierId = DscVerifierId.dsc_sha256_rsa_65537_4096;
expect(await hub.sigTypeToDscCircuitVerifiers(verifierId)).to.equal(dsc.target);
});
it("should not return when view function is called by non-proxy", async () => {
const { hubImpl } = deployedActors;
await expect(hubImpl.sigTypeToDscCircuitVerifiers(1)).to.be.revertedWithCustomError(
hubImpl,
"UUPSUnauthorizedCallContext",
);
});
});
describe("Upgradeabilitiy", () => {
it("should preserve state after upgrade", async () => {
const { hub, owner } = deployedActors;
const registryAddressBefore = await hub.registry();
const vcAndDiscloseCircuitVerifierBefore = await hub.vcAndDiscloseCircuitVerifier();
const registerCircuitVerifierIdsBefore = await hub.sigTypeToRegisterCircuitVerifiers(
RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096,
);
const dscCircuitVerifierIdsBefore = await hub.sigTypeToDscCircuitVerifiers(
DscVerifierId.dsc_sha256_rsa_65537_4096,
);
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
const hubAsImpl = await ethers.getContractAt("testUpgradedIdentityVerificationHubImplV1", hub.target);
await hubAsImpl
.connect(owner)
.upgradeToAndCall(hubV2Implementation.target, HubV2Factory.interface.encodeFunctionData("initialize", [true]));
const hubV2 = await ethers.getContractAt("testUpgradedIdentityVerificationHubImplV1", hub.target);
expect(await hubV2.isTest()).to.equal(true);
expect(await hubV2.registry()).to.equal(registryAddressBefore);
expect(await hubV2.vcAndDiscloseCircuitVerifier()).to.equal(vcAndDiscloseCircuitVerifierBefore);
expect(
await hubV2.sigTypeToRegisterCircuitVerifiers(RegisterVerifierId.register_sha256_sha256_sha256_rsa_65537_4096),
).to.equal(registerCircuitVerifierIdsBefore);
expect(await hubV2.sigTypeToDscCircuitVerifiers(DscVerifierId.dsc_sha256_rsa_65537_4096)).to.equal(
dscCircuitVerifierIdsBefore,
);
const implementationSlot = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
const implementationAddress = await ethers.provider.getStorage(hub.target, implementationSlot);
expect(ethers.zeroPadValue(implementationAddress, 32)).to.equal(
ethers.zeroPadValue(hubV2Implementation.target.toString(), 32),
);
});
it("should not allow non-proxy to upgrade implementation", async () => {
const { hub, hubImpl, owner } = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
const hubAsImpl = await ethers.getContractAt("testUpgradedIdentityVerificationHubImplV1", hub.target);
await expect(
hubImpl
.connect(owner)
.upgradeToAndCall(
hubV2Implementation.target,
HubV2Factory.interface.encodeFunctionData("initialize", [true]),
),
).to.be.revertedWithCustomError(hubAsImpl, "UUPSUnauthorizedCallContext");
});
it("should not allow non-owner to upgrade implementation", async () => {
const { hub, owner, user1 } = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
const hubAsImpl = await ethers.getContractAt("testUpgradedIdentityVerificationHubImplV1", hub.target);
await expect(
hubAsImpl
.connect(user1)
.upgradeToAndCall(
hubV2Implementation.target,
HubV2Factory.interface.encodeFunctionData("initialize", [true]),
),
).to.be.revertedWithCustomError(hubAsImpl, "OwnableUnauthorizedAccount");
});
it("should not allow implementation contract to be initialized directly", async () => {
const { hub, owner } = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
await expect(hubV2Implementation.initialize(true)).to.be.revertedWithCustomError(hub, "InvalidInitialization");
});
it("should not allow direct calls to implementation contract", async () => {
const { hub, owner } = deployedActors;
const HubV2Factory = await ethers.getContractFactory("testUpgradedIdentityVerificationHubImplV1", owner);
const hubV2Implementation = await HubV2Factory.deploy();
await hubV2Implementation.waitForDeployment();
await expect(hubV2Implementation.isTest()).to.be.revertedWithCustomError(
hubV2Implementation,
"UUPSUnauthorizedCallContext",
);
});
});
});

View File

@@ -4,96 +4,92 @@ import { ZeroAddress } from "ethers";
import { MockImplRoot } from "../../typechain-types";
describe("ImplRoot", () => {
let mockImplRoot: MockImplRoot;
let owner: any;
let user1: any;
let mockImplRoot: MockImplRoot;
let owner: any;
let user1: any;
beforeEach(async () => {
[owner, user1] = await ethers.getSigners();
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
mockImplRoot = await MockImplRootFactory.deploy();
await mockImplRoot.waitForDeployment();
});
describe("Initialization", () => {
it("should revert when calling __ImplRoot_init outside initialization phase", async () => {
await expect(mockImplRoot.exposed__ImplRoot_init()).to.be.revertedWithCustomError(
mockImplRoot,
"NotInitializing",
);
});
it("should revert when initializing with zero address owner", async () => {
await expect(mockImplRoot.exposed__Ownable_init(ZeroAddress))
.to.be.revertedWithCustomError(mockImplRoot, "OwnableInvalidOwner")
.withArgs(ZeroAddress);
});
it("should set correct owner when initializing with valid address", async () => {
await mockImplRoot.exposed__Ownable_init(owner.address);
expect(await mockImplRoot.owner()).to.equal(owner.address);
});
it("should revert when initializing twice", async () => {
await mockImplRoot.exposed__Ownable_init(owner.address);
await expect(mockImplRoot.exposed__Ownable_init(owner.address)).to.be.revertedWithCustomError(
mockImplRoot,
"InvalidInitialization",
);
});
});
describe("Upgrade Authorization", () => {
let proxy: any;
let implContract: any;
beforeEach(async () => {
[owner, user1] = await ethers.getSigners();
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
implContract = await MockImplRootFactory.deploy();
await implContract.waitForDeployment();
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
mockImplRoot = await MockImplRootFactory.deploy();
await mockImplRoot.waitForDeployment();
const initData = implContract.interface.encodeFunctionData("exposed__Ownable_init", [owner.address]);
const ProxyFactory = await ethers.getContractFactory("ERC1967Proxy");
proxy = await ProxyFactory.deploy(implContract.target, initData);
await proxy.waitForDeployment();
mockImplRoot = await ethers.getContractAt("MockImplRoot", proxy.target);
});
describe("Initialization", () => {
it("should revert when calling __ImplRoot_init outside initialization phase", async () => {
await expect(
mockImplRoot.exposed__ImplRoot_init()
).to.be.revertedWithCustomError(mockImplRoot, "NotInitializing");
});
it("should revert when calling _authorizeUpgrade from non-proxy", async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
const newImpl = await MockImplRootFactory.deploy();
await newImpl.waitForDeployment();
it("should revert when initializing with zero address owner", async () => {
await expect(
mockImplRoot.exposed__Ownable_init(ZeroAddress)
).to.be.revertedWithCustomError(mockImplRoot, "OwnableInvalidOwner")
.withArgs(ZeroAddress);
});
it("should set correct owner when initializing with valid address", async () => {
await mockImplRoot.exposed__Ownable_init(owner.address);
expect(await mockImplRoot.owner()).to.equal(owner.address);
});
it("should revert when initializing twice", async () => {
await mockImplRoot.exposed__Ownable_init(owner.address);
await expect(
mockImplRoot.exposed__Ownable_init(owner.address)
).to.be.revertedWithCustomError(mockImplRoot, "InvalidInitialization");
});
await expect(implContract.exposed_authorizeUpgrade(newImpl.target)).to.be.revertedWithCustomError(
implContract,
"UUPSUnauthorizedCallContext",
);
});
describe("Upgrade Authorization", () => {
let proxy: any;
let implContract: any;
it("should revert when non-owner calls _authorizeUpgrade", async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
const newImpl = await MockImplRootFactory.deploy();
await newImpl.waitForDeployment();
beforeEach(async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
implContract = await MockImplRootFactory.deploy();
await implContract.waitForDeployment();
const initData = implContract.interface.encodeFunctionData("exposed__Ownable_init", [owner.address]);
const ProxyFactory = await ethers.getContractFactory("ERC1967Proxy");
proxy = await ProxyFactory.deploy(
implContract.target,
initData
);
await proxy.waitForDeployment();
mockImplRoot = await ethers.getContractAt("MockImplRoot", proxy.target);
});
it("should revert when calling _authorizeUpgrade from non-proxy", async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
const newImpl = await MockImplRootFactory.deploy();
await newImpl.waitForDeployment();
await expect(
implContract.exposed_authorizeUpgrade(newImpl.target)
).to.be.revertedWithCustomError(implContract, "UUPSUnauthorizedCallContext");
});
it("should revert when non-owner calls _authorizeUpgrade", async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
const newImpl = await MockImplRootFactory.deploy();
await newImpl.waitForDeployment();
await expect(
mockImplRoot.connect(user1).exposed_authorizeUpgrade(newImpl.target)
).to.be.revertedWithCustomError(mockImplRoot, "OwnableUnauthorizedAccount")
.withArgs(user1.address);
});
it("should allow owner to call _authorizeUpgrade through proxy", async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
const newImpl = await MockImplRootFactory.deploy();
await newImpl.waitForDeployment();
await expect(
mockImplRoot.connect(owner).exposed_authorizeUpgrade(newImpl.target)
).to.not.be.reverted;
});
await expect(mockImplRoot.connect(user1).exposed_authorizeUpgrade(newImpl.target))
.to.be.revertedWithCustomError(mockImplRoot, "OwnableUnauthorizedAccount")
.withArgs(user1.address);
});
it("should allow owner to call _authorizeUpgrade through proxy", async () => {
const MockImplRootFactory = await ethers.getContractFactory("MockImplRoot", owner);
const newImpl = await MockImplRootFactory.deploy();
await newImpl.waitForDeployment();
await expect(mockImplRoot.connect(owner).exposed_authorizeUpgrade(newImpl.target)).to.not.be.reverted;
});
});
});

Some files were not shown because too many files have changed in this diff Show More