| 504 | } |
| 505 | |
| 506 | _toBuffer(number, significantBytes) { |
| 507 | // Convert numeric representation back to a buffer. |
| 508 | const buffer = Integer.toBuffer(number); |
| 509 | if (buffer.length === significantBytes) { |
| 510 | return buffer; |
| 511 | } |
| 512 | |
| 513 | // if first byte is a sign byte, skip it. |
| 514 | let start, length; |
| 515 | if (buffer[0] === 0) { |
| 516 | start = 1; |
| 517 | length = buffer.length - 1; |
| 518 | } else { |
| 519 | start = 0; |
| 520 | length = buffer.length; |
| 521 | } |
| 522 | |
| 523 | const target = Buffer.alloc(significantBytes); |
| 524 | buffer.copy(target, significantBytes - length, start, length + start); |
| 525 | return target; |
| 526 | } |
| 527 | |
| 528 | split(start, end, numberOfSplits) { |
| 529 | const tokenOrder = start.compare(end); |