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: ["*"],
      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: [*] indicates that user can provide a proof of credential issued by any issuer. Alternatively, a specific issuer did can be specified.
    • 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: ["*"],
      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 →