Paste the key into a text file, save it to disk and use the path to that file with geth account import. Here are some example Windows instructions that might help:
Paste key into notepad without any extra characters or quotations
Save the file as nothing_special_delete_me.txt at C:\
Run the command, geth account import C:\...
Contracts do not possess private keys in the same way that your ether wallet does. Instead, they have programming code written in the language of the Ethereum Virtual Machine.
To determine what a contract "does", all members of the Ethereum network simply run the relevant portion of code every time a transaction or other contract uses the contract's ...
I was having the same problem earlier, so I am going to give an extensive answer to how this works. I assume you are using geth as a client. There is an open issue where the geth client returns v in the wrong format, so let's keep in mind that if we get a v that is 0 or 1 we should add 27 to it.
If you are running node and have connected web3 to your ...
You can use MyEtherWallet or MyCrypto(fork of MyEtherWallet) offline only wallet "view wallet details" function to extract private key from wallet json file. Feel free to use its offline version on an air gapped computer to secure your private key.
Edit: MyCrypto only provides this function in the offline version of the wallet now for obvious security ...
From my reading of the Yellow Paper (YP), Yes you would be able to spend the funds of the contract. But as you note, it is with extremely low probability of being able to find a contract's private key.
Spending money in Ethereum is done via a CALL opcode, passing it parameters such as the sender, recipient, value (being spent). Since you have the private ...
Your calculations are right, except there aren't exactly 2^256 private keys -- there are "FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141" (this number is named N in the ETH source code, and is the order of the generator of the elliptic curve secp256k1, from which Ethereum key pairs are generated).
In answer to your question, yes, ...
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 ...
Yes and no.
No - a Bitcoin address cannot be directly used in Ethereum, and vice versa.
Yes - underneath, a bitcoin private key is essentially a random 256-bit number (in a certain range, see bitcoin wiki). And the private key's corresponding public key is essentially the x and y coordinates of a point on an elliptic curve. Bitcoin and Ethereum both use ...
The private key is encrypted and, if you are confident in your password's strength, does not need to be encrypted again. The key is encrypted with 128-bit AES by default if you're using geth, and all of the parameters are in the JSON file. The encrypted private key is in the ciphertext attribute.
I would recommend keeping the entire file,
No, a mnemonic is generated using an hd wallet - a hierarchical deterministic wallet. Private keys are "children" of this mnemonic and there can be millions of them, but there's no way to go back to the parent having only a child private key.
You can generate a new mnemonic if you install MetaMask or most of the other Ethereum wallets out there (Status, ...
As mentioned by Peter, a private key is a random 256 bit blob. It is a common oversight that there're no restrictions.
It has to be valid for the secp256k1 curve, which means two conditions:
cannot be zero
must be less than the order of the curve (called n and has a value of ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141)
ethereumjs-wallet can be used to get public key from private key:
> const hdkey = require('ethereumjs-wallet/hdkey')
> const privateKey = hdkey.fromMasterSeed('random')._hdkey._privateKey
> const Wallet = require('ethereumjs-wallet')
> const wallet = Wallet.fromPrivateKey(privateKey)
It uses web3.js and ethereumjs-tx:
<!-- from https://github.com/ethereumjs/browser-builds/raw/master/dist/...
If you have node.js, you can do this in node
//install keythereum by runing "npm install keythereum"
'./Appdata/roaming/ethereum' is the folder contains 'keystore'. importFile looks for 'keystore' in that folder.
You can now import single/"loose"(as we call) keys into MetaMask if you click the menu in the top right corner. It will drop down with the option "Import account", you can click that and it will take you to a view where it will ask you to import your private key or json file.
geth-compatible keystore file can be created in Node using ethereumjs-wallet library:
> var Wallet = require('ethereumjs-wallet');
> var key = Buffer.from('efca4cdd31923b50f4214af5d2ae10e7ac45a5019e9431cc195482d707485378', 'hex');
> var wallet = Wallet.fromPrivateKey(key);
The steps here are heavily ...
Simply use geth as indicated in the github wiki:
$ geth account update a94f5374fce5edbc8e2a8697c15331677e6ebf0b
Unlocking account a94f5374fce5edbc8e2a8697c15331677e6ebf0b | Attempt 1/3
Account 'a94f5374fce5edbc8e2a8697c15331677e6ebf0b' unlocked.
Please give a new password. Do not ...
For a numbers of 64 hexadecimal digits, there are 16 ^ 64 = 115792089237316195423570985008687907853269984665640564039457584007913129639936 possibilities.
For a numbers of 32 hexadecimal digits, there are 16 ^ 32 = 340282366920938463463374607431768211456 possibilities.
If someone has half your private key, your security has been reduced by a factor of ...
You can start ganache with a mnemonic as a parameter ( -m 'jar boss sister abuse equal ....'). Doing this, you'll:
be guaranteed to have the same addresses generated with each run
be able to derive the private keys from that mnemonic
const bip39 = require('bip39');
const hdkey = require('ethereumjs-wallet/hdkey');
const wallet = require('ethereumjs-wallet')...
Mist has no way to import via GUI, so you need to import using command line (geth). It will show up in your Mist immediately.
Paste key into TextEdit without any extra characters or quotations
Save the file as nothing_special_delete_me.txt to your Desktop
Open Terminal, run command:
geth account import ~/Desktop/...
Edit: the following info is outdated. It still works, but see the verified answer to import directly.
Currently I don't believe you can import into Metamask, so I did it the other way around. Here is how:
1) Go to the account in Metamask and Export the account you want. This will give you the private key.
2) Create a file on your desktop called ...
Some of the links in the comments helped me get the answers to my questions. I have collected all that information combined with my own (recently acquired) knowledge of cryptography from the Coursera Cryptography-I class (for the answer to question number 3).
A1. The private key is never (or should never be) saved unencrypted on disk. It is generated from ...
(I've left this as an answer, rather than a wiki, to encourage multiple answers since there may be other explanations that resonate better with people)
For brevity, this answer assumes that the underlying cryptography of Ethereum has not been broken.
private key = only way to access an Ethereum account
password = protects private key via encryption; ...
There is no general solution for this.
Possible approaches for the client-side are:
Users keep the private key stored in an encrypted keystore file. The "Login" into the DAPP would be: (1) upload locally, not to the server, the keystore file into the DAPP, (2) type in the password to unlock the keystore, (3) use the private key in DAPP. This is how https:/...
Here are two options:
Using ethers.js - the example below uses a mnemonic
ethers wallet documentation
const ethers = require('ethers');
let mnemonic = "YOUR MNEMONIC";
let mnemonicWallet = ethers.Wallet.fromMnemonic(mnemonic);
This doesn't seem to be included in web3, but has been added to the list of ...