Skip to content

Commit

Permalink
Check checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
OBrezhniev committed Mar 29, 2024
1 parent 8cea69d commit 4318bc7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions circuits/auth/authV2.circom
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,28 @@ template checkAuthV2(IdOwnershipLevels, onChainLevels) {
challengeSignatureS
);

/* Check on-chain SMT inclusion existence */
signal cutId <== cutId()(genesisID);
/* Check if state is genesis and if genesisId is valid */

signal cutState <== cutState()(state);

signal isStateGenesis <== IsEqual()([cutId, cutState]);
component genesisIdParts = SplitID();
genesisIdParts.id <== genesisID;

signal calculatedChecksum <== CalculateIdChecksum()(genesisIdParts.typ, genesisIdParts.genesis);
ForceEqualIfEnabled()(
enabled,
[genesisIdParts.checksum, calculatedChecksum]
);

signal isStateGenesis <== IsEqual()([genesisIdParts.genesis, cutState]);

/* Check on-chain SMT inclusion existence */

signal genesisIDHash <== Poseidon(1)([genesisID]);

SMTVerifier(onChainLevels)(
enabled <== enabled,
fnc <== isStateGenesis, // non-inclusion in case if genesis state, otherwise inclusion
fnc <== isStateGenesis, // non-inclusion in case of genesis state, otherwise inclusion
root <== gistRoot,
siblings <== gistMtp,
oldKey <== gistMtpAuxHi,
Expand Down

0 comments on commit 4318bc7

Please sign in to comment.