make required bigint helper public and remove ExplicitZero from SwapEndianess

This commit is contained in:
Lucas Menendez
2025-04-11 12:39:27 +02:00
parent e1622c1ead
commit 710bece00a
3 changed files with 10 additions and 10 deletions

View File

@@ -11,21 +11,21 @@ func SwapEndianness(b []byte) []byte {
for i := range b {
o[len(b)-1-i] = b[i]
}
return ExplicitZero(o)
return o
}
// BigIntToBytes converts a *big.Int into a byte array in Little-Endian
func BigIntToBytes(blen int, bi *big.Int) []byte {
// TODO make the length depending on the tree.hashFunction.Len()
b := make([]byte, blen)
copy(b[:], SwapEndianness(bi.Bytes()))
copy(b[:], ExplicitZero(SwapEndianness(bi.Bytes())))
return b[:]
}
// BytesToBigInt converts a byte array in Little-Endian representation into
// *big.Int
func BytesToBigInt(b []byte) *big.Int {
return new(big.Int).SetBytes(SwapEndianness(b))
return new(big.Int).SetBytes(ExplicitZero(SwapEndianness(b)))
}
// ExplicitZero returns a byte slice with a single zero byte if the input slice