-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'new-ux-refactor-circuits' of https://github.com/zk-pass…
…port/openpassport into new-ux-refactor-circuits
- Loading branch information
Showing
6 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 0 additions & 2 deletions
2
circuits/circuits/register/register_rsapss_65537_sha256.circom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
``` |