# Circuits

We split OpenPassport circuits into two steps according to a Semaphore-style design. This lets users do actions without revealing which signature algorithm was used to sign their passport.

The first step is registration. It allows users to prove their passport is valid without revealing any of their private data.

![Screenshot 2024-06-16 at 08.58.42](https://hackmd.io/_uploads/r1QpoF3BC.png)

We currently support two signature algorithms:

* [sha256WithRSAEncryption](https://github.com/zk-passport/proof-of-passport/blob/main/circuits/circuits/register_sha256WithRSAEncryption_65537.circom)
* sha1WithRSAEncryption

We are working on adding more, [see details here](https://github.com/zk-passport/proof-of-passport/issues/38).

After the proof is generated, it is sent to a smart contract and adds a commitment to a merkle tree. The tree is currently on Optimism, but can be migrated easily. The hash of the issuer's signature is used as a nullifier.

The second step is [interaction](https://github.com/zk-passport/proof-of-passport/blob/main/circuits/circuits/disclose.circom), also called broadcasting a message in Semaphore.

![Screenshot 2024-06-16 at 09.02.48](https://hackmd.io/_uploads/H1t2nthrA.png)

It involves proving inclusion of the commitment in the merkle tree, and optionally disclosing some private data. Any data in the MRZ can be disclosed thanks to a bitmap passed as private inputs. This includes:

* Issuing state
* Name
* Passport number
* Nationality
* Date of birth
* Gender
* Expiry date

Additionally, we crafted specific modules in the circuit to disclose:

* Passport is not expired
* Age is above a certain threshold

A `user_identifier` is committed in this proof. For onchain usage, it is used to avoid frontrunning. For offchain usage, it can be used by apps to identify users uniquely and make sure someone who obtains a proof later cannot impersonate someone.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.openpassport.app/docs/technical-docs/circuits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
