Files
mautrix-telegram/pkg/gotd/crypto/fill_bytes.go
T
2025-06-27 20:03:37 -07:00

16 lines
342 B
Go

package crypto
import "math/big"
// FillBytes is safe version of (*big.Int).FillBytes.
// Returns false if to length is not exact equal to big.Int's.
// Otherwise fills to using b and returns true.
func FillBytes(b *big.Int, to []byte) bool {
bits := b.BitLen()
if (bits+7)/8 > len(to) {
return false
}
b.FillBytes(to)
return true
}