Verification
BLOOCK's identity product allows you to act as verification agents as well. Once our users or holders have their credentials, they will want to be able to verify themselves.
At this point, you have two options:
- Using external verifiers.
- Create your own verifier through BLOOCK.
If you want to use our verification process, here is how it works:
- You must create a request, which is nothing more than a QR code to show to the user or Holder you want to verify. In order to create the request you need to create a Validation Query. This functionality is available in our dashboard.
- Then, you will have to wait for your Holder to scan the request with its wallet or software and generate the proof on your request.
It is important to note that within the request that you will show to your Holder, you can specify what things you want to validate. For example, you can determine that you only want to verify that it holds a credential of the type BloockEmployee or you can verify something more specific, such as that your employee's date of birth is less than 2000.
- Once you receive the proof from the Holder, it will be verified, and you will get a result of true or false, verified or not verified. The BLOOCK verification process establishes a customizable logic, adding an expiration time to the requests, by default 60 min. This means that when the request is created it will be invalidated after 60 min. If the user was already verified, after 60 minutes it will have to be verified again.
Examples
- Typescript
- Python
- Java
- PHP
- Golang
import { Bloock, IdentityClient } 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 IdentityClient
const identityClient = new IdentityClient();
// first you will need to get the proof request, it's basically a json string, you can generate this using our Dashboard Validation Queries.
const proofRequest = `{"id":1708674709,"query":{"type":"BloockEmployee","context":"https://api.bloock.com/hosting/v1/ipfs/QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne","allowedIssuers":["*"],"credentialSubject":{"number":{"$lt":5}},"skipClaimRevocationCheck":false},"circuitId":"credentialAtomicQuerySigV2"}`;
// we call the create verification function, using our proof request. This would create a verification process (by default with an expiration of 60min)
const verification = await identityClient.createVerification(proofRequest);
console.log(verification.sessionID) // the session id it's the integer identifier for you verification process, you will need to save it, to then check the status
console.log(verification.verificationRequest) // // the json that you need to convert to QR code, so you user could scan and be verified
// we can call the wait verification function in order to paused until the verification is made (use this function to have a synchronous process)
const verOK = await identityClient.waitVerification(verification.sessionID); // By default 120000 seconds, you can customize
if (!verOK) {
throw new Error("Error waiting for the verification");
}
// finally to check the verification status and to know if the verification was success, you can call this function
const verified = await identityClient.getVerificationStatus(verification.sessionID);
if (!verified) {
throw new Error("Verification failed");
}
console.log("Successfully verified")
} catch (e) {
console.log(e);
}
import os
import bloock
from bloock.client.identity import IdentityClient
# 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 IdentityClient
identity_client = IdentityClient()
# first you will need to get the proof request, it's basically a json string,
# you can generate this using our Dashboard Validation Queries.
proof_request = '''{"id":1708674709,"query":{"type":"BloockEmployee",
"context":"https://api.bloock.com/hosting/v1/ipfs/QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne
","allowedIssuers":["*"],"credentialSubject":{"number":{"$lt":5}},
"skipClaimRevocationCheck":false},"circuitId":"credentialAtomicQuerySigV2"}'''
# we call the create verification function, using our proof request.
# This would create a verification process (by default with an expiration of 60min)
verification = identity_client.create_verification(proof_request)
# the session id it's the integer identifier for you verification process,
# you will need to save it, to then check the status
print(verification.session_id)
# the json that you need to convert to QR code, so you user could scan and be verified
print(verification.verification_request)
# we can call the wait verification function in order to pause
# until the verification is made (use this function to have a synchronous process)
verOK = identity_client.wait_verification(verification.session_id)
if not verOK:
raise Exception("Error waiting for the verification")
# finally to check the verification status and
# to know if the verification was success, you can call this function
verified = identity_client.get_verification_status(verification.session_id)
if not verified:
raise Exception("Verification failed")
print("Successfully verified")
import java.io.IOException;
import com.bloock.sdk.Bloock;
import com.bloock.sdk.client.IdentityClient;
import com.bloock.sdk.entity.identity.VerificationReceipt;
public class Verification {
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 IdentityClient
IdentityClient identityClient = new IdentityClient();
// first you will need to get the proof request, it's basically a json string, you can generate this using our Dashboard Validation Queries.
String proofRequest = "{\"id\":1708674709,\"query\":{\"type\":\"BloockEmployee\",\"context\":\"https://api.bloock.com/hosting/v1/ipfs/QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne\",\"allowedIssuers\":[\"*\"],\"credentialSubject\":{\"number\":{\"$lt\":5}},\"skipClaimRevocationCheck\":false},\"circuitId\":\"credentialAtomicQuerySigV2\"}";
// we call the create verification function, using our proof request. This would create a verification process (by default with an expiration of 60min)
VerificationReceipt verification = identityClient.createVerification(proofRequest);
// the session id it's the integer identifier for you verification process, you
// will need to save it, to then check the status
System.out.println(verification.getSessionID());
// the json that you need to convert to QR code, so you user could scan and be
// verified
System.out.println(verification.getVerificationRequest());
// we can call the wait verification function in order to paused until the verification is made (use this function to have a synchronous process)
// By default 120000 seconds, you can customize
boolean verOK = identityClient.waitVerification(verification.getSessionID(), 120000);
if (!verOK) {
throw new Exception("Error waiting for the verification");
}
// finally to check the verification status and to know if the verification was success, you can call this function
boolean verified = identityClient.getVerificationStatus(verification.getSessionID());
if (!verified) {
throw new Exception("Verification failed");
}
System.out.println("Successfully verified");
} catch (Exception e) {
System.out.println(e);
}
}
}
<?php
use Bloock\Bloock;
use Bloock\Client\IdentityClient;
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 IdentityClient
$identityClient = new IdentityClient();
// first you will need to get the proof request, it's basically a json string, you can generate this using our Dashboard Validation Queries.
$proofRequest = "{\"id\":1708674709,\"query\":{\"type\":\"BloockEmployee\",\"context\":\"https://api.bloock.com/hosting/v1/ipfs/QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne\",\"allowedIssuers\":[\"*\"],\"credentialSubject\":{\"number\":{\"\$lt\":5}},\"skipClaimRevocationCheck\":false},\"circuitId\":\"credentialAtomicQuerySigV2\"}";
// we call the create verification function, using our proof request. This would create a verification process (by default with an expiration of 60min)
$verification = $identityClient->createVerification($proofRequest);
$verificationSessionID = $verification->getSessionID(); // the session id it's the integer identifier for you verification process, you will need to save it, to then check the status
$verificationRequest = $verification->getVerificationRequest(); // the json that you need to convert to QR code, so you user could scan and be verified
// we can call the wait verification function in order to paused until the verification is made (use this function to have a synchronous process)
$verOk = $identityClient->waitVerification($verification->getSessionID()); //By default 120000 seconds, you can customize
if (!$verOk) {
throw new Exception("Error waiting for the verification", 1);
}
// finally to check the verification status and to know if the verification was success, you can call this function
$verified = $identityClient->getVerificationStatus($verification->getSessionID());
if (!$verified) {
throw new Exception("Verification failed", 1);
}
package main
import (
"log"
"os"
"github.com/bloock/bloock-sdk-go/v2"
"github.com/bloock/bloock-sdk-go/v2/client"
)
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 IdentityClient
identityClient := client.NewIdentityClient()
// first you will need to get the proof request, it's basically a json string, you can generate this using our Dashboard Validation Queries.
proofRequest := `{"id":1708674709,"query":{"type":"BloockEmployee","context":"https://api.bloock.com/hosting/v1/ipfs/QmadTvnNKvj2fBDgen35uAp1TfP9pSPVCNeDWw4fitqqne","allowedIssuers":["*"],"credentialSubject":{"number":{"$lt":5}},"skipClaimRevocationCheck":false},"circuitId":"credentialAtomicQuerySigV2"}`
// we call the create verification function, using our proof request. This would create a verification process (by default with an expiration of 60min)
verification, err := identityClient.CreateVerification(proofRequest)
if err != nil {
log.Fatalln(err)
}
log.Println(verification.SessionID) // the session id it's the integer identifier for you verification process, you will need to save it, to then check the status
log.Println(verification.VerificationRequest) // the json that you need to convert to QR code, so you user could scan and be verified
// we can call the wait verification function in order to paused until the verification is made (use this function to have a synchronous process)
verOK, err := identityClient.WaitVerification(verification.SessionID, identity.NewVerificationParams()) // By default 120000 seconds, you can customize
if err != nil {
log.Fatalln(err)
}
if !verOK {
log.Fatalln("error waiting for the verification")
}
// finally to check the verification status and to know if the verification was success, you can call this function
verified, err := identityClient.GetVerificationStatus(verification.SessionID)
if err != nil {
log.Fatalln(err)
}
if !verified {
log.Fatalln("verification failed")
}
log.Println("successfully verified")
}