mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-15 01:28:02 -05:00
Compare commits
24 Commits
v3.0.0-bet
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
821cdb7fd3 | ||
|
|
dd2df7ab06 | ||
|
|
71fdabe65c | ||
|
|
cce6c31461 | ||
|
|
bd8b06bb7b | ||
|
|
9f692e57e8 | ||
|
|
32aabf81d2 | ||
|
|
a72a57ef63 | ||
|
|
4e5b4495a3 | ||
|
|
578d426d1a | ||
|
|
362b025fac | ||
|
|
84aa8d0eac | ||
|
|
6592a62f25 | ||
|
|
a59a2af50b | ||
|
|
1e68ed1fec | ||
|
|
2abd068cf8 | ||
|
|
8b746ff2bc | ||
|
|
23d9786e16 | ||
|
|
3b20402476 | ||
|
|
91bcc66c17 | ||
|
|
bcf9dad496 | ||
|
|
29195519fb | ||
|
|
17efdb38af | ||
|
|
8713e2b339 |
@@ -57,9 +57,7 @@
|
||||
| Semaphore is a protocol, designed to be a simple and generic privacy layer for Ethereum DApps. Using zero knowledge, Ethereum users can prove their membership of a group and send signals such as votes or endorsements without revealing their original identity. |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
|
||||
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) (NPM: `@semaphore-protocol/contracts`) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org).
|
||||
|
||||
You can find Semaphore V1 on [`version/1.0.0`](https://github.com/semaphore-protocol/semaphore/tree/version/1.0.0).
|
||||
The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/scheme.png). However Semaphore also provides [Solidity contracts](/packages/contracts) and JavaScript libraries to make the steps for offchain proof creation and onchain verification easier. To learn more about Semaphore visit [semaphore.appliedzkp.org](https://semaphore.appliedzkp.org).
|
||||
|
||||
---
|
||||
|
||||
|
||||
10
packages/cli-template-hardhat/.gitignore
vendored
Normal file
10
packages/cli-template-hardhat/.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
node_modules
|
||||
.env
|
||||
coverage
|
||||
coverage.json
|
||||
typechain
|
||||
typechain-types
|
||||
|
||||
# Hardhat files
|
||||
cache
|
||||
artifacts
|
||||
@@ -6,7 +6,7 @@ import "@semaphore-protocol/contracts/interfaces/ISemaphore.sol";
|
||||
/// @title Greeter contract.
|
||||
/// @dev The following code is just a example to show how Semaphore can be used.
|
||||
contract Greeter {
|
||||
event NewGreeting(bytes32 greeting);
|
||||
event NewGreeting(uint256 greeting);
|
||||
event NewUser(uint256 identityCommitment, bytes32 username);
|
||||
|
||||
ISemaphore public semaphore;
|
||||
@@ -18,7 +18,7 @@ contract Greeter {
|
||||
semaphore = ISemaphore(semaphoreAddress);
|
||||
groupId = _groupId;
|
||||
|
||||
semaphore.createGroup(groupId, 20, 0, address(this));
|
||||
semaphore.createGroup(groupId, 20, address(this));
|
||||
}
|
||||
|
||||
function joinGroup(uint256 identityCommitment, bytes32 username) external {
|
||||
@@ -30,7 +30,7 @@ contract Greeter {
|
||||
}
|
||||
|
||||
function greet(
|
||||
bytes32 greeting,
|
||||
uint256 greeting,
|
||||
uint256 merkleTreeRoot,
|
||||
uint256 nullifierHash,
|
||||
uint256[8] calldata proof
|
||||
|
||||
@@ -16,6 +16,11 @@ function getNetworks(): NetworksUserConfig {
|
||||
url: process.env.ETHEREUM_URL,
|
||||
chainId: 5,
|
||||
accounts
|
||||
},
|
||||
arbitrum: {
|
||||
url: process.env.ETHEREUM_URL,
|
||||
chainId: 42161,
|
||||
accounts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/cli-template-hardhat",
|
||||
"version": "0.4.0",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "Semaphore Hardhat template.",
|
||||
"license": "Unlicense",
|
||||
"files": [
|
||||
".gitignore",
|
||||
".env.example",
|
||||
"contracts/",
|
||||
"tasks/",
|
||||
"test/",
|
||||
@@ -31,10 +33,10 @@
|
||||
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
|
||||
"@nomiclabs/hardhat-ethers": "^2.0.0",
|
||||
"@nomiclabs/hardhat-etherscan": "^3.0.0",
|
||||
"@semaphore-protocol/group": "2.6.1",
|
||||
"@semaphore-protocol/hardhat": "^0.1.0",
|
||||
"@semaphore-protocol/identity": "2.6.1",
|
||||
"@semaphore-protocol/proof": "2.6.1",
|
||||
"@semaphore-protocol/group": "3.0.0-beta.7",
|
||||
"@semaphore-protocol/hardhat": "3.0.0-beta.7",
|
||||
"@semaphore-protocol/identity": "3.0.0-beta.7",
|
||||
"@semaphore-protocol/proof": "3.0.0-beta.7",
|
||||
"@typechain/ethers-v5": "^10.1.0",
|
||||
"@typechain/hardhat": "^6.1.2",
|
||||
"@types/chai": "^4.2.0",
|
||||
@@ -53,6 +55,6 @@
|
||||
"typescript": ">=4.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/contracts": "2.6.1"
|
||||
"@semaphore-protocol/contracts": "3.0.0-beta.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,11 @@ task("deploy", "Deploy a Greeter contract")
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, semaphore: semaphoreAddress, group: groupId }, { ethers, run }) => {
|
||||
if (!semaphoreAddress) {
|
||||
const { address: verifierAddress } = await run("deploy:verifier", { logs, merkleTreeDepth: 20 })
|
||||
|
||||
const { address } = await run("deploy:semaphore", {
|
||||
logs,
|
||||
verifiers: [
|
||||
{
|
||||
merkleTreeDepth: 20,
|
||||
contractAddress: verifierAddress
|
||||
}
|
||||
]
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
})
|
||||
|
||||
semaphoreAddress = address
|
||||
semaphoreAddress = semaphore.address
|
||||
}
|
||||
|
||||
const Greeter = await ethers.getContractFactory("Greeter")
|
||||
|
||||
@@ -15,7 +15,7 @@ describe("Greeter", () => {
|
||||
|
||||
const users: any[] = []
|
||||
const groupId = "42"
|
||||
const group = new Group()
|
||||
const group = new Group(groupId)
|
||||
|
||||
before(async () => {
|
||||
if (!existsSync(`${snarkArtifactsPath}/semaphore.wasm`)) {
|
||||
@@ -35,8 +35,8 @@ describe("Greeter", () => {
|
||||
username: ethers.utils.formatBytes32String("anon2")
|
||||
})
|
||||
|
||||
group.addMember(users[0].identity.generateCommitment())
|
||||
group.addMember(users[1].identity.generateCommitment())
|
||||
group.addMember(users[0].identity.commitment)
|
||||
group.addMember(users[1].identity.commitment)
|
||||
})
|
||||
|
||||
describe("# joinGroup", () => {
|
||||
@@ -61,7 +61,7 @@ describe("Greeter", () => {
|
||||
|
||||
const transaction = greeter.greet(
|
||||
greeting,
|
||||
fullProof.publicSignals.merkleRoot,
|
||||
fullProof.publicSignals.merkleTreeRoot,
|
||||
fullProof.publicSignals.nullifierHash,
|
||||
solidityProof
|
||||
)
|
||||
|
||||
@@ -60,7 +60,7 @@ npm i -g @semaphore-protocol/cli
|
||||
or run specific commands with `npx`:
|
||||
|
||||
```bash
|
||||
npx @semaphore-protocol/cli init my-app
|
||||
npx @semaphore-protocol/cli create my-app
|
||||
```
|
||||
|
||||
## 📜 Usage
|
||||
@@ -75,7 +75,7 @@ Options:
|
||||
-h, --help Display this help.
|
||||
|
||||
Commands:
|
||||
init <project-directory> Initialize a Semaphore project with a supported template.
|
||||
create <project-directory> Create a Semaphore project with a supported template.
|
||||
get-groups [options] Get the list of groups from a supported network (Goerli or Arbitrum).
|
||||
get-group [options] <group-id> Get the data of a group from a supported network (Goerli or Arbitrum).
|
||||
help [command] Display help for a specific command.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/cli",
|
||||
"type": "module",
|
||||
"version": "0.4.0",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "A command line tool to set up your Semaphore project and get group data.",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
@@ -40,7 +40,7 @@
|
||||
"typedoc": "^0.22.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@semaphore-protocol/subgraph": "2.6.1",
|
||||
"@semaphore-protocol/subgraph": "3.0.0-beta.7",
|
||||
"chalk": "^5.1.2",
|
||||
"commander": "^9.4.1",
|
||||
"download": "^8.0.0",
|
||||
|
||||
@@ -27,8 +27,8 @@ program
|
||||
})
|
||||
|
||||
program
|
||||
.command("init")
|
||||
.description("Initialize a Semaphore project with a supported template.")
|
||||
.command("create")
|
||||
.description("Create a Semaphore project with a supported template.")
|
||||
.argument("<project-directory>", "Directory of the project.")
|
||||
// .option("-t, --template <template-name>", "Supported Semaphore template.", "hardhat")
|
||||
.action(async (projectDirectory) => {
|
||||
@@ -64,6 +64,8 @@ program
|
||||
.map((s) => ` ${chalk.cyan(`npm run ${s}`)}`)
|
||||
.join("\n")}\n`
|
||||
)
|
||||
|
||||
console.info(` See the README.md file to understand how to use them!\n`)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/contracts",
|
||||
"version": "2.6.1",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "Semaphore contracts to manage groups and broadcast anonymous signals.",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
{
|
||||
"verifiers": {
|
||||
"Verifier16": "0xA5253ba39381Aa99c4C2C5A4D5C2deC036d06629",
|
||||
"Verifier17": "0xe0418A5f8fBF051D6cbc41Ff29855Dd2a02201Ab",
|
||||
"Verifier18": "0x7CdB3336d7d7c55Bce0FB1508594C54521656797",
|
||||
"Verifier19": "0xbd870921d8A5398a3314C950d1fc63b8C3AB190B",
|
||||
"Verifier20": "0x2a96c5696F85e3d2aa918496806B5c5a4D93E099",
|
||||
"Verifier21": "0x5Ec7d851a52A2a25CEc528F42a7ACA8EcF4667Cd",
|
||||
"Verifier22": "0x919d3d9c05FA7411e334deA5a763354fC7B6aA5b",
|
||||
"Verifier23": "0x63917b00a6dA7865bEfdd107AfC83CC2e6BDE552",
|
||||
"Verifier24": "0xd05CAd7d940114c1419098EE3cEA0776ab510E7D",
|
||||
"Verifier25": "0x6D9862e6140D94E932d94c8BcE74a0BDD0ea5ACb",
|
||||
"Verifier26": "0x8c29e0b77e32f704F03eeCE01c041192A5EB6c77",
|
||||
"Verifier27": "0x066cC22f8CA2A8D90D7Ff77D8a10A27e629c9c4C",
|
||||
"Verifier28": "0x698F9507f504E2BD238be7da56E8D9fee60C6D15",
|
||||
"Verifier29": "0xbBfC2E201C3c3c6F50063c3Edb4746c6Fcb36346",
|
||||
"Verifier30": "0x06bcD633988c1CE7Bd134DbE2C12119b6f3E4bD1",
|
||||
"Verifier31": "0x133b69Ce47BF20C49368354914DF47519Ca6cCFE",
|
||||
"Verifier32": "0xe2978F79cb4AF62e5C990EE5c7E12fb22ee22e2D"
|
||||
},
|
||||
"Semaphore": "0x5259d32659F1806ccAfcE593ED5a89eBAb85262f",
|
||||
"Semaphore": "0x89490c95eD199D980Cdb4FF8Bac9977EDb41A7E7",
|
||||
"PoseidonT3": "0xe0A452533853310C371b50Bd91BB9DCC8961350F",
|
||||
"IncrementalBinaryTree": "0x61AE89E372492e53D941DECaaC9821649fa9B236"
|
||||
"IncrementalBinaryTree": "0x9Ed9f58CA9212Ddf0377C8C4Cd089748F9337820",
|
||||
"Pairing": "0xE9c41c912CF750D79Cf304a196d4Bc8Dfd626C86",
|
||||
"SemaphoreVerifier": "0x66e772B0B8Ee1c24E4b6aC99A3A82C77f431792E",
|
||||
"Poseidon": "0xe0A452533853310C371b50Bd91BB9DCC8961350F"
|
||||
}
|
||||
|
||||
@@ -1,33 +1,21 @@
|
||||
import { readFileSync, writeFileSync } from "fs"
|
||||
|
||||
type DeployedContracts = {
|
||||
Pairing?: string
|
||||
SemaphoreVerifier?: string
|
||||
Poseidon?: string
|
||||
IncrementalBinaryTree?: string
|
||||
Semaphore?: string
|
||||
Pairing: string
|
||||
SemaphoreVerifier: string
|
||||
Poseidon: string
|
||||
IncrementalBinaryTree: string
|
||||
Semaphore: string
|
||||
}
|
||||
|
||||
export function getDeployedContracts(network: string | undefined): DeployedContracts | null {
|
||||
try {
|
||||
return JSON.parse(readFileSync(`./deployed-contracts/${network}.json`, "utf8"))
|
||||
} catch (error) {
|
||||
return {}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function saveDeployedContracts(network: string | undefined, newDeployedContracts: DeployedContracts) {
|
||||
const deployedContracts = getDeployedContracts(network)
|
||||
|
||||
writeFileSync(
|
||||
`./deployed-contracts/${network}.json`,
|
||||
JSON.stringify(
|
||||
{
|
||||
...deployedContracts,
|
||||
...newDeployedContracts
|
||||
},
|
||||
null,
|
||||
4
|
||||
)
|
||||
)
|
||||
export function saveDeployedContracts(network: string | undefined, deployedContracts: DeployedContracts) {
|
||||
writeFileSync(`./deployed-contracts/${network}.json`, JSON.stringify(deployedContracts, null, 4))
|
||||
}
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
import { hardhatArguments, run } from "hardhat"
|
||||
import { getDeployedContracts } from "./utils"
|
||||
|
||||
async function verify(address: string, constructorArguments?: any[]): Promise<void> {
|
||||
try {
|
||||
await run("verify:verify", {
|
||||
address,
|
||||
constructorArguments
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const deployedContracts = getDeployedContracts(hardhatArguments.network)
|
||||
|
||||
await run("verify:verify", {
|
||||
address: deployedContracts.IncrementalBinaryTree
|
||||
})
|
||||
|
||||
await run("verify:verify", {
|
||||
address: deployedContracts.Semaphore
|
||||
})
|
||||
|
||||
await run("verify:verify", {
|
||||
address: deployedContracts.Pairing
|
||||
})
|
||||
|
||||
await run("verify:verify", {
|
||||
address: deployedContracts.SemaphoreVerifier
|
||||
})
|
||||
if (deployedContracts) {
|
||||
await verify(deployedContracts.IncrementalBinaryTree)
|
||||
await verify(deployedContracts.Pairing)
|
||||
await verify(deployedContracts.SemaphoreVerifier)
|
||||
await verify(deployedContracts.Semaphore, [deployedContracts.SemaphoreVerifier])
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/group",
|
||||
"version": "2.6.1",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "A library to create and manage Semaphore groups.",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.node.js",
|
||||
|
||||
@@ -88,21 +88,13 @@ import { task, types } from "hardhat/config"
|
||||
task("deploy", "Deploy a Greeter contract")
|
||||
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs }, { ethers, run }) => {
|
||||
const { address: verifierAddress } = await run("deploy:verifier", { logs, merkleTreeDepth: 20 })
|
||||
|
||||
const { address: semaphoreAddress } = await run("deploy:semaphore", {
|
||||
logs,
|
||||
verifiers: [
|
||||
{
|
||||
merkleTreeDepth: 20,
|
||||
contractAddress: verifierAddress
|
||||
}
|
||||
]
|
||||
const { semaphore } = await run("deploy:semaphore", {
|
||||
logs
|
||||
})
|
||||
|
||||
const Greeter = await ethers.getContractFactory("Greeter")
|
||||
|
||||
const greeter = await Greeter.deploy(semaphoreAddress)
|
||||
const greeter = await Greeter.deploy(semaphore.address)
|
||||
|
||||
await greeter.deployed()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/hardhat",
|
||||
"version": "0.1.0",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.node.js",
|
||||
@@ -38,7 +38,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nomiclabs/hardhat-ethers": "^2.1.1",
|
||||
"@semaphore-protocol/contracts": "^2.5.0",
|
||||
"@semaphore-protocol/contracts": "3.0.0-beta.7",
|
||||
"circomlibjs": "^0.0.8",
|
||||
"ethers": "^5.7.1",
|
||||
"hardhat-dependency-compiler": "^1.1.3"
|
||||
|
||||
@@ -4,27 +4,11 @@ import { HardhatConfig, HardhatUserConfig } from "hardhat/types"
|
||||
import "hardhat-dependency-compiler"
|
||||
import "@nomiclabs/hardhat-ethers"
|
||||
import "./tasks/deploy-semaphore"
|
||||
import "./tasks/deploy-verifier"
|
||||
|
||||
extendConfig((config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
|
||||
config.dependencyCompiler.paths = [
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier16.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier17.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier18.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier19.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier20.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier21.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier22.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier23.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier24.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier25.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier26.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier27.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier28.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier29.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier30.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier31.sol",
|
||||
"@semaphore-protocol/contracts/verifiers/Verifier32.sol",
|
||||
"@semaphore-protocol/contracts/base/Pairing.sol",
|
||||
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
||||
"@semaphore-protocol/contracts/Semaphore.sol"
|
||||
]
|
||||
|
||||
|
||||
@@ -1,51 +1,114 @@
|
||||
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
|
||||
import { Contract } from "ethers"
|
||||
import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy:semaphore", "Deploy a Semaphore contract")
|
||||
.addParam("verifiers", "Tree depths and verifier addresses", [], types.json)
|
||||
.addOptionalParam<boolean>("pairing", "Pairing library address", undefined, types.string)
|
||||
.addOptionalParam<boolean>("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
||||
.addOptionalParam<boolean>("poseidon", "Poseidon library address", undefined, types.string)
|
||||
.addOptionalParam<boolean>(
|
||||
"incrementalBinaryTree",
|
||||
"IncrementalBinaryTree library address",
|
||||
undefined,
|
||||
types.string
|
||||
)
|
||||
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ logs, verifiers }, { ethers }): Promise<Contract> => {
|
||||
const poseidonABI = poseidonContract.generateABI(2)
|
||||
const poseidonBytecode = poseidonContract.createCode(2)
|
||||
.setAction(
|
||||
async (
|
||||
{
|
||||
logs,
|
||||
pairing: pairingAddress,
|
||||
semaphoreVerifier: semaphoreVerifierAddress,
|
||||
poseidon: poseidonAddress,
|
||||
incrementalBinaryTree: incrementalBinaryTreeAddress
|
||||
},
|
||||
{ ethers }
|
||||
): Promise<any> => {
|
||||
if (!semaphoreVerifierAddress) {
|
||||
if (!pairingAddress) {
|
||||
const PairingFactory = await ethers.getContractFactory("Pairing")
|
||||
const pairing = await PairingFactory.deploy()
|
||||
|
||||
const [signer] = await ethers.getSigners()
|
||||
await pairing.deployed()
|
||||
|
||||
const PoseidonLibFactory = new ethers.ContractFactory(poseidonABI, poseidonBytecode, signer)
|
||||
const poseidonLib = await PoseidonLibFactory.deploy()
|
||||
if (logs) {
|
||||
console.info(`Pairing library has been deployed to: ${pairing.address}`)
|
||||
}
|
||||
|
||||
await poseidonLib.deployed()
|
||||
pairingAddress = pairing.address
|
||||
}
|
||||
|
||||
if (logs) {
|
||||
console.info(`Poseidon library has been deployed to: ${poseidonLib.address}`)
|
||||
}
|
||||
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier", {
|
||||
libraries: {
|
||||
Pairing: pairingAddress
|
||||
}
|
||||
})
|
||||
|
||||
const IncrementalBinaryTreeLibFactory = await ethers.getContractFactory("IncrementalBinaryTree", {
|
||||
libraries: {
|
||||
PoseidonT3: poseidonLib.address
|
||||
const semaphoreVerifier = await SemaphoreVerifierFactory.deploy()
|
||||
|
||||
await semaphoreVerifier.deployed()
|
||||
|
||||
if (logs) {
|
||||
console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifier.address}`)
|
||||
}
|
||||
|
||||
semaphoreVerifierAddress = semaphoreVerifier.address
|
||||
}
|
||||
})
|
||||
const incrementalBinaryTreeLib = await IncrementalBinaryTreeLibFactory.deploy()
|
||||
|
||||
await incrementalBinaryTreeLib.deployed()
|
||||
if (!incrementalBinaryTreeAddress) {
|
||||
if (!poseidonAddress) {
|
||||
const poseidonABI = poseidonContract.generateABI(2)
|
||||
const poseidonBytecode = poseidonContract.createCode(2)
|
||||
|
||||
if (logs) {
|
||||
console.info(`IncrementalBinaryTree library has been deployed to: ${incrementalBinaryTreeLib.address}`)
|
||||
}
|
||||
const [signer] = await ethers.getSigners()
|
||||
|
||||
const SemaphoreContractFactory = await ethers.getContractFactory("Semaphore", {
|
||||
libraries: {
|
||||
IncrementalBinaryTree: incrementalBinaryTreeLib.address
|
||||
const PoseidonFactory = new ethers.ContractFactory(poseidonABI, poseidonBytecode, signer)
|
||||
const poseidon = await PoseidonFactory.deploy()
|
||||
|
||||
await poseidon.deployed()
|
||||
|
||||
if (logs) {
|
||||
console.info(`Poseidon library has been deployed to: ${poseidon.address}`)
|
||||
}
|
||||
|
||||
poseidonAddress = poseidon.address
|
||||
}
|
||||
|
||||
const IncrementalBinaryTreeFactory = await ethers.getContractFactory("IncrementalBinaryTree", {
|
||||
libraries: {
|
||||
PoseidonT3: poseidonAddress
|
||||
}
|
||||
})
|
||||
const incrementalBinaryTree = await IncrementalBinaryTreeFactory.deploy()
|
||||
|
||||
await incrementalBinaryTree.deployed()
|
||||
|
||||
if (logs) {
|
||||
console.info(`IncrementalBinaryTree library has been deployed to: ${incrementalBinaryTree.address}`)
|
||||
}
|
||||
|
||||
incrementalBinaryTreeAddress = incrementalBinaryTree.address
|
||||
}
|
||||
})
|
||||
|
||||
const semaphoreContract = await SemaphoreContractFactory.deploy(verifiers)
|
||||
const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
|
||||
libraries: {
|
||||
IncrementalBinaryTree: incrementalBinaryTreeAddress
|
||||
}
|
||||
})
|
||||
|
||||
await semaphoreContract.deployed()
|
||||
const semaphore = await SemaphoreFactory.deploy(semaphoreVerifierAddress)
|
||||
|
||||
if (logs) {
|
||||
console.info(`Semaphore contract has been deployed to: ${semaphoreContract.address}`)
|
||||
await semaphore.deployed()
|
||||
|
||||
if (logs) {
|
||||
console.info(`Semaphore contract has been deployed to: ${semaphore.address}`)
|
||||
}
|
||||
|
||||
return {
|
||||
semaphore,
|
||||
pairingAddress,
|
||||
semaphoreVerifierAddress,
|
||||
poseidonAddress,
|
||||
incrementalBinaryTreeAddress
|
||||
}
|
||||
}
|
||||
|
||||
return semaphoreContract
|
||||
})
|
||||
)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Contract } from "ethers"
|
||||
import { task, types } from "hardhat/config"
|
||||
|
||||
task("deploy:verifier", "Deploy a Verifier contract")
|
||||
.addParam<number>("merkleTreeDepth", "Merkle tree depth", undefined, types.int)
|
||||
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
||||
.setAction(async ({ merkleTreeDepth, logs }, { ethers }): Promise<Contract> => {
|
||||
const VerifierContractFactory = await ethers.getContractFactory(`Verifier${merkleTreeDepth}`)
|
||||
|
||||
const verifierContract = await VerifierContractFactory.deploy()
|
||||
|
||||
await verifierContract.deployed()
|
||||
|
||||
if (logs) {
|
||||
console.info(`Verifier${merkleTreeDepth} contract has been deployed to: ${verifierContract.address}`)
|
||||
}
|
||||
|
||||
return verifierContract
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/identity",
|
||||
"version": "2.6.1",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "A library to create Semaphore identities.",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.node.js",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/proof",
|
||||
"version": "2.6.1",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "A library to generate and verify Semaphore proofs.",
|
||||
"license": "MIT",
|
||||
"main": "dist/index.node.js",
|
||||
@@ -37,8 +37,8 @@
|
||||
"typedoc": "^0.22.11"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@semaphore-protocol/group": "2.6.1",
|
||||
"@semaphore-protocol/identity": "2.6.1"
|
||||
"@semaphore-protocol/group": "3.0.0-beta.7",
|
||||
"@semaphore-protocol/identity": "3.0.0-beta.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ethersproject/bignumber": "^5.5.0",
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
| This library allows you to query the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/contracts/Semaphore.sol) contract data (i.e. groups) using the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph) on Kovan, Goerli, and Arbitrum One. It can be used on Node.js and browsers. |
|
||||
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| This library allows you to query the [`Semaphore.sol`](https://github.com/semaphore-protocol/semaphore/blob/main/contracts/Semaphore.sol) contract data (i.e. groups) using the [Semaphore subgraph](https://github.com/semaphore-protocol/subgraph) on Goerli and Arbitrum One. It can be used on Node.js and browsers. |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
|
||||
## 🛠 Install
|
||||
|
||||
@@ -83,7 +83,7 @@ or [JSDelivr](https://www.jsdelivr.com/):
|
||||
|
||||
## 📜 Usage
|
||||
|
||||
\# **new Subgraph**(network: _Network_ = "arbitrum" ): _Subgraph_
|
||||
\# **new Subgraph**(network: _Network_ = "goerli" ): _Subgraph_
|
||||
|
||||
```typescript
|
||||
import { Subgraph } from "@semaphore-protocol/subgraph"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@semaphore-protocol/subgraph",
|
||||
"version": "2.6.1",
|
||||
"version": "3.0.0-beta.7",
|
||||
"description": "A library to query Semaphore contracts.",
|
||||
"license": "MIT",
|
||||
"iife": "dist/index.js",
|
||||
|
||||
@@ -8,9 +8,9 @@ import { Network } from "./types"
|
||||
export default function getURL(network: Network): string {
|
||||
switch (network) {
|
||||
case "goerli":
|
||||
return `https://api.thegraph.com/subgraphs/name/semaphore-protocol/goerli-5259d3`
|
||||
case "arbitrum":
|
||||
return `https://api.thegraph.com/subgraphs/name/semaphore-protocol/arbitrum-86337c`
|
||||
return `https://api.thegraph.com/subgraphs/name/semaphore-protocol/goerli-89490c`
|
||||
// case "arbitrum":
|
||||
// return `https://api.thegraph.com/subgraphs/name/semaphore-protocol/arbitrum-86337c`
|
||||
default:
|
||||
throw new TypeError(`Network '${network}' is not supported`)
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ describe("Subgraph", () => {
|
||||
describe("# Subgraph", () => {
|
||||
it("Should instantiate a subgraph object", () => {
|
||||
subgraph = new Subgraph("goerli")
|
||||
const subgraph1 = new Subgraph()
|
||||
// const subgraph1 = new Subgraph()
|
||||
|
||||
expect(subgraph.url).toContain("goerli")
|
||||
expect(subgraph1.url).toContain("arbitrum")
|
||||
// expect(subgraph1.url).toContain("arbitrum")
|
||||
})
|
||||
|
||||
it("Should throw an error if there is a wrong network", () => {
|
||||
|
||||
@@ -11,7 +11,7 @@ export default class Subgraph {
|
||||
* Initializes the subgraph object with one of the supported networks.
|
||||
* @param network Supported Semaphore network.
|
||||
*/
|
||||
constructor(network: Network = "arbitrum") {
|
||||
constructor(network: Network = "goerli") {
|
||||
checkParameter(network, "network", "string")
|
||||
|
||||
this._url = getURL(network)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type Network = "goerli" | "arbitrum"
|
||||
export type Network = "goerli" // | "arbitrum"
|
||||
|
||||
export type GroupOptions = {
|
||||
members?: boolean
|
||||
|
||||
69
yarn.lock
69
yarn.lock
@@ -2958,13 +2958,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@openzeppelin/contracts@npm:4.4.2":
|
||||
version: 4.4.2
|
||||
resolution: "@openzeppelin/contracts@npm:4.4.2"
|
||||
checksum: 5c6be7bfe757c6a43eb5b24aa9c61a79deaed9de4bc5f59356b35f5519b0fb340f4da8b4df99588bded5e6b6a773fc54961917a1c657063247c1763f9752bd0e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@openzeppelin/contracts@npm:4.7.3":
|
||||
version: 4.7.3
|
||||
resolution: "@openzeppelin/contracts@npm:4.7.3"
|
||||
@@ -3081,11 +3074,11 @@ __metadata:
|
||||
"@nomicfoundation/hardhat-toolbox": ^2.0.0
|
||||
"@nomiclabs/hardhat-ethers": ^2.0.0
|
||||
"@nomiclabs/hardhat-etherscan": ^3.0.0
|
||||
"@semaphore-protocol/contracts": 2.6.1
|
||||
"@semaphore-protocol/group": 2.6.1
|
||||
"@semaphore-protocol/hardhat": ^0.1.0
|
||||
"@semaphore-protocol/identity": 2.6.1
|
||||
"@semaphore-protocol/proof": 2.6.1
|
||||
"@semaphore-protocol/contracts": 3.0.0-beta.7
|
||||
"@semaphore-protocol/group": 3.0.0-beta.7
|
||||
"@semaphore-protocol/hardhat": 3.0.0-beta.7
|
||||
"@semaphore-protocol/identity": 3.0.0-beta.7
|
||||
"@semaphore-protocol/proof": 3.0.0-beta.7
|
||||
"@typechain/ethers-v5": ^10.1.0
|
||||
"@typechain/hardhat": ^6.1.2
|
||||
"@types/chai": ^4.2.0
|
||||
@@ -3109,7 +3102,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@semaphore-protocol/cli@workspace:packages/cli"
|
||||
dependencies:
|
||||
"@semaphore-protocol/subgraph": 2.6.1
|
||||
"@semaphore-protocol/subgraph": 3.0.0-beta.7
|
||||
"@types/clear": ^0.1.2
|
||||
"@types/figlet": ^1.5.5
|
||||
chalk: ^5.1.2
|
||||
@@ -3127,27 +3120,17 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@semaphore-protocol/contracts@npm:2.6.1":
|
||||
version: 2.6.1
|
||||
resolution: "@semaphore-protocol/contracts@npm:2.6.1"
|
||||
"@semaphore-protocol/contracts@npm:3.0.0-beta.7":
|
||||
version: 3.0.0-beta.7
|
||||
resolution: "@semaphore-protocol/contracts@npm:3.0.0-beta.7"
|
||||
dependencies:
|
||||
"@openzeppelin/contracts": 4.7.3
|
||||
"@zk-kit/incremental-merkle-tree.sol": 1.3.1
|
||||
checksum: c66ba23743ce76dd8006f026983bc4883fe167fd2a2f9fe389f652257e2e28fec0e8ec90709f874283da80275f9562510caa41cd43268c87e521adf7ce299e24
|
||||
"@zk-kit/incremental-merkle-tree.sol": 1.3.3
|
||||
checksum: 1acd73f23479b884ea563ea00cb13891f26c22094f48d127307aa2b6a1250b20d954713c62e731f97d20a709377a6ba4b2cb1e41a65036cf76712f61895e2237
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@semaphore-protocol/contracts@npm:^2.5.0":
|
||||
version: 2.5.0
|
||||
resolution: "@semaphore-protocol/contracts@npm:2.5.0"
|
||||
dependencies:
|
||||
"@openzeppelin/contracts": 4.4.2
|
||||
"@zk-kit/incremental-merkle-tree.sol": 1.3.0
|
||||
checksum: e42338749f886f74e207d544787e139e44ff5ccac70ca3a8f529d7ed6e9cbfe50c7dfb9cc0d35394d87fa012c91679fd98ab9b3611cac12fbfc72400b5efc424
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@semaphore-protocol/group@2.6.1, @semaphore-protocol/group@workspace:packages/group":
|
||||
"@semaphore-protocol/group@3.0.0-beta.7, @semaphore-protocol/group@workspace:packages/group":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@semaphore-protocol/group@workspace:packages/group"
|
||||
dependencies:
|
||||
@@ -3162,12 +3145,12 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@semaphore-protocol/hardhat@^0.1.0, @semaphore-protocol/hardhat@workspace:packages/hardhat":
|
||||
"@semaphore-protocol/hardhat@3.0.0-beta.7, @semaphore-protocol/hardhat@workspace:packages/hardhat":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@semaphore-protocol/hardhat@workspace:packages/hardhat"
|
||||
dependencies:
|
||||
"@nomiclabs/hardhat-ethers": ^2.1.1
|
||||
"@semaphore-protocol/contracts": ^2.5.0
|
||||
"@semaphore-protocol/contracts": 3.0.0-beta.7
|
||||
circomlibjs: ^0.0.8
|
||||
ethers: ^5.7.1
|
||||
hardhat: ^2.0.0
|
||||
@@ -3179,7 +3162,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@semaphore-protocol/identity@2.6.1, @semaphore-protocol/identity@workspace:packages/identity":
|
||||
"@semaphore-protocol/identity@3.0.0-beta.7, @semaphore-protocol/identity@workspace:packages/identity":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@semaphore-protocol/identity@workspace:packages/identity"
|
||||
dependencies:
|
||||
@@ -3194,7 +3177,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@semaphore-protocol/proof@2.6.1, @semaphore-protocol/proof@workspace:packages/proof":
|
||||
"@semaphore-protocol/proof@3.0.0-beta.7, @semaphore-protocol/proof@workspace:packages/proof":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@semaphore-protocol/proof@workspace:packages/proof"
|
||||
dependencies:
|
||||
@@ -3210,12 +3193,12 @@ __metadata:
|
||||
snarkjs: ^0.4.13
|
||||
typedoc: ^0.22.11
|
||||
peerDependencies:
|
||||
"@semaphore-protocol/group": 2.6.1
|
||||
"@semaphore-protocol/identity": 2.6.1
|
||||
"@semaphore-protocol/group": 3.0.0-beta.7
|
||||
"@semaphore-protocol/identity": 3.0.0-beta.7
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@semaphore-protocol/subgraph@2.6.1, @semaphore-protocol/subgraph@workspace:packages/subgraph":
|
||||
"@semaphore-protocol/subgraph@3.0.0-beta.7, @semaphore-protocol/subgraph@workspace:packages/subgraph":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@semaphore-protocol/subgraph@workspace:packages/subgraph"
|
||||
dependencies:
|
||||
@@ -4104,20 +4087,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@zk-kit/incremental-merkle-tree.sol@npm:1.3.0":
|
||||
version: 1.3.0
|
||||
resolution: "@zk-kit/incremental-merkle-tree.sol@npm:1.3.0"
|
||||
checksum: 1cd99d6867c87b01ff839ad93bed76ffcab079ca3d687b847b8d9a2f1f7e0d253c38d80587b4e1faa293f8a0c79ceb90ea45c3a0b699db5e7c476948f6a3d713
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@zk-kit/incremental-merkle-tree.sol@npm:1.3.1":
|
||||
version: 1.3.1
|
||||
resolution: "@zk-kit/incremental-merkle-tree.sol@npm:1.3.1"
|
||||
checksum: 8a9edd1490e5d2d5214573d633a15ce9db9b9574a2f961f7334973aa011308416fb8c67a3b9a9fee7135b33b05fef17dd2d9fc5560f6589d15edfb4b8ff6c46c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@zk-kit/incremental-merkle-tree.sol@npm:1.3.3":
|
||||
version: 1.3.3
|
||||
resolution: "@zk-kit/incremental-merkle-tree.sol@npm:1.3.3"
|
||||
|
||||
Reference in New Issue
Block a user