A lightweight library to generate keys commonly used for the terra ecosystem. RawKey, Mnemonic & CLI Key
- Written in C#, with type definitions
- Easy key management for anyone building on the Terra Ecosystem
- Works with all .Net Environments
Grab the latest version off Nuget
dotnet add package Terra.Microsoft.Keys
Please make sure to add the following nuget Packages into your .csproj file
<ItemGroup>
<PackageReference Include="Cryptography.ECDSA.Secp256k1" Version="1.1.3" />
<PackageReference Include="NBitcoin" Version="7.0.23" />
<PackageReference Include="RandomStringCreator" Version="2.0.0" />
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
<PackageReference Include="Terra.Microsoft.Extensions" Version="1.0.1" />
<PackageReference Include="Terra.Microsoft.ProtoBufs" Version="1.0.1" />
</ItemGroup>
Terra.Microsoft.Keys can be used for Mobile & Web Developers, or SDK Developers looking to extend the Terra Platform. Supports all Microsoft Technologies from Xamarin, MAUI, ASP & Unity.
MnemonicKey GenerateMnemonic() {
// Create a key out of a mnemonic string (recovery words)
string recoveryWords = "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius";
// If creating a random mnemonic, don't pass the recovery words
return new MnemonicKey(recoveryWords);
}
//ONLY FOR TESTING & DEVELOPMENT PURPOSES: DO NOT EXPOSE PRIVATE KEY, IT COULD RISK EXPOSING THE WALLET FUNDS IF LOST
MnemonicKey GenerateMnemonicWithPrivateKey() {
string recoveryWords = "notice oak worry limit wrap speak medal online prefer cluster roof addict wrist behave treat actual wasp year salad speed social layer crew genius";
// Create a key out of a mnemonic string (recovery words)
var mnmonic = new MnemonicKey(recoveryWords, exposePrivateKey: true);
Console.WriteLine($"PrivateKey: {mnmonic.privateKeyExposed}");
return mnmonic;
}
If you are using Terra.Microsoft.Keys for Unity, please make sure to install the following asset in your project, and follow the installation instructions above
This software is licensed under the MIT license. See LICENSE for full disclosure.
© 2022 TerraMystics.