Skip to content

Run Redbelly Proof by Query Verifier Instance

Set up your own Verifier with the following steps;

  • Clone the receptor-verifier repository from Github which implements routes for Proof by Query and Selective Disclosure in verifier-backend.
  • Receptor Contracts contains generic contracts that support the Receptor Protocol; which can be accessed from Redbelly Contract Registry.
  • Pre-requisites/Assumptions:
  • Task
  • ts-node
  • Go
  • Run task generateSchema in verifier-backend to generate schema and claim path key for DriversLicenceCredential.
  • Optional: Contracts available in receptor-contracts are deployed if not using Contracts available in Redbelly Registry.

Environment variables

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

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

.env

  • POSEIDON_ADDRESS = 0x88Ce67B3280711AB849082C9754F19850aF559C2
  • MTP_ADDRESS = 0x582E232c669179eff5E03Ed3ab09B19c09A8ED33
  • NETWORK_NAME = 'redbelly'
  • CHAIN_ID = 152
  • RPC_URL = 'https://rbn-aws-eu-north-1a-0-b.devnet.redbelly.network:8545'
  • WALLET_KEY = {Add your Private Key}
  • PORT = {Optional: Add port for Verifier Server}
  • POSEIDON_ADDRESS = Coming Soon
  • MTP_ADDRESS = Coming Soon
  • NETWORK_NAME = 'redbelly'
  • CHAIN_ID = Coming Soon
  • RPC_URL = Coming Soon
  • WALLET_KEY = {Add your Private Key}
  • PORT = {Optional: Add port for Verifier Server}

Install Dependencies

npm i

Run Demo

npm run dev

Get Credential Request

  • Creates Credential Request for the holder to help generate proof.
curl --location --request GET 'http://localhost:4000/get-request'
  • Fetch the credential request generated and append in further steps.

Sample Credential

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

Create Holder's DID

  • Creates a Decentralised Identity (DID) and saves it as a global instance of the DID for the holder's server.
  • Run Holder Instance; and run the following curl command.
curl http://localhost:5000/create-identity
  • Fetch the response generated to get the Verifiable Credential from Issuer.

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": ""
  }
}

Receive VC from Issuer

  • Run Issuer Instance; and run the following curl command which passes the holder's DID for the issuer to issue a Verifiable Credential.
curl --location 'http://localhost:3000/generate-pbq-credentials' \
--header 'Content-Type: application/json' \
--data '{"did":{holderDID}}'
  • Fetch the verifiable credential generated from the above curl request.

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"
          ]
        }
      }
    ]
  }
}

Save VC from Issuer, Generate and Submit Proof

  • Generates proof based on the value provided in verifiableCredential from the Issuer and credentialRequest from the Verifier.
  • The generated proof is then submitted to the Receptor Smart Contract for verification.
  • Run Holder Instance; 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
  • We receive the proof's mapping in the response generated which informs about successful proof verification.

Sample Response

{
  "message": "proof successfully generated and submitted",
  "proofStatus": true
}