Local key
With a local key approach, our customers generate, store and use cryptographic keys within a single device or system. In other words, the keys are managed locally on the device or system rather than being managed by a cloud solution nor BLOOCK.
It is commonly used in situations where the device or system needs to operate independently or offline, without relying on external resources to manage its keys.
In local key management, keys are typically generated on the device or system and stored in a secure location, such as a secure element or a trusted platform module (TPM). The keys are used within the device or system, and should never be shared with external entities.
This approach requires careful consideration of security measures to prevent unauthorized access to the keys. It is important to use strong cryptographic algorithms and key lengths, protect the keys from physical tampering or theft, and implement secure storage and backup mechanisms.
Overall, local key management can provide a secure and reliable way to manage cryptographic keys for devices and systems that operate independently or offline. However, it requires careful planning and implementation to ensure that the keys remain secure and protected.
Generating a local key
- Typescript
- Python
- Java
- PHP
- Golang
import { KeyClient, KeyType } from '@bloock/sdk';
const keyClient = new KeyClient();
// Generate a EcP256k key
let _key = await keyClient.newLocalKey(KeyType.EcP256k);
// Generate a Rsa2048 key
_key = await keyClient.newLocalKey(KeyType.Rsa2048);
// Generate a Rsa3072 key
_key = await keyClient.newLocalKey(KeyType.Rsa3072);
// Generate a Rsa4096 key
_key = await keyClient.newLocalKey(KeyType.Rsa4096);
// Generate a Aes128 key
_key = await keyClient.newLocalKey(KeyType.Aes128);
// Generate a Aes256 key
_key = await keyClient.newLocalKey(KeyType.Aes256);
// Generate a BJJ key
_key = await keyClient.newLocalKey(KeyType.Bjj);
from bloock.entity.key.key_type import KeyType
from bloock.client.key import KeyClient
if __name__ == "__main__":
key_client = KeyClient()
# Generate a EcP256k key
local_key = key_client.new_local_key(KeyType.EcP256k)
# Generate a Rsa2048 key
local_key = key_client.new_local_key(KeyType.Rsa2048)
# Generate a Rsa3072 key
local_key = key_client.new_local_key(KeyType.Rsa3072)
# Generate a Rsa4096 key
local_key = key_client.new_local_key(KeyType.Rsa4096)
# Generate a Aes128 key
local_key = key_client.new_local_key(KeyType.Aes128)
# Generate a Aes256 key
local_key = key_client.new_local_key(KeyType.Aes256)
# Generate a BJJ key
local_key = key_client.new_local_key(KeyType.Bjj)
import com.bloock.sdk.client.KeyClient;
import com.bloock.sdk.entity.key.KeyType;
import com.bloock.sdk.entity.key.LocalKey;
public class NewLocalKey {
public static void main(String[] args) throws Exception {
KeyClient keyClient = new KeyClient();
// Generate a EcP256k key
LocalKey localKey = keyClient.newLocalKey(KeyType.EcP256k);
// Generate a Rsa2048 key
localKey = keyClient.newLocalKey(KeyType.Rsa2048);
// Generate a Rsa3072 key
localKey = keyClient.newLocalKey(KeyType.Rsa3072);
// Generate a Rsa4096 key
localKey = keyClient.newLocalKey(KeyType.Rsa4096);
// Generate a Aes128 key
localKey = keyClient.newLocalKey(KeyType.Aes128);
// Generate a Aes256 key
localKey = keyClient.newLocalKey(KeyType.Aes256);
// Generate a BJJ key
localKey = keyClient.newLocalKey(KeyType.Bjj);
}
}
<?php
require "./vendor/autoload.php";
use Bloock\Client\KeyClient;
use Bloock\Entity\Key\KeyType;
$keyClient = new KeyClient();
// Generate a EcP256k key
$key = $keyClient->newLocalKey(KeyType::EcP256k);
// Generate a Rsa2048 key
$key = $keyClient->newLocalKey(KeyType::Rsa2048);
// Generate a Rsa3072 key
$key = $keyClient->newLocalKey(KeyType::Rsa3072);
// Generate a Rsa4096 key
$key = $keyClient->newLocalKey(KeyType::Rsa4096);
// Generate a Aes128 key
$key = $keyClient->newLocalKey(KeyType::Aes128);
// Generate a Aes256 key
$key = $keyClient->newLocalKey(KeyType::Aes256);
// Generate a BJJ key
$key = $keyClient->newLocalKey(KeyType::Bjj);
package main
import (
"github.com/bloock/bloock-sdk-go/v2/client"
"github.com/bloock/bloock-sdk-go/v2/entity/key"
)
func main() {
keyClient := client.NewKeyClient()
// Generate a EcP256k key
_, _ = keyClient.NewLocalKey(key.EcP256k)
// Generate a Rsa2048 key
_, _ = keyClient.NewLocalKey(key.Rsa2048)
// Generate a Rsa3072 key
_, _ = keyClient.NewLocalKey(key.Rsa3072)
// Generate a Rsa4096 key
_, _ = keyClient.NewLocalKey(key.Rsa4096)
// Generate a Aes128 key
_, _ = keyClient.NewLocalKey(key.Aes128)
// Generate a Aes256 key
_, _ = keyClient.NewLocalKey(key.Aes256)
// Generate a BJJ key
_, _ = keyClient.NewLocalKey(key.Bjj)
}
Loading an existing local key
- Typescript
- Python
- Java
- PHP
- Golang
import { KeyClient, KeyType } from '@bloock/sdk';
const keyClient = new KeyClient();
// Load a EcP256k key
let _key = await keyClient.loadLocalKey(KeyType.EcP256k, 'private key');
// Load a Rsa2048 key
_key = await keyClient.loadLocalKey(KeyType.Rsa2048, 'private key');
// Load a Rsa3072 key
_key = await keyClient.loadLocalKey(KeyType.Rsa3072, 'private key');
// Load a Rsa4096 key
_key = await keyClient.loadLocalKey(KeyType.Rsa4096, 'private key');
// Load a Aes128 key
_key = await keyClient.loadLocalKey(KeyType.Aes128, 'password');
// Load a Aes256 key
_key = await keyClient.loadLocalKey(KeyType.Aes256, 'password');
// Load a BJJ key
_key = await keyClient.loadLocalKey(KeyType.Bjj, 'private key');
from bloock.entity.key.key_type import KeyType
from bloock.client.key import KeyClient
if __name__ == "__main__":
key_client = KeyClient()
# Load a EcP256k key
local_key = key_client.load_local_key(KeyType.EcP256k, "private key")
# Load a Rsa2048 key
local_key = key_client.load_local_key(KeyType.Rsa2048, "private key")
# Load a Rsa3072 key
local_key = key_client.load_local_key(KeyType.Rsa3072, "private key")
# Load a Rsa4096 key
local_key = key_client.load_local_key(KeyType.Rsa4096, "private key")
# Load a Aes128 key
local_key = key_client.load_local_key(KeyType.Aes128, "password")
# Load a Aes256 key
local_key = key_client.load_local_key(KeyType.Aes256, "password")
# Load a BJJ key
local_key = key_client.load_local_key(KeyType.Bjj, "private key")
import com.bloock.sdk.client.KeyClient;
import com.bloock.sdk.entity.key.KeyType;
import com.bloock.sdk.entity.key.LocalKey;
public class LoadLocalKey {
public static void main(String[] args) throws Exception {
KeyClient keyClient = new KeyClient();
// Load a EcP256k key
LocalKey localKey = keyClient.loadLocalKey(KeyType.EcP256k, "private key");
// Load a Rsa2048 key
localKey = keyClient.loadLocalKey(KeyType.Rsa2048, "private key");
// Load a Rsa3072 key
localKey = keyClient.loadLocalKey(KeyType.Rsa3072, "private key");
// Load a Rsa4096 key
localKey = keyClient.loadLocalKey(KeyType.Rsa4096, "private key");
// Load a Aes128 key
localKey = keyClient.loadLocalKey(KeyType.Aes128, "password");
// Load a Aes256 key
localKey = keyClient.loadLocalKey(KeyType.Aes256, "password");
// Load a BJJ key
localKey = keyClient.loadLocalKey(KeyType.Bjj, "private key");
}
}
<?php
require "./vendor/autoload.php";
use Bloock\Client\KeyClient;
use Bloock\Entity\Key\KeyType;
$keyClient = new KeyClient();
// Load a EcP256k key
$key = $keyClient->loadLocalKey(KeyType::EcP256k, "private key");
// Load a Rsa2048 key
$key = $keyClient->loadLocalKey(KeyType::Rsa2048, "private key");
// Load a Rsa3072 key
$key = $keyClient->loadLocalKey(KeyType::Rsa3072, "private key");
// Load a Rsa4096 key
$key = $keyClient->loadLocalKey(KeyType::Rsa4096, "private key");
// Load a Aes128 key
$key = $keyClient->loadLocalKey(KeyType::Aes128, "key");
// Load a Aes256 key
$key = $keyClient->loadLocalKey(KeyType::Aes256, "key");
// Load a BJJ key
$key = $keyClient->loadLocalKey(KeyType::Bjj, "private key");
package main
import (
"github.com/bloock/bloock-sdk-go/v2/client"
"github.com/bloock/bloock-sdk-go/v2/entity/key"
)
func main() {
keyClient := client.NewKeyClient()
// Load a EcP256k key
_, _ = keyClient.LoadLocalKey(key.EcP256k, "private key")
// Load a Rsa2048 key
_, _ = keyClient.LoadLocalKey(key.Rsa2048, "private key")
// Load a Rsa3072 key
_, _ = keyClient.LoadLocalKey(key.Rsa3072, "private key")
// Load a Rsa4096 key
_, _ = keyClient.LoadLocalKey(key.Rsa4096, "private key")
// Load a Aes128 key
_, _ = keyClient.LoadLocalKey(key.Aes128, "password")
// Load a Aes256 key
_, _ = keyClient.LoadLocalKey(key.Aes256, "password")
// Load a BJJ key
_, _ = keyClient.LoadLocalKey(key.Bjj, "private key")
}