Questions tagged [keccak]
keccak is a cryptographic family which is used in ethereum and nowerdays provides the standards for sha-3
194
questions
0
votes
0
answers
14
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
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....
0
votes
1
answer
57
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
21
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
250
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
179
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
11
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
209
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
82
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
40
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
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 ...
1
vote
0
answers
141
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
39
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
547
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....
0
votes
0
answers
242
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
234
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 ...
0
votes
0
answers
38
views
To hash or not to hash strings for bytes32 AccessControl roles
Is there a preferred/safest way to declare roles for Openzeppelin's AccessControl.sol?
I would imagine a straight assignment of a bytes32 from a string would be sufficient for role creation as long as ...
2
votes
3
answers
388
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
0
answers
118
views
How to use keccak256 in assembly instead of keccack256(abi.encodePacked(address))?
I'm trying to use assembly to compare the gas usage of two implementations of the same function.
The following works correctly:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.17;
import ...
0
votes
2
answers
501
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
64
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
69
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
76
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
167
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
594
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
174
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
204
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
221
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
57
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
45
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
77
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
103
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
306
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
333
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
139
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
370
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
61
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
172
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(...
1
vote
1
answer
414
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 ...
0
votes
1
answer
679
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 ...
0
votes
1
answer
20
views
missing encodePacket / .abi + keccak256
I'm not 100% sure how to describe my issue, total noob following the BlindAuction solidity tutorial and stuck unable to compile. any help is much appreciated.
function generateBlindedBidBytes32(uint ...
1
vote
1
answer
491
views
generate function name yielding a specific function selector
Suppose I have a function with arguments (address _to, uint256 number)
The function selector is found using
let signature = "name(address,uint256)";
let selector = Keccack256(signature) ;
I ...
0
votes
1
answer
180
views
Need help trying to replicate ethers.utils.solidityKeccak256 in a Rails 6 controller
I'm not super familiar with Ruby or Rails, but I basically need to replicate this Javascript that uses ethersjs and call it from a Rails 6 controller. Anyone have any ideas how to achieve this? I've ...
1
vote
1
answer
1k
views
use javascript merkle tree to generate hex proof for solidity merkletree validation
Here is my js code of generating hex proof for solidity verification
const express = require('express')
const { MerkleTree } = require('merkletreejs');
const { bufferToHex } = require('ethereumjs-util'...
0
votes
1
answer
34
views
when i call my function metamask telling "this operation is expected to fail"
Hi guys im trying to create question challenge dapp and i have a checkAnswer() function can accessable from frontend.
My question struct:
struct Question{
string qDesc;
uint qPrize;...
0
votes
1
answer
258
views
Recover address from signature works only with MetaMask
I try to implement Web3 login to my page. It works with MetaMask, but with other wallets (like LRC, Coinbase or Argent) it doesn't - recovered address differs from the original one.
Ethereum\EcRecover ...
1
vote
1
answer
728
views
How to hash an address?
I just want to hash the senders' address
function myHash() public returns(string memory){
return(keccak256(abi.encodePacked(msg.sender)));
}
but no matter what I do I get the ...
1
vote
1
answer
275
views
What is the max number of inputs that can be entered in a keccak256(abi.encodePacked()) function?
I'm learning to use the keccak function on an online Solidity tutorial, and seeing that this function takes three inputs:
uint(keccak256(abi.encodePacked(now, msg.sender, randNonce)))
made me wonder ...
0
votes
1
answer
552
views
Different keccak256 for the same string
What is the reason that when i try to get the keccak256 values for the same string (which is "0x0000000000000000000000000000000000000000000000000000000000000001" or simply value of 1 in ...
0
votes
0
answers
24
views
Go Ethereum "invalid signature recovery id" when recovery byte is >= 4 [duplicate]
I have a signed message that was generated by Metamask. It looks like this: ...