Skip to main content

Create Issuer

In order to create an identity in BLOOCK Identity I will first need to create or have a Baby JubJub (BJJ) key. This key will be very important to have it saved because it will be used to control our Issuer.

You have two options to get this key.

  1. You can create a BJJ key with our managed key product (BLOOCK Keys product), your key will be identified by a UUID. This identifier will be enough to control your Issuer. Example: 6f36448d-49f3-4b0e-aa72-6e55863302e8
  2. If you have created a BJJ type key locally, i.e. you are aware of its private key, then you can use it to control your Issuer. Example: bf5e13dd8d9f784aee781b4de7836caa3499168514553eaa3d892911ad3c345j

Examples

import { Bloock, KeyClient, IdentityClient, KeyProtectionLevel, KeyType, ManagedKeyParams, DidMethod, Key, PublishIntervalParams } from '@bloock/sdk';

try {
// we set the API key and create a client
Bloock.setApiKey(process.env['API_KEY'] || "");
// we set de identity managed API host you have deployed
Bloock.setIdentityApiHost(process.env['IDENTITY_MANAGED_API_HOST'] || "");

// initialize the Key Client
const keyClient = new KeyClient();
// initialize the IdentityClient
const identityClient = new IdentityClient();

// create the Baby JubJub managed key using the BLOOCK Keys product
const keyProtection = KeyProtectionLevel.SOFTWARE;
const keyType = KeyType.Bjj;
const managedKey = await keyClient.newManagedKey(
new ManagedKeyParams(keyProtection, keyType)
);

// we create the issuer, passing the Baby JubJub key and issuer information
const issuerKey = new Key(managedKey); // we just passed the Baby JubJub key created before. REQUIRED.
const issuerInterval = PublishIntervalParams.Interval60; // check Issuer intervals documentation to define the best for you model. REQUIRED.
const methodDID = DidMethod.PolygonID; // check DID methods documentation. By default we recommend the PolygonID. REQUIRED.
const name = "BLOOCK Issuer"; // Issuer name. OPTIONAL.
const description = "this is the BLOOCK Issuer"; // Issuer description. OPTIONAL.
const encodedBase64UrlImage = ""; // here you can pass an encoded base 64 url image string. OPTIONAL.

const issuer = await identityClient.createIssuer(
issuerKey,
issuerInterval,
methodDID,
name,
description,
encodedBase64UrlImage
);

// returns an Issuer entity
console.log(issuer.did.did) // will print the Issuer DID public identifier. Ex: did:polygonid:polygon:main:2qCU58EJgrELSJT6EzT27Rw9DhvwamAdbMLpePztYq
console.log(issuer.did.didMethod) // will return the DID method we chosed. Ex: identity.PolygonID
console.log(issuer.key) // will return the Key BJJ object associated to the Issuer.

} catch (e) {
console.log(e);
}