crypto: use clear from go1.21 (#29307)

This commit is contained in:
Daniel Liu 2025-01-03 09:56:02 +08:00
parent d0566e4165
commit efad15f9f4
2 changed files with 3 additions and 9 deletions

View file

@ -287,7 +287,5 @@ func PubkeyToAddress(p ecdsa.PublicKey) common.Address {
} }
func zeroBytes(bytes []byte) { func zeroBytes(bytes []byte) {
for i := range bytes { clear(bytes)
bytes[i] = 0
}
} }

View file

@ -44,12 +44,8 @@ func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int,
// Unpack the result and clear temporaries. // Unpack the result and clear temporaries.
x := new(big.Int).SetBytes(point[:32]) x := new(big.Int).SetBytes(point[:32])
y := new(big.Int).SetBytes(point[32:]) y := new(big.Int).SetBytes(point[32:])
for i := range point { clear(point)
point[i] = 0 clear(scalar)
}
for i := range padded {
scalar[i] = 0
}
if res != 1 { if res != 1 {
return nil, nil return nil, nil
} }