feat: ready for demo
This commit is contained in:
parent
d8f7dd43cb
commit
eefd74c1f3
|
@ -1,6 +1,6 @@
|
|||
export const devNets = ["hardhat", "localhost"];
|
||||
|
||||
export const testNets = ["goerli"];
|
||||
export const testNets = ["goerli", "localhost_integration"];
|
||||
|
||||
export const prodNets = ["mainnet"];
|
||||
|
||||
|
@ -12,6 +12,9 @@ export const isTestNet = (networkName: string) =>
|
|||
export const isProdNet = (networkName: string) =>
|
||||
prodNets.includes(networkName);
|
||||
|
||||
export const useRealVerifier = (networkName: string) =>
|
||||
networkName === "localhost_integration";
|
||||
|
||||
export const getInterepAddress = (networkName: string) => {
|
||||
switch (networkName) {
|
||||
case "mainnet":
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { useRealVerifier } from "../common";
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const { deployments, getUnnamedAccounts } = hre;
|
||||
const { deploy } = deployments;
|
||||
|
||||
const [deployer] = await getUnnamedAccounts();
|
||||
|
||||
await deploy("Verifier20", {
|
||||
from: deployer,
|
||||
log: true,
|
||||
});
|
||||
};
|
||||
export default func;
|
||||
func.tags = ["Verifier20"];
|
||||
// skip when running on mainnet
|
||||
func.skip = async (hre: HardhatRuntimeEnvironment) => {
|
||||
if (useRealVerifier(hre.network.name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
|
@ -1,6 +1,11 @@
|
|||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { getGroups, isDevNet, merkleTreeDepth } from "../common";
|
||||
import {
|
||||
getGroups,
|
||||
isDevNet,
|
||||
merkleTreeDepth,
|
||||
useRealVerifier,
|
||||
} from "../common";
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const { deployments, getUnnamedAccounts } = hre;
|
||||
|
@ -8,7 +13,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|||
|
||||
const [deployer] = await getUnnamedAccounts();
|
||||
|
||||
const verifierAddress = (await deployments.get("VerifierTest")).address;
|
||||
let verifierAddress: string;
|
||||
if (useRealVerifier(hre.network.name)) {
|
||||
verifierAddress = (await deployments.get("Verifier20")).address;
|
||||
} else {
|
||||
verifierAddress = (await deployments.get("VerifierTest")).address;
|
||||
}
|
||||
|
||||
const interepTest = await deploy("InterepTest", {
|
||||
from: deployer,
|
||||
|
@ -33,10 +43,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|||
};
|
||||
export default func;
|
||||
func.tags = ["InterepTest"];
|
||||
func.dependencies = ["VerifierTest"];
|
||||
func.dependencies = ["VerifierTest", "Verifier20"];
|
||||
// skip when running on mainnet
|
||||
func.skip = async (hre: HardhatRuntimeEnvironment) => {
|
||||
if (isDevNet(hre.network.name)) {
|
||||
if (isDevNet(hre.network.name) || useRealVerifier(hre.network.name)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import { HardhatRuntimeEnvironment } from "hardhat/types";
|
||||
import { DeployFunction } from "hardhat-deploy/types";
|
||||
import { getInterepAddress, getValidGroups, isDevNet } from "../common";
|
||||
import {
|
||||
getInterepAddress,
|
||||
getValidGroups,
|
||||
isDevNet,
|
||||
useRealVerifier,
|
||||
} from "../common";
|
||||
|
||||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
||||
const { deployments, getUnnamedAccounts } = hre;
|
||||
|
@ -8,9 +13,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
|
|||
|
||||
const [deployer] = await getUnnamedAccounts();
|
||||
|
||||
const interepAddress = isDevNet(hre.network.name)
|
||||
? (await deployments.get("InterepTest")).address
|
||||
: getInterepAddress(hre.network.name);
|
||||
const interepAddress =
|
||||
isDevNet(hre.network.name) || useRealVerifier(hre.network.name)
|
||||
? (await deployments.get("InterepTest")).address
|
||||
: getInterepAddress(hre.network.name);
|
||||
|
||||
await deploy("ValidGroupStorage", {
|
||||
from: deployer,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"address": "0x165D143C138923a6dc8Ee0dDf5D2DfBE1Cf3B09D",
|
||||
"address": "0xf1F12331aF91E04ea488C941BDF313d278Dc662e",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
|
@ -253,18 +253,18 @@
|
|||
"type": "function"
|
||||
}
|
||||
],
|
||||
"transactionHash": "0xbac6c8619d717cfc5dc98b3c4e5ed269b6c8f6d36850b7b7817b5e34f1b0e91e",
|
||||
"transactionHash": "0x8746281d1df195ea9177b44f148e4932fe1e0341cb986d2fe0fb6defabbf2263",
|
||||
"receipt": {
|
||||
"to": null,
|
||||
"from": "0xd2bE7ac327CEf16490FEBA8bAB2E732518cC4D13",
|
||||
"contractAddress": "0x165D143C138923a6dc8Ee0dDf5D2DfBE1Cf3B09D",
|
||||
"from": "0xabD73e893D0398772f1a679B86C3148f724546ec",
|
||||
"contractAddress": "0xf1F12331aF91E04ea488C941BDF313d278Dc662e",
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "1097158",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x2b57dd131af851d8bbbd5bd71a4bbd28ac8140cb5a08454f584aaa43e954c811",
|
||||
"transactionHash": "0xbac6c8619d717cfc5dc98b3c4e5ed269b6c8f6d36850b7b7817b5e34f1b0e91e",
|
||||
"blockHash": "0x90490daf3a37c8488696641d1258cb31dde94da32add02fe38b9303965fa3c5e",
|
||||
"transactionHash": "0x8746281d1df195ea9177b44f148e4932fe1e0341cb986d2fe0fb6defabbf2263",
|
||||
"logs": [],
|
||||
"blockNumber": 3,
|
||||
"blockNumber": 27,
|
||||
"cumulativeGasUsed": "1097158",
|
||||
"status": 1,
|
||||
"byzantium": true
|
||||
|
@ -272,7 +272,7 @@
|
|||
"args": [
|
||||
[
|
||||
{
|
||||
"contractAddress": "0x235968d78eb550dD57D2e510985E92477369E351",
|
||||
"contractAddress": "0x0d15c8DF0f8D424F014A23D5DE65Ed3015fFC8CC",
|
||||
"merkleTreeDepth": 20
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"address": "0x93234d5091B8143982b733BD6121Fe0020504B88",
|
||||
"address": "0xf02AbFE0D84aCEbdB0E4cA40c13059ee2448743b",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
|
@ -34,18 +34,18 @@
|
|||
"type": "function"
|
||||
}
|
||||
],
|
||||
"transactionHash": "0x0a6246438dbe42f0783649b4b5b6e831d777094ed2257b5ae71a66b09b7f5416",
|
||||
"transactionHash": "0xf5ba34eccc40cb2aef17310cdd4203c5cbb6b8d58e015f6d6d22e05d6012a3d5",
|
||||
"receipt": {
|
||||
"to": null,
|
||||
"from": "0xd2bE7ac327CEf16490FEBA8bAB2E732518cC4D13",
|
||||
"contractAddress": "0x93234d5091B8143982b733BD6121Fe0020504B88",
|
||||
"from": "0xabD73e893D0398772f1a679B86C3148f724546ec",
|
||||
"contractAddress": "0xf02AbFE0D84aCEbdB0E4cA40c13059ee2448743b",
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "3507975",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x94dbd9bb98946d425126eb6d779a1e3d8e670e7d693068431bf192e66a62830b",
|
||||
"transactionHash": "0x0a6246438dbe42f0783649b4b5b6e831d777094ed2257b5ae71a66b09b7f5416",
|
||||
"blockHash": "0xf52d1f0b18625b59a9f17b85966dee2cc6c27853523e78a6056a01dff5859d29",
|
||||
"transactionHash": "0xf5ba34eccc40cb2aef17310cdd4203c5cbb6b8d58e015f6d6d22e05d6012a3d5",
|
||||
"logs": [],
|
||||
"blockNumber": 1,
|
||||
"blockNumber": 25,
|
||||
"cumulativeGasUsed": "3507975",
|
||||
"status": 1,
|
||||
"byzantium": true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"address": "0xc1FCE62F55AAdBFf479fD11Ee7B24a0Ac90cB5C7",
|
||||
"address": "0x5E621a16C8caeA39B70E0442F771509F4a1F9f27",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
|
@ -302,27 +302,27 @@
|
|||
"type": "function"
|
||||
}
|
||||
],
|
||||
"transactionHash": "0xb315677fd33a0e3f161b57b73e9ac5a4f03cc46a394f53f5d17b9103e2c466c2",
|
||||
"transactionHash": "0x7621024d19be77b54556b9b125e29d7742d471ae4110f4f47b5139e9aaac917e",
|
||||
"receipt": {
|
||||
"to": null,
|
||||
"from": "0xd2bE7ac327CEf16490FEBA8bAB2E732518cC4D13",
|
||||
"contractAddress": "0xc1FCE62F55AAdBFf479fD11Ee7B24a0Ac90cB5C7",
|
||||
"from": "0xabD73e893D0398772f1a679B86C3148f724546ec",
|
||||
"contractAddress": "0x5E621a16C8caeA39B70E0442F771509F4a1F9f27",
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "1837815",
|
||||
"gasUsed": "1837827",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x6bc6ea334f92949f4436fae8cb3645d2724558b943b240b8791306a64012f6c8",
|
||||
"transactionHash": "0xb315677fd33a0e3f161b57b73e9ac5a4f03cc46a394f53f5d17b9103e2c466c2",
|
||||
"blockHash": "0x007796bcbc628e9dbacfc954b798c54b35ea1213c4d0cfc10e622e764573db31",
|
||||
"transactionHash": "0x7621024d19be77b54556b9b125e29d7742d471ae4110f4f47b5139e9aaac917e",
|
||||
"logs": [],
|
||||
"blockNumber": 6,
|
||||
"cumulativeGasUsed": "1837815",
|
||||
"blockNumber": 30,
|
||||
"cumulativeGasUsed": "1837827",
|
||||
"status": 1,
|
||||
"byzantium": true
|
||||
},
|
||||
"args": [
|
||||
1000000000000000,
|
||||
20,
|
||||
"0x93234d5091B8143982b733BD6121Fe0020504B88",
|
||||
"0x42c72a240C77CB15051daC2859f3203282c1eE2C"
|
||||
"0xf02AbFE0D84aCEbdB0E4cA40c13059ee2448743b",
|
||||
"0x97bB97A470c8fE3b98589089Ae3994fC4ce053F9"
|
||||
],
|
||||
"numDeployments": 1,
|
||||
"solcInputHash": "b8e33ba299e95051cdf4858cd81bbca9",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"address": "0x42c72a240C77CB15051daC2859f3203282c1eE2C",
|
||||
"address": "0x97bB97A470c8fE3b98589089Ae3994fC4ce053F9",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
|
@ -81,24 +81,24 @@
|
|||
"type": "function"
|
||||
}
|
||||
],
|
||||
"transactionHash": "0xe62d93881ba4a1845430533fe64689adf6170a3f06c2dc34556853cf42fb1c90",
|
||||
"transactionHash": "0x00f503f58d4169714741c53a550722240652dc0534629731b5f071d90e498e80",
|
||||
"receipt": {
|
||||
"to": null,
|
||||
"from": "0xd2bE7ac327CEf16490FEBA8bAB2E732518cC4D13",
|
||||
"contractAddress": "0x42c72a240C77CB15051daC2859f3203282c1eE2C",
|
||||
"from": "0xabD73e893D0398772f1a679B86C3148f724546ec",
|
||||
"contractAddress": "0x97bB97A470c8fE3b98589089Ae3994fC4ce053F9",
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "397310",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0xe2891be0aca5e9fb00f95eec9d1d586d432b06d7a7ceadbbc193d413732e1077",
|
||||
"transactionHash": "0xe62d93881ba4a1845430533fe64689adf6170a3f06c2dc34556853cf42fb1c90",
|
||||
"blockHash": "0x6a2879cf7824d0e8197b8405a2f15cc72aac4704d83c567602e932e2e143044f",
|
||||
"transactionHash": "0x00f503f58d4169714741c53a550722240652dc0534629731b5f071d90e498e80",
|
||||
"logs": [],
|
||||
"blockNumber": 5,
|
||||
"blockNumber": 29,
|
||||
"cumulativeGasUsed": "397310",
|
||||
"status": 1,
|
||||
"byzantium": true
|
||||
},
|
||||
"args": [
|
||||
"0x165D143C138923a6dc8Ee0dDf5D2DfBE1Cf3B09D",
|
||||
"0xf1F12331aF91E04ea488C941BDF313d278Dc662e",
|
||||
[
|
||||
{
|
||||
"provider": "0x6769746875620000000000000000000000000000000000000000000000000000",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"address": "0x235968d78eb550dD57D2e510985E92477369E351",
|
||||
"address": "0x0d15c8DF0f8D424F014A23D5DE65Ed3015fFC8CC",
|
||||
"abi": [
|
||||
{
|
||||
"inputs": [
|
||||
|
@ -30,18 +30,18 @@
|
|||
"type": "function"
|
||||
}
|
||||
],
|
||||
"transactionHash": "0xbb11b001a91afdfb861191e653d09bd53820e670199a037290ff1e549b7e8506",
|
||||
"transactionHash": "0xd59e3cb6386505b34b4e03162f7bb6f0a135d799ddf4be6b82d27ef434bed3b3",
|
||||
"receipt": {
|
||||
"to": null,
|
||||
"from": "0xd2bE7ac327CEf16490FEBA8bAB2E732518cC4D13",
|
||||
"contractAddress": "0x235968d78eb550dD57D2e510985E92477369E351",
|
||||
"from": "0xabD73e893D0398772f1a679B86C3148f724546ec",
|
||||
"contractAddress": "0x0d15c8DF0f8D424F014A23D5DE65Ed3015fFC8CC",
|
||||
"transactionIndex": 0,
|
||||
"gasUsed": "266738",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"blockHash": "0x4f15147f5501ae7862caa8a89a05501874a363313a10e699ebe93b2dbb67a50d",
|
||||
"transactionHash": "0xbb11b001a91afdfb861191e653d09bd53820e670199a037290ff1e549b7e8506",
|
||||
"blockHash": "0x1579b3fd79c82452afad83fee98c5b5a118efce809be1af93cbebcbc89687f46",
|
||||
"transactionHash": "0xd59e3cb6386505b34b4e03162f7bb6f0a135d799ddf4be6b82d27ef434bed3b3",
|
||||
"logs": [],
|
||||
"blockNumber": 2,
|
||||
"blockNumber": 26,
|
||||
"cumulativeGasUsed": "266738",
|
||||
"status": 1,
|
||||
"byzantium": true
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
31337
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,57 @@
|
|||
import createIdentity from "@interep/identity";
|
||||
import { ethers } from "ethers";
|
||||
import { createInterepProof, sToBytes32 } from "../common";
|
||||
// @ts-ignore circom
|
||||
import { poseidon } from "circomlibjs";
|
||||
|
||||
const privateKey = process.argv[2];
|
||||
const rawExistingMembers = process.argv[3] || "[]";
|
||||
|
||||
const existingMembers = JSON.parse(rawExistingMembers);
|
||||
|
||||
if (!privateKey) {
|
||||
console.log("Usage: node generate-proof.js <privateKey>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const wallet = new ethers.Wallet(privateKey);
|
||||
const identity = await createIdentity(
|
||||
(msg) => wallet.signMessage(msg),
|
||||
"Github"
|
||||
);
|
||||
const proof = await createInterepProof({
|
||||
identity,
|
||||
members: [...existingMembers, identity.getCommitment()],
|
||||
groupProvider: "github",
|
||||
groupTier: "bronze",
|
||||
signal: sToBytes32("foo"),
|
||||
externalNullifier: 1,
|
||||
snarkArtifacts: {
|
||||
wasmFilePath: "./test/snarkArtifacts/semaphore.wasm",
|
||||
zkeyFilePath: "./test/snarkArtifacts/semaphore.zkey",
|
||||
},
|
||||
});
|
||||
const identitySecretHash = poseidon([
|
||||
identity.getNullifier(),
|
||||
identity.getTrapdoor(),
|
||||
]);
|
||||
const returnObj = {};
|
||||
Object.assign(returnObj, {
|
||||
identitySecretHash: identitySecretHash.toString(16),
|
||||
identityCommitment: identity.getCommitment().toString(16),
|
||||
groupId: proof.groupId,
|
||||
signal: proof.signal,
|
||||
nullifierHash: proof.publicSignals.nullifierHash,
|
||||
externalNullifier: proof.publicSignals.externalNullifier,
|
||||
solidityProof: proof.solidityProof,
|
||||
});
|
||||
console.log(returnObj);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
|
@ -22,6 +22,9 @@ const getNetworkConfig = (): NetworksUserConfig | undefined => {
|
|||
url: GOERLI_URL,
|
||||
},
|
||||
},
|
||||
localhost_integration: {
|
||||
url: "http://localhost:8545",
|
||||
},
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
|
|
Loading…
Reference in New Issue