Skip to content

Create credential request

Important

Before creating your credential request please ensure you have setup and deployed your Receptor Smart Contract.

The Verifier creates a credential request for the wallet holder.

** Sample CR Structure**

{
    id: requestId,
    circuitId,
    query: {
      allowedIssuers: ["*"], // Accepts any issuer; use trusted issuer DIDs in production.
      type: credentialType,
      context:
        "https://redbellynetwork.github.io/did-schema/driversLicence/credential/v1.jsonld",
      credentialSubject: {
        birthDate: {
          $lt: CRITERIA_VALUE,
        }
      }
    }
  }

  • id: Request Id
  • circuitId: MTP Circuit Id
  • query:
    • allowedIssuers: ["*"] accepts credentials from any issuer. For production and mainnet flows, replace it with the DID values of issuers you trust.
    • type: Type of Credential
    • context: JSON-LD Context of credential.
    • credentialSubject: Contains User’s details

Function Definition

export function createCredentialRequest(
  circuitId: CircuitId,
  credentialType: string,
  requestId: number
): ZeroKnowledgeProofRequest {
  const proofReqMtpOnChain = {
    id: requestId,
    circuitId,
    query: {
      allowedIssuers: ["*"], // Accepts any issuer; use trusted issuer DIDs in production.
      type: credentialType,
      context:
        "https://redbellynetwork.github.io/did-schema/driversLicence/credential/v1.jsonld",
      credentialSubject: {
        birthDate: {
          $lt: 20020101,
        },
      },
    },
  };

  return proofReqMtpOnChain;
}

Initialisation

const proofReqSig: ZeroKnowledgeProofRequest = createCredentialRequest(
  CircuitId.AtomicQueryMTPV2OnChain,
  'DriversLicenceCredential',
  newRequestId
);

The proofRqSig contains the credential request required by the Holder.


Next Up: Set Request →