Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
2
votes
1answer
63 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 ...
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
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
3answers
176 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
1answer
104 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],...
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 ...
2
votes
0answers
237 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
301 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?
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 ...
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
1answer
253 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 ...
0
votes
1answer
134 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( ['...
1
vote
2answers
807 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
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
259 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
2answers
347 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
393 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 ...
0
votes
1answer
584 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 ...
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 ...
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 = ...
1
vote
1answer
79 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
313 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
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
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 ...
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, ...
0
votes
1answer
174 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) + ...
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. ...
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 ...
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
251 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
484 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
278 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
644 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(...
3
votes
1answer
525 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
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
494 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 ...
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 ...
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 ...
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 ...
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/...
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 ...
4
votes
1answer
472 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?