LittleEndian encodes the value of this Int into a little-endian byte-slice at least min bytes but no more than max bytes long. Panics if max != 0 and the Int cannot be represented in max bytes.
(min, max int)
| 389 | // at least min bytes but no more than max bytes long. |
| 390 | // Panics if max != 0 and the Int cannot be represented in max bytes. |
| 391 | func (i *Int) LittleEndian(min, max int) []byte { |
| 392 | act := i.MarshalSize() |
| 393 | vBytes := i.V.Bytes() |
| 394 | vSize := len(vBytes) |
| 395 | if vSize < act { |
| 396 | act = vSize |
| 397 | } |
| 398 | pad := act |
| 399 | if pad < min { |
| 400 | pad = min |
| 401 | } |
| 402 | if max != 0 && pad > max { |
| 403 | panic("Int not representable in max bytes") |
| 404 | } |
| 405 | buf := make([]byte, pad) |
| 406 | reverse(buf[:act], vBytes) |
| 407 | return buf |
| 408 | } |
| 409 | |
| 410 | // HideLen returns the length in bytes of a uniform byte-string encoding of this Int, |
| 411 | // satisfying the requirements of the Hiding interface. |