Skip to content

Commit

Permalink
Verify id checksum is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
OBrezhniev committed Mar 11, 2024
1 parent 4264f58 commit a5c5f47
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions circuits/auth/authV2.circom
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ template checkAuthV2(IdOwnershipLevels, onChainLevels) {

signal isStateGenesis <== IsEqual()([cutId, cutState]);

component genesisIdParts = SplitID();
genesisIdParts.id <== genesisID;

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

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

SMTVerifier(onChainLevels)(
Expand Down
9 changes: 9 additions & 0 deletions circuits/lib/stateTransition.circom
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ template StateTransition(IdOwnershipLevels) {
// get safe one values to be used in ForceEqualIfEnabled
signal {binary} one <== SafeOne()(userID);

component genesisIdParts = SplitID();
genesisIdParts.id <== userID;

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

signal cutId <== cutId()(userID);

signal cutState <== cutState()(oldUserState);
Expand Down
1 change: 0 additions & 1 deletion circuits/lib/utils/idUtils.circom
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma circom 2.1.1;
include "../../../node_modules/circomlib/circuits/bitify.circom";
include "../../../node_modules/circomlib/circuits/poseidon.circom";
include "../../../node_modules/circomlib/circuits/mux1.circom";
include "./safeOne.circom";

template ProfileID(){
signal input in;
Expand Down

0 comments on commit a5c5f47

Please sign in to comment.