p2p/rlpx: optimize XOR operation using bitutil.XORBytes

This commit is contained in:
Micke 2025-07-15 18:02:55 +02:00 committed by GitHub
parent e94123acc2
commit efa19990d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/golang/snappy" "github.com/golang/snappy"
"golang.org/x/crypto/sha3" "golang.org/x/crypto/sha3"
"github.com/ethereum/go-ethereum/common/bitutil"
) )
// Conn is an RLPx network connection. It wraps a low-level network connection. The // Conn is an RLPx network connection. It wraps a low-level network connection. The
@ -676,8 +677,6 @@ func exportPubkey(pub *ecies.PublicKey) []byte {
func xor(one, other []byte) (xor []byte) { func xor(one, other []byte) (xor []byte) {
xor = make([]byte, len(one)) xor = make([]byte, len(one))
for i := 0; i < len(one); i++ { bitutil.XORBytes(xor, one, other)
xor[i] = one[i] ^ other[i]
}
return xor return xor
} }