TransWikia.com

Generating Bitcoin address from private key in browser console

Bitcoin Asked by rcfanboi on January 26, 2021

I am a newbie Bitcoin evangelist and I have a recommendation to see all the code responsible for computing yourPublicKey from yourPrivateKey, especially for big deal addresses.
The easiest way to allow Bitcoin users to see the code is to write it in Javascript to let them run it on console, because any PC user has a browser and almost nobody has Python or any other interpreter. I saw a step-by-step manual in this answer to How can I generate a bitcoin address? but I still have some obstructions to produce one single sheet of code ready for running in console.
Please help me to write that code to make my recommendation easy to follow.

2 Answers

If JavaScript is your language of choice you might be interested in bcoin - the bitcoin full node implementation and modular library written in JS. It's designed for use in nodejs environments but can be compiled for the browser as well.

This guide in particular walks you through the process: https://bcoin.io/guides/webapp.html

Please note that web browsers are insecure environments for cryptography and especially cryptocurrency, this guide is based around public keys and testnet addresses to avoid any real risk. If you try to manage private keys in a browser's JS environment you need to be extremely careful (use an offline computer if possible, no "chrome extensions" etc)

Answered by pinhead on January 26, 2021

You need to learn to use Browserify to pack your javascript libraries, so that you can call it from a browser with require(). The instructions for the library used by the answer can be found here (you don't need step 5). Once you do that you should create a folder with an html page and the script you created. Add to the html page <script src="bitcoinjs.js"></script>. Open the html file in your browser, then you should be able to run your script.

Answered by MCCCS on January 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP