Bitcoin Forum
June 23, 2024, 01:34:17 PM *
News: Voting for pizza day contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Calculate public key from private  (Read 1537 times)
JPage (OP)
Full Member
***
Offline Offline

Activity: 399
Merit: 105



View Profile
August 03, 2014, 10:11:08 PM
 #1

I am not so sure about this ECSDA stuff.  But I do know it is a bit difficult to calculate the private key from a public key. Smiley

However, I understand the other way around is quite easy.  Does anyone have a formula for that?

How do I calculate the public key when I am already in possession of the private key?

micaman
Sr. Member
****
Offline Offline

Activity: 345
Merit: 500



View Profile WWW
August 03, 2014, 10:54:04 PM
 #2

Check this topic:
https://bitcointalk.org/index.php?topic=78132.0

I believe it's the same question.
rz20
Legendary
*
Offline Offline

Activity: 1330
Merit: 1001


View Profile
August 03, 2014, 11:39:17 PM
 #3

In bitaddress you have all the tools to make it https://www.bitaddress.org/
TimS
Sr. Member
****
Offline Offline

Activity: 250
Merit: 253


View Profile WWW
August 04, 2014, 12:23:52 AM
Last edit: August 04, 2014, 12:35:34 AM by TimS
 #4

In mathematical terms: pubKey = privKey * G, where G is a specific base point on the elliptic curve y^2 = x^3 + 7 mod (2^256 - 2^32 - 977) (privKey is a number, G and pubKey are points on the curve)
In programmatic terms (the C# one is about as simple as it goes, for self-contained solutions): http://bitcoin.stackexchange.com/a/25039/12034
If you just want an easy, do-it-for-me sort of thing, enter your private key at https://brainwallet.github.io/
R2D221
Hero Member
*****
Offline Offline

Activity: 658
Merit: 500



View Profile
August 04, 2014, 02:34:33 AM
 #5

If you just want an easy, do-it-for-me sort of thing, enter your private key at https://brainwallet.github.io/
You should NEVER enter you private key in any website. If you want to use it, you should download it and run it locally first.

An economy based on endless growth is unsustainable.
bigasic
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1000



View Profile
August 04, 2014, 02:02:44 PM
 #6

Im not sure how this secure is, but I get a computer that I never use for bitcoin purposes, go to bitaddress.org then disconnect my internet connection and then do the random thing, then print out X amount of public and private keys that is directly connected to my printer. I think thats about as secure as im going to get.
JPage (OP)
Full Member
***
Offline Offline

Activity: 399
Merit: 105



View Profile
August 04, 2014, 05:50:59 PM
 #7

In mathematical terms: pubKey = privKey * G, where G is a specific base point on the elliptic curve y^2 = x^3 + 7 mod (2^256 - 2^32 - 977) (privKey is a number, G and pubKey are points on the curve)
In programmatic terms (the C# one is about as simple as it goes, for self-contained solutions): http://bitcoin.stackexchange.com/a/25039/12034
If you just want an easy, do-it-for-me sort of thing, enter your private key at https://brainwallet.github.io/

Thanks TimS - you are awesome.  That's what I wanted.
tianshiqmdvb147
Member
**
Offline Offline

Activity: 68
Merit: 10


View Profile
August 05, 2014, 03:20:40 AM
 #8

Check this topic:
https://bitcointalk.org/index.php?topic=78132.0

I believe it's the same question.
What?what said?

QORA | 2ND GEN | NEW SOURCE CODE | QMEhgTSMU5wkScHrvJfsTQr48GJkB23Xti
Get Daily Free SignatureCoins.T1odXbrCUVdS59Hm2BoiSg8hSjtepw4Qbh
bigasic
Hero Member
*****
Offline Offline

Activity: 924
Merit: 1000



View Profile
August 05, 2014, 04:22:57 AM
 #9

i hope the guy that used this address 1Q7f2rL2irjpvsKVys5W2cmKJYss82rNCy doesn't use it anymore.. the passphrase for the private key, etc is satoshi nakamoto, lol...... I wonder how many easy addresses were made.. this is just another great reason to make sure its fucking secure...
ForgottenPassword
Full Member
***
Offline Offline

Activity: 154
Merit: 100


View Profile
August 05, 2014, 04:32:01 AM
 #10

i hope the guy that used this address 1Q7f2rL2irjpvsKVys5W2cmKJYss82rNCy doesn't use it anymore.. the passphrase for the private key, etc is satoshi nakamoto, lol...... I wonder how many easy addresses were made.. this is just another great reason to make sure its fucking secure...

There are a couple of bots that are "mining" brain wallets. They're using common password dictionaries to generate thousands of brainwallets and emptying any funds.

Here is the address of one of them:
https://blockchain.info/address/1brain7kAZxPagLt2HRLxqyc3VgGSa1GR

Currently 12.4BTC profit for the owner.

Apparently some unlucky guy accidentally sent 10BTC to the address "correct horse battery staple" (default on some brainwallet sites):
https://blockchain.info/tx/31ff3dc5a0b490e0dc709a27fc50b1dc9c6d17a82b7bae36244293464352fb38

It was taken by the 1brain bot.

I have private messages disabled. Send me an email instead. My contact details can be found here.

Tip Address: 13Lwo1hK5smoBpFWxmqeKSL52EvN8U7asX
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 05, 2014, 07:04:43 AM
 #11

the passphrase for the private key, etc is satoshi nakamoto, lol...... I wonder how many easy addresses were made.

[offtopic]
Do not wonder. You can calc them yourself. About 18k are already seen in the blockchain.
Read this reddit article http://www.reddit.com/r/Bitcoin/comments/1zti1p/17956_hacked_brainwallet_passwords/
and visit http://chbs.esy.es
[/offtopic]

Answering the subject question.
Here is my code for Qt/C++/openssl (rewritten from original bitcoin-qt)

Code:
static EC_KEY* EC_KEY_regenerate_key ( const quint8* priv )
{
  static EC_KEY* eckey = EC_KEY_new_by_curve_name ( NID_secp256k1 );
  static const EC_GROUP* group = EC_KEY_get0_group ( eckey );
  BIGNUM* privkey = BN_bin2bn ( priv, 32, BN_new ( ) );
  BN_CTX* ctx = BN_CTX_new ( );
  EC_POINT* pubkey = EC_POINT_new ( group );
  EC_POINT_mul ( group, pubkey, privkey, 0, 0, ctx );
  EC_KEY_set_private_key ( eckey, privkey );
  EC_KEY_set_public_key ( eckey, pubkey );
  EC_POINT_free ( pubkey );
  BN_CTX_free ( ctx );
  BN_clear_free ( privkey );
  return eckey;
}
//--------------------------------------------------------------
const char* MyKey32::getPublicKey ( char* buf ) const
{
  quint8 pubkey [65];
  quint8* pbegin = pubkey;
  i2o_ECPublicKey ( EC_KEY_regenerate_key ( constPtr ( ) ), &pbegin );
  fassert ( pubkey [0] == 0x04 );
  memcpy ( buf, pubkey + 1, 64 ); // without 0x04 prefix
  return (const char*)buf;
}
//--------------------------------------------------------------
const QByteArray MyKey32::getPublicKeyClassic ( ) const
{
  char buf [65];
  getPublicKey ( buf + 1 );
  buf [0] = 0x04;
  return QByteArray ( buf, 65 );
}
//--------------------------------------------------------------
const QByteArray MyKey32::getPublicKeyCompressed ( ) const
{
  char buf [65];
  getPublicKey ( buf + 1 );
  buf [0] = 0x02 + ( buf [64] & 1 );
  return QByteArray ( buf, 33 );
}
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!