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

Example of generating an EdDsa key and signature using the blockchain module.

See Note on examples.
using Dinamo.Hsm;
using System;
using System.Text;
using System.IO;
namespace BchainEddsaSign
{
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 EdDsa key marked for use in the blockchain module.
*/
api. BchainGenerateKey(DinamoClient.KEY_ALG.ALG_ECX_ED25519, keyId, false, false);
Console.Out.WriteLine("Key generated successfully!");
byte[] data = Encoding.UTF8.GetBytes("Dinamo Networks");
/*
Signs the data using the generated EdDsa key.
*/
byte[] signature = api. BchainEdDsaSign(DinamoApi.DN_BCHAIN_EDDSA_SIG_PURE,
data, keyId);
Console.Out.WriteLine("Signature generated successfully!");
Console.Out.WriteLine("Signature: " + BitConverter.ToString(signature).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_EDDSA_SIG_PURE
Definition DinamoApi.cs:2573
const string DN_BCHAIN_EDDSA_CSTR_UNUSED
Definition DinamoApi.cs:2570
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
KEY_ALG
Definition DinamoClient.cs:227
Exception class for errors from Dinamo.
Definition DinamoException.cs:10
override string Message
Definition DinamoException.cs:42
void BchainGenerateKey(Dinamo.Hsm.DinamoClient.KEY_ALG dwAlg, string szId, bool isExportable, bool isTemporary)
Generates a marked key for use in the blockchain module.
Definition DinamoClient.cs:7264
byte[] BchainEdDsaSign(byte bType, string szCtxStr, byte[] pbData, string szId)
Generates an EdDsa signature using the blockchain module.
Definition DinamoClient.cs:7239
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