Hot answers tagged

12

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 need to call utils.sha3('test').


11

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.120:8545 ... ℹ 35:02:42.89 ethminer Nonce: ff4136b6b6a244ec ℹ 35:02:42.89 ethminer Mixhash: ...


10

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 you need to understand what a hashing function is. A hashing function is a one way(non invertible function) that maps a set of inputs to a set of outputs hash(s) -...


9

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 issues, or major security problem. The only reason I can think of where hashing is helpful is to maintain parity between externally owned accounts and internal ...


8

What you see in block explorers is the sha3 of the block header, not the ethash.


8

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'}); As a general side-note: you have to pay gas costs to do any custom work in Solidity so, when possible, you are best off working on the javascript side.


7

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 bytes32s prepended with a 0x called first and second, it looks something like: # keccak, change before upgrading pysha >= 3.10 from sha3 import sha3_256 ...


7

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 bytes in hex is 1220, where 12 denotes that this is the SHA256 hash function and 20 is the length of the hash in bytes - 32 bytes. Source Although SHA2-256 ...


7

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 draft Keccak submission, only the padding rule has changed. The padding change is the only difference, this allows future tree hashing modes as well as the ...


6

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's address, and when the block is published, the miner just gets 5 more Ether added to their balance, without the need for a transaction. See this question for ...


6

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 passes them all. Conclusion: The experimental results show the KECCAK hash function has excellent pseudo randomness, and its security shows that it can be ...


6

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-and-global-variables.html So you would need to construct signedTransaction since this value is not exposed to solidity, cf. https://stackoverflow.com/...


5

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 hashing functions like sha256, keccak256: https://github.com/ethereum/solidity/issues/980. So generally the members of the structs have to be compared against each ...


5

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 algorithm. Keccak-256 is the most commonly-used hash function. Keccak-256 is used internally in places like when making hashes for block headers, but the place ...


5

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 today's price, it's $0.177 per tx. You can optimize it by using aggregations services, such as Open Timestamps In Ethereum, there are at two options to store ...


5

Below are the steps to calculate blockHash, given a blockNumber: Step1. eth.getBlock(400000) Output:{ difficulty: '6022643743806', extraData: '0xd583010202844765746885676f312e35856c696e7578', gasLimit: 3141592, gasUsed: 0, hash: '0x5d15649e25d8f3e2c0374946078539d200710afc977cdfc6a977bd23f20fa8e8', logsBloom: '...


4

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 includes the hash of the said data was generated Problem solved: proof of existence can be a service in itself, but it can also enable broader services such as ...


4

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. There are hard and soft, system wide and per user limits. To check the maximum number of file descriptors configured on your Linux system: user@Kumquat:~$ cat ...


4

Yes, hash was an old type that's been replaced with bytes32. You can call sha3(data1, data2, ...) and use that as a key. There's still some open discussion on hash.


4

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 random generator. It is a riddle to produce a hash of the last block with a certain amount of zeros as prefix. This is essential for Proof of work systems. With ...


4

In Parity the hash is the an item for the ordering criteria, as you can see here: https://github.com/paritytech/parity/blob/1aaafa2d11b42af6be97754f4bc06e2856904464/ethcore/src/miner/transaction_queue.rs#L179 So in theory, the hash can decide the order, if the previous ordering compared to "equal". However miners can, and probably do, run custom algorithms ...


4

It doesn't work because a string is encoded differently than bytes32, so it won't work through using the call method, because you have to the ABI encoding yourself. It will work for other types such as uint or bool.


4

If I understand correctly your want to upload a file from the client machine to the web application using the standard HTML tag <input type="file"> and then hash the content of the file. Your code is actually hashing the full path of the file. If you want to read the content of a file, I recommend to use FileReader like this: HTML: <div> &...


4

There is no way to cancel the transaction (even if you know the tx hash) It is most likely pending for a long time, because of the low gas price. It might take you a few days until your transaction gets through. If you know your transaction's gas price is under 3 it takes a long time. For current gas prices see here: https://www.ethgasstation.info/


3

Hashing is one-way: If you have text you can create a hash, but if you have a hash you can't use it to recreate the text.


3

Also, you can perform keccak256( address ) in a constant solidity function locally, and then pass the result into a transaction. Of course, this is not safe for production, if you let users do that in their browser.


3

There is really no way you can do what you want. If you think about it some more and take into account the architecture of a distributed p2p system such as IPFS - the definition of being "valid" or "existent" is not really that obvious. If you ask IPFS for a file matching a given hash - it walks through a set of available nodes in the network trying to find ...


3

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 together like this: function hashSeriesNumber(string calldata series, uint256 number) external pure returns (bytes32) { return keccak256(abi.encode(number, ...


3

Question 1: How to get the hash value head/current block in a private chain? You can use the web3.eth.getBlock function and then get the hash from that: web3.eth.getBlock(blockNumber, function(block) { console.log(block.hash); }) Question 2: Why the number of blocks keeps increasing in a private chain even though no transaction is being sent to the ...


3

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, as showed in this image 1. Therefore in order to calculate the transaction function, you need to be able to: Calculate the KEC256 bit hash of an arbitrary ...


Only top voted, non community-wiki answers of a minimum length are eligible