Questions tagged [keccak]
keccak is a cryptographic family which is used in ethereum and nowerdays provides the standards for sha-3
206
questions
0
votes
0
answers
18
views
Calculate Transaction Receipt Root
I made a transaction on a local ethereum network that I spin up on my machine.
After that I fetch the transaction receipt & the block it was processed in, through an ethereum http provider from my ...
0
votes
1
answer
28
views
Problem recovering public-key from signature using secp256k1 module
When i try to recover the pubklic key using :
const publicKey = signature.recoverPublicKey(message_hash);
It return a point
Point {
px: ...
1
vote
2
answers
37
views
web3.js Keccak256 giving different answer
Minimum reproducible example :
hash1 = "be516d52220ea58966754101dd7ee25be73a695febd2bca54145681e2cc72fe9"
hash2 = "edede15ad23aba32fd2613ffee105278e322b2d81314bcb66eb4c453ad072bd4"
...
2
votes
1
answer
72
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: ...
1
vote
1
answer
94
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 = ...
0
votes
2
answers
53
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:
...
1
vote
1
answer
214
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):
...
0
votes
0
answers
115
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 ...
0
votes
1
answer
42
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 ...
0
votes
1
answer
58
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 (...
0
votes
2
answers
30
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 ...
0
votes
1
answer
87
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 = "...
1
vote
0
answers
52
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 ...
1
vote
1
answer
421
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 = ...
0
votes
0
answers
33
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 = ...
0
votes
1
answer
138
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....
0
votes
1
answer
188
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"],
...
1
vote
1
answer
99
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
...
0
votes
1
answer
799
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 {
...
0
votes
1
answer
474
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() ...
1
vote
0
answers
17
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 ...
0
votes
1
answer
684
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, ...
1
vote
1
answer
152
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 ...
0
votes
1
answer
46
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 ...
1
vote
0
answers
199
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 ...
1
vote
0
answers
179
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....
2
votes
1
answer
81
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 ...
4
votes
1
answer
1k
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....
1
vote
0
answers
494
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 ...
3
votes
1
answer
330
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 ...
2
votes
3
answers
693
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 ...
0
votes
2
answers
801
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 ...
2
votes
2
answers
113
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 ...
1
vote
0
answers
79
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 ...
2
votes
1
answer
88
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,...
0
votes
1
answer
256
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 ...
1
vote
1
answer
760
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 ...
1
vote
0
answers
207
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 ...
1
vote
1
answer
278
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()")
...
2
votes
0
answers
299
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 ...
0
votes
0
answers
70
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 ...
2
votes
1
answer
56
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 ...
2
votes
1
answer
99
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 ...
1
vote
1
answer
144
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.
...
1
vote
1
answer
457
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 ...
0
votes
1
answer
421
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 (...
0
votes
1
answer
187
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 ...
0
votes
1
answer
518
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 ...
1
vote
1
answer
81
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-...
1
vote
2
answers
216
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(...