Skip to main content


Time to make a light DID using the previously created account for the Claimer. Since a light DID is not registered on the blockchain, you don't need funds for creating one. Remember light DIDs can:

  • Sign attestation requests and presentation with the authentication keys
  • Encrypt messages with the encryption keys

Take a look at our DID documentation to learn more about DIDs and the difference between their light and full versions.

Generate Keysโ€‹

Similar to the Attester, the Claimer must set up the DID keys.

import * as Kilt from '@kiltprotocol/sdk-js'
import {
} from '@polkadot/util-crypto'
import { generateAccount } from './generateAccount'

function generateKeyAgreement(mnemonic: string) {
const secretKeyPair = sr25519PairFromSeed(mnemonicToMiniSecret(mnemonic))
const { path } = keyExtractPath('//did//keyAgreement//0')
const { secretKey } = keyFromPath(secretKeyPair, path, 'sr25519')
return Kilt.Utils.Crypto.makeEncryptionKeypairFromSeed(blake2AsU8a(secretKey))

export function generateKeypairs(mnemonic = mnemonicGenerate()) {
const { account } = generateAccount(mnemonic)

const authentication = {
type: 'sr25519'
} as Kilt.KiltKeyringPair

const keyAgreement = generateKeyAgreement(mnemonic)

return {
authentication: authentication,
keyAgreement: keyAgreement

The Claimer only needs an authentication key and an encryption key. Here the keys are both derived from the same seed, but they could also have two different seeds.

Generate Light DIDโ€‹

Once our keypairs are generated we can create our light DID. Because it's off-chain we can just create the DID object every time, we don't need to resolve them before using it. But we'll still accept the mnemonic and prompt to save it in .env for our reference.

import { config as envConfig } from 'dotenv'

import { mnemonicGenerate } from '@polkadot/util-crypto'

import * as Kilt from '@kiltprotocol/sdk-js'

import { generateKeypairs } from './generateKeypairs'

export function generateLightDid(mnemonic: string): Kilt.DidDocument {
const { authentication, keyAgreement } = generateKeypairs(mnemonic)
return Kilt.Did.createLightDidDocument({
authentication: [authentication as Kilt.NewLightDidVerificationKey],
keyAgreement: [keyAgreement]

// Don't execute if this is imported by another file.
if (require.main === module) {
;(async () => {

try {
await Kilt.init()

const mnemonic = mnemonicGenerate()
console.log('\nsave following to .env to continue\n')
} catch (e) {
console.log('Error while setting up claimer DID')
throw e

After everything is initialized, we create a mnemonic that will be used to create the light DID. As you may have noticed the Claimer doesn't have an account. The Claimer doesn't need to hold funds and also doesn't need a blockchain account.


yarn ts-node ./claimer/generateLightDid.ts

Your output will provide you with CLAIMER_DID_MNEMONIC. Be sure to save it in your .env file, it should now look similar to this.


ATTESTER_ACCOUNT_MNEMONIC="warrior icon use cry...
ATTESTER_DID_MNEMONIC="beyond large galaxy...

CLAIMER_DID_MNEMONIC="danger awkward wrestle snap...

Well done - You've successfully generated a light DID!