zkID Login Doc
  • Guide
    • Introduction
      • Why zkID-Login
      • DID Account Management
      • VC Management
      • Blockchain Connection
    • Basic Concepts
      • DID
        • DID Protocol Main Architecture
        • ZK DID Method
        • DID-Keys
      • VC
        • What are Verifiable Credentials
        • Key roles of VC
        • Core Data Model
    • Architecture
      • zkID Wallet
      • Provider
    • Usage of VC
      • Digest Disclosure
      • Selective Disclosure
      • All Credential Content Disclosure
  • API Reference
    • Provider API
    • Events
    • Errors
    • Using The Provider
  • SDK
    • Introduction
    • Method
      • verifyDidLogin
      • verifyCredentialDigest
      • verifyCredentialContent
  • Getting Started
    • Preliminary Preparation
    • Use Case
      • Login with DID
      • Login with Digest Disclosure
      • Login with Selective Disclosure
Powered by GitBook
On this page
  • verifyDidLogin
  • verifyCredentialDigest
  • verifyCredentialContent
  1. SDK

Method

PreviousSDKNextGetting Started

Last updated 2 years ago

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 .

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

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

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

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

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);

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

Check more details about .

This 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.

Check more details about .

this SDK Function on our Github
verifyCredentialDigest
this SDK Function on our Github
verifyCredentialContent
this SDK Function on our Github