Questions tagged [hash-algorithm]

A hash algorithm is any algorithm that can be used to map data of arbitrary size to data of fixed size. The values returned by a hash function are called hash values, hash codes, hash sums, or simply hashes. In Ethereum, the algorithm used is Keccak 256.

Filter by
Sorted by
Tagged with
0 votes
1 answer
51 views

How to detect `Keccak256` collision inputs

I'm trying to solve this -simple- small CTF challenge, the goal is to change the solver value to our address by calling the talk function: // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8....
REZAZI MOHAMED ABDESSAMED's user avatar
1 vote
0 answers
95 views

MerkleTree hashing keccak256 in golang is different with in js

I am dealing with hashing keccak256 of address and amount to push to merkle tree in golang. I try to hash in js by using https://github.com/OpenZeppelin/merkle-tree lib and it is valid. but in golang ...
Vini Tran's user avatar
1 vote
1 answer
448 views

How to implement Poseidon hash function into a smart contract

I am building a Merkle tree inside a smart contract, and I want to use the Poseidon hash function to later prove that an element belongs to the tree through a ZK proof. The problem is that I cannot ...
Fred Baptista's user avatar
0 votes
0 answers
24 views

Can PoS validators directly influence and choose the output hash of the block?

I'm interested in explanation for Ethereum Beacon [1] and also any forked EVM network [2] (Polygon, Binance, Fantom). Here's validator turn to validate the block. Can he directly pick the set of ...
0 votes
0 answers
63 views

PoSA(Proof of Stake Authority) and NPoS(Nominated Proof of Stake Authority?

The Proof-of-Staked-Authority (PoSA) consensus algorithm is a hybrid between the Proof-of-Staking and Proof-of-Authority consensus mechanism. Nominated proof of stake, or NPoS, is similar to proof of ...
Leon Africa's user avatar
0 votes
1 answer
34 views

Is there a way to change the block hashing method of private Etherem?

As all we know, Ethereum hashes blocks by Keccak-256 and this method used in private Ethereum too. Now, if we need to use Keccak-512 for hashing blocks in a PoA private Ethereum (For our project), ...
Alireza's user avatar
  • 533
3 votes
2 answers
401 views

if I put a message's sha256() hash on smart contract, can anyone recoverd the message?

If no one can recover the message, can I use this message as a "password" to some functions in the smart contract? like: contract Test { bytes32 hash; constructor(bytes32 _hash) { ...
JESSE Bin's user avatar
  • 187
1 vote
0 answers
589 views

How to correctly calculate the hash to sign of a transaction with Ethers? is "\x19Ethereum Signed Message:\n32" still necessary?

I am trying to get the public key of the sender from a signed transaction. I am getting the transaction information with the help of alchemy and quicknode. The response I get is a json object like ...
Oscar Serna's user avatar
0 votes
1 answer
190 views

How to determine if the hash is finalized?

For some reason, I am require to store the hash to database. I would like to know is there any criteria to determine that the hash is finalize? For example, Block #15000000 have hash value of ...
karfai's user avatar
  • 101
1 vote
1 answer
617 views

Tornado Cash Hasher contract - circom

In the Tornado Cash constructor, it takes an argument: Ihasher _hasher; where the Ihasher is: interface IHasher { function MiMCSponge(uint256 in_xL, uint256 in_xR) external pure returns (uint256 ...
thefett's user avatar
  • 3,813
0 votes
2 answers
2k views

What exactly is the output of a keccak256() function?

I've been looking through articles and youtube videos and I still don't get it. I'm trying to get to a place where I can explain it to myself in simple terms (I'm still pretty new to coding). What I ...
saxajeel's user avatar
0 votes
2 answers
315 views

Does SHA256 and/or Keccak consider current date time in hashing?

Does SHA256 and/or Keccak considers current date time in hashing? I am curious how it avoids or reduces chances of collision. With so many wallets addresses getting created, I hope there is some ...
Ra Murd's user avatar
  • 43
1 vote
0 answers
518 views

Can I get the IPFS hash from file (without uploading it & with java)?

As far as I'm concerned IPFS client uses the resulting SHA-256 hash from files, and also compatible with others, to index them in the IPFS Protocol. My problem is that I'm not sure how to consistently ...
Alexander Herranz's user avatar
1 vote
0 answers
23 views

Understanding Hash Lock Atomic Swaps

I have trouble understanding how exactly atomic swaps take place in HTLCs. Let's take the generic example: Alice wants to trade 1 BTC with Bob in exchange for 15 ETH. Alice creates a contract where ...
Anters Bear's user avatar
0 votes
0 answers
197 views

solidity compiler hashing function

What hashing function or encoding scheme does solidity default compiler use to encode or hash the data of smart contracts in remix ide?
nazya's user avatar
  • 1
0 votes
0 answers
652 views

How do I know what the hashing algorithm is for my BEP20 Token?

How do I find the hashing algorithm for the BEP20 Token that I created using remix.Ethereum? I am fairly new to the token world, but I managed to create a token. Here is the link to Bscscan if that is ...
Taylor3417's user avatar
1 vote
0 answers
18 views

Check string similarity percentage

How can I efficiently check the similarity of two strings? Or better yet, if I have an array of strings, I want to check that the given string is less than e.g. 80 % similar to any of the other ...
user2340939's user avatar
1 vote
1 answer
192 views

Why is this Javascript Ethash implementation returning a wrong hash result?

I'm trying to calculate the hash result for the "light" implementation of the Etash algorithm from ethereum/ethash/js but I can't seem to get the correct result. The expected result for ...
watson's user avatar
  • 68
0 votes
1 answer
2k views

When is hashing used when creating a smart contract?

I was going through the solidity docs and in a contract example given I have seen keccak256 used. // Perform checks to determine if transferring a token to the // `OwnedToken` contract should proceed ...
YulePale's user avatar
  • 1,823
8 votes
2 answers
5k views

Solidity's keccak256 hash doesn't match WEB3 keccak hash

TL;DR: I have a method in a contract to calculate a keccak256 hash, and I'm trying to replicate it in Web3, but the hashes don't match. My problem is very similar to the one in this question, but the ...
Justcurious's user avatar
0 votes
1 answer
4k views

Hardhat local network keys generation

I noticed the generation of Hardhat local Etheruem network keys are found on the Mainnet. Example: After running npx hardhat node. Accounts ======== Account #0: ...
penguin's user avatar
  • 133
1 vote
1 answer
217 views

How to use bcrypt in a smart contract?

Is it possible to use bcrypt hash function in a ethereum smart contract? Or only keccak is available? Searching I got to this question, where the OP apparently assumes it's possible, but there is no ...
Justcurious's user avatar
5 votes
1 answer
13k views

What is Ethash4G? Is it related to Ethash?

I've been toying around with the online crypto calculators, and stumbled across this on WhatToMine. What is Ethash4G? Is it related to Ethash in anyway, and by extension, Ethereum? Any insight would ...
GipsyD's user avatar
  • 153
4 votes
0 answers
231 views

how to calculate the message part for pedersen hash in solidity

I am trying to implement pedersen hash using solidity. Is it possible to implement and how to split the message according to the conditions of pedersen hash.
gasbot's user avatar
  • 41
1 vote
0 answers
32 views

Why does proof of work targeted zeros always comes at the start of hash? why is it not in the middle or the end of hash?

My question is why always targeted zeros come at the start of hash of the block? I have never seen more than 2 zeros in middle or somewhere else in the hash of mined block... What's the reason?.... ...
zohaib's user avatar
  • 11
1 vote
1 answer
207 views

Is it cheaper overall to store a keccak hash or to store a ripemd(keccak) hash?

As titled. I'm learning to build a DApp and I'm wondering if it's worth it to add the extra RIPEMD layer over keccak for a shorter hash to reduce storage costs.
bishopqpalzm's user avatar
4 votes
0 answers
142 views

what is a pseudorandom cache mentioned in ethereum yellow paper

in ethereum yellow paper it says: "There exists a seed which can be computed for each block by scanning through the block headers up until that point. From the seed, one can compute a pseudorandom ...
zifan yan's user avatar
2 votes
1 answer
1k views

Is any 40 character hex string a valid ethereum address?

I know an ethereum address is generated by getting the last 20 bytes of the keccak-256 hash of the public key, which is 40 hex digits. I also know, an address does not need to have transactions ...
Guiomar Raissa's user avatar
0 votes
1 answer
89 views

Building a deterministic wallet without random seed phrase instead multiple static inputs

If I want to be able to create a private key given inputs x,y,z and these inputs are constant, if I add enough entropy as a salt would it be secure to create a key this way (in terms of brute force ...
Brian's user avatar
  • 101
1 vote
1 answer
437 views

How to verify the sha256 result of integer 5 in the Zokrates tutorial?

The Zokrates tutorial here starts with calculating the SHA256 hash of (the number) 5. The hex representation of the result is shown at the bottom here: However, I could not reproduce this on my ...
Ytsen de Boer's user avatar
6 votes
3 answers
11k 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('...
Kevin Wad's user avatar
  • 317
0 votes
0 answers
56 views

Need to help in adding bigendian support for Keccak256.cpp

Need help in making the keccakf function based on endiness in https://github.com/ethereum/solidity/blob/develop/libdevcore/Keccak256.cpp. I have gone through similar functionality at https://github....
R_SS's user avatar
  • 101
3 votes
2 answers
2k views

Hashnot matching generated from solidity contract and web3js

I want to make hash same as generating by solidity contract from web3 or ether's js. In solidity contract hash generation by below : sha256(abi.encodePacked(no of parameters)). Kindly help for it. ...
chinmay's user avatar
  • 31
1 vote
1 answer
1k views

How does a message signed in Remix IDE?

What is signing method that is used in remix IDE and how is the hash value calculated from the message that is being signed?
user48127's user avatar
7 votes
2 answers
2k views

block-header hash verification

As part of a validation service I am working on, I need to be able to verify that the blockHeader hash was created correctly. Based on my understanding following are the steps to regenerate the header ...
AnuragP's user avatar
  • 421
0 votes
1 answer
806 views

Match web3py hashing function to solidity hashing function

If I am using web3py to hash some data, like so, msgHash = w3.soliditySha3(['bytes32','bytes32'], [dataBytes, saltBytes]); What would be the correct way to hash inside of a Solidity contract and ...
Sean Thoman's user avatar
1 vote
2 answers
638 views

HMAC-x implementation for solidity

Is there any implementation of HMAC-SHA1 or HMAC-SHA256 or any other hashing algorithms for solidity? I found this but it's not working.
saman.shahmohamadi's user avatar
2 votes
1 answer
701 views

I want to compare hash that I have passed in the argument of the function but keep getting this error

function compare(string memory input, uint _y) public returns (uint){ bytes32 hashedinput = keccak256(input); } Error: Invalid type for argument in function call. Invalid implicit conversion from ...
Nedo Nido's user avatar
2 votes
1 answer
136 views

Calculating a hash of a set of keys in Solidity

I have the following problem that I'm trying to think of an efficient solution for. Suppose I have a set of unordered keys (KEY_1, KEY_5, KEY_2, KEY_4), and I want to calculate a unique hash for this ...
Adam Dossa's user avatar
  • 1,287
3 votes
0 answers
81 views

Why does a full client need to store the DAG?

The yellow paper says that miners and full clients must store the DAG dataset, but light clients can verify block headers by generating only a few necessary pages from the DAG. It makes sense to me ...
user46363's user avatar
0 votes
1 answer
244 views

Why is this random algorithm not good enough?

Many lotteries on Ethereum use random algorithms to determine a 'winner'. For instance, this function is bad because has some vulnerabilities (read here about some): function random() private view ...
Iulian's user avatar
  • 640
0 votes
2 answers
983 views

retrieving an original data from a hash: is it reliable?

Normally, one of the purposes of hashing a string (such as a transaction) is summarizing the data to save the size because of the space limitation. If this proposition is true, now assume we need to ...
Questioner's user avatar
  • 2,670
5 votes
2 answers
1k views

How is the keccak256(a, b) function implemented?

I need to understand how keccak256(a, b) is implemented and how it differs from keccak256(a || b). Is the content padded? I need this because I do not want to allow for vulnerabilities where a user ...
Symeof's user avatar
  • 1,434
1 vote
2 answers
293 views

Common use cases for hashing functions? [closed]

I'm developing my first dapp with solidity and I was wondering in which cases should I use hashing functions like keccak. I know how they work but it is not clear to me when should I use them and to ...
pan1994's user avatar
  • 169
0 votes
1 answer
82 views

Hash of address pair combination where order is irrelevant

I have a contract where I often set stuff for a combination of 2 addresses. Because the parameters addressA and addressB are interchangeable I currently save the information redundantly. Example: ...
CodingYourLife's user avatar
0 votes
1 answer
2k views

sha256() output

I used sha256() hash of a string and I got the following result 0x0de69f56365c10550d05e65ae8229dd0686f7894a807830daec8caa879731f4d for string Hello World2. Now I want to find out leading byte from the ...
Divya Galla's user avatar
2 votes
1 answer
156 views

Hashing Algorithm - Multiple choices in Solidity

Is it possible to choose another SHA algorithm - say SHA256 - in Solidity? Anyone having issues with NIST compliance?
BlockRocked's user avatar
1 vote
0 answers
117 views

Error deploying contract to my private network

I keep getting this "Error: The contract code couldn't be stored, please check your gas amount." message when I try to deploy my contract to the blockchain. I read that is a generic error so I'd like ...
Kurosh D.'s user avatar
2 votes
1 answer
2k 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 ...
hannes's user avatar
  • 21
2 votes
3 answers
248 views

Are Ethereum Contracts Vulnerable to Hash Table Poisoning Attacks?

Does anybody know something about this? I know that in general terms we will say not, but looking on the internet I found that isn't sure the answer to the question: Can the EVM’s Internal ...
CPereez19's user avatar
  • 2,835