Method

verifyDidLogin

export async function verifyDidLogin<T extends 'did_login' | 'did_login$Kilt' = 'did_login'>(
  message: HexString | Uint8Array | string,
  data: RequestRpcs<T>[T][1],
  resolver?: DidResolver
): Promise<boolean> {
......
}

Description

This SDK function aims for helping developers to authenticate User. This should be invoked after using the didLogin(params) function in the Provider, verifyDidLogin(params) function helps verify whether the User is actually the Owner of the DID.

Params

  • message: the message which the User signed on (this should be the same with the massage in didLogin(params))

  • signature: the signature on that message, started with '0x'

  • publicKey: the publicKey of User's AuthenticationKey, which is contains in the DID info (can be obtained by getCurrentDid() function in the Provider.

Return Boolean -- Whether the signature is actually signed by the User (in other word -- Whether developers should allow the User to login)

Usage

Check more details about this SDK Function on our Github.

import { verifyDidLogin } from '@zcloak/login-verify';

// to sign message
const message = '';

const did = await provider.getCurrentDid();

const signature = await provider.didLogin(message);

// to verify the signature in order to authenticate the user
const result = verifyDidLogin(message, signature, did.authenticationKey);

console.log(result)

verifyCredentialDigest

export async function verifyCredentialDigest<
  T extends
    | 'did_requestCredentialDigest'
    | 'did_requestCredentialDigest$Kilt' = 'did_requestCredentialDigest'
>(
  credentialDigest: RequestRpcs<T>[T][1],
  challenge: string,
  owner: T extends 'did_requestCredentialDigest' ? DidUrl : DidUri,
  resolver?: DidResolver
): Promise<boolean> {
......
}

Description

This verifyCredentialDigest method provided in our SDK can be used to check whether the Digest Disclosure is valid, whether the User is the Credential’s Owner.

Params

  • credentialDigest: the RequestCredentialDigestReponse of login-rpc, can be obtained use did_requestCredentialDigest method

  • challenge: a random string, the same with the challenge in the did_requestCredentialDigest method

  • owner: the credential owner

Return

boolean -- The Verification result of the Digest Disclosure

Usage

Check more details about this SDK Function on our Github.

import { verifyCredentialDigest } from '@zcloak/login-verify';

const challenge = '';

const did = await provider.getCurrentDid();

// verify credential digest
const credentialDigest = await provider.requestCredentialDigest(challenge);

const result = await verifyCredentialDigest(credentialDigest, challenge, did.didUri);

verifyCredentialContent

export async function verifyCredentialContent<
  T extends
    | 'did_requestCredentialContent'
    | 'did_requestCredentialContent$Kilt' = 'did_requestCredentialContent'
>(
  credential: RequestRpcs<T>[T][1],
  challenge: string,
  owner: T extends 'did_requestCredentialContent' ? DidUrl : DidUri,
  resolver?: DidResolver
): Promise<boolean> {
......
}

Description

This verifyCredentialContent method provided in our SDK can be used to check whether the Selective Disclosure or All Credential Content Disclosure is valid, whether the User is the Credential's Owner.

Params

  • credentialDigest: the RequestCredentialContentReponse of login-rpc, can be obtained use did_requestCredentialContent method

  • challenge: a random string, the same with the challenge in the did_requestCredentialDigest method

  • owner: the credential owner

Return

boolean -- The Verification result of the Selective Disclosure or All Credential Content Disclosure.

Usage

Check more details about this SDK Function on our Github.

import { verifyCredentialContent } from '@zcloak/login-verify';

const challenge = '';

const did = await provider.getCurrentDid();

const credential = await provider.requestCredentialContent(challenge);

// verify credential content
const result = await verifyCredentialContent(credential, challenge, did.didUri);

console.log(result);

Last updated