Skip to content

Run Redbelly Proof by Query Holder Instance

Environment variables

You will need these values to run holder on the various Redbelly environments.

  • Create .env file.
  • Copy values from .env.example to .env

.env

  • RHS_URL = 'https://rhs.testnet.redbelly.network'
  • CIRCUITS_PATH = {Add path to Iden3 Circuits}
  • RPC_URL = 'https://rbn-aws-eu-north-1a-0-b.devnet.redbelly.network:8545'
  • WALLET_KEY = {Add your Private Key}
  • STATE_CONTRACT_ADDRESS = 0x73Fdb30a0A01aEB6d2A6fc8cdAc6d88D891898F9
  • BSC_ADDRESS = 0x403e0043a2D1016a4D8765965843441444e0fc13
  • PORT = {Optional: Add port for Holder Server}
  • RHS_URL = 'https://rhs.redbelly.network'
  • CIRCUITS_PATH = {Add path to Iden3 Circuits}
  • RPC_URL = 'https://rbn-aws-eu-north-1a-0-b.devnet.redbelly.network:8545'
  • WALLET_KEY = {Add your Private Key}
  • STATE_CONTRACT_ADDRESS = Coming Soon
  • BSC_ADDRESS = Coming Soon
  • PORT = {Optional: Add port for Holder Server}

Install Dependencies

npm i

Run Demo

npm run start

Note

Run in watch mode using npm run dev

Create DID

Creates a Decentralised Identity (DID) and saves it as a global instance of the DID for the holder server.

curl http://localhost:5000/create-identity
  • Fetch the response generated and append below as holder's DID.

Sample Holder's DID

{
  "message": "did successfully created",
  "did": {
    "method": "iden3",
    "id": "polygon:mumbai:x5fEEnyoRGR6dTCWMwJ87gUBRTRWYPiLJkyEHYCv6",
    "idStrings": [
      "polygon",
      "mumbai",
      "x5fEEnyoRGR6dTCWMwJ87gUBRTRWYPiLJkyEHYCv6"
    ],
    "params": [],
    "path": "",
    "pathSegments": [],
    "query": "",
    "fragment": ""
  },
  "did_String": "did:iden3:polygon:mumbai:x5fEEnyoRGR6dTCWMwJ87gUBRTRWYPiLJkyEHYCv6"
}

Create Issuer's DID

curl --location 'http://localhost:3000/create-identity'

Sample Issuer's DID

{
  "payload": {
    "method": "iden3",
    "id": "polygon:mumbai:x32x9zKVv8mxno2EE6DiP7YeKSxhQbeHL4p7GbDAM",
    "idStrings": [
      "polygon",
      "mumbai",
      "x32x9zKVv8mxno2EE6DiP7YeKSxhQbeHL4p7GbDAM"
    ],
    "params": [],
    "path": "",
    "pathSegments": [],
    "query": "",
    "fragment": ""
  }
}

Pass DID to Issuer

  • Run Issuer Instance;
  • Pass the generated holder's DID to the Issuer to obtain the Verifiable Credential.
  • Run Issuer Instance; and run the following curl command.
curl --location 'http://localhost:3000/generate-pbq-credentials' \
--header 'Content-Type: application/json' \
--data '{"did":{holderDID}}'
  • Fetch the Verifiable Credential generated by the Issuer's Response.

Sample Verifiable Credential

{
  "message": "OK",
  "credential": {
    "id": "urn:951481e8-e5f5-48c3-b185-b3f9e6263ac2",
    "@context": [
      "https://www.w3.org/2018/credentials/v1",
      "https://schema.iden3.io/core/jsonld/iden3proofs.jsonld",
      "https://redbellynetwork.github.io/did-schema/passport/credential/v1.jsonld"
    ],
    "type": ["VerifiableCredential", "PassportCredential"],
    "credentialSubject": {
      "id": "did:iden3:polygon:mumbai:x3LXBvzJR4vwV4kHvwSrkBP9PRNYpiLwwTisVEKrZ",
      "name": "james testeleven",
      "passportNumber": "E55173628",
      "nationality": "AUS",
      "birthDate": 19600101,
      "customerReference": "2fcecbfc-a926-cf72-6182-4f475da27b28",
      "expiryDate": 20250101,
      "publicAddress": "0x9e125dB4B5Af7DBe334aA9653b2829b6F07e0391",
      "type": "PassportCredential"
    },
    "issuer": "did:iden3:polygon:mumbai:wznFQLNCwNgrcysagm7M1WZ1iv2ZgZqwYK8dZMZ1k",
    "issuanceDate": "2024-01-31T08:32:25.358Z",
    "credentialSchema": {
      "id": "https://redbellynetwork.github.io/did-schema/passport/credential/PassportCredential-v1.json",
      "type": "JsonSchema2023"
    },
    "credentialStatus": {
      "id": "http://localhost:8080/node?state=d00c36de5b7818e102b47c534fd97c125d88796826b064115acfd74e397ab00f",
      "type": "Iden3ReverseSparseMerkleTreeProof",
      "revocationNonce": 1940
    },
    "proof": [
      {
        "issuerData": {
          "id": "did:iden3:polygon:mumbai:wznFQLNCwNgrcysagm7M1WZ1iv2ZgZqwYK8dZMZ1k",
          "state": {
            "rootOfRoots": "0000000000000000000000000000000000000000000000000000000000000000",
            "revocationTreeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
            "claimsTreeRoot": "8299309aaa4def73548235a717ec3b2fc8b91efbdba958aacaefbcccdbeb011c",
            "value": "d00c36de5b7818e102b47c534fd97c125d88796826b064115acfd74e397ab00f"
          },
          "mtp": {
            "existence": true,
            "siblings": []
          },
          "authCoreClaim": "cca3371a6cb1b715004407e325bd993c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000789a607710ebfa952cde0c650dedec522311e2ae3821a9c7471ef3d41fda5e0bbdf80c621861243963cf45ec8aa5024c18ed0e8188b72ad25c0029e284512c180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
          "credentialStatus": {
            "id": "http://localhost:8080/node?state=d00c36de5b7818e102b47c534fd97c125d88796826b064115acfd74e397ab00f",
            "type": "Iden3ReverseSparseMerkleTreeProof",
            "revocationNonce": 0
          }
        },
        "type": "BJJSignature2021",
        "coreClaim": "cca3371a6cb1b715004407e325bd993c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000789a607710ebfa952cde0c650dedec522311e2ae3821a9c7471ef3d41fda5e0bbdf80c621861243963cf45ec8aa5024c18ed0e8188b72ad25c0029e284512c180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "signature": "signature"
      },
      {
        "issuerData": {
          "id": "did:iden3:polygon:mumbai:wznFQLNCwNgrcysagm7M1WZ1iv2ZgZqwYK8dZMZ1k",
          "state": {
            "claimsTreeRoot": "edf712698b5c2b42e9923129f74bea6c62cbc02f283839231543c70566ea4d13",
            "revocationTreeRoot": "0000000000000000000000000000000000000000000000000000000000000000",
            "rootOfRoots": "df9330f8306c7b8e68195648ae120b7b01b1bbfdd238dddada02e0d78a3ec724",
            "value": "48eca96ed3813815860a42c7b2674574aa019be5c2f5db4b1b6c75ade7e15a14",
            "txId": "0xf276904e0a34b1fc43bc51a3a7d29bafec0502b12a6e6f16b928dadbb214724d"
          }
        },
        "type": "Iden3SparseMerkleTreeProof",
        "coreClaim": "coreClaim",
        "mtp": {
          "existence": true,
          "siblings": [
            "0",
            "12668154443577484692186593348211170053898334608718851465299950935342343821698"
          ]
        }
      }
    ]
  }
}

Receive CR from Verifier

  • Run Verifier Instance; and run the following curl command.
curl --location --request GET 'http://localhost:4000/get-request'
  • Fetch the Credential Request generated by the Verifier's Response.

Sample Credential Request

{
  "id": 26,
  "circuitId": "credentialAtomicQueryMTPV2OnChain",
  "query": {
    "allowedIssuers": ["*"],
    "type": "DriversLicenceCredential",
    "context": "https://redbellynetwork.github.io/did-schema/driversLicence/credential/v1.jsonld",
    "credentialSubject": { "birthDate": { "$lt": 20020101 } }
  }
}

Save VC from Issuer, Generate and Submit Proof

Generates proof based on the value provided in verifiableCredential and credentialRequest. The generated proof is then submitted to the Receptor Smart Contract for verification. Append verifiable credential and credential request to curl command below.

curl -X POST \
-H "Content-Type: application/json" \
-d '{"verifiableCredential": <--verifiableCredential from Issuer-->, "credentialRequest": <--credentialRequest from Verifier-->}' \
http://localhost:5000/generate-submit-proof
Sample Response
{
  "message": "proof successfully generated and submitted",
  "proofStatus": true
}

On successful proof verification, we receive the proof's mapping in response which informs about successful proof verification.