Verify Credential

After authentication is complete, you will get the user's authorization information, which contains the user's CKB address and credential, and you may want to verify that the user credential has ownership of the corresponding CKB Address.

Verify a credential against a CKB address is simple and requires only one asynchronous function call:

import { authWithPopup, verifyCredential } from '@joyid/core'

const { error, data } = await authWithPopup(request)
if (error == null) {
    const { keyType, address, pubkey, alg } = data
    const result = await verifyCredential(pubkey, address, keyType, alg)
    alert(result) // true or false
}

Verify Credential on chain

Note that if the Credential is of type sub_key, JoyID SDK will request our centralized server to verify. If you don't trust JoyID's centralized server, you can verify it on chain by yourself. Verify credential on chain takes three steps:

  1. Deploy a CKB node
  2. Deploy a CoTA Aggregator
  3. Verify it via the CoTA Aggregator RPC

Try it out

Loading Sandbox...
Loading Sandbox...