git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit dc345a6b3c23a49b736a6ae85494f4e5be6fb17d

U256: support padding output to other than 32 bytes

Alex Beregszaszi committed on 8/16/2016, 10:33:25 PM
Parent: ed7fedaaf934add17793bd10403532159cd34f21

Files changed

u256.jschanged
u256.jsView
@@ -16,10 +16,13 @@
1616 }
1717 return this._value.toString(radix)
1818 }
1919
20- toBuffer () {
21- return this._value.toBuffer('le', 32)
20+ toBuffer (width) {
21+ if (width <= 0 || width > 32) {
22+ throw new Error('Invalid U256 width')
23+ }
24+ return this._value.toBuffer('le', width || 32)
2225 }
2326
2427 sub (u256) {
2528 return new U256(this._value.sub(u256._value))

Built with git-ssb-web