Last active
June 20, 2018 09:56
-
-
Save imyourm8/3a98ae96642653733dee194c59dba1a1 to your computer and use it in GitHub Desktop.
Generate Private Key for Loom Using BIP39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add this function to Loom SDK CryptoUtils.cs | |
public static byte[] GeneratePrivateKey(byte[] seed) { | |
byte[] publicKey32; | |
byte[] privateKey64; | |
Ed25519.KeyPairFromSeed(out publicKey32, out privateKey64, seed); | |
return privateKey64; | |
} | |
// You can use any BIP39 implementation. In this example i used https://github.com/ByronAP/BIP39.NET-Portable | |
var mnemonic = "spin sunset pact nature enhance include fatigue occur blind wire inner foot"; | |
var importer = new Bitcoin.BIP39.BIP39(mnemonic); | |
var seed = new byte[32]; | |
for(int i = 0; i < 32; ++i) { | |
seed[i] = importer.SeedBytes[i]; // use only first 32 bytes | |
} | |
PrivateKey = Loom.Unity3d.CryptoUtils.GeneratePrivateKey(seed); // generate private key - ready to use. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment