semaphore-protocol / semaphore

A zero-knowledge protocol for anonymous interactions.
https://semaphore.pse.dev
MIT License
883 stars 193 forks source link

Create CLI Foundry template #185

Open cedoor opened 1 year ago

cedoor commented 1 year ago

Description

There is a CLI Hardhat template called cli-template-contracts-hardhat with a sample contract and tests for that contract.

The idea is to recreate that same template using Foundry instead of Hardhat. The template will be called cli-template-contracts-foundry.

Previous work

https://github.com/vplasencia/semaphore-foundry

https://github.com/vplasencia/semaphore-foundry-hardhat

https://github.com/vplasencia/semaphore-hardhat-foundry

vplasencia commented 1 year ago

The challenge here is to deploy the Semaphore contract properly using Foundry in the test environment. The equivalent in Hardhat is: https://github.com/semaphore-protocol/semaphore/blob/main/packages/hardhat/src/tasks/deploy-semaphore.ts

More context: Getting the poseidon code and linking libraries:

The poseidon function in the PoseidonT3 library is empty by default, to get its code the circomlibjs javascript library is used. Then, it is necessary to link the PoseidonT3 library with the new code, to the IncrementalBinaryTree library.

We didn't change the implementation of the poseidon function because that code is already audited.

cedoor commented 7 months ago

Re-opening this issue as Semaphore V4 will use an actual contract for Poseidon and there shouldn't be any problems with Foundry.