Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force trusted setup if circuits have been modified #1029

Merged

Conversation

eugypalu
Copy link
Contributor

@eugypalu eugypalu commented Sep 29, 2022

What does this implement/fix? Explain your changes.

The goal of this pr is to check if there have been any changes to the circuits and if so, go to force a trusted setup.
To do this is kept within the /output/circuithash.txt (in the worker), the list of all circuits with their hash.
So it checks if the hash of the current circuit differs, or is not in the file, and in case a trusted setup is forced

Does this close any currently open issues?

Resolves #989

@@ -31,7 +31,6 @@ module.exports = {
TXHASH_TREE_HASH_TYPE: 'keccak256',
STATE_GENESIS_BLOCK: process.env.STATE_GENESIS_BLOCK,
CIRCUITS_HOME: process.env.CIRCUITS_HOME || '/app/circuits/',
ALWAYS_DO_TRUSTED_SETUP: process.env.ALWAYS_DO_TRUSTED_SETUP || false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still want to preserve the ability to force a trusted setup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, reverted this change

const fileBuffer = fs.readFileSync(`./circuits/${circuit}`);
const hcircuit = crypto.createHash('md5').update(fileBuffer).digest('hex');

const checkHash = await axios.post(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a way for force a trusted setup. Also, what happens if ther eis not vk[i] defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I restored the ability to force trusted setup.
from the tests I did in the case vk[i] is undefined there was always also a difference on the hash, but for safety I added the vk[i] check, if undefined trusted setup is forced

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you already have tests, can you also include those? or were they manual?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, sorry but they were all manual tests

Copy link
Contributor

@druiz0992 druiz0992 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some additional questions:

  • What happens if there are new circuits where hash doesnt match?

@eugypalu
Copy link
Contributor Author

in case new circuits were added:

-if the hash is present in the file but does not match the one just calculated, the hash contained in the file is updated and the trusted setup is generated.

-if, on the other hand, the hash is not present in the file, it is added to the file and the trusted setup is generated

Copy link
Contributor

@RogerTaule RogerTaule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the getCircuitHash enpdoint :)

@RogerTaule RogerTaule merged commit b8ae9a5 into master Sep 30, 2022
@IlyasRidhuan IlyasRidhuan deleted the eugenio/Force-trusted-setup-is-circuits-have-been-modified branch September 30, 2022 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Force trusted setup is circuits have been modified
3 participants