You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

15 lines
342 B

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
}