bsv2 2.0.24 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/{.babelrc.test → .babel.test} +1 -1
  2. package/.husky/pre-commit +1 -1
  3. package/.mocharc.yml +1 -1
  4. package/.travis.yml +1 -1
  5. package/babel.config.cjs +44 -0
  6. package/benchmark.js +10 -18
  7. package/bin/bsv.js +1 -1
  8. package/bin/network.js +2 -1
  9. package/dist/bsv2.mjs +36061 -4
  10. package/dist/bsv2.umd.js +28 -0
  11. package/doc/assets/anchor.js +350 -0
  12. package/doc/assets/bass-addons.css +12 -0
  13. package/doc/assets/bass.css +544 -0
  14. package/doc/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
  15. package/doc/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
  16. package/doc/assets/fonts/LICENSE.txt +93 -0
  17. package/doc/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
  18. package/doc/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
  19. package/doc/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
  20. package/doc/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
  21. package/doc/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
  22. package/doc/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
  23. package/doc/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
  24. package/doc/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
  25. package/doc/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
  26. package/doc/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
  27. package/doc/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
  28. package/doc/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
  29. package/doc/assets/fonts/source-code-pro.css +23 -0
  30. package/doc/assets/github.css +123 -0
  31. package/doc/assets/site.js +168 -0
  32. package/doc/assets/split.css +15 -0
  33. package/doc/assets/split.js +782 -0
  34. package/doc/assets/style.css +147 -0
  35. package/doc/index.html +9461 -0
  36. package/entry.js +2 -3
  37. package/eslint.config.mjs +8 -0
  38. package/index.js +1 -5
  39. package/{karma.conf.js → karma.conf.ts} +2 -3
  40. package/lib/ach.js +5 -5
  41. package/lib/address.js +11 -9
  42. package/lib/aescbc.js +3 -3
  43. package/lib/bip-39.js +12 -11
  44. package/lib/block.js +2 -2
  45. package/lib/bn.js +12 -17
  46. package/lib/bsm.js +1 -1
  47. package/lib/config.js +1 -1
  48. package/lib/constants.js +1 -1
  49. package/lib/ecdsa.js +24 -23
  50. package/lib/interp.js +18 -14
  51. package/lib/merkle.js +1 -1
  52. package/lib/op-code.js +137 -135
  53. package/lib/priv-key.js +1 -1
  54. package/lib/script.js +44 -42
  55. package/lib/sig.js +12 -12
  56. package/lib/struct.js +9 -6
  57. package/lib/tx.js +6 -6
  58. package/load-babel.js +3 -1
  59. package/mtest/test.html +6 -4
  60. package/mtest/test.js +1 -1
  61. package/out/Sig.html +541 -0
  62. package/out/bip-32.js.html +523 -0
  63. package/out/bip-39.js.html +336 -0
  64. package/out/block.js.html +183 -0
  65. package/out/bn.js.html +512 -0
  66. package/out/ecdsa.js.html +546 -0
  67. package/out/fonts/OpenSans-Bold-webfont.eot +0 -0
  68. package/out/fonts/OpenSans-Bold-webfont.svg +1830 -0
  69. package/out/fonts/OpenSans-Bold-webfont.woff +0 -0
  70. package/out/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  71. package/out/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  72. package/out/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  73. package/out/fonts/OpenSans-Italic-webfont.eot +0 -0
  74. package/out/fonts/OpenSans-Italic-webfont.svg +1830 -0
  75. package/out/fonts/OpenSans-Italic-webfont.woff +0 -0
  76. package/out/fonts/OpenSans-Light-webfont.eot +0 -0
  77. package/out/fonts/OpenSans-Light-webfont.svg +1831 -0
  78. package/out/fonts/OpenSans-Light-webfont.woff +0 -0
  79. package/out/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  80. package/out/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  81. package/out/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  82. package/out/fonts/OpenSans-Regular-webfont.eot +0 -0
  83. package/out/fonts/OpenSans-Regular-webfont.svg +1831 -0
  84. package/out/fonts/OpenSans-Regular-webfont.woff +0 -0
  85. package/out/global.html +220 -0
  86. package/out/index.html +128 -0
  87. package/out/interp.js.html +2064 -0
  88. package/out/merkle.js.html +143 -0
  89. package/out/msg.js.html +235 -0
  90. package/out/priv-key.js.html +208 -0
  91. package/out/pub-key.js.html +281 -0
  92. package/out/script.js.html +876 -0
  93. package/out/scripts/linenumber.js +25 -0
  94. package/out/scripts/prettify/Apache-License-2.0.txt +202 -0
  95. package/out/scripts/prettify/lang-css.js +2 -0
  96. package/out/scripts/prettify/prettify.js +28 -0
  97. package/out/sig-operations.js.html +171 -0
  98. package/out/sig.js.html +450 -0
  99. package/out/struct.js.html +440 -0
  100. package/out/styles/jsdoc-default.css +358 -0
  101. package/out/styles/prettify-jsdoc.css +111 -0
  102. package/out/styles/prettify-tomorrow.css +132 -0
  103. package/out/tx-builder.js.html +644 -0
  104. package/out/tx-in.js.html +223 -0
  105. package/out/tx-verifier.js.html +260 -0
  106. package/out/tx.js.html +481 -0
  107. package/package.json +34 -39
  108. package/vite.config.js +36 -0
  109. package/dist/bsv2.bundle.js +0 -8
  110. package/dist/bsv2.cjs.js +0 -2
  111. package/dist/bsv2.cjs.js.LICENSE.txt +0 -1
  112. package/dist/bsv2.module.js +0 -2
  113. /package/{webpack.config.js → mtest/webpack.config.js} +0 -0
package/out/bn.js.html ADDED
@@ -0,0 +1,512 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>JSDoc: Source: bn.js</title>
6
+
7
+ <script src="scripts/prettify/prettify.js"> </script>
8
+ <script src="scripts/prettify/lang-css.js"> </script>
9
+ <!--[if lt IE 9]>
10
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
+ <![endif]-->
12
+ <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="main">
19
+
20
+ <h1 class="page-title">Source: bn.js</h1>
21
+
22
+
23
+
24
+
25
+
26
+
27
+ <section>
28
+ <article>
29
+ <pre class="prettyprint source linenums"><code>/**
30
+ * Big Number
31
+ * ==========
32
+ *
33
+ * Since javascript numbers are only precise up to 53 bits, and bitcoin is
34
+ * based on cryptography that uses 256 bit numbers, we must use a big number
35
+ * library. The library we use at the moment is Fedor Indutny's bn.js library.
36
+ * Since big numbers are extremely useful, we provide some very basic wrappers
37
+ * for his big number class and expose it. The wrappers merely allow you to do,
38
+ * say, bn.cmp(num) instead of just bn.cmp(bn), which is nice. The primary way
39
+ * to use this is:
40
+ * const bn = Bn(str) // str is base 10
41
+ * const bn = Bn(num)
42
+ * const bn = Bn().fromBuffer(buf)
43
+ * const bn = Bn().fromSm(buf); // sign+magnitude format, first bit is sign
44
+ *
45
+ * For little endian, pass in an options value:
46
+ * const bn = Bn().fromBuffer(buf, {endian: 'little'})
47
+ * const bn = Bn().fromSm(buf, {endian: 'little'})
48
+ *
49
+ * Getting output:
50
+ * const str = Bn().toString() // produces base 10 string
51
+ * const buf = Bn().toBuffer() // produces buffer representation
52
+ * const buf = Bn().toBuffer({size: 32}) //produced 32 byte buffer
53
+ */
54
+ 'use strict'
55
+
56
+ import _Bn from 'bn.js'
57
+
58
+ function Bn (n, base, ...rest) {
59
+ if (!(this instanceof Bn)) {
60
+ return new Bn(n, base, ...rest)
61
+ }
62
+ _Bn.call(this, n, base, ...rest)
63
+ }
64
+
65
+ Object.keys(_Bn).forEach(function (key) {
66
+ Bn[key] = _Bn[key]
67
+ })
68
+ Bn.prototype = Object.create(_Bn.prototype)
69
+ Bn.prototype.constructor = Bn
70
+
71
+ function reverseBuf (buf) {
72
+ const buf2 = Buffer.alloc(buf.length)
73
+ for (let i = 0; i &lt; buf.length; i++) {
74
+ buf2[i] = buf[buf.length - 1 - i]
75
+ }
76
+ return buf2
77
+ }
78
+
79
+ Bn.prototype.fromHex = function (hex, opts) {
80
+ return this.fromBuffer(Buffer.from(hex, 'hex'), opts)
81
+ }
82
+
83
+ Bn.prototype.toHex = function (opts) {
84
+ return this.toBuffer(opts).toString('hex')
85
+ }
86
+
87
+ Bn.prototype.toJSON = function () {
88
+ return this.toString()
89
+ }
90
+
91
+ Bn.prototype.fromJSON = function (str) {
92
+ const bn = Bn(str)
93
+ bn.copy(this)
94
+ return this
95
+ }
96
+
97
+ Bn.prototype.fromNumber = function (n) {
98
+ const bn = Bn(n)
99
+ bn.copy(this)
100
+ return this
101
+ }
102
+
103
+ Bn.prototype.toNumber = function () {
104
+ return parseInt(this.toString(10), 10)
105
+ }
106
+
107
+ Bn.prototype.fromString = function (str, base) {
108
+ const bn = Bn(str, base)
109
+ bn.copy(this)
110
+ return this
111
+ }
112
+
113
+ Bn.fromBuffer = function (buf, opts = { endian: 'big' }) {
114
+ if (opts.endian === 'little') {
115
+ buf = reverseBuf(buf)
116
+ }
117
+ const hex = buf.toString('hex')
118
+ const bn = new Bn(hex, 16)
119
+ return bn
120
+ }
121
+
122
+ Bn.prototype.fromBuffer = function (buf, opts) {
123
+ const bn = Bn.fromBuffer(buf, opts)
124
+ bn.copy(this)
125
+
126
+ return this
127
+ }
128
+
129
+ Bn.prototype.toBuffer = function (opts = { size: undefined, endian: 'big' }) {
130
+ let buf
131
+ if (opts.size) {
132
+ const hex = this.toString(16, 2)
133
+ const natlen = hex.length / 2
134
+ buf = Buffer.from(hex, 'hex')
135
+
136
+ if (natlen === opts.size) {
137
+ // pass
138
+ } else if (natlen > opts.size) {
139
+ buf = buf.slice(natlen - buf.length, buf.length)
140
+ } else if (natlen &lt; opts.size) {
141
+ const rbuf = Buffer.alloc(opts.size)
142
+ for (let i = 0; i &lt; buf.length; i++) {
143
+ rbuf[rbuf.length - 1 - i] = buf[buf.length - 1 - i]
144
+ }
145
+ for (let i = 0; i &lt; opts.size - natlen; i++) {
146
+ rbuf[i] = 0
147
+ }
148
+ buf = rbuf
149
+ }
150
+ } else {
151
+ const hex = this.toString(16, 2)
152
+ buf = Buffer.from(hex, 'hex')
153
+ }
154
+
155
+ if (opts.endian === 'little') {
156
+ buf = reverseBuf(buf)
157
+ }
158
+ const longzero = Buffer.from([0])
159
+ if (Buffer.compare(buf, longzero) === 0) {
160
+ return Buffer.from([])
161
+ }
162
+ return buf
163
+ }
164
+
165
+ Bn.prototype.toFastBuffer = Bn.prototype.toBuffer
166
+
167
+ Bn.fromFastBuffer = Bn.fromBuffer
168
+ Bn.prototype.fromFastBuffer = Bn.prototype.fromBuffer
169
+
170
+ /**
171
+ * Signed magnitude buffer. Most significant bit represents sign (0 = positive,
172
+ * 1 = negative).
173
+ */
174
+ Bn.prototype.fromSm = function (buf, opts = { endian: 'big' }) {
175
+ if (buf.length === 0) {
176
+ this.fromBuffer(Buffer.from([0]))
177
+ }
178
+
179
+ const endian = opts.endian
180
+ if (endian === 'little') {
181
+ buf = reverseBuf(buf)
182
+ }
183
+
184
+ if (buf[0] &amp; 0x80) {
185
+ buf[0] = buf[0] &amp; 0x7f
186
+ this.fromBuffer(buf)
187
+ this.neg().copy(this)
188
+ } else {
189
+ this.fromBuffer(buf)
190
+ }
191
+ return this
192
+ }
193
+
194
+ Bn.prototype.toSm = function (opts = { endian: 'big' }) {
195
+ const endian = opts.endian
196
+
197
+ let buf
198
+ if (this.cmp(0) === -1) {
199
+ buf = this.neg().toBuffer()
200
+ if (buf[0] &amp; 0x80) {
201
+ buf = Buffer.concat([Buffer.from([0x80]), buf])
202
+ } else {
203
+ buf[0] = buf[0] | 0x80
204
+ }
205
+ } else {
206
+ buf = this.toBuffer()
207
+ if (buf[0] &amp; 0x80) {
208
+ buf = Buffer.concat([Buffer.from([0x00]), buf])
209
+ }
210
+ }
211
+
212
+ if ((buf.length === 1) &amp; (buf[0] === 0)) {
213
+ buf = Buffer.from([])
214
+ }
215
+
216
+ if (endian === 'little') {
217
+ buf = reverseBuf(buf)
218
+ }
219
+
220
+ return buf
221
+ }
222
+
223
+ /**
224
+ * Produce a Bn from the "bits" value in a blockheader. Analagous to Bitcoin
225
+ * Core's uint256 SetCompact method. bits is assumed to be UInt32.
226
+ */
227
+ Bn.prototype.fromBits = function (bits, opts = { strict: false }) {
228
+ // To performed bitwise operations in javascript, we need to convert to a
229
+ // signed 32 bit value.
230
+ let buf = Buffer.alloc(4)
231
+ buf.writeUInt32BE(bits, 0)
232
+ bits = buf.readInt32BE(0)
233
+ if (opts.strict &amp;&amp; bits &amp; 0x00800000) {
234
+ throw new Error('negative bit set')
235
+ }
236
+ const nsize = bits >> 24
237
+ const nword = bits &amp; 0x007fffff
238
+ buf = Buffer.alloc(4)
239
+ buf.writeInt32BE(nword)
240
+ if (nsize &lt;= 3) {
241
+ buf = buf.slice(1, nsize + 1)
242
+ } else {
243
+ const fill = Buffer.alloc(nsize - 3)
244
+ fill.fill(0)
245
+ buf = Buffer.concat([buf, fill])
246
+ }
247
+ this.fromBuffer(buf)
248
+ if (bits &amp; 0x00800000) {
249
+ Bn(0)
250
+ .sub(this)
251
+ .copy(this)
252
+ }
253
+ return this
254
+ }
255
+
256
+ /**
257
+ * Convert Bn to the "bits" value in a blockheader. Analagous to Bitcoin
258
+ * Core's uint256 GetCompact method. bits is a UInt32.
259
+ */
260
+ Bn.prototype.toBits = function () {
261
+ let buf
262
+ if (this.lt(0)) {
263
+ buf = this.neg().toBuffer()
264
+ } else {
265
+ buf = this.toBuffer()
266
+ }
267
+ let nsize = buf.length
268
+ let nword
269
+ if (nsize > 3) {
270
+ nword = Buffer.concat([Buffer.from([0]), buf.slice(0, 3)]).readUInt32BE(0)
271
+ } else if (nsize &lt;= 3) {
272
+ const blank = Buffer.alloc(3 - nsize + 1)
273
+ blank.fill(0)
274
+ nword = Buffer.concat([blank, buf.slice(0, nsize)]).readUInt32BE(0)
275
+ }
276
+ if (nword &amp; 0x00800000) {
277
+ // The most significant bit denotes sign. Do not want unless number is
278
+ // actually negative.
279
+ nword >>= 8
280
+ nsize++
281
+ }
282
+ if (this.lt(0)) {
283
+ nword |= 0x00800000
284
+ }
285
+ const bits = (nsize &lt;&lt; 24) | nword
286
+ // convert bits to UInt32 before returning
287
+ buf = Buffer.alloc(4)
288
+ buf.writeInt32BE(bits, 0)
289
+ return buf.readUInt32BE(0)
290
+ }
291
+
292
+ // This is analogous to the constructor for CScriptNum in bitcoind. Many ops
293
+ // in bitcoind's script interpreter use CScriptNum, which is not really a
294
+ // proper bignum. Instead, an error is thrown if trying to input a number
295
+ // bigger than 4 bytes. We copy that behavior here. There is one exception -
296
+ // in CHECKLOCKTIMEVERIFY, the numbers are allowed to be up to 5 bytes long.
297
+ // We allow for setting that variable here for use in CHECKLOCKTIMEVERIFY.
298
+ Bn.prototype.fromScriptNumBuffer = function (
299
+ buf,
300
+ fRequireMinimal,
301
+ nMaxNumSize,
302
+ bigInt = false
303
+ ) {
304
+ if (nMaxNumSize === undefined) {
305
+ nMaxNumSize = 4
306
+ }
307
+ if (buf.length > nMaxNumSize) {
308
+ throw new Error(`script number overflow nMaxNumSize: ${nMaxNumSize}`)
309
+ }
310
+
311
+ if (fRequireMinimal &amp;&amp; buf.length > 0) {
312
+ // Check that the number is encoded with the minimum possible
313
+ // number of bytes.
314
+ //
315
+ // If the most-significant-byte - excluding the sign bit - is zero
316
+ // then we're not minimal. Note how this test also rejects the
317
+ // negative-zero encoding, 0x80.
318
+ if ((buf[buf.length - 1] &amp; 0x7f) === 0) {
319
+ // One exception: if there's more than one byte and the most
320
+ // significant bit of the second-most-significant-byte is set
321
+ // it would conflict with the sign bit. An example of this case
322
+ // is +-255, which encode to 0xff00 and 0xff80 respectively.
323
+ // (big-endian).
324
+ if (buf.length &lt;= 1 || (buf[buf.length - 2] &amp; 0x80) === 0) {
325
+ throw new Error('non-minimally encoded script number')
326
+ }
327
+ }
328
+ }
329
+ // TODO?
330
+ // https://github.com/bitcoin-sv/bitcoin-sv/blob/4d3444909a5a98f129d3d2991bf8f0f7f15d3969/src/script/script_num.cpp#L34
331
+ if (buf.byteLength === 0) {
332
+ if (bigInt) {
333
+ // m_value = bint{0};
334
+ }
335
+ } else if (buf.byteLength &lt;= nMaxNumSize) {
336
+ if (bigInt) {
337
+ // m_value = bsv::bint::deserialize(span);
338
+ } else {
339
+ // m_value = bsv::deserialize&lt;int64_t>(span.begin(), span.end());
340
+ }
341
+ }
342
+
343
+ return this.fromSm(buf, { endian: 'little' })
344
+ }
345
+
346
+ // The corollary to the above, with the notable exception that we do not throw
347
+ // an error if the output is larger than four bytes. (Which can happen if
348
+ // performing a numerical operation that results in an overflow to more than 4
349
+ // bytes).
350
+ Bn.prototype.toScriptNumBuffer = function (buf) {
351
+ return this.toSm({ endian: 'little' })
352
+ }
353
+
354
+ Bn.prototype.neg = function () {
355
+ const _neg = _Bn.prototype.neg.call(this)
356
+ const neg = Object.create(Bn.prototype)
357
+ _neg.copy(neg)
358
+ return neg
359
+ }
360
+
361
+ Bn.prototype.add = function (bn) {
362
+ const _bn = _Bn.prototype.add.call(this, bn)
363
+ bn = Object.create(Bn.prototype)
364
+ _bn.copy(bn)
365
+ return bn
366
+ }
367
+
368
+ Bn.prototype.sub = function (bn) {
369
+ const _bn = _Bn.prototype.sub.call(this, bn)
370
+ bn = Object.create(Bn.prototype)
371
+ _bn.copy(bn)
372
+ return bn
373
+ }
374
+
375
+ Bn.prototype.mul = function (bn) {
376
+ const _bn = _Bn.prototype.mul.call(this, bn)
377
+ bn = Object.create(Bn.prototype)
378
+ _bn.copy(bn)
379
+ return bn
380
+ }
381
+
382
+ /**
383
+ * to be used if this is positive.
384
+ */
385
+ Bn.prototype.mod = function (bn) {
386
+ const _bn = _Bn.prototype.mod.call(this, bn)
387
+ bn = Object.create(Bn.prototype)
388
+ _bn.copy(bn)
389
+ return bn
390
+ }
391
+
392
+ /**
393
+ * to be used if this is negative.
394
+ */
395
+ Bn.prototype.umod = function (bn) {
396
+ const _bn = _Bn.prototype.umod.call(this, bn)
397
+ bn = Object.create(Bn.prototype)
398
+ _bn.copy(bn)
399
+ return bn
400
+ }
401
+
402
+ Bn.prototype.invm = function (bn) {
403
+ const _bn = _Bn.prototype.invm.call(this, bn)
404
+ bn = Object.create(Bn.prototype)
405
+ _bn.copy(bn)
406
+ return bn
407
+ }
408
+
409
+ Bn.prototype.div = function (bn) {
410
+ const _bn = _Bn.prototype.div.call(this, bn)
411
+ bn = Object.create(Bn.prototype)
412
+ _bn.copy(bn)
413
+ return bn
414
+ }
415
+
416
+ Bn.prototype.ushln = function (bits) {
417
+ const _bn = _Bn.prototype.ushln.call(this, bits)
418
+ const bn = Object.create(Bn.prototype)
419
+ _bn.copy(bn)
420
+ return bn
421
+ }
422
+
423
+ Bn.prototype.ushrn = function (bits) {
424
+ const _bn = _Bn.prototype.ushrn.call(this, bits)
425
+ const bn = Object.create(Bn.prototype)
426
+ _bn.copy(bn)
427
+ return bn
428
+ }
429
+
430
+ Bn.prototype.cmp = function (bn) {
431
+ return _Bn.prototype.cmp.call(this, bn)
432
+ }
433
+
434
+ /**
435
+ * All the standard big number operations operate on other big numbers. e.g.,
436
+ * bn1.add(bn2). But it is frequenly valuble to add numbers or strings, e.g.
437
+ * bn.add(5) or bn.add('5'). The decorator wraps all methods where this would
438
+ * be convenient and makes that possible.
439
+ */
440
+ function decorate (name) {
441
+ Bn.prototype['_' + name] = Bn.prototype[name]
442
+ const f = function (b) {
443
+ if (typeof b === 'string') {
444
+ b = new Bn(b)
445
+ } else if (typeof b === 'number') {
446
+ b = new Bn(b.toString())
447
+ }
448
+ return this['_' + name](b)
449
+ }
450
+ Bn.prototype[name] = f
451
+ }
452
+
453
+ Bn.prototype.eq = function (b) {
454
+ return this.cmp(b) === 0
455
+ }
456
+
457
+ Bn.prototype.neq = function (b) {
458
+ return this.cmp(b) !== 0
459
+ }
460
+
461
+ Bn.prototype.gt = function (b) {
462
+ return this.cmp(b) > 0
463
+ }
464
+
465
+ Bn.prototype.geq = function (b) {
466
+ return this.cmp(b) >= 0
467
+ }
468
+
469
+ Bn.prototype.lt = function (b) {
470
+ return this.cmp(b) &lt; 0
471
+ }
472
+
473
+ Bn.prototype.leq = function (b) {
474
+ return this.cmp(b) &lt;= 0
475
+ }
476
+
477
+ decorate('add')
478
+ decorate('sub')
479
+ decorate('mul')
480
+ decorate('mod')
481
+ decorate('invm')
482
+ decorate('div')
483
+ decorate('cmp')
484
+ decorate('gt')
485
+ decorate('geq')
486
+ decorate('lt')
487
+ decorate('leq')
488
+
489
+ export { Bn }
490
+ </code></pre>
491
+ </article>
492
+ </section>
493
+
494
+
495
+
496
+
497
+ </div>
498
+
499
+ <nav>
500
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Sig.html">Sig</a></li></ul><h3>Global</h3><ul><li><a href="global.html#decorate">decorate</a></li></ul>
501
+ </nav>
502
+
503
+ <br class="clear">
504
+
505
+ <footer>
506
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Fri Feb 28 2025 03:51:24 GMT+0100 (hora estándar de Europa central)
507
+ </footer>
508
+
509
+ <script> prettyPrint(); </script>
510
+ <script src="scripts/linenumber.js"> </script>
511
+ </body>
512
+ </html>