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.
- 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
- 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
- Typescript
- Python
- Java
- PHP
- Golang
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);
}
import os
import bloock
from bloock.client.identity import IdentityClient
from bloock.client.key import KeyClient
from bloock.entity.identity.publish_interval_params import PublishIntervalParams
from bloock.entity.key.key_protection_level import KeyProtectionLevel
from bloock.entity.key.key_type import KeyType
from bloock.entity.key.key import Key
from bloock.entity.key.managed_key_params import ManagedKeyParams
from bloock.entity.identity.did_method import DidMethod
# we set the API key and create a client
bloock.api_key = os.environ["API_KEY"]
# we set de identity managed API host you have deployed
bloock.identity_api_host = os.environ["IDENTITY_MANAGED_API_HOST"]
# initialize the Key Client
key_client = KeyClient()
# initialize the IdentityClient
identity_client = IdentityClient()
# create the Baby JubJub managed key using the BLOOCK Keys product
protection = KeyProtectionLevel.SOFTWARE
key_type = KeyType.Bjj
params = ManagedKeyParams(protection, key_type)
managed_key = key_client.new_managed_key(params)
managed_key = key_client.new_managed_key(params)
# we create the issuer, passing the Baby JubJub key and issuer information
# we just passed the Baby JubJub key created before. REQUIRED.
issuer_key = Key(managed_key)
# check Issuer intervals documentation to define the best for you model. REQUIRED.
issuer_interval = PublishIntervalParams.Interval60
# check DID methods documentation. By default we recommend the PolygonID. REQUIRED.
method_did = DidMethod.PolygonID
# Issuer name. OPTIONAL.
name = "BLOOCK Issuer"
# Issuer description. OPTIONAL.
description = "this is the BLOOCK Issuer"
# here you can pass an encoded base 64 url image string. OPTIONAL.
encoded_base64_url_image = ""
issuer = identity_client.create_issuer(
issuer_key, issuer_interval, method_did, name, description)
# returns an Issuer entity
# will print the Issuer DID public identifier.
# Ex: did:polygonid:polygon:main:2qCU58EJgrELSJT6EzT27Rw9DhvwamAdbMLpePztYq
print(issuer.did)
# will return the DID method we chosed. Ex: identity.PolygonID
print(issuer.did_method)
# will return the Key BJJ object associated to the Issuer.
print(issuer.key)
import java.io.IOException;
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.IdentityClient;
import com.bloock.sdk.client.KeyClient;
import com.bloock.sdk.entity.identity.DidMethod;
import com.bloock.sdk.entity.identity.Issuer;
import com.bloock.sdk.entity.identity.PublishIntervalParams;
import com.bloock.sdk.entity.key.Key;
import com.bloock.sdk.entity.key.KeyProtectionLevel;
import com.bloock.sdk.entity.key.KeyType;
import com.bloock.sdk.entity.key.ManagedKey;
import com.bloock.sdk.entity.key.ManagedKeyParams;
public class CreateIssuer {
public static void main(String[] args) throws Exception {
try {
// we set the API key and create a client
Bloock.apiKey = System.getenv("API_KEY");
// we set de identity managed API host you have deployed
Bloock.identityApiHost = System.getenv("IDENTITY_MANAGED_API_HOST");
// initialize the Key Client
KeyClient keyClient = new KeyClient();
// initialize the IdentityClient
IdentityClient identityClient = new IdentityClient();
// create the Baby JubJub managed key using the BLOOCK Keys product
KeyProtectionLevel keyProtectionLevel = KeyProtectionLevel.SOFTWARE;
KeyType keyType = KeyType.Bjj;
ManagedKey managedKey = keyClient.newManagedKey(new ManagedKeyParams(keyProtectionLevel, keyType));
// we create the issuer, passing the Baby JubJub key and issuer information
// we just passed the Baby JubJub key created before. REQUIRED.
Key issuerKey = new Key(managedKey);
// check Issuer intervals documentation to define the best for you model.
// REQUIRED.
PublishIntervalParams issuerInterval = PublishIntervalParams.Interval60;
// check DID methods documentation. By default we recommend the PolygonID.
// REQUIRED.
DidMethod methodDID = DidMethod.PolygonID;
// Issuer name. OPTIONAL.
String name = "BLOOCK Issuer";
// Issuer description. OPTIONAL.
String description = "this is the BLOOCK Issuer";
// here you can pass an encoded base 64 url image string. OPTIONAL.
String encodedBase64UrlImage = "";
Issuer issuer = identityClient.createIssuer(
issuerKey,
issuerInterval,
methodDID,
name,
description,
encodedBase64UrlImage);
// returns an Issuer entity
// will print the Issuer DID public identifier. Ex:
// did:polygonid:polygon:main:2qCU58EJgrELSJT6EzT27Rw9DhvwamAdbMLpePztYq
System.out.println(issuer.getDid().getDid());
// will return the DID method we chosed. Ex: identity.PolygonID
System.out.println(issuer.getDid().getDidMethod());
// will return the Key BJJ object associated to the Issuer.
System.out.println(issuer.getKey());
} catch (Exception e) {
System.out.println(e);
}
}
}
<?php
use Bloock\Bloock;
use Bloock\Client\KeyClient;
use Bloock\Client\IdentityClient;
use Bloock\Entity\Key\KeyProtectionLevel;
use Bloock\Entity\Key\KeyType;
use Bloock\Entity\Key\ManagedKeyParams;
use Bloock\Entity\Identity\PublishIntervalParams;
use Bloock\Entity\Key\Key;
use Bloock\Entity\Identity\DidMethod;
require "./vendor/autoload.php";
// we set the API key and create a client
Bloock::$apiKey = getenv("API_KEY") ?: "";
// we set de identity managed API host you have deployed
Bloock::$identityApiHost = getenv("IDENTITY_MANAGED_API_HOST") ?: "";
// initialize the Key Client
$keyClient = new KeyClient();
// initialize the IdentityClient
$identityClient = new IdentityClient();
// create the Baby JubJub managed key using the BLOOCK Keys product
$keyProtection = KeyProtectionLevel::SOFTWARE;
$keyType = KeyType::Bjj;
$params = new ManagedKeyParams($keyProtection, $keyType);
$managedKey = $keyClient->newManagedKey($params);
// we create the issuer, passing the Baby JubJub key and issuer information
$issuerKey = new Key($managedKey); // we just passed the Baby JubJub key created before. REQUIRED.
$issuerInterval = PublishIntervalParams::Interval60; // check Issuer intervals documentation to define the best for you model. REQUIRED.
$methodDID = DidMethod::PolygonID; // check DID methods documentation. By default we recommend the PolygonID. REQUIRED.
$name = "BLOOCK Issuer"; // Issuer name. OPTIONAL.
$description = "this is the BLOOCK Issuer"; // Issuer description. OPTIONAL.
$encodedBase64UrlImage = ""; // here you can pass an encoded base 64 url image string. OPTIONAL.
$issuer = $identityClient->createIssuer($issuerKey, $issuerInterval, $methodDID, $name, $description);
// returns an Issuer entity
$createdIssuerDid = $issuer->getDid()->getDid(); // will print the Issuer DID public identifier. Ex: did:polygonid:polygon:main:2qCU58EJgrELSJT6EzT27Rw9DhvwamAdbMLpePztYq
$createdIssuerDidMethod = $issuer->getDid()->getDidMethod(); // will return the DID method we chosed. Ex: identity.PolygonID
$createdIssuerKey = $issuer->getKey(); // will return the Key BJJ object associated to the Issuer.
package main
import (
"log"
"os"
"github.com/bloock/bloock-sdk-go/v2"
"github.com/bloock/bloock-sdk-go/v2/client"
"github.com/bloock/bloock-sdk-go/v2/entity/identity"
"github.com/bloock/bloock-sdk-go/v2/entity/key"
)
func main() {
// we set the API key and create a client
bloock.ApiKey = os.Getenv("API_KEY")
// we set de identity managed API host you have deployed
bloock.IdentityApiHost = os.Getenv("IDENTITY_MANAGED_API_HOST")
// initialize the Key Client
keyClient := client.NewKeyClient()
// initialize the IdentityClient
identityClient := client.NewIdentityClient()
// create the Baby JubJub managed key using the BLOOCK Keys product
managedKey, err := keyClient.NewManagedKey(key.ManagedKeyParams{
KeyType: key.Bjj,
})
if err != nil {
log.Fatalln(err)
}
// we create the issuer, passing the Baby JubJub key and issuer information
issuerKey := key.Key{ManagedKey: &managedKey} // we just passed the Baby JubJub key created before. REQUIRED.
issuerInterval := identity.Interval60 // check Issuer intervals documentation to define the best for you model. REQUIRED.
methodDID := identity.PolygonID // check DID methods documentation. By default we recommend the PolygonID. REQUIRED.
name := "BLOOCK Issuer" // Issuer name. OPTIONAL.
description := "this is the BLOOCK Issuer" // Issuer description. OPTIONAL.
encodedBase64UrlImage := "" // here you can pass an encoded base 64 url image string. OPTIONAL.
issuer, err := identityClient.CreateIssuer(issuerKey, issuerInterval, methodDID, name, description, encodedBase64UrlImage)
if err != nil {
log.Fatalln(err)
}
// returns an Issuer entity
log.Println(issuer.Did.Did) // will print the Issuer DID public identifier. Ex: did:polygonid:polygon:main:2qCU58EJgrELSJT6EzT27Rw9DhvwamAdbMLpePztYq
log.Println(issuer.Did.DidMethod) // will return the DID method we chosed. Ex: identity.PolygonID
log.Println(issuer.Key) // will return the Key BJJ object associated to the Issuer.
}