16
votes
Accepted
Difference between keccak256 and sha3
from an answer to What are the key differences between the draft SHA-3 standard and the Keccak submission?:
No they did not, the internals and security levels have not been
changed from the ...
16
votes
How to calculate the assigned txHash of a transaction?
Short answer
It cannot be done.
Longer answer
The txhash is keccak256(signedTransaction).
This keccak256 function is available as a solidity function
http://solidity.readthedocs.io/en/v0.4.21/units-...
15
votes
Accepted
Why are there no leading zeroes in ethereum block hash?
In the Ethereum blockchain, the difficulty is used to calculate a target.
Here are the ethminer logs for block number 1257006:
ℹ 35:02:42.89 ethminer Solution found; Submitting to http://192.168.4....
15
votes
What is a block hash?
The block header is the hash returned from generating a Merkle tree that is below the current difficulty target for the blocks data.
What's a hash?
In order to understand what the block header is ...
14
votes
Accepted
trying to use web3-utils but not working
Please check your web3.js library version.
In versions < 1.0 you can call web3.sha3('test').
In 1.0 it was moved to web3.utils.sha3
Another option is to use web3-utils library, in this case you ...
13
votes
Accepted
Why are Ethereum addresses hashes of public keys?
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 ...
9
votes
Accepted
What datatype should I use for an IPFS address hash?
bytes because they are more than 32 bytes. An IPFS hash:
itself specifies the hash function and length of the hash in the first
two bytes of the multihash. In the examples above the first two ...
eth♦
- 83.3k
9
votes
Why are there no leading zeroes in ethereum block hash?
What you see in block explorers is the sha3 of the block header, not the ethash.
8
votes
keccak3 in SOLIDITY and in WEB3 different hashes for an address type field
web3.sha3() takes an encoding parameter to specify that you are passing in a hex address:
address_string = '0x5b2063246f2191f18f2675cedb8b28102e957458';
web3.sha3(address_string, {encoding: 'hex'});
...
8
votes
block-header hash verification
Below are the steps to calculate blockHash, given a blockNumber:
Step1. eth.getBlock(400000)
Output:{ difficulty: '6022643743806', extraData: '0xd583010202844765746885676f312e35856c696e7578', ...
8
votes
Block header hash calculation
Below are the steps to calculate blockHash, given a blockNumber:
Step1. eth.getBlock(400000)
Output:{ difficulty: '6022643743806', extraData: '0xd583010202844765746885676f312e35856c696e7578', ...
7
votes
Accepted
Does a mining reward transaction have a hash?
There are no inputs and outputs in Ethereum, just state changes and balances. Therefore, mining rewards don't have a transaction hash since they are not a transaction.
Each block contains the miner'...
7
votes
Accepted
How does keccak256 concatenate values inside a Solidity smart contract?
The arguments are expressed as bytes, left-padded with zeroes to the maximum length of the data type you've passed in, and concatenated without any kind of delimiter.
In Python, given two hex-encoded ...
7
votes
Difference between keccak256 and sha3
Keccak and sha-3 are not the same. In 2007, U.S. National Institute of Standard and Technology (NIST) initiated a competition about SHA-3. In 2012, Keccak team won the competition. From then on, ...
7
votes
Can we use block hash as verifiable randomness for the off-chain lottery?
we want to use the block hash of some block in the future as a seed for the random generator.
I think using a future block hash is generally considered "safe". (This article discusses using ...
7
votes
Accepted
How to use ethers keccak256?
Let's look at the function definition for keccak256:
export function keccak256(data: BytesLike): string {
return '0x' + sha3.keccak_256(arrayify(data));
}
The input is not a string - it's a ...
6
votes
Accepted
Distribution of KECCAK-256 hash values
I came across this paper that looks at using Keccak-256 (the original one that Ethereum uses, not SHA3) as a PRNG. It subjects the output of the hash to a large number of tests of randomness and it ...
6
votes
How to calculate the assigned txHash of a transaction?
According to geth source code (file core/types/transactions) and this medium post the hash of a transaction is given by the keccak 256-bit hashing of the rlp encoding of all fields of a transaction, ...
6
votes
Accepted
How to generate the full list of function selectors for a contract?
Maybe you can use the online Ethereum IDE (Remix):
Paste the whole code of the address you posted.
Select the same compiler version: v0.4.25+commit.59dbf8f1.
Select the contract by name: ...
6
votes
Accepted
Solidity's keccak256 hash doesn't match WEB3 keccak hash
The abi.encode function encode its parameters for a contract call using Solidity's ABI specs. For fixed size types like uintXXX, bool, address, it's quite easy, just pad them to 32 bytes; for dynamic ...
5
votes
Accepted
How to compare hash of two structures?
The return value of sha256 is bytes32. So use bytes32 a = sha256(...) and do the same for b. This will fix the compiler errors and a == b will work.
But currently you cannot pass a struct to ...
eth♦
- 83.3k
5
votes
Does Ethereum use Ethash or KECCAK-256 (an alias to SHA3) as hash function?
A hash function is different to a proof-of-work algorithm. Much of the effort in following a proof-of-work algorithm involves making hashes, but they're distinct things.
Ethash is the proof-of-work ...
5
votes
Accepted
Price of storing a hash SHA3 in Ethereum and Bitcoin
In Bitcoin, you can store 80 bytes in one transaction with OP_RETURN. SHA-3(256) has a size of 32 bytes and can be stored in one transaction. The fee for the OP_RETURN transaction is 0.0001 BTC. By ...
5
votes
Accepted
Is it possible to have a mapping with a hash as key?
Yes, hash was an old type that's been replaced with bytes32. You can call keccak256(data1, data2, ...) and use that as a key.
Prior discussion on hash.
eth♦
- 83.3k
5
votes
Accepted
Build a hash from a string and a number uint256 on Solidity
Another correction (2019-05-17): In modern Solidity version you can no longer pass multiple arguments to keccak256. It now only takes one argument of type bytes. You can still hash multiple values ...
5
votes
Accepted
How to decode txn_hash from contract function call via Python web3.py, w3.eth.sendRawTransaction
Use hex().
txnHash = w3.eth.sendRawTransaction(signed.rawTransaction)
print('txnHash: '+ str(txnHash))
txnHashHex = txnHash.hex()
print('txnHash.hex(): '+ txnHashHex)
Output in terminal:
txnHash: b'\...
5
votes
Accepted
How to get the type of transaction (Send/Receive/Approve/Swap) and the ERC20 tokens involved in that transaction?
First, you are not querying the right endpoint. If you want to fetch ERC-20 events, you must do the following query :
https://api.etherscan.io/api?module=account&action=tokentx&address=...
4
votes
Hashes per Ether, before and after PoS
The number of hashes depends on the number of miners that partecipate in a lottery to win the Ether fee.
Therefore you can not have a number NoHashes/Eth.
The hashing is a way do have a distributed ...
4
votes
Accepted
Dangling hash node ref: too many open files
Check Open File Descriptor Limits
You may need to increase the Linux file limit to handle the number of connections your nodes are serving. Here are some articles on checking and setting the limits. ...
4
votes
Accepted
What is "Universal Hash Time"?
Universal Hash Time is a proof of existence service that you can build on top of a blockchain.
To further answer your questions:
Purpose: it proves that some data existed at the time a block that ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
hash × 249solidity × 67
keccak × 36
transactions × 35
blockchain × 30
hash-algorithm × 24
signature × 21
web3js × 19
mining × 15
sha3 × 13
etherscan × 12
blocks × 12
javascript × 11
cryptography × 11
randomness × 11
go-ethereum × 9
remix × 8
ethers.js × 8
contract-development × 7
contract-design × 7
ether × 7
security × 7
addresses × 7
raw-transaction × 7
block-header × 7