<p>You can find information how to calculate Public key from Private here <a href="https://bitcoin-math.000webhostapp.com" rel="nofollow noreferrer">https://bitcoin-math.000webhostapp.com</a> Also, you can find Doubling, Addition and Scalar multiply functions on C# without NBitcoin class Key, BigInteger is used only.</p>

CC BY-SA 4.0
2022-02-04T19:54:51.930Z
2022-02-04T19:54:51.930Z
Messenger
<p>I have implemented it by javascript, maybe it can help you.</p>
<pre><code>//usage:
//$ yarn add bip32 bip39
// node --version is 16.1.0

const bs58check = require('bs58check');
const bip39 = require(&quot;bip39&quot;);
const bip32 = require(&quot;bip32&quot;);
const createHash = require('create-hash');


function addr(node) {
    var hash = node.identifier; // hash160 of the publicKey

    const payload = Buffer.allocUnsafe(21);

    var version = 0x0;
    payload.writeUInt8(version, 0);

    hash.copy(payload, 1);

    var address = bs58check.encode(payload);
    return address;
}

var puzzle = &quot;some puzzle you inputting&quot;;

var entropy = createHash(&quot;sha256&quot;).update(puzzle).digest().toString(&quot;hex&quot;);
console.log(&quot;entropy: &quot; + entropy);

var mnemonic = bip39.entropyToMnemonic(entropy);
console.log(&quot;mnemonic: &quot; + mnemonic);

var passphrase = &quot;&quot;;

var seed = bip39.mnemonicToSeedSync(mnemonic, passphrase);
var master = bip32.fromSeed(seed); // m

// generate 10 btc addresses...
for (var i = 0; i &lt; 3; i++) {
    var node = master.derivePath(&quot;m/44'/0'/0'/1/&quot; + i);
    var address = addr(node);
    console.log(&quot;BTC #&quot; + i + &quot;: &quot; + address);
}

</code></pre>

CC BY-SA 4.0
2021-08-26T02:13:40.320Z
2021-08-26T02:13:40.320Z
Ethan
<p>I want to take a private key as input from the user and convert it to a wallet address using C#.</p>
<p>I have seen this in a tutorial to generate a random key:</p>
<pre><code>Key privateKey = new Key();
PubKey publicKey = privateKey.PubKey;
Console.WriteLine(publicKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main));
</code></pre>
<p>How do I convert a private key string from the user to a wallet address for main net?</p>

<address-generation><private-key-import><c#><nbitcoin>
Generate address of 'private key' from user input
svvc
# Generate address of 'private key' from user input

(Asked by: username_0 on 2020-11-21)

I want to take a private key as input from the user and convert it to a wallet address using C#.
I have seen this in a tutorial to generate a random key:
Key privateKey = new Key();
PubKey publicKey = privateKey.PubKey;
Console.WriteLine(publicKey.GetAddress(ScriptPubKeyType.Legacy, Network.Main));

How do I convert a private key string from the user to a wallet address for main net?

**Tags:** address-generation, private-key-import, c#, nbitcoin


---

## 2 answers

### Answer by username_1 on 2022-02-04. Score: 0

You can find information how to calculate Public key from Private here <https://bitcoin-math.000webhostapp.com> Also, you can find Doubling, Addition and Scalar multiply functions on C# without NBitcoin class Key, BigInteger is used only.


---

### Answer by username_2 on 2021-08-26. Score: 0

I have implemented it by javascript, maybe it can help you.
//usage:
//$ yarn add bip32 bip39
// node --version is 16.1.0

const bs58check = require('bs58check');
const bip39 = require("bip39");
const bip32 = require("bip32");
const createHash = require('create-hash');


function addr(node) {
    var hash = node.identifier; // hash160 of the publicKey

    const payload = Buffer.allocUnsafe(21);

    var version = 0x0;
    payload.writeUInt8(version, 0);

    hash.copy(payload, 1);

    var address = bs58check.encode(payload);
    return address;
}

var puzzle = "some puzzle you inputting";

var entropy = createHash("sha256").update(puzzle).digest().toString("hex");
console.log("entropy: " + entropy);

var mnemonic = bip39.entropyToMnemonic(entropy);
console.log("mnemonic: " + mnemonic);

var passphrase = "";

var seed = bip39.mnemonicToSeedSync(mnemonic, passphrase);
var master = bip32.fromSeed(seed); // m

// generate 10 btc addresses...
for (var i = 0; i < 3; i++) {
    var node = master.derivePath("m/44'/0'/0'/1/" + i);
    var address = addr(node);
    console.log("BTC #" + i + ": " + address);
}


---

