-
Notifications
You must be signed in to change notification settings - Fork 1.4k
common/bitutil: deprecate XORBytes in favor of stdlib crypto/subtle #18218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
common/bitutil/bitutil.go
Outdated
| // XORBytes xors the bytes in a and b. The destination is assumed to have enough | ||
| // space. Returns the number of bytes xor'd. | ||
| // | ||
| // If dst does not have length at least n, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really explain what the n is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It refers to min(len(a), len(b))
| xorOff = (binary.LittleEndian.Uint32(cache[dstOff:]) % uint32(rows)) * hashBytes | ||
| ) | ||
| bitutil.XORBytes(temp, cache[srcOff:srcOff+hashBytes], cache[xorOff:xorOff+hashBytes]) | ||
| subtle.XORBytes(temp, cache[srcOff:srcOff+hashBytes], cache[xorOff:xorOff+hashBytes]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage is in the ethash implementation, so you can also consider removing ethash :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Means your suggestion is to remove this entire execution/protocol/rules/ethash directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do that yet :)
chfast
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already approved. My intention was just to indicate that the single usage of this function is in the semi-dead code, i.e. risk is very low.
With
Go 1.20, the standard library now providescrypto/subtle.XORBytes, which is more efficient than our existingbitutil.XORBytes. Because the custom implementation is referenced in only a single spot inerigon, deprecating it is straightforward.