diff --git a/docs/faqs/content/issuer-node-reusing-issuer-did.md b/docs/faqs/content/issuer-node-reusing-issuer-did.md index 66520769..02233582 100644 --- a/docs/faqs/content/issuer-node-reusing-issuer-did.md +++ b/docs/faqs/content/issuer-node-reusing-issuer-did.md @@ -22,4 +22,5 @@ If you **have not deleted the database** and wish to reuse a previously configur Wrong answer: If you want to reuse a previously used DID, it's sufficient to manually edit the database entries to reflect the old DID, bypassing the need to update environment files or restart any services. This direct database manipulation ensures immediate reuse of the DID without considering system synchronization or security implications. + diff --git a/docs/issuer-node/install-kubernetes.md b/docs/issuer-node/install-kubernetes.md index d5144da2..7ecf6740 100644 --- a/docs/issuer-node/install-kubernetes.md +++ b/docs/issuer-node/install-kubernetes.md @@ -65,7 +65,7 @@ export ISSUERNAME="My Issuer" export ISSUER_ETHERUM_URL="https://polygon-mumbai.XXXX" export INGRESS_ENABLED=true export VAULT_PWD=password -export RHS_MODE=None +export RHS_MODE=None export RHS_URL="https://reverse-hash-service.com" ``` @@ -142,7 +142,7 @@ export ISSUERNAME="My Issuer" export ISSUER_ETHERUM_URL="https://polygon-mumbai.XXXX" export INGRESS_ENABLED=false export VAULT_PWD=password -export RHS_MODE=None +export RHS_MODE=None export RHS_URL="https://reverse-hash-service.com" ``` diff --git a/docs/issuer/refresh-service/customization.md b/docs/issuer/refresh-service/customization.md index 25e33684..4169fada 100644 --- a/docs/issuer/refresh-service/customization.md +++ b/docs/issuer/refresh-service/customization.md @@ -20,6 +20,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl'; Extend customization by incorporating custom providers and integrating them into the refresh flow. This is the easiest way to add custom business logic to retrieve data from a data provider. Go to [setup guide](/docs/issuer/refresh-service/setup-guide/#setup-with-custom-data-provider) for more information + ## 2. Flexible HTTP package Utilize the [flexible HTTP package](https://github.com/0xPolygonID/refresh-service/blob/main/providers/flexiblehttp/http.go) to configure HTTP requests to a data provider. Refer to the [configuration guide](https://github.com/0xPolygonID/refresh-service/blob/main/README.md) for instructions on how to set this up. diff --git a/docs/issuer/refresh-service/setup-guide.md b/docs/issuer/refresh-service/setup-guide.md index 526a5328..bf8d28bb 100644 --- a/docs/issuer/refresh-service/setup-guide.md +++ b/docs/issuer/refresh-service/setup-guide.md @@ -17,146 +17,165 @@ keywords: import useBaseUrl from '@docusaurus/useBaseUrl'; > **NOTE: Current implementation of [refresh service](https://github.com/0xPolygonID/refresh-service) works only with [issuer-node](https://github.com/0xPolygonID/issuer-node/).** -> ## Preparation + 1. Run the issuer-node locally by following the [quick-start installation guide](https://github.com/0xPolygonID/issuer-node/#quick-start-installation). 1. Clone the refresh service using the command `git clone git@github.com:0xPolygonID/refresh-service.git`. 1. Build JSON and JSONLD schemas, utilizing the provided examples: - - [JSON](https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/non-zero-balance.json) - - [JSONLD](https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/non-zero-balance.jsonld) +- [JSON](https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json/non-zero-balance.json) +- [JSONLD](https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/non-zero-balance.jsonld) - Generate custom schemas through the [schema builder](https://schema-builder.polygonid.me/builder). Additional details can be found in the [schema builder documentation](/docs/issuer/schema-builder/). +Generate custom schemas through the [schema builder](https://schema-builder.polygonid.me/builder). Additional details can be found in the [schema builder documentation](/docs/issuer/schema-builder/). ## Setup with custom data provider + Consider an example of integrating [polygon scan](https://polygonscan.com/) as a data provider for the refresh service. 1. Integrate the custom data provider into the [data provider module](https://github.com/0xPolygonID/refresh-service/tree/main/providers): - ```go - const polygonBalanceURL = "https://api.polygonscan.com/api?module=account&action=balance&address=%s&apikey=%s" - type BalanceResponse struct { - Status string `json:"status"` - Result string `json:"result"` - Message string `json:"message"` +```go +const polygonBalanceURL = "https://api.polygonscan.com/api?module=account&action=balance&address=%s&apikey=%s" + +type BalanceResponse struct { + Status string `json:"status"` + Result string `json:"result"` + Message string `json:"message"` +} + +func GetBalanceByAddress(address string) (map[string]any, error) { + resp, err := http.Get( + fmt.Sprintf(polygonBalanceURL, address, ""), + ) + if err != nil { + return nil, + fmt.Errorf("failed to get balance: %w", err) } - func GetBalanceByAddress(address string) (map[string]any, error) { - resp, err := http.Get( - fmt.Sprintf(polygonBalanceURL, address, ""), - ) - if err != nil { - return nil, - fmt.Errorf("failed to get balance: %w", err) - } - - balanceResp := &BalanceResponse{} - if err = json.NewDecoder(resp.Body).Decode(balanceResp); err != nil { - return nil, - fmt.Errorf("failed to decode balance response: %w", err) - } - defer resp.Body.Close() - - if balanceResp.Status != "1" { - return nil, - fmt.Errorf("invalid status in balance response: %s", balanceResp.Message) - } - - // convert to credential subject format - // ensure that these fields align with the attributes specified in the JSONLD schema. - return map[string]any{ - "balance": balanceResp.Result, - "address": address, - }, nil + balanceResp := &BalanceResponse{} + if err = json.NewDecoder(resp.Body).Decode(balanceResp); err != nil { + return nil, + fmt.Errorf("failed to decode balance response: %w", err) } - ``` + defer resp.Body.Close() + + if balanceResp.Status != "1" { + return nil, + fmt.Errorf("invalid status in balance response: %s", balanceResp.Message) + } + + // convert to credential subject format + // ensure that these fields align with the attributes specified in the JSONLD schema. + return map[string]any{ + "balance": balanceResp.Result, + "address": address, + }, nil +} +``` + 1. Use the custom data provider within the refresh service: - 1. Remove the default data provider: - ```go - flexibleHTTP, err := rs.providers.ProduceFlexibleHTTP(credentialType) - if err != nil { - return nil, - errors.Wrapf(ErrCredentialNotUpdatable, - "for credential '%s' not possible to find a data provider: %v", credential.ID, err) - - } - updatedFields, err := flexibleHTTP.Provide(credential.CredentialSubject) - if err != nil { - return nil, err - } - ``` - 1. Use the new polygon scan data provider: - ```go - // confirm the credentialType matches a supported type in the refresh service, - // and its urn:uuid aligns with the id in the JSONLD schema - if credentialType != "urn:uuid:f50cfcf6-ded4-470e-83be-2d6820a66998" { - return nil, errors.New("unknow credentialType") - } - - updatedFields, err := polygonscan.GetBalanceByAddress(credential.CredentialSubject["address"].(string)) - if err != nil { - return nil, err - } - ``` + + 1. Remove the default data provider: + + ```go + flexibleHTTP, err := rs.providers.ProduceFlexibleHTTP(credentialType) + if err != nil { + return nil, + errors.Wrapf(ErrCredentialNotUpdatable, + "for credential '%s' not possible to find a data provider: %v", credential.ID, err) + + } + updatedFields, err := flexibleHTTP.Provide(credential.CredentialSubject) + if err != nil { + return nil, err + } + ``` + + 1. Use the new polygon scan data provider: + + ```go + // confirm the credentialType matches a supported type in the refresh service, + // and its urn:uuid aligns with the id in the JSONLD schema + if credentialType != "urn:uuid:f50cfcf6-ded4-470e-83be-2d6820a66998" { + return nil, errors.New("unknow credentialType") + } + + updatedFields, err := polygonscan.GetBalanceByAddress(credential.CredentialSubject["address"].(string)) + if err != nil { + return nil, err + } + ``` + 1. Populate the .env variables: - ``` - export IPFS_URL="https://infure..." - export SUPPORTED_RPC="137=https://infura..." - export SUPPORTED_STATE_CONTRACTS="137=0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" - export SUPPORTED_ISSUERS="*=https://my-issuer-node.com" - export ISSUERS_BASIC_AUTH="*=myuser:mypassword" - ``` + ``` + export IPFS_URL="https://infure..." + export SUPPORTED_RPC="137=https://infura..." + export SUPPORTED_STATE_CONTRACTS="137=0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + export SUPPORTED_ISSUERS="*=https://my-issuer-node.com" + export ISSUERS_BASIC_AUTH="*=myuser:mypassword" + ``` 1. Generate a blank config.yaml file: - ```bash - touch config.yaml - ``` + +```bash +touch config.yaml +``` + 1. Run the refresh service: - ```bash - source .env - go run . - ``` + +```bash +source .env +go run . +``` ## Setup with default provider + To integrate [polygon scan](https://polygonscan.com/) data provider with the default data provider, follow these general steps: + 1. Create a `config.yaml` file with the following content: - ```yaml - urn:uuid:f50cfcf6-ded4-470e-83be-2d6820a66998: - settings: - timeExpiration: 5m - provider: - url: https://api.polygonscan.com/api - method: GET - requestSchema: - params: - module: account - action: balance - address: "{{ credentialSubject.address }}" # this value will be substituted from the credentialSubject.address field - apikey: - headers: - Content-Type: application/json - responseSchema: - type: json - properties: - result: - type: string - match: credentialSubject.balance - ``` + +```yaml +urn:uuid:f50cfcf6-ded4-470e-83be-2d6820a66998: + settings: + timeExpiration: 5m + provider: + url: https://api.polygonscan.com/api + method: GET + requestSchema: + params: + module: account + action: balance + address: "{{ credentialSubject.address }}" # this value will be substituted from the credentialSubject.address field + apikey: + headers: + Content-Type: application/json + responseSchema: + type: json + properties: + result: + type: string + match: credentialSubject.balance +``` + 2. Populate the .env variables: - ``` - export IPFS_URL="https://infura..." - export SUPPORTED_RPC="137=https://infura..." - export SUPPORTED_STATE_CONTRACTS="137=0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" - export SUPPORTED_ISSUERS="*=https://my-issuer-node.com" - export ISSUERS_BASIC_AUTH="*=myuser:mypassword" - ``` + +``` +export IPFS_URL="https://infura..." +export SUPPORTED_RPC="137=https://infura..." +export SUPPORTED_STATE_CONTRACTS="137=0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" +export SUPPORTED_ISSUERS="*=https://my-issuer-node.com" +export ISSUERS_BASIC_AUTH="*=myuser:mypassword" +``` + 3. Run the service: - ```bash - source .env - go run . - ``` + +```bash +source .env +go run . +``` ## Testing + 1. Go to the issuer-node UI and generate a credential with refresh service section:
@@ -200,4 +219,4 @@ To integrate [polygon scan](https://polygonscan.com/) data provider with the def
-
\ No newline at end of file + diff --git a/docs/verifier/on-chain-verification/overview.md b/docs/verifier/on-chain-verification/overview.md index ef1840ff..8dd1eaad 100644 --- a/docs/verifier/on-chain-verification/overview.md +++ b/docs/verifier/on-chain-verification/overview.md @@ -580,5 +580,5 @@ Now that you have been able to create your first on-chain ZK-based application, Another possibility to customize your Smart Contract involves setting different ZK requests. First of all, multiple `REQUEST_ID` must be defined inside the main Smart Contract. Therefore, the contract deployer can set a different query for each request ID and create different outcomes inside `_afterProofSubmit` according to the type of proof received. For example, an airdrop contract can verify the role of a user inside a DAO and distribute a different amount of tokens based on the role. ## Estimated Gas Costs for On-Chain Verifier -While it is clear that gas cost is highly dependent on the complexity of the logic that you add to the `_afterProofSubmit` and `_beforeProofSubmit` functions, the sample code for the on-chain verifier in this tutorial costs approximately 700k gas to execute on-chain. The zk proof verification function specifically costs approximately 520k gas. The above estimates are accurate as of January 2024. +While it is clear that gas cost is highly dependent on the complexity of the logic that you add to the `_afterProofSubmit` and `_beforeProofSubmit` functions, the sample code for the on-chain verifier in this tutorial costs approximately 700k gas to execute on-chain. The zk proof verification function specifically costs approximately 520k gas. The above estimates are accurate as of January 2024. diff --git a/docs/verifier/verification-library/zk-query-language.md b/docs/verifier/verification-library/zk-query-language.md index 66fb33eb..f6b6cb65 100644 --- a/docs/verifier/verification-library/zk-query-language.md +++ b/docs/verifier/verification-library/zk-query-language.md @@ -522,7 +522,7 @@ const proofRequest: protocol.ZKPRequest = { ## Multi query -In the example below, the verifier requests two different proof queries in the single authorization request. Queries can be created for different credentials. +In the example below, the verifier requests two different proof queries in the single authorization request. Queries can be created for different credentials. ```json { diff --git a/docs/verifier/verifier-backend.md b/docs/verifier/verifier-backend.md index 6c484cfc..e3bb10d0 100644 --- a/docs/verifier/verifier-backend.md +++ b/docs/verifier/verifier-backend.md @@ -3,7 +3,7 @@ id: verifier-backend title: Verifier Backend API sidebar_label: Verifier Backend API description: Verifier Backend API. -keywords: +keywords: - docs - polygon id - ID holder @@ -16,12 +16,14 @@ The [Verifier Backend](https://github.com/0xPolygonID/verifier-backend) project It is built using libraries developed by the iden3 protocol team. Below, we'll explain how to install it using Docker and how it can be used to perform zero knowledge proofs. -You can try our [Verifier Backend API](https://verifier-backend.polygonid.me/) running. +You can try our [Verifier Backend API](https://verifier-backend.polygonid.me/) running. ## Local Installation + To run the verifier backend with Docker, after cloning the code from the repository, simply follow these steps: 1. Create a file named `resolvers_settings.yaml`, using the `resolvers_settings_samples.yaml` file as a base. In this file, configure only your RPC for the Polygon Mumbai and Main networks, i.e., the two variables named `networkURL`. + ```yaml polygon: mumbai: @@ -33,6 +35,7 @@ polygon: ``` 2. Create a .env file (you can use the .env-sample file as a base). + ```shell VERIFIER_BACKEND_HOST=https://your-public-ip VERIFIER_BACKEND_PORT=3010 @@ -42,7 +45,9 @@ VERIFIER_BACKEND_MUMBAI_SENDER_DID=did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4 VERIFIER_BACKEND_MAIN_SENDER_DID=did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv VERIFIER_BACKEND_RESOLVER_SETTINGS_PATH=./resolvers_settings.yaml ``` + From this file, it's important and necessary to modify the following variable: + ```shell VERIFIER_BACKEND_HOST: must be the public IP of the machine where the verifier backend is running. ``` @@ -51,34 +56,34 @@ VERIFIER_BACKEND_HOST: must be the public IP of the machine where the verifier b If everything went well, you will be able to see the API documentation at: `https://your-public-ip/` - ### Alternative 1 + The following image shows the simplest flow to generate a QR code to request a ZK Proof as a verifier:
- The endpoint `/sign-in` allows creating that QR code and configuring the backend to later validate the proof. A possible body for this endpoint could be the following: ```json { "chainID": "80001", "circuitID": "credentialAtomicQuerySigV2", - "skipClaimRevocationCheck": false, + "skipClaimRevocationCheck": false, "query": { "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", "allowedIssuers": ["*"], "type": "KYCAgeCredential", "credentialSubject": { - "birthday": { - "$eq": 19960424 - } + "birthday": { + "$eq": 19960424 + } } } } ``` + Keep in mind that: - the `chainID` field can be 80001 for Mumbai or 137 for the Mainnet. @@ -88,87 +93,81 @@ This endpoint will respond with a similar response to the following: ```json { - "qrCode": { - "body": { - "callbackUrl": "https://your-public-ip/callback?sessionID=975903", - "reason": "test flow", - "scope": [ - { - "circuitId": "credentialAtomicQuerySigV2", - "id": 1, - "query": { - "allowedIssuers": [ - "*" - ], - "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", - "credentialSubject": { - "birthday": { - "$eq": 19960424 - } - }, - "skipClaimRevocationCheck": false, - "type": "KYCAgeCredential" - } - } - ] - }, - "from": "did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT", - "id": "7f38a193-0918-4a48-9fac-36adfdb8b542", - "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542", - "typ": "application/iden3comm-plain-json", - "type": "https://iden3-communication.io/authorization/1.0/request" + "qrCode": { + "body": { + "callbackUrl": "https://your-public-ip/callback?sessionID=975903", + "reason": "test flow", + "scope": [ + { + "circuitId": "credentialAtomicQuerySigV2", + "id": 1, + "query": { + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + "credentialSubject": { + "birthday": { + "$eq": 19960424 + } + }, + "skipClaimRevocationCheck": false, + "type": "KYCAgeCredential" + } + } + ] }, - "sessionID": 975903 + "from": "did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT", + "id": "7f38a193-0918-4a48-9fac-36adfdb8b542", + "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542", + "typ": "application/iden3comm-plain-json", + "type": "https://iden3-communication.io/authorization/1.0/request" + }, + "sessionID": 975903 } ``` - The value of the `qrCode` field is the one that should be displayed as a QR code to be scanned by the Polygon ID wallet. The `sessionID` should be used to check the status of the proof. To query the status of the proof, i.e., whether it was valid or not, you should call the endpoint `/status?sessionID=975903`. ### Alternative 2 - QR Store -Flow 2 allows the generation of QR codes that are sometimes more comfortable to read for certain mobile phones. +Flow 2 allows the generation of QR codes that are sometimes more comfortable to read for certain mobile phones.
- In this case, after calling the '/sign-in' endpoint, you should call the '/qr-store' endpoint using as a body the response obtained from the '/sign-in' endpoint in the 'qrCode' field. For example, ```json { - "body": { - "callbackUrl": "https://your-public-ip/callback?sessionID=975903", - "reason": "test flow", - "scope": [ - { - "circuitId": "credentialAtomicQuerySigV2", - "id": 1, - "query": { - "allowedIssuers": [ - "*" - ], - "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", - "credentialSubject": { - "birthday": { - "$eq": 19791109 - } - }, - "type": "KYCAgeCredential" - } + "body": { + "callbackUrl": "https://your-public-ip/callback?sessionID=975903", + "reason": "test flow", + "scope": [ + { + "circuitId": "credentialAtomicQuerySigV2", + "id": 1, + "query": { + "allowedIssuers": ["*"], + "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", + "credentialSubject": { + "birthday": { + "$eq": 19791109 } - ] - }, - "from": "did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT", - "id": "7f38a193-0918-4a48-9fac-36adfdb8b542", - "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542", - "typ": "application/iden3comm-plain-json", - "type": "https://iden3-communication.io/authorization/1.0/request" + }, + "type": "KYCAgeCredential" + } + } + ] + }, + "from": "did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT", + "id": "7f38a193-0918-4a48-9fac-36adfdb8b542", + "thid": "7f38a193-0918-4a48-9fac-36adfdb8b542", + "typ": "application/iden3comm-plain-json", + "type": "https://iden3-communication.io/authorization/1.0/request" } ``` @@ -180,6 +179,6 @@ iden3comm://?request_uri=https://your-public-ip/qr-store?id=9d5beb41-3108-4341-a This response is the one you should then display as a QR code. - ### Some extra commands -To stop the verifier backend, you can execute `make stop`. The preceding command halts the Docker container. If you want to restart the verifier backend, for instance, if you updated the code, you can execute `make restart`. \ No newline at end of file + +To stop the verifier backend, you can execute `make stop`. The preceding command halts the Docker container. If you want to restart the verifier backend, for instance, if you updated the code, you can execute `make restart`. diff --git a/docs/wallet/wallet-sdk/polygonid-sdk/credential/get-credential-by-id.md b/docs/wallet/wallet-sdk/polygonid-sdk/credential/get-credential-by-id.md index c020aed3..994db1af 100644 --- a/docs/wallet/wallet-sdk/polygonid-sdk/credential/get-credential-by-id.md +++ b/docs/wallet/wallet-sdk/polygonid-sdk/credential/get-credential-by-id.md @@ -33,4 +33,4 @@ where: This method is essential for retrieving credentials based on their unique identifiers, allowing for specific operations on individual credentials within the SDK. -::: \ No newline at end of file +::: diff --git a/docs/wallet/wallet-sdk/polygonid-sdk/proof/init-circuits-download-and-get-info-stream.md b/docs/wallet/wallet-sdk/polygonid-sdk/proof/init-circuits-download-and-get-info-stream.md index 8c9c8cf6..b07a8f17 100644 --- a/docs/wallet/wallet-sdk/polygonid-sdk/proof/init-circuits-download-and-get-info-stream.md +++ b/docs/wallet/wallet-sdk/polygonid-sdk/proof/init-circuits-download-and-get-info-stream.md @@ -35,4 +35,4 @@ so far. This method is used to download the necessary circuits for proof generation. The download progress can be monitored by listening to the returned stream. -::: \ No newline at end of file +::: diff --git a/docs/wallet/wallet-sdk/polygonid-sdk/proof/is-already-downloaded-circuits-from-server.md b/docs/wallet/wallet-sdk/polygonid-sdk/proof/is-already-downloaded-circuits-from-server.md index f3c78a5c..e8255688 100644 --- a/docs/wallet/wallet-sdk/polygonid-sdk/proof/is-already-downloaded-circuits-from-server.md +++ b/docs/wallet/wallet-sdk/polygonid-sdk/proof/is-already-downloaded-circuits-from-server.md @@ -33,4 +33,4 @@ returns `true`, otherwise, it returns `false`. This method is used to avoid unnecessary downloads of the circuits for proof generation. It checks if the circuits file already exists in the local storage. -::: \ No newline at end of file +:::