public WalletData CreateNewWalletData(Keys _Keys, string _pass, string _walletName) { WalletData WalletDataLocal = new WalletData(); WalletDataLocal.Keydata = _Keys; WalletDataLocal.passCode = PasswordManager.GenerateSaltedOutputBytes(_pass); WalletDataLocal.walletName = _walletName; //Now we got the object filled, store its data WalletData.WriteWalletData(WalletDataLocal, _walletName); return(WalletDataLocal); }
/*OK, as far as I figured out now we need to do the following: * - Step 1: Generate private spend key (SHA 256 hash of passcode + username) * - Step 2: Generate private view key (SHA 256 hash of passcode + hash of private spend key) * - Step 3: Generate public spend key (ed25519 scalarmult of private spend key) * - Step 4: Generate public view key (ed25519 scalarmult of private view key) * - Step 5: Add network byte to public spend and view key * - Step 6: this 65 byte needs to be hashed with keccak 256 * - Step 7: Add first 4 bytes from hashed value to the 67 bytes (at the end) * - Step 8: Convert the 71 bytes to Base58 * - Step 9: Maybe we'd like to have one "superkey" which unlocks private spend and view key...who knows * - Known bug: prefix */ public static Keys GenerateKeySet(string _passCode, string _walletName) { Keys keyStorage = new Keys(); byte[] privateSpendKey = KeyManager.GeneratePrivateSpendKey(_passCode, _walletName); //Done byte[] privateViewKey = KeyManager.GeneratePrivateViewKey(_passCode, privateSpendKey); //Done byte[] publicSpendKey = KeyManager.GeneratePubSpendKey(privateSpendKey); //Done byte[] publicViewKey = KeyManager.GeneratePubViewKey(privateViewKey); //Done byte[] networkByte = KeyManager.StringToByteArray(Config.GetConfiguration().NetworkPreFix); //Done byte[] hashedKey = KeyManager.HashKeccak256(publicSpendKey, publicViewKey, networkByte); //Done string publicAddress = KeyManager.ConvertToPubAddressChunked(hashedKey); //Done //Store the data of the wallet keyStorage.StoreKeySet(privateSpendKey, privateViewKey, publicSpendKey, publicViewKey, networkByte, hashedKey, publicAddress, PasswordManager.GenerateSaltedOutputBytes(_passCode), _walletName); return(keyStorage); //Return the public address, the rest we have to store somewhere safe... }