ccip_template
yann300 1 year ago
parent 41a4ebba14
commit bbe69aaf29
  1. 10
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/3_store_groups.ts
  2. 2
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/helpers/deploy.ts
  3. 5
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/manual operations/4.5_generate_proof_with_trusted_setup.ts
  4. 4
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/manual operations/6_get_verified_proofs.ts
  5. 2
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/manual operations/7_generate_cids.ts
  6. 18
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/tests/hackerClient.test.ts
  7. 12
      libs/remix-ws-templates/src/templates/chainlink-ccip-semaphore/scripts/tests/hackergroup.test.ts

@ -13,11 +13,11 @@ import { ISemaphoreDeploymentData, IGroup, IGroupMember } from './types/types'
//console.log(contract.filters) //console.log(contract.filters)
let eventFilter = contract.filters.GroupCreated() let eventFilter = contract.filters.GroupCreated()
let groupsCreated = await contract.queryFilter(eventFilter) const groupsCreated = await contract.queryFilter(eventFilter)
const groupIds: any = [] const groupIds: any = []
for (let groupCreated of groupsCreated) { for (const groupCreated of groupsCreated) {
console.log(groupCreated) console.log(groupCreated)
const group = await contract.groups(groupCreated.args[0]) const group = await contract.groups(groupCreated.args[0])
@ -28,11 +28,11 @@ import { ISemaphoreDeploymentData, IGroup, IGroupMember } from './types/types'
} }
eventFilter = contract.filters.MemberAdded() eventFilter = contract.filters.MemberAdded()
let membersAdded = await contract.queryFilter(eventFilter) const membersAdded = await contract.queryFilter(eventFilter)
const groups: IGroup[] = [] const groups: IGroup[] = []
for (let groupId of groupIds) { for (const groupId of groupIds) {
console.log('checking group members of group ' + groupId) console.log('checking group members of group ' + groupId)
const group: IGroup = { const group: IGroup = {
@ -40,7 +40,7 @@ import { ISemaphoreDeploymentData, IGroup, IGroupMember } from './types/types'
members: [], members: [],
} }
for (let member of membersAdded) { for (const member of membersAdded) {
if (member.args[0].toHexString() == BigNumber.from(groupId).toHexString()) { if (member.args[0].toHexString() == BigNumber.from(groupId).toHexString()) {
console.log('found member ') console.log('found member ')
console.log(member.args[2].toString()) console.log(member.args[2].toString())

@ -16,7 +16,7 @@ export const deploy = async (
const signer = new ethers.providers.Web3Provider(web3Provider).getSigner() const signer = new ethers.providers.Web3Provider(web3Provider).getSigner()
// internal Remix method that resolves the artifacts and links the libraries // internal Remix method that resolves the artifacts and links the libraries
let factory = await ethers.getContractFactory(contractName as any, null, { const factory = await ethers.getContractFactory(contractName as any, null, {
signer, signer,
libraries, libraries,
} as any) } as any)

@ -1,6 +1,7 @@
import { ethers, BigNumber } from 'ethers' import { ethers, BigNumber } from 'ethers'
import { IncrementalMerkleTree } from '@zk-kit/incremental-merkle-tree' import { IncrementalMerkleTree } from '@zk-kit/incremental-merkle-tree'
import { poseidon } from 'circomlibjs' // v0.0.8 import { poseidon } from 'circomlibjs' // v0.0.8
// eslint-disable-next-line @typescript-eslint/no-var-requires
const snarkjs = require('snarkjs') const snarkjs = require('snarkjs')
import { Identity } from '@semaphore-protocol/identity' import { Identity } from '@semaphore-protocol/identity'
import { generateProof, verifyProof } from '@semaphore-protocol/proof' import { generateProof, verifyProof } from '@semaphore-protocol/proof'
@ -69,11 +70,11 @@ function hash(message: any): bigint {
return return
} }
let proof1 = tree.createProof(0) const proof1 = tree.createProof(0)
console.log('check index in tree') console.log('check index in tree')
let index = tree.indexOf(identities[0].commitment) const index = tree.indexOf(identities[0].commitment)
console.log(index.toString()) console.log(index.toString())

@ -12,8 +12,8 @@ import { ISemaphoreDeploymentData, IGroup, IGroupMember } from './types'
//console.log(contract.filters) //console.log(contract.filters)
let eventFilter = contract.filters.ProofVerified() const eventFilter = contract.filters.ProofVerified()
let proofs_verified = await contract.queryFilter(eventFilter) const proofs_verified = await contract.queryFilter(eventFilter)
console.log(JSON.stringify(proofs_verified, null, '\t')) console.log(JSON.stringify(proofs_verified, null, '\t'))

@ -5,7 +5,7 @@ import { BigNumberToSignal } from './helpers/convertsignal'
const cids = [] const cids = []
for (let proof of verified_proofs) { for (const proof of verified_proofs) {
const cid = BigNumberToSignal(proof.args[3].hex) const cid = BigNumberToSignal(proof.args[3].hex)
const signal = proof.args[4].hex const signal = proof.args[4].hex
cids.push({ cids.push({

@ -15,7 +15,7 @@ let hackerclient
let semaphoreAddress let semaphoreAddress
let CCIPBNM let CCIPBNM
let proof: SemaphoreProof let proof: SemaphoreProof
let _paymentChainSelector = '16015286601757825753' const _paymentChainSelector = '16015286601757825753'
let _receiver let _receiver
let cid let cid
const router = ethers.Wallet.createRandom() // some random address uses instead of the CCIP router const router = ethers.Wallet.createRandom() // some random address uses instead of the CCIP router
@ -82,8 +82,8 @@ describe('Hackerclient', function () {
const signer = new ethers.providers.Web3Provider(web3Provider).getSigner() const signer = new ethers.providers.Web3Provider(web3Provider).getSigner()
const contract = await ethers.getContractAt('HackerGroup', hackergroup.address, signer) const contract = await ethers.getContractAt('HackerGroup', hackergroup.address, signer)
let eventFilter = contract.filters.bugCreated() const eventFilter = contract.filters.bugCreated()
let bugs = await contract.queryFilter(eventFilter) const bugs = await contract.queryFilter(eventFilter)
expect(bugs.length).to.equal(1) expect(bugs.length).to.equal(1)
console.log('bugs created') console.log('bugs created')
@ -116,7 +116,7 @@ describe('Hackerclient', function () {
const signer = new ethers.providers.Web3Provider(web3Provider).getSigner() const signer = new ethers.providers.Web3Provider(web3Provider).getSigner()
const contract = await ethers.getContractAt('HackerGroup', hackergroup.address, signer) const contract = await ethers.getContractAt('HackerGroup', hackergroup.address, signer)
let eventFilter = contract.filters.TokensTransferred(null) const eventFilter = contract.filters.TokensTransferred(null)
const tokens = await contract.queryFilter(eventFilter) const tokens = await contract.queryFilter(eventFilter)
expect(tokens.length).to.equal(1) expect(tokens.length).to.equal(1)
@ -136,8 +136,8 @@ describe('Hackerclient', function () {
//console.log(contract.filters) //console.log(contract.filters)
let eventFilter = contract.filters.ProofVerified() const eventFilter = contract.filters.ProofVerified()
let proofs_verified = await contract.queryFilter(eventFilter) const proofs_verified = await contract.queryFilter(eventFilter)
// write it to the filesystem // write it to the filesystem
await remix.call('fileManager', 'setFile', './build/proofs_verified.json', JSON.stringify(proofs_verified, null, '\t')) await remix.call('fileManager', 'setFile', './build/proofs_verified.json', JSON.stringify(proofs_verified, null, '\t'))
@ -147,7 +147,7 @@ describe('Hackerclient', function () {
const cids = [] const cids = []
const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json')) const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json'))
for (let proof of verified_proofs) { for (const proof of verified_proofs) {
const cid = BigNumberToSignal(proof.args[3].hex) const cid = BigNumberToSignal(proof.args[3].hex)
const signal = proof.args[4].hex const signal = proof.args[4].hex
cids.push({ cids.push({
@ -165,9 +165,9 @@ describe('Hackerclient', function () {
}) })
it('writes bugs to file', async () => { it('writes bugs to file', async () => {
let bugs = [] const bugs = []
const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json')) const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json'))
for (let proof of verified_proofs) { for (const proof of verified_proofs) {
const cid = BigNumberToSignal(proof.args[3].hex) const cid = BigNumberToSignal(proof.args[3].hex)
const externalNullifier = proof.args[3].hex const externalNullifier = proof.args[3].hex
console.log(externalNullifier) console.log(externalNullifier)

@ -15,7 +15,7 @@ import { BigNumberToSignal } from '../helpers/convertsignal'
let hackergroup let hackergroup
let semaphoreAddress let semaphoreAddress
let proof: SemaphoreProof let proof: SemaphoreProof
let _paymentChainSelector = '16015286601757825753' const _paymentChainSelector = '16015286601757825753'
let _receiver let _receiver
let cid let cid
let CCIPBNM let CCIPBNM
@ -166,8 +166,8 @@ describe('Hackergroup', function () {
//console.log(contract.filters) //console.log(contract.filters)
let eventFilter = contract.filters.ProofVerified() const eventFilter = contract.filters.ProofVerified()
let proofs_verified = await contract.queryFilter(eventFilter) const proofs_verified = await contract.queryFilter(eventFilter)
// write it to the filesystem // write it to the filesystem
await remix.call('fileManager', 'setFile', './build/proofs_verified.json', JSON.stringify(proofs_verified, null, '\t')) await remix.call('fileManager', 'setFile', './build/proofs_verified.json', JSON.stringify(proofs_verified, null, '\t'))
@ -177,7 +177,7 @@ describe('Hackergroup', function () {
const cids = [] const cids = []
const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json')) const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json'))
for (let proof of verified_proofs) { for (const proof of verified_proofs) {
const cid = BigNumberToSignal(proof.args[3].hex) const cid = BigNumberToSignal(proof.args[3].hex)
const signal = proof.args[4].hex const signal = proof.args[4].hex
cids.push({ cids.push({
@ -195,9 +195,9 @@ describe('Hackergroup', function () {
}) })
it('writes bugs to file', async () => { it('writes bugs to file', async () => {
let bugs = [] const bugs = []
const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json')) const verified_proofs = JSON.parse(await remix.call('fileManager', 'readFile', './build/proofs_verified.json'))
for (let proof of verified_proofs) { for (const proof of verified_proofs) {
const cid = BigNumberToSignal(proof.args[3].hex) const cid = BigNumberToSignal(proof.args[3].hex)
const externalNullifier = proof.args[3].hex const externalNullifier = proof.args[3].hex
console.log(externalNullifier) console.log(externalNullifier)

Loading…
Cancel
Save