mirror of
https://github.com/vocdoni/arbo.git
synced 2026-01-10 06:17:58 -05:00
make required bigint helper public and remove ExplicitZero from SwapEndianess
This commit is contained in:
6
utils.go
6
utils.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user