9 votes
Accepted

How do these OpenSSL commands create a Bitcoin private/key from a ECDSA keypair

Bitcoin uses ECDSA so ECDSA keypairs are Bitcoin keypairs as well. echo "Generating private key" openssl ecparam -genkey -name secp256k1 -rand /dev/urandom -out $PRIVATE_KEY This generates the ...
Ava Chow's user avatar
  • 70.4k
6 votes

Openssl magic values? Secp256k1 and ECDSA similarities? What makes secp256k1 special?

You are using the eliptic curve function of openssl and providing a serialized bytestring as an input. DER (Distinguished Encoding Rules) is a restricted variant of BER for producing unequivocal ...
Dontpanicburns's user avatar
5 votes
Accepted

Openssl magic values? Secp256k1 and ECDSA similarities? What makes secp256k1 special?

These magic values: 302e0201010420 a00706052b8104000a Openssl seems to use these values for DER encoding rules, and it doesn't seem to have anything to do with secp256k1 or Bitcoin ...
Pieter Wuille's user avatar
5 votes

Sign a tx with "low s" value using OpenSSL

Alternatively, you could use libsecp256k1. This is the code used by Bitcoin Core for signing, and will automatically create low-S signatures (disclaimer: I'm the main author of that library). Perhaps ...
Pieter Wuille's user avatar
4 votes
Accepted

OpenSSL and Secp256k1 differing in implementation of ECDSA signatures?

The code you are referring to in libsecp256k1 is not for ECDSA. It implements the custom compact signatures that Bitcoin Core uses for message signing and verification. The normal ECDSA code in ...
Pieter Wuille's user avatar
4 votes

Generate bitcoin address from public key file

Which kind of address do you want? Assuming that you have compressed public key(compressed_public_key.txt), to generate P2PKH you can use these commands (hash160 and encoding with base58) ...
monkeyUser's user avatar
4 votes
Accepted

Were uncompressed public keys always supported by Bitcoin?

The original Bitcoin software used OpenSSL for verifying (and creating signatures) as a black box. Whatever OpenSSL accepted was accepted in blocks and transactions. OpenSSL accepted both compressed ...
Pieter Wuille's user avatar
3 votes
Accepted

Block 9 Transaction 1 Output 0 ScriptPubKey openssl validation fails

You have the wrong elliptic curve parameters in your PEM file. Bitcoin uses secp256k1, but you have (copied) the curve parameters for NIST P-256 (aka secp256r1). algorithmIdentifierParameters should ...
Ava Chow's user avatar
  • 70.4k
3 votes
Accepted

Sign transaction legacy with Openssl

The problem is that you are doing all of the hashing (and putting it into hex) and then having OpenSSL hash it again. openssl dgst will hash the message before signing, but this is incorrect for ...
Ava Chow's user avatar
  • 70.4k
3 votes

Convert EC PRIVATE KEY from .pem into WIF

How can i convert this (preferably using bash/Perl/python) into a WIF that can be imported into (preferably) Electrum? OpenSSL .pem files contain base-64 encoding of the values encoded using DER. In ...
Coding Enthusiast's user avatar
3 votes

Transaction signature algorithm

The ECDSA digital signature scheme returns two values. To be specific, the X and Y values computed on the elliptic curve are returned. In Bitcoin the signture is DER encoded, which is represented as ...
Bjarne Magnussen's user avatar
3 votes

Building on Ubuntu 16, missing SSL during ./configure

I fixed the issue by installing extra libraries, the whole list sudo apt-get install -y autoconf g++ make openssl libssl-dev libcurl4-openssl-dev sudo apt-get install -y libcurl4-openssl-dev pkg-...
David's user avatar
  • 31
2 votes
Accepted

Signing tx with OpenSSL, but fails when sending with bitcoin qt. How to debug?

I've found one bug in those shell scripts, though I'm not sure it's the only one. Once fixed, it's now generating the same sha256d's of the unsigned txs as another tool I've tried (before it was not). ...
Christopher Gurnee's user avatar
2 votes
Accepted

Verifying a bitcoin trx on the Unix cmd line with OpenSSL?

You got the pubkey correct but at least one thing wrong and maybe more in the parts you didn't show. First and fundamentally, bitcoin uses an unconventional (arguably nonstandard) scheme where the ...
dave_thompson_085's user avatar
2 votes

Sign a tx with "low s" value using OpenSSL

Open SSL won't force it, you will have to do it yourself. From BIP 62: The value S in signatures must be between 0x1 and 0x7FFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF 5D576E73 57A4501D DFE92F46 681B20A0 (...
meshcollider's user avatar
  • 11.8k
2 votes

How do these OpenSSL commands create a Bitcoin private/key from a ECDSA keypair

Generation of both PrivKey and PubKey: openssl ecparam -genkey -name secp256k1 -text -noout -outform DER | xxd -p -c 1000 | sed 's/41534e31204f49443a20736563703235366b310a30740201010420/PrivKey: /' | ...
k06a's user avatar
  • 133
2 votes
Accepted

Representation of coordinates in signature. OpenSSL

The value r is just a number and doesn't explicitly store or encode any point coordinates. In a signature, r is set to the X coordinate of the point R, which is really k*G, where k is the secret ...
arubi's user avatar
  • 1,864
2 votes

Bitcoind does not like ECDSA (r, s) pair produced by OpenSSL

A possible reason is that Bitcoin Core expects a low S value. Try changing s with N-s if s > N/2 (N is the curve order). Source here
Mike D's user avatar
  • 3,569
2 votes

Creating a Bitcoin address using the 9 steps. Stuck on stage 2

The problem is that you are hashing the string of hex characters instead of the actual bytes that the hex string represents. You should be using an array instead with the bytes specified. The ...
Ava Chow's user avatar
  • 70.4k
2 votes

OpenSSL generate Bitcoin address

OpenSSL's RNG is considered secure, so there should be no problem with this method. I don't think you need to use -rand /dev/urandom since OpenSSL already uses /dev/urandom for seeding the RNG.
Ava Chow's user avatar
  • 70.4k
2 votes
Accepted

How to Compress Public Key with OpenSSL / Bash

Instead of compressing 'by hand' you can have OpenSSL do it: openssl ec -in privatekey.pem -pubout -conv_form compressed -outform der | tail -c 33 | xxd -p -c 33 >compressedpub.hex And .pem is ...
dave_thompson_085's user avatar
2 votes

How to generate private/public key pairs in c++ using openssl

Usually you'd just pass around the EVP_PKEY structure to other OpenSSL calls. To put the secret into memory, you can use char* secret_key; BIO* bio_priv = BIO_new(BIO_s_mem()); ...
meshcollider's user avatar
  • 11.8k
1 vote
Accepted

How to properly decrypt Android Bitcoin wallet backup from 2014?

This happens because of the double encryption. The wallet backup had spending pin and password, So I had to restore it using Android App then export another backup which decrypts fine. This seem to ...
terry franklin's user avatar
1 vote

How to generate a bitcoin public key from an existing private key using openssl?

OpenSSL will compute a public key corresponding to a private key, try: $ openssl ec -in private_key.openssl.pem -text There must be correct input provided to OpenSSL. It is not enough to convert ...
Greg Tonoski's user avatar
1 vote

Proper way to get sha256 hash in c++ using openssl?

Is there any reason to do this... SHA256_CTX sha256; SHA256_Init (&sha256); SHA256_Update (&sha256, text, len); SHA256_Final (hash, &sha256); Yes there is. But not for your particular ...
0xC0000022L's user avatar
1 vote
Accepted

Proper way to get sha256 hash in c++ using openssl?

This would probably be more suitable asked on Cryptography StackExchange. I think that SHA256() is preferred over the _CTX, _Init, _Update, _Final functions. IIRC, these latter "low-level" ...
meshcollider's user avatar
  • 11.8k
1 vote
Accepted

Signing transaction offline - manual way vs. Electrum

The version number is sort of arbitrary and up to the client, so long as the number chosen is valid. The nLockTime is usually set to the current block height in modern wallets, this is a simple ...
Claris's user avatar
  • 15.4k
1 vote

Generate public/private key for bitcoin with openssl

Yes, it's randomness is trustworthy, so it's safe. The only problem I see is that "rm" does not remove all of its traces from the hard drive. The private key may be recovered. The pedantic way to ...
MCCCS's user avatar
  • 10.2k
1 vote

How can you generate a bitcoin Public Key from an existing Private Key using openssl?

Yes, openssl shows a public key corresponding to a private key that is input, e.g. $ openssl ec -in priv_key.openssl -text -conv_form compressed
Greg Tonoski's user avatar
1 vote

How to generate a bitcoin address from a hexadecimal private key using openssl in swift

I wanted to put this as a short comment, but it get’s unreadable. I also don’t go into segwit. I am not clear on your question: are you looking how to use the OpenSSL library for iOS (then this might ...
pebwindkraft's user avatar
  • 5,086

Only top scored, non community-wiki answers of a minimum length are eligible