Author

Topic: Javascript ECDSA / Bitcoin address generation (Read 3016 times)

member
Activity: 110
Merit: 10
February 09, 2014, 08:01:19 AM
#7
@JP, I hate submitting one-line posts, but thanks for sharing that.
jp
member
Activity: 69
Merit: 10
February 08, 2014, 03:29:03 AM
#6
For anyone still looking at it, I wrote an article that may help you: http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript
sr. member
Activity: 336
Merit: 250
Cuddling, censored, unicorn-shaped troll.
November 26, 2013, 06:34:56 PM
#5
Just curious, how did this turn out?  Interested in your experiences with SJCL.

Err, you know TF ran away with thousands of coins and most likely won't come back just to reply to you, right?  Grin
sr. member
Activity: 280
Merit: 257
bluemeanie
November 26, 2013, 05:36:38 PM
#4
Just curious, how did this turn out?  Interested in your experiences with SJCL.
vip
Activity: 1316
Merit: 1043
👻
Look at bitaddress.org source code. It's very easy to read. Near the end there is the wallet details tab. You'll see there which functions are called to get the public key. Search back for the function and see how it's done.

This code is also good as a template for writing in other languages.
eg. some bits chopped out,
Code:
var ecparams = EllipticCurve.getSECCurveByName("secp256k1");

ECKey.prototype.getPub = function () {
if (this.pub) return this.pub;
return this.pub = ecparams.getG().multiply(this.priv).getEncoded(0);
};

ECKey.prototype.getPubKeyHex = function () {
if (this.pubKeyHex) return this.pubKeyHex;
return this.pubKeyHex = Crypto.util.bytesToHex(this.getPub()).toString().toUpperCase();
};
A bit more digging and should have it.
Thanks, did some testing but it's absolutely useless as an vanity address generator as it takes like 600ms to generate on a i7...
hero member
Activity: 784
Merit: 1009
firstbits:1MinerQ
Look at bitaddress.org source code. It's very easy to read. Near the end there is the wallet details tab. You'll see there which functions are called to get the public key. Search back for the function and see how it's done.

This code is also good as a template for writing in other languages.
eg. some bits chopped out,
Code:
var ecparams = EllipticCurve.getSECCurveByName("secp256k1");

ECKey.prototype.getPub = function () {
if (this.pub) return this.pub;
return this.pub = ecparams.getG().multiply(this.priv).getEncoded(0);
};

ECKey.prototype.getPubKeyHex = function () {
if (this.pubKeyHex) return this.pubKeyHex;
return this.pubKeyHex = Crypto.util.bytesToHex(this.getPub()).toString().toUpperCase();
};
A bit more digging and should have it.
vip
Activity: 1316
Merit: 1043
👻
I really can't figure out how to get the ECDSA public key of a private key in Javascript. I looked in SJCL but it apparently does it in some non-standard way and isn't compatible with everything else Huh
Jump to: