Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
40 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
119 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
45 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
203 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
223 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
433 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
25 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
192 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
108 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( ['...
0
votes
0answers
19 views

key rocever from MEW locally thanks to a combo of addresses and signed transaction?

Hello I have used a private key to send the funds off line from and address to another using Myether wallet All the signed transactions made, and the addressess where the coins ...
1
vote
2answers
501 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
128 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
166 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
285 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
96 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
28 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
307 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
202 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
473 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
227 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
70 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
137 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
260 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
3k 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
170 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
85 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
155 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
1k 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. ...
7
votes
4answers
4k 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
107 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
210 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
175 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
414 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
253 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
565 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
457 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
1k 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
470 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
447 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
867 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
43 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/...
4
votes
3answers
2k 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 ...
5
votes
1answer
449 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?
2
votes
2answers
369 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
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; ...
8
votes
1answer
496 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 ...
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 ...