Xcb.Net 2.2.1

.NET 5.0 .NET Core 3.0 .NET Standard 2.1
dotnet add package Xcb.Net --version 2.2.1
NuGet\Install-Package Xcb.Net -Version 2.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xcb.Net" Version="2.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xcb.Net --version 2.2.1
#r "nuget: Xcb.Net, 2.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xcb.Net as a Cake Addin
#addin nuget:?package=Xcb.Net&version=2.2.1

// Install Xcb.Net as a Cake Tool
#tool nuget:?package=Xcb.Net&version=2.2.1


This is a client library of core-coin blockchain in .Net for managing Private/Public keys, creating and signing transactions of the blockchain.

Usage of keys

//can be byte array as well
var privateKey =

var networkId = 1;

//import key from stored private key
var key = new XcbECKey(privateKey, networkId);

//generate new key randomely
var newKey = XcbECKey.GenerateKey(networkId);

//generate wallet address from the key
var address = key.GetAddress();


//getting the public key bytes
var publicKey = key.GetPublicKey();

//getting the public key hex
var publicKeyHex = publicKey.ToHex();

//"hello" in hex is "0x666f6f"
var message = "666f6f"

//signing the message (it will prehash the message with SHA3NIST)
var signatureBytes = key.SignHashOfMessage(message.HexToByteArray());

//public key can be recovered from the signature
var recoveredPublicKey = XcbECKey.GetPublicKeyFromSignature(signatureBytes).ToHex();


//wallet address can be recovered from public key
var recoveredAddress = XcbECKey.GetAddressFromPublicKey(publicKey,networkId);

Assert.Equal(address, recoveredAddress);

Usage of transactions

var networkId = 11;

// creating the XcbECKey with the provided private-key
XcbECKey key = new XcbECKey("69bb68c3a00a0cd9cbf2cab316476228c758329bbfe0b1759e8634694a9497afea05bcbf24e2aa0627eac4240484bb71de646a9296872a3c0e", networkId);

// creating a simple transaction
// the destination address (the fund receiver) is ce276773ac97d16855a3c8faa45399136b56d4194860
// the fund amount which will be sent is 200 units
// nonce is zero (this is the first transaction from this private key)
Transaction transaction = new Transaction(to: "ce276773ac97d16855a3c8faa45399136b56d4194860",
amount: BigInteger.Parse("200"),
nonce: BigInteger.Parse("0"),
energyLimit: BigInteger.Parse("999999"),
energyPrice: BigInteger.Parse("10"),
data: "");


// signing the transaction with XcbECKey
transaction.Sign(key, 0);

// getting the rlp encoding of the signed trasnaction
var encoded = transaction.GetRlpEncoding();

// getting the hex of the encoded data
var encodedHex = encoded.ToHex(true);

// parse a transaction from encoded data
var transaction2 = Transaction.Decode(encoded);

// re-encode the transaction
var reEncode = transaction2.GetRlpEncoding();


// assert checking if everything is fine
Assert.Equal(encoded, reEncode);

Usage of Hierarchical Deterministic Wallet (HD-Wallet)

// suppose you have an master extended private key
var masterExtPrivateKey = (ExtendedPrivateKey)"004e843c2991930124e5a0711c6a8be763f5b605ee80f089dfa9cbec5ebb20123dcc787b162a7baf37b0251f6bdd4ac14ae111491ef391cf0d1413821ed67083c855c6db4405dd4fa5fdec39e1c761be1415623c1c202c5cb5176e578830372b7e07eb1ef9cf71b19518815c4da0fd2d3594"

// you can also generate a new random master extended private key
var masterExtPrivateKey = ExtendedPrivateKey.GenerateRandomMaster();

// or generate a deterministic master extended private key using a seed
var seed = byte[64];

// this key is the master key which m in derivaiton path stands for this key
var masterExtPrivateKey = ExtendedPrivateKey.SeedToMaster(seed);

// with an master extended private key you are able to create a private hd wallet
// "m/44'/654'/0'/0'" is the derivation path
var privateWallet = PrivateWallet.GetPrivateWalletAtSpecificDerivationPath(masterPrivateKey,  "m/44'/654'/0'/0'");

// you can derive a child private key
// this private key derivation path will be "m/44'/654'/0'/0'/20"
var derivedPrivateKey = privateWallet.GetPrivateKey(20);

// this private key derivation path will be "m/44'/654'/0'/0'/14/36/15"
var derivedPrivateKey = privateWallet.GetPrivateKey(14,36,15); // you can also pass "14/36/15"

// you can get XcbECKey from a wallet directly too
var xcbeckey = privateWallet.GetXcbECKey("14/36/15");

//you can also get public key or address from private hd wallet
// this public key derivation path will be "m/44'/654'/0'/0'/14/36/15"
var derivedPublicKey = privateWallet.GetPublicKey(14,36,15); // you can also pass "14/36/15"

var networkId = 1;
// this address derivation path will be "m/44'/654'/0'/0'/14/36/15"
var derivedAddress = privateWallet.GetAddress(networkId, 14, 36, 15) // you can also pass "14/36/15"

// you can also have public hd wallet, which they only have access to public key and address not private keys
// mostly they are used for watch-only wallets

// with a master private key and a derivation path you can create a public hd wallet
var publicWallet = PrivateWallet.GetPublicWalletAtSpecificDerivationPath(masterPrivateKey,  "m/44'/654'/0'/0'");

// same as private hd wallet you can derive public keyes or addresses at any derivation path after "m/44'/654'/0'/0'"
// this public key derivation path will be "m/44'/654'/0'/0'/14/36/15"
var derivedPublicKey = publicWallet.GetPublicKey(14, 36, 15); // you can also pass "14/36/15"

var networkId = 1;
// this address derivation path will be "m/44'/654'/0'/0'/14/36/15"
var derivedAddress = publicWallet.GetAddress(networkId, 14, 36, 15) // you can also pass "14/36/15"

// public hd wallets cannot derive private keys

Notice: if you create public/private hd wallet from a pair of master extended keys they will be associated with each other, which means a private key derived at m/44'/654'/0'/0'/8 can sign a message which a public key derived from public hd wallet at m/44'/654'/0'/0'/8 can verify it.

also remember that the standard derivation path for coreblockchain XCB is m/44'/654'/0'/0'


CORE License

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.1 2,006 10/28/2022
2.2.0 623 10/17/2022
2.1.0 259 10/14/2022
2.0.0 268 9/27/2022
1.0.5 1,377 8/30/2022
1.0.4 495 7/20/2022
1.0.3 315 6/28/2022
1.0.2 285 6/28/2022
1.0.1 289 6/28/2022