Last active
August 29, 2015 14:12
-
-
Save braydonf/c76fcfcfc634dd1183c0 to your computer and use it in GitHub Desktop.
elliptic.js
This file contains hidden or 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
// elliptic.js | |
var EC = require('elliptic').ec | |
var ec = new EC('secp256k1') | |
var point = ec.g.mul('f2cc9d2b008927db94b89e04e2f6e70c180e547b3e5e564b06b8215d1c264b53') | |
// <EC Point x: 495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba y: 41a2d4539b40a914e755a3a24367ce731195c354480dad4f2ce9e9c8f8003bce> | |
var point1 = e.curve.pointFromX(true, '495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba') | |
// <EC Point x: 495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba y: 3dc9318f0a7ae59bafbccef98692931dc6a8c28208333e88de5c031766f70777> | |
var point2 = e.curve.pointFromX(false, '495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba') | |
// <EC Point x: 495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba y: c236ce70f5851a6450433106796d6ce239573d7df7ccc17721a3fce79908f4b8> | |
var keypair = e.keyPair('f2cc9d2b008927db94b89e04e2f6e70c180e547b3e5e564b06b8215d1c264b53') | |
// <Key priv: f2cc9d2b008927db94b89e04e2f6e70c180e547b3e5e564b06b8215d1c264b53 pub: null > | |
var pub = keypair.getPublic(true, 'hex') | |
// incorrect pub: '02495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba' | |
// bitcoinjs | |
var bitcoinjs = require('bitcoinjs-lib'); | |
var eckey = bitcoinjs.ECKey.fromWIF('L5MgSwNB2R76xBGorofRSTuQFd1bm3hQMFVf3u2CneFom8u1Yt7G') | |
var priv = eckey.d.toHex() | |
// 'f2cc9d2b008927db94b89e04e2f6e70c180e547b3e5e564b06b8215d1c264b53' | |
var pub = eckey.pub.toHex() | |
// currect pub: '03e275faa35bd1e88f5df6e8f9f6edb93bdf1d65f4915efc79fd7a726ec0c21700' | |
// lookup the associated address of the different results | |
var bitcore = require('bitcore'); | |
var PublicKey = bitcore.PublicKey; | |
var Address = bitcore.Address; | |
var address = new Address.fromPublicKey(new PublicKey('03e275faa35bd1e88f5df6e8f9f6edb93bdf1d65f4915efc79fd7a726ec0c21700')); | |
// <Address: 19FKem9YKbszEwsXRLw9WnkggMQrdLbAhE, type: pubkeyhash, network: livenet> | |
var address1 = new Address.fromPublicKey(new PublicKey('02495f99aa21d7e60ff3f065f2a14e67612b29b1cb5af7b7fc4738cede6f2d9eba')); | |
// <Address: 1279WAo1PmBoYmu12UeQdsGN2ZqPqPuCzb, type: pubkeyhash, network: livenet> | |
// bitcoin-qt debug window | |
importprivkey "L5MgSwNB2R76xBGorofRSTuQFd1bm3hQMFVf3u2CneFom8u1Yt7G" | |
dumpprivkey "19FKem9YKbszEwsXRLw9WnkggMQrdLbAhE" | |
// outputs: L5MgSwNB2R76xBGorofRSTuQFd1bm3hQMFVf3u2CneFom8u1Yt7G | |
dumpprivkey "1279WAo1PmBoYmu12UeQdsGN2ZqPqPuCzb" | |
// outputs "Private key for address 1279WAo1PmBoYmu12UeQdsGN2ZqPqPuCzb is not known (code -4)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment