Skip to content

Commit

Permalink
fix issue with invalid proof (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmidyllic authored Jun 1, 2024
1 parent ae2a69a commit 7f14e57
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iden3/js-iden3-auth",
"version": "1.3.2",
"version": "1.3.3",
"description": "iden3-auth implementation in JavaScript",
"main": "dist/cjs/index.js",
"source": "./src/index.ts",
Expand Down
6 changes: 1 addition & 5 deletions src/circuits/atomicMtpV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ export class AtomicQueryMTPV2PubSignalsVerifier
throw new Error(`resolver not found for issuerID ${this.pubSignals.issuerID.string()}`);
}

await checkUserState(
resolver,
this.pubSignals.issuerID,
this.pubSignals.issuerClaimIdenState
);
await checkUserState(resolver, this.pubSignals.issuerID, this.pubSignals.issuerClaimIdenState);

if (this.pubSignals.isRevocationChecked === 0) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/circuits/atomicV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class AtomicQueryV3PubSignalsVerifier
}
break;
default:
throw new Error('invalid proof type');
// if proof type is not specified in query any proof type in signals is OK.
}

const nSessionId = BigInt((params?.nullifierSessionId as string) ?? 0);
Expand Down
7 changes: 2 additions & 5 deletions src/circuits/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function checkUserState(
userId: Id,
userState: Hash
): Promise<ResolvedState> {
return await resolver.resolve(userId.bigInt(), userState.bigInt());
return await resolver.resolve(userId.bigInt(), userState.bigInt());
}

export async function checkGlobalState(
Expand All @@ -24,10 +24,7 @@ export async function checkIssuerNonRevState(
issuerId: Id,
issuerClaimNonRevState: Hash
): Promise<ResolvedState> {
return await resolver.resolve(
issuerId.bigInt(),
issuerClaimNonRevState.bigInt()
);
return await resolver.resolve(issuerId.bigInt(), issuerClaimNonRevState.bigInt());
}

export function getResolverByID(resolvers: Resolvers, id: Id): IStateResolver {
Expand Down
6 changes: 3 additions & 3 deletions test/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ describe('Common', () => {
BigInt('13483594486393726782589954979757194488582220051583949915340451442108840786819')
);
it('checkUserState fails', async () => {
await expect(
checkUserState(mockResolverWithNoStateInContract, issuerID, hash)
).rejects.toThrow('State is not genesis and not registered in the smart contract');
await expect(checkUserState(mockResolverWithNoStateInContract, issuerID, hash)).rejects.toThrow(
'State is not genesis and not registered in the smart contract'
);
});
it('checkUserState', async () => {
await checkUserState(mockResolverWithNotLatesState, issuerID, hash);
Expand Down

0 comments on commit 7f14e57

Please sign in to comment.