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
0
votes
1answer
133 views

What is the equivalent of solidity to perform ethereumjs-abi.soliditySHA3?

I am trying to tightly pack some typed-data (array of structs or nested JSON) and generate SHA3 hash from it. In JS, I can use ethereumjs-abi.soliditySHA3() method, ethAbi.soliditySHA3( ['...
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 ...
2
votes
1answer
61 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 = '...
0
votes
1answer
580 views

Problem with sha3.keccak_256() update method in Python

I made a simple SHA3 Python script to generate Ethereum addresses and priv/pub keys. After that I sent some ETH to those addresses but then found out that priv keys do not correspond to the addresses ...
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 ...
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 ...
0
votes
1answer
103 views

How to get the same SHA3 hash as soliditySHA3(ethereumjs-abi) returns using web3.sha3 in js?

I'm trying to hash a message as shown here: function constructPaymentMessage(contractAddress, amount) { return ethereumjs.ABI.soliditySHA3( ["address", "uint256"], [contractAddress, amount],...
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 ...
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('...
0
votes
0answers
32 views

Problems trying to implement Nexus (NXS) Skein-Keccak (SK1024) in Golang

) I know this might not be the perfect place to ask, but as ETH is also a Blockchain Tech and also uses Go within their stack, I couldn't find a forum that seems more appropriate. My Problem: I'm ...
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 ? ...
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,...
1
vote
1answer
637 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 ...
0
votes
1answer
308 views

What is the gas cost of keccak256(“abc”)?

According to this answer, the gas cost of keccak256 is: 30 gas + 6 gas for each word (rounded up) for input data to a SHA3 Keccak-256 operation I'm assuming that the size of a word is 256 bits and ...
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 ...
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 ...
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 ...
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 ...
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 ...
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
1answer
299 views

Why does keccak256() return bytes32 instead of uint256 in Solidity?

A hashing function outputs an integer that is 256 bits long... so why not store it as such?
0
votes
1answer
30 views

What happens when a contract has overlapping function selectors? [duplicate]

The method to execute a function on a contract in Ethereum is to use the JSON RPC protocol to make a request which has the details of which function you want to call. https://github.com/ethereum/wiki/...
1
vote
2answers
799 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 ...
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 ...
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
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: ...
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 ...
0
votes
2answers
346 views

Getting hash of a file

I want to create a contract that would produce a hash from a file and have it signed. Can i put a file through the sha3 using the solidity to get a hash? Or do i have to do it through js?
0
votes
1answer
107 views

SHA3_512 library, convert the input and output to 512-bit bytes

The SHA3_512 library takes an input uint64[8] and outputs uint32[16]. To convert the input from 64 bytes and the output back to bytes, I wrote this, but it gives the wrong result. What are some ...
0
votes
1answer
33 views

Smartpools' sha3_512, is there a stand alone implementation?

Smart pool has implemented sha3_512 (contract), tough it looks like it is combined with EthHash. Is there a stand alone library just for the sha3_512 function?
-1
votes
2answers
392 views

sha512 in Solidity or assembly, does it exist? [duplicate]

Is it possible to do sha512 within a smart contract? Or, not?
0
votes
1answer
228 views

Web3 behaves different on the client and server with different providers

I'm trying to read a mapping storage variable from blockchain. Below, are my attempts, from client and server. Testing on Rinkeby network. From client: Metamask is installed and I'm trying from the ...
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
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 ...
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 ...
0
votes
1answer
330 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 = ...
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)...
0
votes
1answer
160 views

How to get the same output using `sha3` by providing same address as 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(owner); ...
0
votes
1answer
311 views

Need to make a sha256 hash from two addresses

In solidity, what is the best way to combine two addresses? I cannot find a consistent pattern for doing this with the address type. Would the recommended pattern be to convert address to string, ...
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 ...
0
votes
1answer
173 views

Concatenation of different datatypes and hashing it

How can I concat two different datatypes and then hash it? for example: sha3(int8 + address) Or it is also good for me hash them separately, and then hash together. like this: sha3(sha3(int8) + ...
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, ...
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. ...
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 ...
0
votes
1answer
122 views

delegateContract address getting reset on delegatecall using geth console

I've deployed the following contracts on the rinkeby testnet. They are completely separate with different addresses: pragma solidity ^0.4.11; contract Backend { address public delegateContract; ...
0
votes
1answer
249 views

General question: Reasons to use sha3 (or any hash) in contracts?

I'm going through the Numerai contracts and noticing a common pattern - https://github.com/numerai/contract/blob/master/contracts/NumeraireBackend.sol and https://gist.github.com/Arachnid/...
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: ...
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
276 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 ...
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(...