Bitcoin Forum
May 06, 2024, 04:01:02 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Convert key to addr/sign with php or python (no bitcoin core / remote API)  (Read 877 times)
Kazimir (OP)
Legendary
*
Offline Offline

Activity: 1176
Merit: 1001



View Profile
April 09, 2015, 01:41:15 PM
Last edit: April 09, 2015, 02:38:43 PM by gmaxwell
 #1

Suppose on my website, I have a private key. Whether in base58 / WIF format, or hex, whatever, I have the 256 bits.

Now I want to convert this server side to an address. Preferably in PHP, but Python would work as well. I do NOT have a Bitcoin core client running there, and it can NOT depend on a remote API like blocktrail.com or blockchain.info or blockcypher.com etc. I need to do this purely server side.

Is there a trustworthy piece of code or library that can do this?

--- Mod merged from another post ----

Similar to my question about converting private keys to addresses, I also would like to create and sign a transaction on my webserver. Again preferably in PHP, but Python would work as well. I do NOT have a Bitcoin core client running there, and it can NOT depend on a remote API like blocktrail.com or blockchain.info or blockcypher.com etc. I need to do this purely server side.

Suppose I have a private key + address along with all its spendable outputs (i.e. unspent outputs with txids etc), and a 2nd address where I want to send some coins. So all required data is there. How would I got about creating the tx, signing it, so I can manually push it to the network later?

Is there a trustworthy piece of code or library that can do this? I guess something like BitcoinJS, but in PHP or Python?

In theory, there's no difference between theory and practice. In practice, there is.
Insert coin(s): 1KazimirL9MNcnFnoosGrEkmMsbYLxPPob
1714968062
Hero Member
*
Offline Offline

Posts: 1714968062

View Profile Personal Message (Offline)

Ignore
1714968062
Reply with quote  #2

1714968062
Report to moderator
The trust scores you see are subjective; they will change depending on who you have in your trust list.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714968062
Hero Member
*
Offline Offline

Posts: 1714968062

View Profile Personal Message (Offline)

Ignore
1714968062
Reply with quote  #2

1714968062
Report to moderator
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4158
Merit: 8382



View Profile WWW
April 09, 2015, 02:30:29 PM
Last edit: April 09, 2015, 05:36:38 PM by gmaxwell
 #2

Is there a trustworthy piece of code or library that can do this?
Trustworthy? Not as far as I am aware of.  There are various pieces of software which have never been subject to peer review, have no tests, have no comments, could not possibly be free of timing sidechannels, etc. Several times people have posted things in this subforum which were outright backdoored (I'd link, but I delete the posts); exploiting the fact that most people don't have the time or patience to audit them. (Of course, all this can also be said for the various cloud services, plus they have a whole host of additional potential weaknesses.)

I wouldn't expect to find one any time soon, writing software in PHP and Python is incompatible with avoiding timing sidechannels or leaving around private key data in memory (not to mention slow); so it's not a first choice for the development of conscientious cryptographic software; and it takes a tremendous amount of work to produce something that deserves confidence.

Signing is even harder, as there have been a large number of implementations out there which were outright broken; using non-cryptographic RNGs that leave the private keys exposed to recovery.  If you didn't require the software be PHP/Python, only callable from it, bitcoin-tx command-line tool in Bitcoin Core can be used for signing, and doesn't require having anything running.
domob
Legendary
*
Offline Offline

Activity: 1135
Merit: 1161


View Profile WWW
April 09, 2015, 03:04:26 PM
 #3

You can take a look here: https://github.com/vbuterin/pybitcointools  This is a Python library that, as far as I know, can do all you need.  I do not know, though, whether or not it is "trustworthy" or how thoroughly it was tested and all that - gmaxwell's comment is a good one.

Use your Namecoin identity as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS | GPG 0xA7330737
samson
Legendary
*
Offline Offline

Activity: 2097
Merit: 1068


View Profile
April 09, 2015, 06:53:26 PM
 #4

There's a good article at the following URL which describes what you want, he also broadcasts a transaction to the network without a Bitcoin client.

http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html

If I was going to do this I'd do it in C and probably use PolarSSL which is now renamed to mbedTLS since the ARM CPU manufacturers took it over.
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!