139

Recently this article came to my attention that is way more in depth and technical than my more accessible version below. It also walks you through how to generate one on your own. I highly recommend it: https://kobl.one/blog/create-full-ethereum-keypair-and-address/ From the Yellow Paper There are three main steps to get from private -> address: Create ...


123

Ethereum uses KECCAK-256. It should be noted that it does not follow the FIPS-202 based standard (a.k.a SHA-3), which was finalized in August 2015. According to this, NIST changed the padding to SHA3-256(M) = KECCAK [512] (M || 01, 256). This was different from the padding proposed by the Keccak team in The Keccak SHA-3 submission version 3 (final, winning ...


50

I was stuck on this issue as well for a very long time. So the solution is: Add this prefix string to your Solidity smart contract. function verify(bytes32 hash, uint8 v, bytes32 r, bytes32 s) constant returns(bool) { bytes memory prefix = "\x19Ethereum Signed Message:\n32"; bytes32 prefixedHash = keccak256(prefix, hash); return ecrecover(...


38

You can if and only if a transaction has been sent from the account. When you send a tx, you sign the transaction and it includes these v r and s values. You parse these from the signed tx and then pass these v r and s values and the hash of the transaction back into a function and it'll spit out the public key. This is actually how you get the from address ...


33

thx @Edmunx Edgar, i tried to use ECIES, but it failed to install because of a subdepencency. I now used the bitcore-lib together with bitcore-ecies. This works like expected. EDIT: I created a npm-module which does exactly theses things and also has some performance optimisations and tutorials: github:eth-crypto. Here is my code for anyone with the same ...


27

Even though I do not know the real reason, I will try to guess. There would be the following considerations: Size of the namespace. There are not so many possible opcodes, so these need to be allocated very sparingly. The space of contract addresses, on the other hand, is practically unlimited for all practical purposes. Risk of name re-use. It is a good ...


26

Oraclize stores the TLSnotary secret in an Amazon Web Services (AWS) Virtual Machine. Using the techniques described here, they are able to provide some additional guarantees regarding the software running in the AWS instance and when/whether it has been modified since being initialised. The "proofs of honesty" they provide (and allow you to verify with ...


24

Ethereum uses Keccak-256, instead of the SHA-3 FIPS 202 standard. In the sha3 libraries you are using, try looking for the option to specify using Keccak-256. For Python see Getting Method ID "Keccak hash" in Python For Javascript, this library js-sha3 would involve using the keccak_256 function instead of sha3_256. keccak_256(''); // ...


23

Solidity and Serpent have ecrecover for this purpose. ecrecover(bytes32 data, uint8 v, bytes32 r, bytes32 s) returns (address) The function arguments are: data is what was signed. Since it is 32 bytes, that usually means that the initial data is hashed first to 32 bytes, before it was signed. v, r, s is the signature. (v is the recovery id: a 1 ...


23

Just to clarify, the "trivial solution" referred to is about how to produce a series of random numbers from a single random seed. As a general rule, BLOCKHASH can only be safely used for a random number if the total amount of value resting on the quality of that randomness is lower than what a miner earns by mining a single block. To see why this is the ...


19

v, r, s are the values for the transaction's signature. They can be used as in Get public key of any ethereum account A little more information, r and s are outputs of an ECDSA signature, and v is the recovery id. https://bitcoin.stackexchange.com/questions/38351/ecdsa-v-r-s-what-is-v also applies to Ethereum. For replay attack prevention, Ethereum ...


18

Currently, Ethereum uses elliptic curve cryptography, which is not quantum resistant. In the upcoming Serenity upgrade, however, accounts will be able to specify their own scheme for validating transactions, so individuals could choose to use Lamport signatures or other quantum proof algorithms. The Serenity blog post has a more in depth look at account ...


15

To make it clearer that Ethereum uses KECCAK-256 instead of the NIST standardized SHA-3 hash function, Solidity 0.4.3 has introduced keccak256. (It is an alias to sha3, meaning that keccak256 produces identical results to sha3, but with the intent to avoid confusion, especially for developers new to Ethereum.) It's recommended that new code use keccak256 ...


15

Extending on this answer: Ethereum uses Keccak hashing, which was submitted to the NIST competition for SHA3. It was subsequently selected as a winner in 2012, but the final standard was only released in August 2015. Ethereum uses Keccak in its form as it was selected in 2012. Too bad some parameters of the algorithm were tweaked for the final ...


15

Ethereum addresses are 160 bit hashes, meaning there are 2^160 possible hashes. Per the birthday problem, the chance of a collision rises to 50% when there are about 2^80 accounts created. To give you an idea of how unlikely that is, if every person on earth spent all their time doing nothing but generating Ethereum accounts, and they generated one a second,...


14

There's a functionality from the JSON RPC API not yet ported to web3 to sign data directly with one RPC function call, without messing with keys and crypto. If you don't need to sign messages clientside (because this requires an rpc connection and the account needs to be unlocked), then you can use eth_sign. eth_sign accepts two parameters, the address you ...


13

First, you'll need the private key for your account. To generate a brand new key, I use elliptic.js: import {ec as EC} from 'elliptic'; const ec = new EC('secp256k1'); const keypair = ec.genKeyPair(); If you have a key in your Ethereum node, you can use keythereum to import it. This will also give you an elliptic.js key. Once you have a key, you need a ...


13

Currently, Ethereum uses elliptic curve cryptography (ECDSA), the same as Bitcoin. So whatever "unsafe" concerns there are with how Bitcoin transactions are signed, would be the same with Ethereum currently. In Bitcoin and Ethereum, sending from an address will reveal the public key easily. Quantum computers compromise ECDSA and would make it easy to ...


12

web3 does not support this feature yet, but it might be coming with web3 1.0. In the meantime you can use ethereumjs-utils ecrecover feature. Note that this function expects v to be in {27, 28}, and since your signature comes from geth, (since it doesn't return signatures in the canonical format yet) you will have to add 27 to your v. Given a signature sgn ...


11

Not an authority, but I know of someone who is... From Vitalik's article, A Prehistory of the Ethereum Protocol The second was the idea of “precompiles”, solving the problem of allowing complex cryptographic computations to be usable in the EVM without having to deal with EVM overhead. We had also gone through many more ambitious ideas about “...


11

According to issue #3731: Geth prepends the string \x19Ethereum Signed Message:\n<length of message> to all data before signing it (https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign). If you want to verify such a signature from Solidity, you'll have to prepend the same string in solidity before doing the ecrecovery. Here's a working example I ...


11

A blockchain masters, as of now, would only be worth your time and money if it's from a school with a lot of time under it's belt working on bitcoin(It's been around longer) or taught by Nick Szabo. Something I feel would carry over more would probably be a Masters in Cybersecurity as security in smart contracts is paramount and with your ability to work as ...


10

Assuming you have the public key of the person you want to send a message to (if they've already signed a transaction you can recover it from the signature) it should be possible to encrypt and decrypt using ECIES. Apparently there's a JavaScript library for this, I assume you can use it in a browser: https://bitcointalk.org/index.php?topic=627927.0 I have ...


10

Shuffling a deck Commutative encryption: Alice and Bob want to shuffle a deck of cards, such that neither knows what the other's hand contains, but the hands are disjoint (i.e. only one may have a particular card). Protocol: Alice and Bob decide on an encryption protocol with the following features EK(X) is X encrypted with key K DK[ EK(X) ] = X for all ...


10

Solidity docs say that sha256 (and sha3, ripemd160) arguments are tightly packed: “tightly packed” means that the arguments are concatenated without padding. This means that the following are all identical: sha3("ab", "c") sha3("abc") sha3(0x616263) sha3(6382179) sha3(97, 98, 99) Using the question's example of a = sha256(uint ...


10

Geth adds prefix to the message before siginig it in web3.eth.sign (see JSON-PRC spec). Without this it can be possible to trick user to sign transaction (more here). So, the correct code to sign message with web3.eth.sign and recover address with ethereumjs-util.ecrecover or (Solidity's ecrecover) should add the prefix explicitly. const util = require('...


9

Since Ethereum contracts can have their source code verified then this should be as simple as making use of an RNG to pick cards randomly from a deck. Anyone who wishes to verify that the deck is adequately shuffled can verify the contract source code. Since generation of good randomness is addressed elsewhere this answer assumes that the card shuffling ...


9

No it does not suffer from malleability (anymore). The homestead hardfork included the malleability fix and transactions that have their signature in the upper range of secp256k1n/2 are rejected.


9

I'll not enter on crypto hard details, because I don't know that much about it, and it needs pages and pages to be explained correctly. But let's try it!!! ZKSnarks also known as: Zero Knowledge Succinct Non-interactive Arguments of Knowledge, are fast computational zero knowledge proofs that allow you to demonstrate things without giving any info and even ...


9

Indeed, ethereum's address reuse renders the "protection against an ecc public key attack" argument null. For externally owned accounts, using the public key directly would likely not result in any issues, or major security problem. The only reason I can think of where hashing is helpful is to maintain parity between externally owned accounts and internal ...


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