NET API
HSM Dinamo
Loading...
Looking for...
No entries found
bchain_get_pub.cs

Example of public key recovery using the blockchain module.

See Note on examples.
using Dinamo.Hsm;
using System;
using System.Text;
using System.IO;
namespace BchainGetPub
{
class Program
{
private static String addr = "127.0.0.1";
private static String userId = "test";
private static String userPwd = "12345678";
static void Main(string[] args)
{
String keyId = "key";
try {
/*
Connect to HSM
*/
api.Connect(addr, userId, userPwd);
Console.Out.WriteLine("Connected successfully!");
/*
Generates the XPriv BIP-32 key.
*/
api. BchainCreateXPrvBip32(keyId, DinamoApi.DN_BCHAIN_VER_BIP32_MAINNET, false, false);
Console.Out.WriteLine("Key generated successfully!");
/*
Recover the public key from the generated private key.
*/
byte[] pub = api. BchainGetPubKey(DinamoApi.DN_BCHAIN_PBK_BIP340, keyId);
Console.Out.WriteLine("Public key recovered successfully!");
Console.Out.WriteLine("Public key: " + BitConverter.ToString(pub).Replace("-", ""));
} catch (DinamoException e) {
Console.Out.WriteLine(e.Message);
} finally{
/*
Disconnects from HSM
*/
api.Disconnect();
Console.Out.WriteLine("Successfully disconnected!");
}
}
}
}
Low-level class for accessing the HSM. To use this class you need to understand more ...
Definition DinamoApi.cs:15
const byte DN_BCHAIN_VER_BIP32_MAINNET
Definition DinamoApi.cs:2394
const byte DN_BCHAIN_PBK_BIP340
Definition DinamoApi.cs:2512
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
Exception class for errors from Dinamo.
Definition DinamoException.cs:10
override string Message
Definition DinamoException.cs:42
void BchainCreateXPrvBip32(string szId, byte bVersion, bool isExportable, bool isTemporary)
Creates an XPriv private key in BIP32 format.
Definition DinamoClient.cs:7016
byte[] BchainGetPubKey(byte bType, string szId)
Retrieves a public key using the blockchain module.
Definition DinamoClient.cs:7148
void RemoveObjectIfExists(string ObjectId)
Removes an object from the HSM, if it exists.
Definition DinamoClient.cs:2410
void Connect(string User, string Password)
Establishes an encrypted connection to the HSM using the load balance settings.
Definition DinamoClient.cs:562
void Disconnect(bool flagClose)
Terminates the connection to the HSM.
Definition DinamoClient.cs:814
Namespace denoting a set of functions for accessing the HSM Dinamo and their respective exceptions.
Definition DinamoClient.cs:12