Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [keccak]

keccak is a cryptographic family which is used in ethereum and nowerdays provides the standards for sha-3

Filter by
Sorted by
Tagged with
1 vote
2 answers
29 views

web3.js Keccak256 giving different answer

Minimum reproducible example : hash1 = "be516d52220ea58966754101dd7ee25be73a695febd2bca54145681e2cc72fe9" hash2 = "edede15ad23aba32fd2613ffee105278e322b2d81314bcb66eb4c453ad072bd4" ...
shadow's user avatar
  • 23
2 votes
1 answer
56 views

C code to sign a message compatible (such that can be verified) with Metamask, mycrypto, etc

I am on macOS and trying to put together the code to sign (and once I succeed to verify) a message with an Ethereum private key. So, the private key (just used to test, no funds there lol) is: ...
capodieci's user avatar
1 vote
1 answer
88 views

Is the sum of hashes cryptographically secure for a set of addresses?

In a smart contract, I want to maintain a set of addresses independent of the order. Would the sum of the hashes for each of the addresses be a cryptographically secure approach? If I do: root = ...
wolf dun's user avatar
0 votes
2 answers
44 views

How do I get the correct 4bytes?

I'm using this tool to get the keccak 256 hash: https://emn178.github.io/online-tools/keccak_256.html However I'm trying to the 4bytes for executeOrder. The executeOrder function signature is this: ...
caker's user avatar
  • 195
1 vote
1 answer
157 views

Getting incorrect signer address on verifying the signature with the generated hash of the signed message in solidity

Basically on verifying the signature with the generated hash of the signed message, I'm getting the correct signer on JS, but not on Solidity. JS Code (According to Keir Finlow-Bates' suggestion): ...
SYED ASAD KAZMI's user avatar
0 votes
0 answers
82 views

eth_sign invalid "from" address in signature in Trust Wallet browser extension or 0 balance when user has money

Problem I have code for sending 1 dollar from user to my account. It always works for all wallets except the trust wallet extension (trust wallet mobile works also). When I watch the result ...
noofdmsl1987's user avatar
0 votes
1 answer
33 views

Cannot verify signature

I have been trying to do it but it always return me false, tried a lot of ways but I don't know. Here is the smart contract function _verify( bytes32 hashedMessage, bytes memory ...
AndRockSYS's user avatar
0 votes
1 answer
41 views

How to change the offset of calldata value?

Suppose I have a contract below: contract Hack { Switch private target; constructor(address _target) { target = Switch(_target); } function test() external pure returns (...
Shubham's user avatar
  • 25
0 votes
2 answers
20 views

Hashes don't seem to match even though created with the same params

I have a function in Solidity that is supposed to check if the recovery hash committed by the Email recovery service matches the hash generated through the token and nonce sent by the user (He ...
alfheimrShiven's user avatar
0 votes
1 answer
42 views

How do I manually find the storage slot for a string greater than 32 bytes?

This is my contract: SPDX-License-Identifier: MIT pragma solidity 0.8.22; contract StringStorage { string short_string = "ABCD"; string long_string = "...
davidastro's user avatar
1 vote
0 answers
36 views

Merkle Tree Verification Consistently Fails in Solidity Smart Contract Tests

I am working on a Solidity smart contract for a lottery system using Merkle trees to verify winners. However, I consistently encounter an issue where the verify method of the Merkle Tree returns false ...
PraveenMatheesha's user avatar
1 vote
1 answer
271 views

How can I create a message hash in Solidity that matches Viem?

I'm creating a message hash with Viem in typescript and in Solidity, however, I can't seem to get the hash in Solidity to match the one created with Viem. My viem code: const hashedMessage = ...
Rohan Nero's user avatar
  • 1,607
0 votes
0 answers
29 views

Verify signature from dApp on contract

I am creating a signed message using a user address, nonce and number (amount of eth to send) like this: const ammount = 1; const userAddr = await otherAccount.address const nonce = ...
Jesse Jacob's user avatar
0 votes
1 answer
92 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
0 votes
1 answer
163 views

Signing message using web3 and using ethers gives different result. Why?

I'm encoding a message using ethers' solidityPackedKeccak256() const encodedMessage = ethers.solidityPackedKeccak256( ["address", "uint256", "uint256"], ...
ujjwalvinze's user avatar
1 vote
1 answer
62 views

How to create a hash based on struct array types?

I have the following arguments to call a function in a smart contract: ERC20Reward[] calldata _erc20Rewards ERC721Reward[] calldata _erc721Rewards ERC1155Reward[] calldata _erc1155Rewards ...
Falcon Stakepool's user avatar
0 votes
1 answer
627 views

How to reverse keccak256 in solidity

I need help with the following code where I'm given the keccak256 of a parameter and need to reverse it to find the parameter to solve the challenge contract LessonFive is AFoundryCourseChallenge { ...
moustafa meta's user avatar
0 votes
1 answer
382 views

How to use ethers.js keccak256 along with a salt phrase so that it's compatible with Solidity keccak256 function?

I have a Solidity 0.4.26 smart contract. I'm using a commit-reveal pattern to hide to first user's commitment move. I have a helper contract Hasher that hashes the user's commitment with a hash() ...
Mila A's user avatar
  • 1,219
1 vote
0 answers
15 views

How to manually hash blocks and transactions to get a better feel for the Ethereum protocol?

Is there a way to easily get a transaction, the full transaction payload, and then hash it with keccak256 using a hash tool, to get a better feel for how the protocol works? Ditto for full blocks. I ...
Danny B's user avatar
  • 323
0 votes
1 answer
474 views

"invalid signature length" when trying to verify signature

I'm using the entire source code to sign and verify messages from https://solidity-by-example.org/signature/ on Remix. But when I go through the process of running the functions getMessageHash, ...
ratib90486's user avatar
1 vote
1 answer
125 views

Does casting a Keccak256 hash to a uint256 increase likelihood of a collision?

I have a smart contract with 50+ trillion possible NFT names that could be minted (all have unique names), is there any chance that this method could cause a collision of token ID's? - uint256 tokenID ...
Vince Reid's user avatar
0 votes
1 answer
44 views

Custom digital signature of a wallet

I would like to get a custom signature from a wallet. What I mean is, according to EIP-712 the signature algorithm used in Ethereum is kekkac256; I would like instead to use a custom signature ...
Mattia Monari's user avatar
1 vote
0 answers
158 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
0 answers
172 views

Python | eth_utils | Public Ethereum Address derivation from Public key not working

I have the below, trying to derive the Ethereum Address from public key (working) using keccak and to_checksum_address on eth_util, but doesn't match up with derivation on iancoleman.io or miguelmota....
mull's user avatar
  • 21
2 votes
1 answer
67 views

Verifying OTP on-chain (keccak vs ecdsa)

I am looking to build a smart contract that enables a user to withdraw the contract funds via a one-time-password provided by the creator. My idea was to hash a password off-chain and store that ...
wenzel's user avatar
  • 21
4 votes
1 answer
868 views

The Solidity 'keccak256' and the Javascript ethers.js 'solidityKeccak256' produces different output

I'm trying to code a signature like opensea does for approving the Terms of Service. To do so I'm using the ECDSA library. This code in javascript using ethers: const message = ethers.utils....
Loo's user avatar
  • 41
1 vote
0 answers
412 views

The definition and Implementation of the Keccak256() function

So I don't know if this is a silly/obvious question or not but after many hours I turn to the community for help. So for the past few days I've been writing my own C++ code to take an input public key ...
Daemin's user avatar
  • 11
3 votes
1 answer
288 views

calldata ambiguity - likelihood of hash collision

To call a function in a smart contract, a transaction (or a message call depending on where it originates from) is sent to the contract address with a data field that has the encoded function ...
Adham's user avatar
  • 181
2 votes
3 answers
596 views

possible to calculate keccak256(abi.encodePacked("abc")) in DAPP layer?

In my solidity code, I am doing a lot of stuff like this: keccak256(abi.encodePacked("abc", "def")) And then returning the value in an event, which is picked up in dapp. Now, since ...
Somjit's user avatar
  • 265
0 votes
2 answers
675 views

Blockhash and Block Timestamp manipulation in PoS

I was looking at generating some psuedo-random numbers in an Etheresum smart contract and understand that it is possible for miners to manipulate the blockhash and block.timestamp. The Solidity ...
chriscrutt's user avatar
2 votes
2 answers
100 views

How come these 2 Ethereum addresses are identical except for 1 character?

I always assumed that Ethereum addresses were, more or less, uniformly (randomly) distributed over their 40-char hex representation. Is that not the case? I've found these 2 addresses that only differ ...
Geert-Jan's user avatar
  • 169
1 vote
0 answers
76 views

Getting wrong signature while using etherjs in react native

I'm trying to get the signature using etherjs in a react native project which should be compatible with ECDSA.sol, When i try to get the signature with metamask it returns totally fine. but when i try ...
Hamza Yasin's user avatar
2 votes
1 answer
82 views

I want to encode and store the address variable and the uint256 variable

I am currently using it as follows. bytes memory _byte = abi.encode(ca, tokenId); I learned that this method can take different variables and produce the same results. If I use the keccak256 function,...
Primrose's user avatar
0 votes
1 answer
218 views

Same value for keccak256 in different contracts

In Solidity, let's say there are two contracts A and B with the same code as in the following example. By the way, do they return the same bytes32 value when retrieving ROLE? Why do we use keccak256 ...
Shift_that's user avatar
1 vote
1 answer
729 views

Recover public key from signature and address only works with MetaMask provider

I have to implement a login system with a web3modal using WalletConnect & MetaMask. After many attempts, it seems that all the existing source codes about this on the internet only work with ...
Gniax's user avatar
  • 21
1 vote
0 answers
202 views

EIP712 - Unable to verify signature return from js

I am trying to verify a signed message in my smart contract that I generated from javascript. I followed another example but for some reason can't figure out why the verify function keeps returning ...
730wavy's user avatar
  • 85
1 vote
1 answer
250 views

Whta's difference between web3.utils.toHex() and web3.utils.keccak256()?

I've been practicing Ethernaut CTF and I'm stuck on the Delegation problem. First, I tried to approach this in the console. But I couldn't get ownership. var pwn = web3.utils.toHex("pwn()") ...
Shift_that's user avatar
2 votes
0 answers
276 views

Keccak256 hashing of types and values in Java

I'm trying to use the Web3j library (or any other library for that matter) to Keccak256-hash a list of types and a list of values to sign a quote. Specifically, I need to implement the second code ...
Hopscotch's user avatar
0 votes
0 answers
65 views

Convert kecka256 hash string back to bytes32

I am storing kecccak256 to hash some string value and store it as mapping. mapping(bytes32 => address) internal _owners; and my mint function looks like this - function _mint(address to, string ...
Ujjwal Kumar Gupta's user avatar
2 votes
1 answer
51 views

What information can I get from a hash?

Say i have a hash - I think sha256/keccak: 90ad6dec4ce7167e92c7a7122232d48a1fd5e6c5e81cb3f45c147424b6728437 What do i do with it? Is there something on etherscan that can decipher it or show what it ...
LazyOctopus's user avatar
2 votes
1 answer
88 views

Question about the namehash algorithm in EIP-137

I am trying to recreate the namehash algorithm from EIP-137. After spending a lot of time trying to create my own algorithm, I tried to find a working python3 package online and couldn't find any. I ...
Jack Hancock's user avatar
1 vote
1 answer
133 views

Cannot generate Ethereum address from private key

I am trying to use the Bitcoin ECDSA Library to generate an Ethereum address from a private key. I took the private key from my Metamask wallet then used the following code to generate the public key. ...
Melkor's user avatar
  • 121
1 vote
1 answer
415 views

What's the probability of getting the same signature using ECDSA?

If I hash the message "HELLO" - keccak256("Hello") then run it to an ECDSA, what's the probability that I will get the same r, s and v value everytime? Do I need to add some unique ...
Lonewarp's user avatar
  • 151
0 votes
1 answer
402 views

ecrecover returns incorrect address

I use these contract functions to verify signed message: function verify( address to, uint256 amount, uint256 nonce, bytes memory signature ) public view returns (...
Ruarin's user avatar
  • 13
0 votes
1 answer
176 views

Signature from array of tokenId's isn't verifying

The domain message is: struct Offer{ address from; address to; uint256 nonce; uint256[] tokenIds; uint256 duration; } bytes32 constant ...
Владимир Владимирович's user avatar
0 votes
1 answer
460 views

Why does web3j and javascript keccak256 return different hashes if '0x' is at the start of the string?

We are trying to build a merkle tree in web3j and put the root for verification into the smart contract. Due to this problem we can't generate the same route between web3j and solidity/js... In ...
Neil Collier's user avatar
1 vote
1 answer
73 views

How to compare string and bytes32 in an optimal way?

I have keccak256 string encrypt in blockchain and keccak256(decrypt) bytes in function. This code works well. I pass an unencrypted string to the function and check it for validity. // SPDX-License-...
Alex Baker's user avatar
1 vote
2 answers
205 views

Cannot get correct MethodID from a function

I am trying to derive the MethodID from the function, based on this post. However, when I look at this transaction on Etherscan, I cannot see how swapExactTokensForETHSupportingFeeOnTransferTokens(...
gioro's user avatar
  • 15
1 vote
1 answer
486 views

Python Merkle Tree Libraries Don't Produce The Same Merkle Root As Node.js's "merkletreejs"

I have been trying to create merkle tree proofs in python. In a whitelisted NFT project, I've used npm's merkletreejs which is a JavaScript library and it worked beautifully. Here is the Github page ...
ChristianOConnor's user avatar
0 votes
1 answer
810 views

Recover Parameter from given signed message

I got a problem with keccak hashing. The Goal: A Server should create a parameter list and a sign. (I try it here with just one uint256 parameter) The Contract should check if the sign fits with the ...
MaTok's user avatar
  • 331

1
2 3 4 5