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
18 views

ecrecover() gives back wrong signer

I try to verify a message signer. Everything seems to be working well (hashing values, sign message, vrs values … are correct) But when I call the ecrecover function it gives back a wrong address... ...
user avatar
  • 111
0 votes
1 answer
18 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 ...
user avatar
  • 133
0 votes
0 answers
24 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 ...
user avatar
0 votes
1 answer
18 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 ...
user avatar
  • 1
0 votes
1 answer
196 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'...
user avatar
0 votes
1 answer
18 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;...
user avatar
0 votes
0 answers
69 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 ...
user avatar
  • 1
0 votes
1 answer
102 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 ...
user avatar
  • 1
1 vote
1 answer
71 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 ...
user avatar
0 votes
1 answer
71 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 ...
user avatar
0 votes
0 answers
17 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: ...
user avatar
0 votes
0 answers
12 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){ ...
user avatar
  • 1
0 votes
1 answer
111 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 ...
user avatar
5 votes
2 answers
2k 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 ...
user avatar
0 votes
2 answers
361 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 ...
user avatar
1 vote
1 answer
63 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 = ...
user avatar
  • 69
0 votes
0 answers
34 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&...
user avatar
0 votes
0 answers
67 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)...
user avatar
  • 183
0 votes
2 answers
63 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 ...
user avatar
0 votes
1 answer
167 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) ...
user avatar
  • 13
0 votes
2 answers
555 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 ...
user avatar
1 vote
1 answer
167 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....
user avatar
  • 133
0 votes
1 answer
86 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 ...
user avatar
  • 101
0 votes
0 answers
77 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 ...
user avatar
0 votes
0 answers
24 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 ...
user avatar
  • 1,215
1 vote
1 answer
156 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 ...
user avatar
1 vote
0 answers
352 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 ...
user avatar
  • 131
0 votes
0 answers
58 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 ...
user avatar
  • 23
1 vote
2 answers
441 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?
user avatar
  • 23
1 vote
0 answers
136 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'...
user avatar
1 vote
1 answer
130 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....
user avatar
0 votes
1 answer
133 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, ...
user avatar
  • 1
0 votes
1 answer
544 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,...))
user avatar
5 votes
2 answers
3k 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 ...
user avatar
  • 83
0 votes
0 answers
117 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 ...
user avatar
0 votes
1 answer
58 views

getting incorrect topic[0] from web3.utils.sha3

I have the following event: event DelegatedManagerSet(bytes32 indexed loanId, address indexed delegator, address indexed delegated, bool isActive); I am trying to calculate the value of topic[0]. I ...
user avatar
1 vote
1 answer
129 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 ...
user avatar
  • 68
0 votes
2 answers
279 views

What is the significance of the function keccak256(abi.encode(to, ids))

I have seen a Solidity smart contract made by Polkamon, which is used to store NFT hashes, so that users can create an NFT without minting it, so that they can save Gas fees if they don't like their ...
user avatar
0 votes
1 answer
753 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 ...
user avatar
  • 1,343
5 votes
1 answer
3k 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 ...
user avatar
1 vote
0 answers
22 views

How to store in `address` two kinds of addresses at once?

I have a set of address values, each of them can contain a real Ethereum account (user account or contract) or a "virtual" address (an address pseudo-randomly generated by my contract, in ...
user avatar
  • 1,344
7 votes
2 answers
565 views

eip-1967 address calculation

I have read EIP-1967 and i have study how work proxy contracts. There is something i do not understand in EIP-1967. Here is what i have understood: Logic contract's storage variables are stored in ...
user avatar
  • 1,089
1 vote
0 answers
455 views

Constructing a Merkle tree of objects

I can keccak strings to construct the leaves of a Merkle tree, for example, ['a', 'b', 'c']. But what's the recommended approach to constructing objects instead of merely 'a'? Let's say: { address:...
user avatar
  • 244
0 votes
1 answer
451 views

How do I Encrypt Transaction Input Data Encode ABI

I'm buying erc20 token how can I encrypt my transaction input data . I using Javascript WEB3.JS method Can you help me with this? like this when try on check etherscan. Warning: Unable to decode input ...
user avatar
1 vote
1 answer
2k views

How to sign and verify data with ethereumjs-utils?

In my contract I'm verifying if some data was correctly signed by the owner. It looks like this: require( owner() == ecrecover(keccak256(abi.encodePacked(this, aCustomId)), v, r, s), ...
user avatar
  • 113
2 votes
1 answer
1k views

How to get the non-packed solidityKeccak hash in Python Web3

For Web3.solidityKeccak(['bool'], [True]) , Python Web3 yields: 0x5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2 This matches the output of keccak256(abi.encodePacked(true)) in ...
user avatar
  • 376
0 votes
1 answer
3k views

How to implement owner check in Solidity

Is there any EIP that specifies how to implement function in contract, that let's you call any other function as contract owner, with provided signature? I don't want to reinvent wheel. For example: I ...
user avatar
  • 713
6 votes
1 answer
2k views

What is the computing power of the Ethereum network in FLOPS?

The aproximate computing power of current Bitcoin network in terms of FLOPS (FP32) has been estimated at about ~80,000 exaFLOPS and being aware of the limits of the analogy because of the widespread ...
user avatar
  • 11
1 vote
0 answers
284 views

How to call the super contract function where msg.sender should be same in solidity?

I am trying to call contract A.fun_A() via Contract C contract A{ function fun_A(address tenant, uint itemId){ //Here the msg.sender should be msg.sender in C require(msg.sender == ...
user avatar
  • 11
0 votes
1 answer
402 views

How to get data location for string > 31 length

The documentation says: bytes and string are encoded identically. For byte arrays that store data which is 32 or more bytes long, the main slot stores length * 2 + 1 and the data is stored as usual ...
user avatar
  • 190