Hacker News new | ask | show | jobs
by dada78641 1513 days ago
I've never seen whatever code this is, so correct me if I'm saying something stupid, but do they really use uint256 for their number variables? Like a number that goes from 0 to 115792089237316195423570985008687907853269984665640564039457584007913129639935? Are they trying to keep track of the number of atoms in the universe or something?
2 comments

Vitalik has said using 256-bit word sizes in the EVM was his biggest regret from the early days of Ethereum.

As others have mentioned, it was largely chosen because of the ubiquity of 32 byte hashes. But overkill for regular math. One pernicious issue is that it makes translating existing smart contracts into ZK rollups really challenging because 256 but arithmetic blows up the circuit size.

https://www.theblockcrypto.com/post/116413/vitalik-buterin-r...

It’s to prevent any possible chance of brute forcing the value. 64 bits is vulnerable. 128 bits is impervious, and probably won’t ever be vulnerable. But 256 bit crypto keys are common.
That's not quite right. We're talking about the type of the integer, this doesn't have anything to do (directly) with cryptography. It's a bit of a silly decision but Ethereum uses uint256 for many things to avoid having to do floating point math.
> Ethereum uses uint256 for many things to avoid having to do floating point math.

Wow. I'm pretty ignorant when it comes to Solidity, so it hadn't previously occured to me that it doesn't have floating point. It stretches the limits of the imagination to consider the insanity we'd be seeing if Ethereum did have floating point math.

Sure, there are other benefits of uint256. But it does simplify carrying around crypto keys.

256 bit integers to avoid floats seems like a good idea too. I’ve wished for it whenever I try to represent integers as double. 2^53 is such an arbitrary restriction.