This commit is contained in:
Kevaundray Wedderburn 2025-07-10 23:14:07 +01:00
parent adf6119e88
commit 66425aa070

View file

@ -438,8 +438,9 @@ func berlinMultComplexity(x uint64) *uint256.Int {
// TODO: if x > 2^64 - 7 // TODO: if x > 2^64 - 7
ceilDiv8 := (x >> 3) + ((x&7 + 7) >> 3) // safe ceil(x / 8) ceilDiv8 := (x >> 3) + ((x&7 + 7) >> 3) // safe ceil(x / 8)
z := new(uint256.Int).SetUint64(ceilDiv8) z := new(uint256.Int).SetUint64(ceilDiv8)
return new(uint256.Int).Mul(z, z) // square without overflow return new(uint256.Int).Mul(z, z) // square without overflow
} }
// Slow Bigint way (benchmark this) // Slow Bigint way (benchmark this)
// func berlinMultComplexity(xInt uint64) *big.Int { // func berlinMultComplexity(xInt uint64) *big.Int {
// x := new(big.Int).SetUint64(xInt) // x := new(big.Int).SetUint64(xInt)