Credential Offering
The credential offering process refers to the transfer of the Verifiable Credential (VC) to the assigned user or Holder. It requires two agents (Issuer and Holder) and a wallet or software where the credential will be stored. At the Holder level, this is done by scanning a QR code generated by the Issuer from the Holder's wallet. At the protocol level this communication is highly secure thanks to the DIDComm protocol used and the authentication and identity proofs mechanisms.
Examples
- Typescript
- Python
- Java
- PHP
- Golang
import { Bloock, DidMethod, IdentityClient, Key, KeyClient } 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();
// we must have our Issuer Baby JubJub key identifier. Ex: 6f36448d-49f3-4b0e-aa72-6e55863302e8
const savedIssuerKey = '6f36448d-49f3-4b0e-aa72-6e55863302e8';
const loadedManagedKey = await keyClient.loadManagedKey(savedIssuerKey);
// if we don't have our Issuer entity, here you can import you Issuer from the key
const importedIssuerKey = new Key(loadedManagedKey);
const issuerMethodDID = DidMethod.PolygonID;
const importedIssuer = await identityClient.importIssuer(
importedIssuerKey,
issuerMethodDID
);
// we need to get the credential id, we want to make the offering
const credentialID = 'fdd4bf52-bac7-4f41-a743-5b0580168eb3';
// once we have the issuer and the credential id, we can called the offering function
const jsonOffer = await identityClient.getCredentialOffer(
importedIssuer,
credentialID
);
console.log(jsonOffer); // it's the json result that we would convert to a QR code
} catch (e) {
console.log(e);
}
import os
import bloock
from bloock.client.identity import IdentityClient
from bloock.client.key import KeyClient
from bloock.entity.key.key import Key
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()
# we must have our Issuer Baby JubJub key identifier. Ex: 6f36448d-49f3-4b0e-aa72-6e55863302e8
saved_issuer_key = "6f36448d-49f3-4b0e-aa72-6e55863302e8"
loaded_managed_key = key_client.load_managed_key(saved_issuer_key)
# if we don't have our Issuer entity, here you can import you Issuer from the key
imported_issuer_key = Key(loaded_managed_key)
issuer_method_did = DidMethod.PolygonID
imported_issuer = identity_client.import_issuer(
imported_issuer_key, issuer_method_did)
# we need to get the credential id, we want to make the offering
credential_id = "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
# once we have the issuer and the credential id, we can called the offering function
json_offer = identity_client.get_credential_offer(
imported_issuer, credential_id)
# it's the json result that we would convert to a QR code
print(json_offer)
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.CredentialReceipt;
import com.bloock.sdk.entity.identity.DidMethod;
import com.bloock.sdk.entity.identity.Issuer;
import com.bloock.sdk.entity.key.Key;
import com.bloock.sdk.entity.key.ManagedKey;
public class CredentialOffering {
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();
// we must have our Issuer Baby JubJub key identifier. Ex: 6f36448d-49f3-4b0e-aa72-6e55863302e8
String savedIssuerKey = "6f36448d-49f3-4b0e-aa72-6e55863302e8";
ManagedKey loadedManagedKey = keyClient.loadManagedKey(savedIssuerKey);
// if we don't have our Issuer entity, here you can import you Issuer from the key
Key importedIssuerKey = new Key(loadedManagedKey);
DidMethod issuerMethodDID = DidMethod.PolygonID;
Issuer importedIssuer = identityClient.importIssuer(importedIssuerKey, issuerMethodDID);
// we need to get the credential id, we want to make the offering
String credentialID = "fdd4bf52-bac7-4f41-a743-5b0580168eb3";
// once we have the issuer and the credential id, we can called the offering function
String jsonOffer = identityClient.getCredentialOffer(importedIssuer, credentialID);
System.out.println(jsonOffer); // it's the json result that we would convert to a QR code
} catch (Exception e) {
System.out.println(e);
}
}
}
<?php
use Bloock\Bloock;
use Bloock\Client\KeyClient;
use Bloock\Client\IdentityClient;
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();
// we must have our Issuer Baby JubJub key identifier. Ex: 6f36448d-49f3-4b0e-aa72-6e55863302e8
$savedIssuerKey = "6f36448d-49f3-4b0e-aa72-6e55863302e8";
$loadedManagedKey = $keyClient->loadManagedKey($savedIssuerKey);
// if we don't have our Issuer entity, here you can import you Issuer from the key
$importedIssuerKey = new Key($loadedManagedKey);
$issuerMethodDID = DidMethod::PolygonID;
$importedIssuer = $identityClient->importIssuer($importedIssuerKey, $issuerMethodDID);
// we need to get the credential id, we want to make the offering
$credentialID = "fdd4bf52-bac7-4f41-a743-5b0580168eb3";
// once we have the issuer and the credential id, we can called the offering function
$jsonOffer = $identityClient->getCredentialOffer($importedIssuer, $credentialID);
$jsonOffering = $jsonOffer; // it's the json result that we would convert to a QR code
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()
// we must have our Issuer Baby JubJub key identifier. Ex: 6f36448d-49f3-4b0e-aa72-6e55863302e8
savedIssuerKey := "6f36448d-49f3-4b0e-aa72-6e55863302e8"
loadedManagedKey, err := keyClient.LoadManagedKey(savedIssuerKey)
if err != nil {
log.Fatalln(err)
}
// if we don't have our Issuer entity, here you can import you Issuer from the key
importedIssuerKey := key.Key{ManagedKey: &loadedManagedKey}
issuerMethodDID := identity.PolygonID
importedIssuer, err := identityClient.ImportIssuer(importedIssuerKey, issuerMethodDID)
if err != nil {
log.Fatalln(err)
}
// we need to get the credential id, we want to make the offering
credentialID := "fdd4bf52-bac7-4f41-a743-5b0580168eb3"
// once we have the issuer and the credential id, we can called the offering function
jsonOffer, err := identityClient.GetCredentialOffer(importedIssuer, credentialID)
if err != nil {
log.Fatalln(err)
}
log.Println(jsonOffer) // it's the json result that we would convert to a QR code
}