ReadBits encodes the absolute value of bigint as big-endian bytes. Callers must ensure that buf has enough space. If buf is too short the result will be incomplete.
(bigint *big.Int, buf []byte)
| 175 | // ReadBits encodes the absolute value of bigint as big-endian bytes. Callers must ensure |
| 176 | // that buf has enough space. If buf is too short the result will be incomplete. |
| 177 | func ReadBits(bigint *big.Int, buf []byte) { |
| 178 | i := len(buf) |
| 179 | for _, d := range bigint.Bits() { |
| 180 | for j := 0; j < wordBytes && i > 0; j++ { |
| 181 | i-- |
| 182 | buf[i] = byte(d) |
| 183 | d >>= 8 |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | // U256 encodes as a 256 bit two's complement number. This operation is destructive. |
| 189 | func U256(x *big.Int) *big.Int { |
no outgoing calls