-
Notifications
You must be signed in to change notification settings - Fork 9
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
Validator balances circom circuit #161
Comments
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The public inputs to the circuit are:
validatorsAccumulator
: A Merkle tree accumulator of validator public keys and Eth1 deposit indexes. Eth1 deposit index is need to validate if the validator is already part of the beacon chain.stateRoot
: The current beacon state root against which the proof is made.balanceSum
: The sum of all active validator balances.The workflow of the circuit is as follows:
Epoch Calculation: The
currentEpoch
is calculated from the providedslot
. This calculation is then constrained. A Merkle proof verifies that theslot
aligns with the providedstateRoot
.Index and Root Validations: The circuit checks if the
currentEth1DepositIndex
aligns with thestateRoot
. It also validates whether the providedvalidatorsRoot
andbalancesRoot
are part of thestateRoot
.Validator Verification: The circuit validates all validators within
validatorsRoot
. It uses theRangeCheck
circuit to confirm that thecurrentEpoch
falls between the validator's activation and exit epochs. If a validator is inactive or their Eth1 deposit index precedes the validator's Eth1 deposit index, the bitmask for that validator is set to 0. Validators whose Eth1 deposit index is larger than the current Eth1 deposit index aren't constrained to have valid Merkle proof because they aren't yet part of the tree.Balance Index Check: The circuit checks that provided
balancesProofIndexes
correspond to thevalidatorIndex
divided by 4 plusbalancesProofIndexesRemainders
. This is because balances are stored in a 256-bit array, with each balance occupying a separate 64 bits of the 256-bit segment.Balance Validations: It validates that all the passed balances are valid with respect to the
balancesRoot
.Validator Accumulator Validation: The circuit verifies that the hash tree root of all passed validators and their Eth1 deposit indexes matches the passed
validatorAccumulator
.Balance Sum Calculation: The circuit sums all the balances according to the bitmask calculated for the validators.
Hashing and Output Generation: The public values are hashed. The circuit outputs the first 253 bits of the SHA-256 hash of the public inputs to make circuit verification more cost-effective.
The circuit is implemented in #153
The text was updated successfully, but these errors were encountered: