20

Yes, both cryptocoins use the same elliptic curve SECP256K1. Perhaps a better alternative is to use a BIP32 wallet. You have a master key that is not directly used for transactions, but it is used to derive child keys than can be used. You can derive separate keys for bitcoin and ethereum. You will always be able to use the master key to sign transactions ...


4

There's a package that contains suitable functions, here -> pubkey/eth-crypto See: publicKey.compress(), and publicKey.decompress() The compress code is below. (Copy + pasted from this file.) var _secp256k = require('secp256k1'); function compress(startsWith04) { // add trailing 04 if not done before var testBuffer = Buffer.from(startsWith04, '...


4

A Bitcoin address is made by: private key -> public key -> hash An Ethereum address is made by: private key -> public key -> hash -> throw some of it away and keep the rest This means that the address alone is not enough to give you the address from the other system, but if you have the public key, you can create both the Bitcoin address and the ...


2

I believe both Bitcoin and Ethereum use the same elliptic curve (SECP256K1) for public key creation - so you should be able to directly port over your Bitcoin private key and use it to create the same address on the Ethereum blockchain. That being said, in the next "release" of Ethereum (Metropolis), users will be able to "define their own security model", ...


2

Self-answering my own question 4 years later: Yes! I wrote an Secp256k1 implementation in Crystal: github.com/q9f/secp256k1.cr In that process, I implemented both key management for Bitcoin and Ethereum. The same keypair can be used to retrieve Bitcoin and Ethereum formatted addresses: generate a compressed bitcoin mainnet address: key = Secp256k1::...


2

If you use web3 to sign a message and then try to verify that message in a contract, you need to prepend the following string to the message before running ecrecover in a contract: \x19Ethereum Signed Message:\n<length of message> There are the two places where I found this. https://github.com/ethereum/go-ethereum/issues/3731 https://github.com/...


2

Ethers.js prefixes the signature with \x19Ethereum Signed Message:\n<message length> before signing it, and signs a hash of the message. This is equivalent to the personal_sign JSON-RPC method. To match the behaviour of Ethers.js with the secp256k1 library, you have to: Get a hash of the message (e) using Keccak256(message). Hash e, using Keccak256(&...


2

if I finish following the tutorial and build a signed TXN with these wrong R+S values, the txn works This seems to suggest the signing by secp256k1.ecdsaSign is correct, but just not deterministic, i.e. it changes every time you sign, even with the same key and data. Notice the tutorial uses private_key.sign_deterministic, so, to produce the same result, ...


2

I'm also not a Rust programmer, so someone will probably have a better answer, but have a look in Parity's keypair.rs, which itself uses rust-secp256k1. Of interest is probably the KeyPair implementation. impl KeyPair { /// Create a pair from secret key pub fn from_secret(secret: Secret) -> Result<KeyPair, Error> { let context = &...


1

Sure! As bitcoins are simply your "rights" to control the value of stored blockchain ledger entries, practically speaking, all you ever need is a private key to store bitcoins. Example of a Bitcoin private key represented in WIF format: 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nFCDPsGHMGALCn1E and its associated address: 1PsL2jSXpg8ojDdj9ZfVKib5vJKhmts4PP In ...


1

I solved this problem. Each byte in secret key(sk) must be a number. void skstr_to_sk(const unsigned char *sk_str, unsigned char *sk) { const unsigned char *sk_pos = sk_str; int i; for (i = 0; i < PRIVATE_KEY_SIZE; i++) { sscanf(sk_pos, "%2hhx", &sk[i]); sk_pos += 2; } } int main(void) { ... unsigned char *sk_str = "...


1

I have never programmed Ruby but I know a little bit about Bitcoin and Ethereum signatures. I hope I can help you. A bitcoin signature consists of two parts: (r,s). An Ethereum signature consists of three parts: (v,r,s). The extra value v which is only one byte allows for the derivation of the public key from the signature. There are only four possible ...


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