Project 05
Identity
This is the project everything else has been building toward: selective disclosure applied to who you are, not just what you did. Prove a fact about yourself without revealing the rest.
What you'll learn
- Proving a threshold about a private credential, without revealing the credential itself
- Why "is this true" and "what is the value" are different questions on-chain
- How this same pattern generalizes to age checks, credit checks, and verified credentials
The contract
Save this as contracts/identity.compact:
pragma language_version >= 0.23;
import CompactStandardLibrary;
witness getBirthYear(): Uint<16>;
export ledger isVerifiedAdult: Boolean;
export circuit verifyAge(currentYear: Uint<16>, minimumAge: Uint<16>): [] {
const age = currentYear - getBirthYear();
isVerifiedAdult = disclose(age >= minimumAge);
}Notice the shape of this
This should look familiar. It's structurally the same pattern as Module 04's credit-score check: a private fact (birth year, or a repayment score) compared against a public threshold, with only the pass/fail verdict disclosed. Once you recognize this shape, you'll start seeing it everywhere privacy-preserving identity and credentials come up.
Where a real version goes further
A production identity system needs the birth year itself to be independently verified, typically by a trusted issuer signing a credential, rather than a user simply asserting it as a witness. That's the "verified credentials" layer, a genuinely deep topic worth researching once this basic pattern feels natural to you.
Build it yourself
compact compile contracts/identity.compact contracts/managed/identity
Deploy, call verifyAge() with a witness birth year that makes someone under 18, and again with one that makes someone over. Confirm isVerifiedAdult flips correctly, with the actual birth year never appearing in ledger state either time.
That's the full mini-project set. From here, the natural next step is combining these patterns into something bigger, like the credit-scoring lending concept explored in the Private Credit Score project.