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

Recurssive light client commit inputs #227

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

stefan-nikolov96
Copy link
Contributor

@stefan-nikolov96 stefan-nikolov96 commented Sep 11, 2023

@Dimo99, please review changes of the logic when adding the final poseidon commitment

Copy link
Collaborator

@Dimo99 Dimo99 left a comment

Choose a reason for hiding this comment

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

Also, you should build the circuit modify get_light_client_recursive_input.ts if needed and generate the proofs using light_client_recursive_updates.ts.
Change the proofs in vendor/eth2-light-client-updates/mainnet/recursive-proofs to the newly generated proofs for the new recursive light client. And check that the verify_updates.ts script works.


for (var i = 0; i < 2; i++) {
commitment.in[cummulative_index + i] <== nextHeaderHashNum[i];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add an empty line after the bracket


for (var i = 0; i < 2; i++) {
commitment.in[cummulative_index + i] <== originator[i];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add an empty line after the bracket

commitment.in[cummulative_index + i*2*k + j*k + q] <== IC[i][j][q];
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add an empty line after the bracket

commitment.in[cummulative_index + i*2*k + j*k + q] <== gamma2[i][j][q];
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add an empty line after the bracket

commitment.in[cummulative_index + i*2*k + j*k + q] <== negalfa1xbeta2[i][j][q];
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

add an empty line after the bracket

signal input gamma2[2][2][k];
signal input delta2[2][2][k];
signal input IC[pubInpCount+1][2][k];
signal input historicSyncCommiteeHashTreeRoot;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be named historicParticipationRateHashTreeRoot

template VerifierPoseidon(pubInpCount, k) {
signal input originator[2];
signal input nextHeaderHashNum[2];

Copy link
Collaborator

Choose a reason for hiding this comment

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

the domain should also be part of the commitment

Copy link
Collaborator

Choose a reason for hiding this comment

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

You should extend the recursive verification code starting at line 214. Specifically the public inputs part starting line 246.
The public input should now be the prevVerifierCommitment, which you should not get as input to the circuit but calculate it using the originator, prevHeaderHashNum as nextHeaderHashNum as this is the commitment to the previous proof. And using the historicParticipationRateHashTreeRoot which should be calculated somehow using the historicParticipation (omitting the new one and somehow remembering the past one)

@stefan-nikolov96 stefan-nikolov96 force-pushed the recurssive_light_client_commit_inputs branch from c87753e to 87628cc Compare September 13, 2023 11:07
@stefan-nikolov96 stefan-nikolov96 force-pushed the recurssive_light_client_commit_inputs branch from 3cdfce6 to 6176fd8 Compare September 13, 2023 11:27
@stefan-nikolov96 stefan-nikolov96 force-pushed the recurssive_light_client_commit_inputs branch from 6176fd8 to 31cbf71 Compare September 13, 2023 11:29
@stefan-nikolov96
Copy link
Contributor Author

@Dimo99 Please review the circuits, before I update the tests

Copy link
Collaborator

@Dimo99 Dimo99 left a comment

Choose a reason for hiding this comment

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

Fix the syncCommitteeHistoricParticipationIndex usage maybe it should be used in the calculation of prevVerifierCommitment somehow


include "../../../node_modules/circomlib/circuits/comparators.circom";

template updateSyncCommitteeHistoricParticipation(N, Periods) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make the template start with upercase


include "../../../node_modules/circomlib/circuits/comparators.circom";

template updateSyncCommitteeHistoricParticipation(N, Periods) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also Periods is better to be renamed to PERIODS as it is constant.

@@ -25,6 +26,9 @@ template LightClientRecursive(N, K) {

// private inputs
signal input prevHeaderHashNum[2];
signal input syncCommitteeHistoricParticipation[1024];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is actually a public input

groth16Verifier.pubInput[2] <== prevHeaderHashNum[0];
groth16Verifier.pubInput[3] <== prevHeaderHashNum[1];
signal prevVerifierCommitment <== VerifierPoseidon(pubInpCount, k)(
originator, prevHeaderHashNum, negalfa1xbeta2, gamma2, delta2, IC, historicParticipationRateHashTreeRoot
Copy link
Collaborator

Choose a reason for hiding this comment

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

historicParticipationRateHashTreeRoot is not defined

@@ -25,6 +26,9 @@ template LightClientRecursive(N, K) {

// private inputs
signal input prevHeaderHashNum[2];
signal input syncCommitteeHistoricParticipation[1024];
signal input syncCommitteeHistoricParticipationIndex;
signal input prevVerifierCommitment;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is calculated bellow and shouldn't be input

@stefan-nikolov96
Copy link
Contributor Author

@Dimo99 prevVerifierCommitment is now computed using the prevHeaderHashNum, prevSyncCommitteeHistoricParticipationIndex and prevSyncCommitteeHistoricParticipation

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.

2 participants