### Run Docker Services for RHS Source: https://docs.privado.id/docs/issuer/reverse-hash-service Starts the necessary services for the Reverse Hash Service using Docker Compose. This command is used in the Docker Setup Guide. ```bash docker-compose up -d ``` -------------------------------- ### Build and Run RHS Service Source: https://docs.privado.id/docs/issuer/reverse-hash-service Compiles the Go source code for the Reverse Hash Service and then runs the executable. This is the final step for Standalone Mode setup. ```bash go build &&./reverse-hash-service ``` -------------------------------- ### Issuer Node API Setup Guide Source: https://docs.privado.id/docs/category/issuer-node-api Guides users on how to set up the Issuer API. This includes necessary steps and prerequisites for a successful installation and configuration. ```English Learn how to set up an Issuer API. ``` -------------------------------- ### Example App with Android SDK Source: https://docs.privado.id/docs/category/android-sdk Guides on building an example app with the Privado ID Android SDK. ```English Learn how to build an example app with the Android SDK. ``` -------------------------------- ### Run the Service (Bash/Go) Source: https://docs.privado.id/docs/issuer/refresh-service/setup-guide This snippet shows the commands to execute the service. It first sources the environment variables from a .env file and then runs the main Go program. ```bash source .env go run . ``` -------------------------------- ### Copy Schema to DB Container Source: https://docs.privado.id/docs/issuer/reverse-hash-service Copies the schema.sql file into the reverse-hash-service_db_1 container. This is a step in the Docker Setup Guide. ```bash dockercp schema.sql reverse-hash-service_db_1:/ ``` -------------------------------- ### Install Dart Packages Source: https://docs.privado.id/docs/wallet/wallet-sdk/polygonid-sdk/example-app This command downloads the necessary Dart packages for the project, including the Polygon ID SDK, after the dependencies have been added to pubspec.yaml. ```Shell flutter pub get ``` -------------------------------- ### Add Authorization Package - Golang Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup Installs the go-iden3-auth v2 package for Golang projects, which is required for verifier server setup. ```bash go get github.com/iden3/go-iden3-auth/v2 ``` -------------------------------- ### Create and Populate RHS Database Source: https://docs.privado.id/docs/issuer/reverse-hash-service Creates a PostgreSQL database named 'rhs' and then populates it using the schema.sql file. This is the first step in the Standalone Mode Guide. ```bash createdb rhs && psql -d rhs <./schema.sql ``` -------------------------------- ### Bash: Run Refresh Service Source: https://docs.privado.id/docs/issuer/refresh-service/setup-guide This Bash command shows how to execute the refresh service after setting up the environment variables. It first sources the `.env` file to load the configurations and then runs the main Go program. ```Bash source .env go run . ``` -------------------------------- ### Setup Issuer Node UI API and User Interface Source: https://docs.privado.id/docs/category/issuer-node-ui This guide explains the process of setting up both the Issuer UI API and its corresponding user interface. It details the necessary steps to get the Issuer Node UI operational. ```English This guide explains the process of setting up both the Issuer UI API and its corresponding user interface. It details the necessary steps to get the Issuer Node UI operational. ``` -------------------------------- ### Build App with Flutter SDK Source: https://docs.privado.id/docs/category/flutter-sdk Guides users on getting started with creating an application using the Privado ID Flutter SDK. This section focuses on the initial setup and development process. -------------------------------- ### Navigate to Example Directory Source: https://docs.privado.id/docs/wallet/wallet-sdk/polygonid-sdk/example-app This command changes the current directory to the 'example' folder within the cloned polygonid-sdk-repository, which is necessary for setting up the project. ```Shell cd example ``` -------------------------------- ### Build Example App with Flutter SDK Source: https://docs.privado.id/docs/category/flutter-sdk Details on how to build an example application using the Privado ID Flutter SDK. This section serves as a practical guide for developers to understand the SDK's implementation. -------------------------------- ### Upload Schema to RHS DB Source: https://docs.privado.id/docs/issuer/reverse-hash-service Imports the schema.sql file into the 'rhs' PostgreSQL database using the 'iden3' user on 'localhost'. This is a step in the Docker Setup Guide. ```bash psql -h localhost -U iden3 -d rhs < schema.sql ``` -------------------------------- ### Start All Issuer Node Services Source: https://docs.privado.id/docs/issuer/issuer-migration-guide This command starts all the necessary services for the Issuer Node v3 after the migration process is complete. It ensures all components are running correctly. ```Shell make run-all ``` -------------------------------- ### Install Debug App with Gradle Source: https://docs.privado.id/docs/wallet/wallet-sdk/android-sdk/example-app This command installs the debug version of the application using Gradle. It's a common step in Android development to deploy an app to a connected device or emulator for testing. ```Gradle ./gradlew installDebug app ``` -------------------------------- ### Execute DB Container Source: https://docs.privado.id/docs/issuer/reverse-hash-service Opens an interactive terminal session inside the reverse-hash-service_db_1 Docker container. Used for database operations in the Docker Setup Guide. ```bash dockerexec -it reverse-hash-service_db_1 /bin/bash ``` -------------------------------- ### Run Verifier Example Code Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup This snippet provides the executable code for setting up and running a Verifier as described in the tutorial. It demonstrates how to set up the query for verifying a Credential. ```Shell The executable code for this section can be found here. ``` -------------------------------- ### View Schema Examples Source: https://docs.privado.id/docs/category/schemas Explore a collection of schema samples to understand common patterns and best practices. These examples can serve as a starting point for your own schema definitions. ```Documentation Check a few schema samples. ``` -------------------------------- ### Create RHS Database Source: https://docs.privado.id/docs/issuer/reverse-hash-service Creates a new PostgreSQL database named 'rhs' with the user 'iden3' and host 'localhost'. This command is part of the Docker Setup Guide. ```bash createdb -U iden3 -h localhost rhs ``` -------------------------------- ### Run Polygon ID JS SDK using npm Source: https://docs.privado.id/docs/js-sdk/js-sdk-example This command executes the main script of the Polygon ID JS SDK using npm. Ensure that Node.js and npm are installed on your system before running this command. It initiates the SDK's operations. ```bash npm run start ``` -------------------------------- ### Bash: Create Configuration File Source: https://docs.privado.id/docs/issuer/refresh-service/setup-guide This Bash command creates an empty configuration file named `config.yaml`. This file is typically used to store custom configurations for the refresh service. ```Bash touch config.yaml ``` -------------------------------- ### Install Go Verifier SDK Source: https://docs.privado.id/docs/verifier/verification-library/config Installs the go-iden3-auth v2 SDK for Golang, used for building verifier applications. ```Go go get github.com/iden3/go-iden3-auth/v2 ``` -------------------------------- ### Install Golang Core Library Source: https://docs.privado.id/docs/js-sdk/js-sdk-dynamic-did This command installs the go-iden3-core library, which provides the core functionalities for working with the Iden3 protocol in Golang applications. ```bash go get "github.com/iden3/go-iden3-core/v2" ``` -------------------------------- ### Express Server Setup for Verifier Client Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup This JavaScript code sets up an Express server to serve static files and handle API requests for the Verifier Client. It uses `express.static` to serve frontend files (HTML, CSS, JS) and defines API endpoints for `/api/sign-in` to get the authentication request and `/api/callback` to handle the callback from the authentication process. It also initializes a map to store authentication requests. ```javascript const express = require("express"); const { auth, resolver, protocol } = require("@iden3/js-iden3-auth"); const getRawBody = require("raw-body"); const app = express(); const port = 8080; app.use(express.static("../static")); app.get("/api/sign-in", (req, res) => { console.log("get Auth Request"); GetAuthRequest(req, res); }); app.post("/api/callback", (req, res) => { console.log("callback"); Callback(req, res); }); app.listen(port, () => { console.log("server running on port 8080"); }); // Create a map to store the auth requests and their session IDs const requestMap = new Map(); ``` -------------------------------- ### Install JS-SDK for Authentication Source: https://docs.privado.id/docs/js-sdk/js-sdk-dynamic-did This command installs the '@iden3/js-iden3-auth' package, which is necessary for integrating authentication functionalities using the JS-SDK in a Node.js environment. ```bash npm i @iden3/js-iden3-auth --save ``` -------------------------------- ### Clone On-chain Merklized Issuer Demo Repository Source: https://docs.privado.id/docs/issuer/on-chain-issuer/on-chain-tutorial This command clones the demonstration repository for the on-chain merklized issuer. It is the first step in setting up the demo application. ```bash git clone https://github.com/0xPolygonID/onchain-merklized-issuer-demo ``` -------------------------------- ### Verifier Server Setup - Golang Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup Sets up a basic HTTP server in Golang with two endpoints: `/api/sign-in` to generate authentication requests and `/api/callback` to handle verification callbacks. It includes necessary imports and a KeyLoader struct for managing verification keys. ```go package main import( "encoding/json" "fmt" "io" "log" "net/http" "os" "strconv" "time" "github.com/ethereum/go-ethereum/common" circuits "github.com/iden3/go-circuits/v2" auth "github.com/iden3/go-iden3-auth/v2" "github.com/iden3/go-iden3-auth/v2/pubsignals" "github.com/iden3/go-iden3-auth/v2/state" "github.com/iden3/iden3comm/v2/protocol" ) const VerificationKeyPath ="verification_key.json" type KeyLoader struct{ Dir string } // Load keys from embedded FS func(m KeyLoader)Load(id circuits.CircuitID)([]byte,error){ return os.ReadFile(fmt.Sprintf("%s/%v/%s", m.Dir, id, VerificationKeyPath)) } funcmain(){ http.HandleFunc("/api/sign-in", GetAuthRequest) http.HandleFunc("/api/callback", Callback) log.Println("Starting server at port 8080") if err := http.ListenAndServe(":8080",nil); err !=nil{ log.Fatal(err) } } // Create a map to store the auth requests and their session IDs var requestMap =make(map[string]interface{}) ``` -------------------------------- ### Create and Run a Flutter App Source: https://docs.privado.id/docs/wallet/wallet-sdk/flutter-sdk/build-app-with-flutter-sdk This snippet demonstrates the basic commands to create a new Flutter project and run it. It assumes you have the Flutter SDK installed and configured. ```bash cd new-app-directory flutter create firstapp flutter run ``` -------------------------------- ### Deploy Identity Example Contract on Amoy Network Source: https://docs.privado.id/docs/issuer/on-chain-issuer/on-chain-tutorial This command deploys the Identity Example contract to the Amoy testnet using Hardhat. It requires setting environment variables for the private key and RPC URL of the Amoy network. ```bash export AMOY_PRIVATE_KEY={private_key}&& export AMOY_RPC_URL={rpc_url}&& npx hardhat run scripts/deployIdentityExample.ts --network amoy ``` -------------------------------- ### Copy Sample Configuration File Source: https://docs.privado.id/docs/issuer/setup-issuer-core This command copies the sample environment configuration file for the Issuer Node API, which needs to be customized for your specific environment. ```Shell cp .env-issuer.sample .env-issuer ``` -------------------------------- ### Build and Run Docker Compose Source: https://docs.privado.id/docs/issuer/on-chain-issuer/on-chain-tutorial These commands build the Docker images for the application and then start the services in detached mode. This is the final step to run the on-chain issuer demo. ```bash docker-compose build docker-compose up -d ``` -------------------------------- ### Export RHS Database Configuration Source: https://docs.privado.id/docs/issuer/reverse-hash-service Sets an environment variable for the RHS database connection string, specifying the host, user, password, and database name. Required for Standalone Mode. ```bash exportRHS_DB="host=localhost password=pgpwd user=postgres database=rhs" ``` -------------------------------- ### Verifier Server Setup - Javascript Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup Initializes an Express.js server in Javascript with `/api/sign-in` and `/api/callback` endpoints. It imports necessary modules for handling authentication requests and callbacks. ```javascript const express =require("express"); const{ auth, resolver, protocol }=require("@iden3/js-iden3-auth"); const getRawBody =require("raw-body"); const app =express(); const port =8080; app.get("/api/sign-in",(req, res)=>{ console.log("get Auth Request"); GetAuthRequest(req, res); }); app.post("/api/callback",(req, res)=>{ console.log("callback"); Callback(req, res); }); app.listen(port, ()=>{ console.log("server running on port 8080"); }); // Create a map to store the auth requests and their session IDs const requestMap =newMap(); ``` -------------------------------- ### Run Issuer Node UI with Docker Source: https://docs.privado.id/docs/issuer/setup-issuer-ui This command initiates the Issuer Node UI using Docker. Ensure you have cloned the repository and configured the environment file (`.env-ui`) before running this command. The UI will be accessible at http://localhost:8088. ```shell make run-all ``` -------------------------------- ### Get All Credentials Source: https://docs.privado.id/docs/wallet/wallet-sdk/polygonid-sdk/example-app Retrieves all saved credentials from the Wallet SDK. It can optionally filter credentials based on predefined criteria. Requires an identifier and private key, with filters being optional. ```Dart Future getAllClaims({ List? filters, required String identifier, required String privateKey, }) async { List claimList = await sdk.claim.getAllClaims( filters: filters, identifier: identifier, privateKey: privateKey, ); } ``` -------------------------------- ### Get Polygon ID Identifier Source: https://docs.privado.id/docs/wallet/wallet-sdk/polygonid-sdk/example-app Retrieves the unique identifier associated with an identity using its private key. The private key must be obtained from a previously created PrivateIdentityEntity. ```dart Future getIdentifier() async { String privateKey = privateIdentityEntity.privateKey; String identifier = await sdk.identity.getIdentifier(privateKey: privateKey); } ``` -------------------------------- ### Refresh Service Implementation Example Source: https://docs.privado.id/docs/issuer/refresh-service/overview This snippet provides an example of how to implement the refresh service, likely demonstrating the interaction with the issuer node or data providers. It is crucial for understanding the practical application of the refresh service. ```Go Example of refresh service implementation can be found here ``` -------------------------------- ### Get Iden3Message from String Source: https://docs.privado.id/docs/wallet/wallet-sdk/android-sdk/example-app Parses a string message, typically obtained from a QR code scan, into an Iden3Message object. This is used for communication between the wallet and issuers or verifiers in the Polygon ID ecosystem. ```Java PolygonIdSdk.getInstance().getIden3Message( context, theMessage ) ``` -------------------------------- ### Unzip Circuits Source: https://docs.privado.id/docs/js-sdk/js-sdk-example This bash command unzips the downloaded 'latest.zip' file into the 'circuits' directory within the project repository. This prepares the necessary circuit data for the JS SDK. ```bash unzip latest.zip -d circuits ``` -------------------------------- ### Get DID Identifier from Private Key Source: https://docs.privado.id/docs/wallet/wallet-sdk/android-sdk/example-app Retrieves the Decentralized Identifier (DID) for an identity using its private key and environment details. This function requires the context, private key, blockchain, and network information to generate the DID. ```Java PolygonIdSdk.getInstance().getDidIdentifier( context = context, privateKey = privateKey, blockchain = env.blockchain, network = env.network, ) ``` -------------------------------- ### Get Credentials by IDs Source: https://docs.privado.id/docs/wallet/wallet-sdk/polygonid-sdk/example-app Retrieves specific credentials from an issuer based on their IDs. The function takes a list of claim IDs, an identifier, and a private key to fetch the corresponding credentials as ClaimEntity objects. ```Dart Future getClaimsByIds({ required List claimIds, required String identifier, required String privateKey, }) async { List claimList = await sdk.credential.getClaimsByIds( claimIds: claimIds, identifier: identifier, privateKey: privateKey, ); } ``` -------------------------------- ### Get Current Polygon ID SDK Environment Source: https://docs.privado.id/docs/wallet/wallet-sdk/android-sdk/example-app Retrieves the current environment configuration of the Polygon ID SDK. This method returns an EnvEntity object containing details about the blockchain, network, and other relevant settings. ```Java PolygonIdSdk.getInstance().getEnv(context = context) ``` -------------------------------- ### Run Ngrok to Expose Localhost Source: https://docs.privado.id/docs/issuer/on-chain-issuer/on-chain-tutorial This command starts ngrok to create a secure tunnel to your local server running on port 8080. This is used to make your local issuer accessible from external networks. ```bash ngrok http 8080 ``` -------------------------------- ### Set Environment Variables (Bash) Source: https://docs.privado.id/docs/issuer/refresh-service/setup-guide This snippet demonstrates how to set essential environment variables required for the service. These variables configure IPFS gateway URLs, supported RPCs, state contracts, issuers, and issuer basic authentication. ```bash exportIPFS_GATEWAY_URL="https://infura..." exportSUPPORTED_RPC="137=https://infura..." exportSUPPORTED_STATE_CONTRACTS="137=0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" exportSUPPORTED_ISSUERS="*=https://my-issuer-node.com" exportISSUERS_BASIC_AUTH="*=myuser:mypassword" ``` -------------------------------- ### Configure PolygonScan Data Provider (YAML) Source: https://docs.privado.id/docs/issuer/refresh-service/setup-guide This snippet shows the configuration for integrating with the PolygonScan API as a default data provider. It specifies the API URL, request method, parameters, and response schema for fetching balance data. ```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 ``` -------------------------------- ### Get Credentials - Polygon ID SDK Source: https://docs.privado.id/docs/wallet/wallet-sdk/android-sdk/example-app Retrieves saved credentials from the wallet SDK. This function requires the user's DID identifier and private key. An optional 'filters' parameter can be used to specify criteria for retrieving specific credentials. ```Java PolygonIdSdk.getInstance().getClaims( context = context, genesisDid = did, privateKey = privateKey, filters = filters ) ``` -------------------------------- ### Build and Run Issuer Node API Source: https://docs.privado.id/docs/issuer/setup-issuer-core These commands build and run the Issuer Node API. It includes steps to bring up the necessary services, build the API, and then run it. ```Shell make up &&make build-api &&make run-api ``` -------------------------------- ### JavaScript Verifier Client Logic Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup This JavaScript code snippet demonstrates the core logic for a Verifier Client. It includes setting up state resolvers for Ethereum, fetching an authentication request, initializing a Verifier with circuits and an IPFS gateway, and executing the full verification process with optional delay settings. It handles potential errors during verification and sends the response. ```javascript const resolvers = { ["privado:main"]: new EthStateResolver( "https://rpc-mainnet.privado.id", "0x3C9acB2205Aa72A05F6D77d708b5Cf85FCa3a896" ) }; // fetch authRequest from sessionID const authRequest = requestMap.get(`${sessionId}`); // EXECUTE VERIFICATION const verifier = await auth.Verifier.newVerifier({ stateResolver: resolvers, circuitsDir: path.join(__dirname, "./circuits-dir"), ipfsGatewayURL: "", }); try { const opts = { AcceptedStateTransitionDelay: 5 * 60 * 1000, // 5 minute }; authResponse = await verifier.fullVerify(tokenStr, authRequest, opts); } catch (error) { return res.status(500).send(error); } return res.status(200).set("Content-Type", "application/json").send(authResponse); ``` -------------------------------- ### Error Logs for DID Identity Retrieval Source: https://docs.privado.id/docs/faqs/content/issuer-node-error-no-identity-by-did-no-rows-in-result-set This snippet displays example error logs encountered when attempting to retrieve an identity by DID. It highlights issues like 'no rows in result set' and 'issuer DID must exist', providing context for troubleshooting. ```Go time=2023-11-27T12:29:51.334Z level=ERROR msg="error getting identity by DID"err="no rows in result set"did=did:polygonid:polygon:amoy:2qHm5f6GZsJdLxpmGNCnn6TckCJWzhGmUUWebpFy5c time=2023-11-27T12:29:51.334Z level=ERROR msg="issuer DID must exist"did="{Method:polygonid ID:polygon:amoy:2qHm5f6GZsJdLxpmGNCnn6TckCJWzhGmUUWebpFy5c IDStrings:[polygon amoy 2qHm5f6GZsJdLxpmGNCnn6TckCJWzhGmUUWebpFy5c] Params:[] Path: PathSegments:[] Query: Fragment:}" ``` -------------------------------- ### Implement Android SDK Source: https://docs.privado.id/docs/category/android-sdk Guides on initializing and implementing the Android SDK for Privado ID. ```English Learn how to initialize and implement the Android SDK. ``` -------------------------------- ### Get Credentials by IDs - Polygon ID SDK Source: https://docs.privado.id/docs/wallet/wallet-sdk/android-sdk/example-app Retrieves specific credentials from an Issuer based on their unique IDs. This function takes a list of claim IDs, the user's DID identifier, and their private key as input, returning a list of ClaimEntity objects. ```Java PolygonIdSdk.getInstance().getClaimsByIds( context = context, genesisDid = did, privateKey = privateKey, claimIds = listOf(id) ) ``` -------------------------------- ### Add Authorization Package - Javascript Source: https://docs.privado.id/docs/verifier/verification-library/verifier-setup Installs the @iden3/js-iden3-auth package using npm for Javascript projects, essential for implementing authentication flows. ```bash npm i @iden3/js-iden3-auth ```