Skip to content

Commit

Permalink
Check external nullifier on server side
Browse files Browse the repository at this point in the history
  • Loading branch information
robknight committed Jul 5, 2024
1 parent 8ec1fa7 commit 59d698c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/lib/zuauth/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const revealedFields: Record<
*/
export async function authenticate(
pcdStr: string,
{ watermark, config, fieldsToReveal }: ZuAuthArgs
{ watermark, config, fieldsToReveal, externalNullifier }: ZuAuthArgs
): Promise<ZKEdDSAEventTicketPCD> {
const serializedPCD = JSON.parse(pcdStr);
if (serializedPCD.type !== ZKEdDSAEventTicketPCDTypeName) {
Expand All @@ -73,6 +73,10 @@ export async function authenticate(
throw new ZuAuthAuthenticationError("PCD watermark does not match");
}

if (pcd.claim.externalNullifier?.toString() !== externalNullifier) {
throw new ZuAuthAuthenticationError("External nullfier does not match");
}

// For each of the fields configured to be revealed, check that the claim
// contains values.
for (const [revealedField, fieldName] of Object.entries(revealedFields)) {
Expand Down

0 comments on commit 59d698c

Please sign in to comment.