Personhood
Each ID has its own unique identifier. This identifier doesn't reveal any information about the person nor their ID but is guaranteed to be unique and the same for the same ID. The identifier is scoped to your domain name and also to the scope you specified in the request (if you specified one). Learn more about the unique identifier here.
Following this logic, you can use this as a base to check the personhood of the user, i.e. if the user is a real person and not a bot. However, there are a few limitations to this:
- A person can have multiple IDs, so if you want to have
one person <-> one accountfor example, it won't be exactly that but moreone ID <-> one account. - If you want a truly robust proof of personhood, you should use FaceMatch in your query.
- The default identifier can be recomputed by anyone with complete knowledge of the ID chip data — including the government that issued the ID. For increased privacy, request a salted unique identifier instead, which cannot be linked back to the ID by the issuing entity.
Check uniqueness
To have a proof of unique ID, simply initiate a request with no information disclosure, then get the identifier back when you verify the proofs on your server.
- React
- Vanilla JS
import { VerifyWithZKPassport } from "@zkpassport/ui/react-button";
<VerifyWithZKPassport
purpose="Prove your personhood"
service={{ scope: "personhood" }}
query={{}}
onSuccess={async ({ proofs, result }) => {
// Send the proofs to your server to verify them and register the user
const response = await fetch("/api/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ proofs, result }),
});
return (await response.json()).registered;
}}
/>;
import { VerifyWithZKPassport } from "@zkpassport/ui/button";
VerifyWithZKPassport.render("#zkpassport", {
purpose: "Prove your personhood",
service: { scope: "personhood" },
query: {},
onSuccess: async ({ proofs, result }) => {
// Send the proofs to your server to verify them and register the user
const response = await fetch("/api/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ proofs, result }),
});
return (await response.json()).registered;
},
});
On your server, recreate the query and verify the proofs (see Quick Start), then use the unique identifier:
const { query } = zkPassport.createQuery().done();
const { verified, uniqueIdentifier } = await zkPassport.verify({
proofs,
originalQuery: query,
queryResult: result,
scope: "personhood",
});
if (!verified) return { registered: false };
// For example, check if the user is already registered under this identifier
if (await db.users.exists({ uniqueIdentifier })) {
console.log("User is already registered");
return { registered: false };
}
// If not registered yet, register the user with the new identifier
await db.users.insert({ uniqueIdentifier });
return { registered: true };