Skip to content

Commit

Permalink
Merge branch 'new-ux-refactor-circuits' of https://github.com/zk-pass…
Browse files Browse the repository at this point in the history
…port/openpassport into new-ux-refactor-circuits
  • Loading branch information
remicolin committed Aug 20, 2024
2 parents f26b5a0 + 899556f commit e9e3c71
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 12 deletions.
3 changes: 0 additions & 3 deletions circuits/circuits/register/register_ecdsa_sha1.circom
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
pragma circom 2.1.5;

include "circomlib/circuits/poseidon.circom";
include "@zk-email/circuits/utils/bytes.circom";
include "../verifier/passport_verifier_ecdsa_sha1.circom";
include "binary-merkle-root.circom";
include "../utils/splitSignalsToWords.circom";
include "../utils/computeCommitment.circom";

template REGISTER_ECDSA_SHA1(n, k, max_datahashes_bytes, nLevels, signatureAlgorithm) {
Expand Down
3 changes: 0 additions & 3 deletions circuits/circuits/register/register_ecdsa_sha256.circom
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
pragma circom 2.1.5;

include "circomlib/circuits/poseidon.circom";
include "@zk-email/circuits/utils/bytes.circom";
include "../verifier/passport_verifier_ecdsa_sha256.circom";
include "binary-merkle-root.circom";
include "../utils/splitSignalsToWords.circom";
include "../utils/computeCommitment.circom";

template REGISTER_ECDSA_SHA256(n, k, max_datahashes_bytes, nLevels, signatureAlgorithm) {
Expand Down
2 changes: 0 additions & 2 deletions circuits/circuits/register/register_rsa_65537_sha1.circom
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pragma circom 2.1.5;

include "circomlib/circuits/poseidon.circom";
include "@zk-email/circuits/utils/bytes.circom";
include "../verifier/passport_verifier_rsa_65537_sha1.circom";
include "binary-merkle-root.circom";
include "../utils/splitSignalsToWords.circom";
include "../utils/leafHasher.circom";
include "../utils/computeCommitment.circom";
Expand Down
2 changes: 0 additions & 2 deletions circuits/circuits/register/register_rsa_65537_sha256.circom
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pragma circom 2.1.5;

include "circomlib/circuits/poseidon.circom";
include "@zk-email/circuits/utils/bytes.circom";
include "../verifier/passport_verifier_rsa_65537_sha256.circom";
include "binary-merkle-root.circom";
include "../utils/splitSignalsToWords.circom";
include "../utils/leafHasher.circom";
include "../utils/computeCommitment.circom";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
pragma circom 2.1.5;

include "circomlib/circuits/poseidon.circom";
include "@zk-email/circuits/utils/bytes.circom";
include "../verifier/passport_verifier_rsapss_65537_sha256.circom";
include "binary-merkle-root.circom";
include "../utils/splitSignalsToWords.circom";
include "../utils/leafHasher.circom";
include "../utils/computeCommitment.circom";
Expand Down
90 changes: 90 additions & 0 deletions sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# SDK

## Installation

```bash
yarn add @openpassport/sdk
```

## Development

```bash
yarn install-sdk
```
## Tests

```bash
yarn test
```

## How to use

### Web2 applications

To use the `OpenPassportWeb2Verifier` in Web2 applications, import and initialize it as follows:


```typescript
import { OpenPassportWeb2Verifier } from '@openpassport/sdk';
const verifier = new OpenPassportWeb2Verifier({
scope: "yourScope",
requirements: [["older_than", "18"], ["nationality", "France"]]
});
```

#### parameters for `OpenPassportWeb2Verifier`

| Parameter | Optional | Description |
|---------------|----------|-------------|
| `scope` | No | The scope of your application, is unique for each application. |
| `attestationId` | Yes | The ID of the attestation, defaults to `PASSPORT_ATTESTATION_ID`. |
| `requirements` | Yes | An array of requirements, each an array with an attribute and its expected value. |
| `rpcUrl` | Yes | The RPC URL to connect to the blockchain, defaults to `DEFAULT_RPC_URL`. |

Finally, verify the proof:
The function fired from the OpenPassport app will send a `OpenPassportWeb2Inputs` object.

```typescript

const result = await verifier.verify(openPassportWeb2Inputs); // OpenPassportWeb2Inputs : OpenPassportWeb2Inputs
```

### Web3 application
For Web3 applications, use the `OpenPassportWeb3Verifier` as follows:

```typescript
import { OpenPassportWeb3Verifier } from '@openpassport/sdk';
const verifier = new OpenPassportWeb3Verifier({
scope: "yourScope",
rpcUrl: "https://custom.rpc.url"
});
```
#### Parameters for `OpenPassportWeb3Verifier`

| Parameter | Optional | Description |
|---------------|----------|-------------|
| `scope` | No | The scope of the verification. |
| `attestationId` | Yes | The ID of the attestation, defaults to `PASSPORT_ATTESTATION_ID`. |
| `requirements` | Yes | An array of requirements, each an array with an attribute and its expected value. |
| `rpcUrl` | Yes | The RPC URL to connect to the blockchain, defaults to `DEFAULT_RPC_URL`. |

#### Verify the user owns a sbt which satisfies the requirements:

```typescript
const result = await verifier.verify(address, tokenId);
```

### Handle the report

Each verification will returns a OpenPassportVerifierReport object which contains all the informations about the verification of each requirement.

If a requirement is not satisfied, the corresponding field will be set to `true`.
The `valid` field will be `false` if there is at least one requirement that is not satisfied.

`nullifier` and `user_identifier` are also accessible as report fields.

```typescript
const report = await verifier.verify(publicSignals, proof);
const nullifier = report.nullifier;
const userIdentifier = report.user_identifier;
```

0 comments on commit e9e3c71

Please sign in to comment.