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
0 answers
9 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
18 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
25 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
18 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
41 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. ...
  • 121
0 votes
0 answers
14 views

Retrieving nounce of transaction without any other information but a random hash

The function eth.getTransactionByHash returns an object TransactionForRPC. Can I assume the parameters in this object can be parsed and read the same way as a JSON? Context: I am trying to retrieve ...
1 vote
1 answer
35 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 ...
  • 131
0 votes
0 answers
32 views

NFT whitelist merkletree

I hope you are all well. I am trying to make a frontend for an NFT minting DAPP. I use this code for the mint function: async function mint() { if(typeof window.ethereum !== 'undefined') { ...
  • 53
0 votes
1 answer
49 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
43 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
41 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
29 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
35 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(...
  • 15
0 votes
0 answers
82 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
146 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 ...
  • 251
0 votes
1 answer
9 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
0 votes
1 answer
60 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 ...
  • 135
0 votes
0 answers
92 views

Getting public and private keys for an ethereum account keyfile and password

I was trying to generate the private and public key of an Ethereum account keyfile(one which gets generated at new account creation) and the password of account. After I found 1st method, I tried to ...
0 votes
1 answer
34 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
0 votes
1 answer
524 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
24 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
0 answers
125 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
1 vote
1 answer
239 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 ...
  • 41
1 vote
1 answer
119 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 cryptozombies, and seeing that this function takes three inputs: uint(keccak256(abi.encodePacked(now, msg.sender, randNonce))) made me wonder how many ...
0 votes
1 answer
171 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
18 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: ...
0 votes
0 answers
20 views

I have made a DAO handler by using mapping of daoName and bytes32 and generated a random no. using keccak but the output is still coming 0;

// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; contract DAOManager { mapping(bytes32 => string) public daos; function _registerDAO(string memory daoName) public returns(bytes32){ ...
  • 1
0 votes
1 answer
211 views

Hash of hex value is different between Solidity and Ethers

Assume you have a string of hex data you want to hash. In Ethers: ethers.utils.keccak256("0x1234"); // "0x56570de287d73cd1cb6092bb8fdee6173974955fdef345ae579ee9f475ea7432" In ...
7 votes
2 answers
3k views

How to use ethers keccak256?

I tried to use ethers' keccak256 function like this: import { keccak256 } from "@ethersproject/keccak256"; const signature = keccak256("balanceOf(address)"); But the script ...
0 votes
2 answers
808 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 ...
1 vote
1 answer
102 views

Can you get a duplicate hash with params that are NOT a string or array, using keccak256(abi.encodePacked(a, b))?

It's relatively common to confirm a msg.sender is pre-approved for some contract interaction by verifying a signed hash of their address and another parameter. For instance: bytes32 checkHsh = ...
  • 69
0 votes
0 answers
53 views

CryptoZombies - Confused on how exactly using "randomNum % 10^16" shortens randomNum to 16 digits?

In the second to last line, I can see that the input argument is being hashed into a random 256-bit hexadecimal number. Then in the last line, it takes the random number and uses " % dnaModulus&...
0 votes
0 answers
120 views

Keccak hash for empty buffer("0x") is different in "web3-utils" and "ethereumjs-util"

Consider this example: import { keccak256 } from 'web3-utils' import { keccak } from 'ethereumjs-util' let web3UtilHash = keccak256('0x'); // web3UtilHash == null let ethUtilHash = keccak('0x', 256)...
  • 246
0 votes
2 answers
99 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 ...
0 votes
1 answer
292 views

What is the return of uint(keccak256(_str));?

I'm doing the chapter 1 of the crypto zombies course. uint id = zombies.push(Zombie(_name, _dna)) - 1; NewZombie(id, _name, _dna); } function _generateRandomDna(string _str) ...
  • 13
0 votes
2 answers
856 views

Using ECDSA to verify a signature inside smart contract

Following the technique to verify ethereum signature with ECDSA. Sign it like you mean it: creating and verifying Ethereum signatures Signing and Verifying Messages in Ethereum A Closer Look At ...
1 vote
1 answer
235 views

Unable to construct hash from address and uint256 for ecrecover and signature verification

I am creating a signature with web3.js form a hashed message that contains two numbers and an address: const tokenIds = [1,2,3]; const state = 1; const messageHash = web3.utils.keccak256(tokenIds....
  • 133
0 votes
1 answer
130 views

Minimum and Maximum Values Returned by keccak256

In the statement: uint256 x = uint256(keccak256(abi.encodePacked(valuesToEncode))); What’s the minimum and maximum possible values for x? When I looped random valuesToEncode the smallest resulting ...
  • 136
0 votes
0 answers
109 views

Why We use hex'ff' for genrate the pair address in uniswapV2 library?

I am working on uniswap router contract for _addLiquadity and there uniswap used uniswapV2library and into that library this below function is return the pair address but i dont understand what first ...
0 votes
0 answers
26 views

Vulnerability detection using Constraint Solving: Problem with the understanding Example of keccak256 as constraint

I am trying to discuss a paper based on Teether tool. It uses constraint programming to detect Vulnerabilities The text is discussing about an algorithm related to constraint solving and gives an ...
  • 1,285
2 votes
1 answer
229 views

How to make ethereum address from public key?

I want to manually create ethereum addres from any str message like that: const msg = '00' const pk = bytesToHex(sha256(msg)) //pk is ...
  • 176
1 vote
0 answers
430 views

How do I perform _hashTypedDataV4 on a struct containing an array of structs

I have signed a typed data, and I am trying to recover the address of the signer from my contract using ECDSA.recover(). But each time I try it, I get an address that is different from the address of ...
  • 131
0 votes
0 answers
64 views

Is the primary reason keccak256(a, b, c) was changed to keccak256(abi.encodePacked(a, b, c)) because of the forgery attack vector?

I am/have been a noob developer attempting to develop dApp. When keccak256(a, b, c) was suddenly deprecated years ago, it seemed to me like it just added unnecessary complexity. In hindsight, I have ...
  • 23
1 vote
2 answers
640 views

Which of abi.encodePacked and abi.encode was standard in Solidity compiler before Solidity 0.5?

Before Solidity v0.5, keccak256() took multiple arguments, and after v0.5 it requires a single bytes argument. Which of the two encoding types, encode/encodePacked, did the compiler use?
  • 23
1 vote
1 answer
196 views

Equivalent of CREATE2 address generation in JS

I have this solidity code from PancakeSwap's library, want to generate the same result in JS using ethers or Web3. How can I achieve that ? address(uint(keccak256(abi.encodePacked( hex'ff'...
1 vote
1 answer
157 views

Keccak 256 Error

I encountered keccal256 error in binance smart chain based coin. This error occurred in a token generated with cointool.app. I came across this example. how to solve this error? https://blog....
0 votes
1 answer
165 views

Decompiling the contract with keccak function

Currently, I'm researching how to construct the solidity version from the bytecode. However, I try to understand how keccak works, but I'm not sure about the parameters (such as the below code) So, ...
  • 1
0 votes
1 answer
751 views

Java Keccak 256 hashing implementation of multiple inputs

What's the best way to achieve the equivalent hashing in Java as below in Solidity? keccak256(abi.encodePacked(arg1,arg2,...))
5 votes
2 answers
4k views

How does keccak256 with abi.encodePacked internally works? I am getting two conflicting results

I have two uint256 values -> 2 and 0 When performing: keccak256(abi.encodePacked(uint(2), uint(0))) I got the correct result: 0xabbb5caa7dda850e60932de0934eb1f9d0f59695050f761dc64e443e5030a569 What ...
  • 83
0 votes
0 answers
133 views

Workaround invalid checksum when using ETH Private Key to sign messages sent to contract

I'm using an ETH private key to sign messages sent to a contract. I'm recovering the address from the signature inside the contract to verify the message (This actually took me days to piece together ...