The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [sha3]

Regarding the use of the Secure Hash Algorithm SHA-3. Note that Ethereum and tools such as Solidity and web3.js uses Keccak-256.

Filter by
Sorted by
Tagged with
88
votes
2answers
50k views

Which cryptographic hash function does Ethereum use?

Many sources refer to the use of the "SHA3" cryptographic hash function within Ethereum, but the Ethereum project began before the SHA3 standard was finalised, and there was some confusion/controversy ...
24
votes
3answers
9k views

How does Solidity's sha3 / keccak256 hash uints?

This is not a question about the issue with Ethereum using a non-standard sha3. I have found the right JS hashing library, and am able to get matching hashes in JS and Solidity on byte strings. What I ...
21
votes
1answer
6k views

What is the cheapest hash function available in solidity?

AFAIK there are 3 hash functions to choose from in solidity (sha3, sha256, and ripemd). sha3 is native while the others use precompiled contracts. Which one of these is cheapest (in terms of gas)?
20
votes
2answers
6k views

Why aren't Solidity sha3 hashes not matching what other sha3 libraries produce?

Solidity has a function named sha3 and I tested it with an empty string input. It is not matching what other sha3 libraries produce. I see contracts written by others using the same sha3 function ...
9
votes
1answer
433 views

Are there any plans to switch Ethereum's primary hash algorithm from Keccak-256 to SHA3?

The Ethereum project was started before the SHA3 standard was finalised, and currently uses an earlier version of Keccak-256 which does not precisely match the FIPS-202 standard for SHA. Are there ...
8
votes
5answers
5k views

How to keccak256 multiple types in web3js to match Solidity keccak256?

if I keccak256(string1, address1) in Solidity, and then use web3.sha3(string1, address1) in web3.js, I get different results, even though when I do both with only string1 as a single argument, they ...
7
votes
1answer
513 views

How to install and test Viper programming language?

Viper is a new functional, strongly typed, bounds/overflow-checking, fixed-point-decimal python syntax-based HLL. The repository does not inlcude any documentation yet. I built and installed ...
7
votes
1answer
588 views

Calculating difficulty and verifying a hash as a solution

I have a scheme right now where individuals are committing to a contract a solution to a problem similar to Bitcoin's proof-of-work protocol. Here's the basic flow...the contract calculates a seed ...
6
votes
3answers
461 views

Is it possible to verify Ethash PoW in a contract?

Reading on EtHash, I was thinking if it is possible to verify the current Ethereum Proof Of Work by a smart contract. There is an instruction SHA3, which computes 256-bit hash, but EtHash uses 512-bit ...
5
votes
1answer
2k views

Python and Solidity keccak256 function gives different results

I am working on implementing a smart contract application in which, on and off chain calculations will exist. I will have to calculate the Hash Function of multiple integers with Python and Solidity. ...
5
votes
1answer
499 views

How to interact with the blinded auction contract from web3.js

My question is about the blind auction contract in the solidity examples. What is the right way to interact with the contract from web3.js? I tried this, but it does not give the right result. var ...
4
votes
1answer
923 views

How does keccak256 concatenate values inside a Solidity smart contract?

I'm developing a smart contract in Solidity in which I need to evaluate the hash of two concatenated bytes32. I don't have to concatenate the bytes32 since the sha3 function supports more than one ...
4
votes
2answers
1k views

keccak256 Error Undeclared identifier in browser-solidity

I try to use sha3/keccak functions inside a Solidity contract, but I get a weird error: Untitled:5:13: Error: Undeclared identifier. bytes32 d=keccak256(0x616263); The contract : pragma ...
4
votes
1answer
1k views

Getting Method ID “Keccak hash” in Python

I am trying to derive the Method ID, the Keccak (SHA-3) hash, in Python so that I may call the functions of my contracts once they are deployed as detailed in the ABI documentation: https://github.com/...
4
votes
1answer
844 views

Hash Test: How to produce hash output

Here is a basic hash test. I am trying to reproduce the output with: http://emn178.github.io/online-tools/sha3_256.html Is sha3-256 correct? The output for '1' as the value input is ...
4
votes
2answers
702 views

How to compute SHA-3 of an array of numbers in Javascript?

The documentation says that sha3 calculates the hash of the tightly packed arguments. Numbers seem to be converted to ASCII chars. Consider using sha3(values) in Solidity with the type int8[3] values,...
4
votes
1answer
377 views

XOR bytes32 (from web3.sha3) in Javascript

How can I perform bitwise operations with a bytes32 object in Javascript? This might seem like a general Javascript question but since this is quite common practice to obfuscate input values in a ...
4
votes
1answer
471 views

What is the bkp component in a presale JSON file?

Is the "bkp" component of a presale json file a SHA3 hash of the wallet password?
3
votes
1answer
2k views

Price of storing a hash SHA3 in Ethereum and Bitcoin

I'm involved in a Proof of Existence project and I need to know if it is convenient to create a private blockchain or we can use Bitcoin or Ethereum. I would like to know the price of storing a SHA3 ...
3
votes
3answers
3k views

Keccak256(parameter) How to pass a string to be hashed?

I'm trying to do something that in theory is very simple: I want to pass a string like "hello" to a function and then compute the sha3/keccak256 hash. I think the problem is that if the parameter is a ...
3
votes
1answer
523 views

I need help with signatures

So, for my studies, I am supposed to interact with a contract function that has the following built in condition: if (ecrecover(_h, _v, _r, _s) == msg.sender && _h == sha3(this)) I am ...
3
votes
1answer
493 views

how to create a nested for loop that stores the hashed value for each

I have two arrays: address[ ] addresses uint [ ] numbers I want to create a function that creates another array that stores the hashed value of both. bytes32[ ] addressNumbers for instance, if I ...
3
votes
1answer
476 views

Ecrecover after eth_sign update with preamble

I've just discovered that with b59c839 geth is now pre-appending the string: *\x19Ethereum Signed Message:\n<length of message>* before signing the passed message. I've read here that to use ...
2
votes
1answer
4k views

How to use keccak256 in Solidity?

I have created a Student registration form and taking input as firstName, lastName and studentRegId. Something like this: contract Unique { string fn; string ln; bytes20 val; bytes32 sId; ...
2
votes
1answer
62 views

Different outputs for Keccak256(), which one is right?

To get a value from contract storage I used this geth code succesfully: var contractAddress = '0x88e726de6cbadc47159c6ccd4f7868ae7a037730' var index = '...
2
votes
1answer
33 views

How are we able to send 512 bit hash as a bytes32 variable?

I have a code that is working: solidity function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) { bytes memory prefix = "\x19Ethereum Signed ...
2
votes
1answer
277 views

WEB3.SHA3 JSON CURL

I am trying to convert the string function name Double(int256) to hash using the Keccak-256 SHA3 algorithm using web3sha3 for curl. In geth I use the command as such web3.sha3('double(int256)') and ...
2
votes
2answers
420 views

Where can I see the output of Solidity's sha3 function?

I have written the below code and it runs perfectly. After mining and passing the values along with certain gas value, i get transaction hash as output on the geth console. Now i want to know the ...
2
votes
1answer
87 views

Fair, barely malleable CSPRNG that can still be deterministic?

Just for fun, I wanted to start off making a test contract that generates ERC-20 tokens based off of prime length when in binary representation. I decided to use Rabin-Miller for the primality test, ...
2
votes
0answers
236 views

Comparing solidity sha3 with web3 sha3 inside smart-contract

The problem is that sha3 in solidity returns bytes32 and I have a string returned from IPFS by oraclize, and if hash calculated in solidity and returned to web3js (bytes32 got interpreted as a string) ...
2
votes
0answers
483 views

On Ubuntu, I can't build sha3sum

I was following this article. When I saw that I've to have this keccak256-sum, I moved to this GitHub repo. But, when I am building it, it's giving below issue. $ make cc -Wall -Wextra -pedantic ...
2
votes
1answer
44 views

Revealing played value

I'm writing a smart contract where participants are asked to submit a value (1 to 1000000) in the submission period, and then reveal what that value is in the revealing period. In order to hide it ...
2
votes
0answers
150 views

Blind Auction: Reveal>>>How to successfully fill data fields [duplicate]

http://solidity.readthedocs.org/en/latest/solidity-by-example.html#id2 Not confident in how to "blind" a secret and reveal it. Using http://emn178.github.io/online-tools/keccak_256.html for the hash....
1
vote
1answer
4k views

How can I generate a wallet in python?

Im trying to write a python script that can generate a new wallet for that user, but I need to be able to keep the private key. I followed this : Stack overflow answer And got these results: import ...
1
vote
2answers
800 views

does keccak256 and sha3 reproduce the same hash ?

I have this solidity method: function hashData(bytes32 data) public constant returns (bytes32) { var hash = keccak256(data, msg.sender); return hash; } for a data = "0x707974686f6e62" and ...
1
vote
1answer
2k views

How to compare hash of two structures?

function checkOffers() public returns (bool){ uint256 a = sha256(offerFromProducer); uint256 b = sha256(offerFromConsumer); if(a == b){ return true; } return false; } Is ...
1
vote
3answers
170 views

Testing sha256(abi.encodePacked(_argument))

When trying to test a smart contract that uses sha256(abi.encodePacked(_myargument)) I don't get the same hash on truffle ! I tried both web3.utils.keccak256('_myargument') web3.utils.sha3('...
1
vote
1answer
643 views

How to generate consistent hash value with Solidity within Truffle?

I would like to generate hash value within Truffle using the web3.sha3() function and the hash value is required to be consistent with that one generated in Solidity. The basic example is sha3(uint256(...
1
vote
1answer
78 views

What should I do to get the same output using `sha3` by providing multiple input on nodejs?

I have following contract: pragma solidity ^0.4.0; contract Lottery { address public owner; bytes32 public hash; function Lottery() { owner = msg.sender; hash = sha3(10, owner)...
1
vote
2answers
139 views

What do the parameter in sha3() in Proof of Work implementation of Ethereum mean

sha3(nonce, currentChallenge, block.blockhash(block.number-1)) In this line I get it that blockhash is a random number, but why are we taking it from the previous block, any hard and fast rule here ? ...
1
vote
1answer
33 views

Is there a way to obtain the same Hash using Keccak256 from Web3 and ZoKrates hash function such as sha256packed?

I am trying to use the hash obtained from keccak256 (applied to a number or input) and using it into sha256packet from ZoKrates (or other function) for comparing it with the Hash obtained in Zokrates ...
1
vote
1answer
639 views

From golang sha3 to solidity sha3

Trying to match "golang.org/x/crypto/sha3" lib with solidity sha3() is giving me a hard time. Its been discussed in here, but I somehow cant apply it in go. How do I handle a big.Int type s.t i get ...
1
vote
1answer
251 views

How to derive the storage key of mapping to an account?

I am trying to derive changes of account storage by mapping accounts (here, the accounts represent the key address in the ERC20 balances mapping mapping(address => uint256)) to their corresponding ...
1
vote
1answer
140 views

What the sha3 function do with 2 parameters?

Who can explain what the second line exactly do ? this function verify ecdsa signature. the msg is already hashaed and it seems like with sha3(prefix,msgHash) will be hashed twice. function isSigned(...
1
vote
1answer
183 views

Correctly address Smart Contract storage address using web3js 1.0.0 library functions

A short while ago, I found a fantastic Medium article explaining Smart Contract storage. The examples in this article have helped me to understand how to read a Smart Contract's storage values from ...
1
vote
1answer
203 views

Can't understand hashing mechanism for mappings

I have a contract with function function addToBalance () payable { userBalances[msg.sender] += msg.value ; } Debugged assembly and stumbled on the code that calculates key for store: ...
1
vote
0answers
67 views

Does web3 soliditySha3 work with json object?

The above hash data is generated by web3 soliditySha3 with the objects below. It seems the function generates hashes as I wanted; each object has different hash value. But I am not sure if it's ...
1
vote
0answers
257 views

What are sha3Uncles and why are they mostly same for all blocks [duplicate]

I was looking at sha3Uncles in my chain and found it to be constant throughout. After looking at the example response to JSON RPC requests, I found the same value: ...
0
votes
1answer
333 views

Keccak hash of null values, result in different hashes for different types

I was testing the hash value of null values for different types and I'm curious how it generates different results for different types. Here are the results. String = ...
0
votes
1answer
1k views

How to generate keccak256(STRING,INTEGER) from Javascript?

In my solidity code I use bytes32 generated by keccak256("STRING_VALUE',INTEGER) to store values in the map. One of the sample values that get generated is ...