@btc-vision/bitcoin 6.5.3 → 6.5.5

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 (93) hide show
  1. package/browser/address.d.ts +2 -6
  2. package/browser/bech32utils.d.ts +6 -0
  3. package/browser/chunks/{crypto-0PweVewC.js → crypto-BhCpKpek.js} +4 -4
  4. package/browser/chunks/{payments-CgasufRS.js → payments-yjA0Evsv.js} +639 -597
  5. package/browser/chunks/{psbt-BIwOrKer.js → psbt-URK2hBFc.js} +1259 -1316
  6. package/browser/chunks/{script-CROJPzz_.js → script-DyPItFEl.js} +33 -33
  7. package/browser/chunks/{transaction-DchBu35N.js → transaction-C_UbhMGn.js} +3 -3
  8. package/browser/chunks/{utils-CO5kmxe9.js → utils-DNZi-T5W.js} +26 -26
  9. package/browser/index.d.ts +3 -1
  10. package/browser/index.js +102 -90
  11. package/browser/payments/embed.d.ts +1 -1
  12. package/browser/payments/index.d.ts +12 -104
  13. package/browser/payments/p2ms.d.ts +1 -1
  14. package/browser/payments/p2op.d.ts +1 -1
  15. package/browser/payments/p2pk.d.ts +1 -1
  16. package/browser/payments/p2pkh.d.ts +1 -1
  17. package/browser/payments/p2sh.d.ts +1 -1
  18. package/browser/payments/p2tr.d.ts +1 -1
  19. package/browser/payments/p2wpkh.d.ts +1 -1
  20. package/browser/payments/p2wsh.d.ts +1 -1
  21. package/browser/payments/types.d.ts +93 -0
  22. package/browser/psbt/bip371.d.ts +0 -1
  23. package/browser/psbt/psbtutils.d.ts +0 -7
  24. package/browser/pubkey.d.ts +8 -0
  25. package/browser/script.d.ts +1 -2
  26. package/browser/script_signature.d.ts +1 -0
  27. package/browser/types.d.ts +3 -0
  28. package/build/address.d.ts +2 -6
  29. package/build/address.js +19 -37
  30. package/build/bech32utils.d.ts +6 -0
  31. package/build/bech32utils.js +26 -0
  32. package/build/index.d.ts +3 -1
  33. package/build/index.js +1 -0
  34. package/build/payments/embed.d.ts +1 -1
  35. package/build/payments/embed.js +1 -1
  36. package/build/payments/index.d.ts +12 -104
  37. package/build/payments/index.js +12 -24
  38. package/build/payments/p2ms.d.ts +1 -1
  39. package/build/payments/p2ms.js +1 -1
  40. package/build/payments/p2op.d.ts +1 -1
  41. package/build/payments/p2op.js +2 -2
  42. package/build/payments/p2pk.d.ts +1 -1
  43. package/build/payments/p2pk.js +1 -1
  44. package/build/payments/p2pkh.d.ts +1 -1
  45. package/build/payments/p2pkh.js +2 -2
  46. package/build/payments/p2sh.d.ts +1 -1
  47. package/build/payments/p2sh.js +1 -1
  48. package/build/payments/p2tr.d.ts +1 -1
  49. package/build/payments/p2tr.js +2 -6
  50. package/build/payments/p2wpkh.d.ts +1 -1
  51. package/build/payments/p2wpkh.js +1 -1
  52. package/build/payments/p2wsh.d.ts +1 -1
  53. package/build/payments/p2wsh.js +2 -2
  54. package/build/payments/types.d.ts +93 -0
  55. package/build/payments/types.js +13 -0
  56. package/build/psbt/bip371.d.ts +0 -1
  57. package/build/psbt/bip371.js +2 -6
  58. package/build/psbt/psbtutils.d.ts +0 -7
  59. package/build/psbt/psbtutils.js +2 -54
  60. package/build/psbt.js +3 -2
  61. package/build/pubkey.d.ts +8 -0
  62. package/build/pubkey.js +56 -0
  63. package/build/script.d.ts +1 -2
  64. package/build/script.js +1 -4
  65. package/build/script_signature.d.ts +1 -0
  66. package/build/script_signature.js +4 -1
  67. package/build/tsconfig.tsbuildinfo +1 -1
  68. package/build/types.d.ts +3 -0
  69. package/package.json +5 -2
  70. package/src/address.ts +20 -50
  71. package/src/bech32utils.ts +43 -0
  72. package/src/index.ts +2 -3
  73. package/src/payments/embed.ts +2 -2
  74. package/src/payments/index.ts +40 -164
  75. package/src/payments/p2ms.ts +2 -2
  76. package/src/payments/p2op.ts +2 -2
  77. package/src/payments/p2pk.ts +2 -2
  78. package/src/payments/p2pkh.ts +3 -3
  79. package/src/payments/p2sh.ts +2 -10
  80. package/src/payments/p2tr.ts +6 -5
  81. package/src/payments/p2wpkh.ts +1 -1
  82. package/src/payments/p2wsh.ts +8 -2
  83. package/src/payments/types.ts +154 -0
  84. package/src/psbt/bip371.ts +6 -13
  85. package/src/psbt/psbtutils.ts +2 -104
  86. package/src/psbt.ts +3 -2
  87. package/src/pubkey.ts +99 -0
  88. package/src/script.ts +2 -7
  89. package/src/script_signature.ts +10 -1
  90. package/src/types.ts +5 -0
  91. package/test/address.spec.ts +8 -7
  92. package/test/integration/taproot.spec.ts +2 -1
  93. package/test/payments.spec.ts +4 -4
@@ -3,7 +3,7 @@ import * as bcrypto from '../crypto.js';
3
3
  import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
4
4
  import * as bscript from '../script.js';
5
5
  import { isPoint, typeforce as typef } from '../types.js';
6
- import { PaymentType } from './index.js';
6
+ import { PaymentType } from './types.js';
7
7
  import * as lazy from './lazy.js';
8
8
  const OPS = bscript.opcodes;
9
9
  const EMPTY_BUFFER = Buffer.alloc(0);
@@ -1,2 +1,2 @@
1
- import { P2WSHPayment, PaymentOpts } from './index.js';
1
+ import { P2WSHPayment, PaymentOpts } from './types.js';
2
2
  export declare function p2wsh(a: Omit<P2WSHPayment, 'name'>, opts?: PaymentOpts): P2WSHPayment;
@@ -2,8 +2,8 @@ import { bech32 } from 'bech32';
2
2
  import * as bcrypto from '../crypto.js';
3
3
  import { bitcoin as BITCOIN_NETWORK } from '../networks.js';
4
4
  import * as bscript from '../script.js';
5
- import { isPoint, stacksEqual, typeforce as typef } from '../types.js';
6
- import { PaymentType } from './index.js';
5
+ import { isPoint, stacksEqual, typeforce as typef, } from '../types.js';
6
+ import { PaymentType } from './types.js';
7
7
  import * as lazy from './lazy.js';
8
8
  const OPS = bscript.opcodes;
9
9
  const EMPTY_BUFFER = Buffer.alloc(0);
@@ -0,0 +1,93 @@
1
+ import type { Network } from '../networks.js';
2
+ import type { Taptree } from '../types.js';
3
+ export declare enum PaymentType {
4
+ P2PK = "p2pk",
5
+ P2PKH = "p2pkh",
6
+ P2SH = "p2sh",
7
+ P2MS = "p2ms",
8
+ P2WPKH = "p2wpkh",
9
+ P2WSH = "p2wsh",
10
+ P2TR = "p2tr",
11
+ P2OP = "p2op",
12
+ Embed = "embed",
13
+ ScriptRedeem = "scriptRedeem"
14
+ }
15
+ export interface BasePayment {
16
+ name?: PaymentType;
17
+ network?: Network;
18
+ output?: Buffer;
19
+ input?: Buffer;
20
+ address?: string;
21
+ witness?: Buffer[];
22
+ redeem?: ScriptRedeem;
23
+ useHybrid?: boolean;
24
+ useUncompressed?: boolean;
25
+ }
26
+ export interface ScriptRedeem extends BasePayment {
27
+ output?: Buffer;
28
+ redeemVersion?: number;
29
+ network?: Network;
30
+ }
31
+ export interface P2PKPayment extends BasePayment {
32
+ name: PaymentType.P2PK;
33
+ pubkey?: Buffer;
34
+ signature?: Buffer;
35
+ }
36
+ export interface P2PKHPayment extends BasePayment {
37
+ name: PaymentType.P2PKH;
38
+ hash?: Buffer;
39
+ pubkey?: Buffer;
40
+ signature?: Buffer;
41
+ }
42
+ export interface P2SHPayment extends BasePayment {
43
+ name: PaymentType.P2SH;
44
+ hash?: Buffer;
45
+ signatures?: Buffer[];
46
+ }
47
+ export interface P2MSPayment extends BasePayment {
48
+ name: PaymentType.P2MS;
49
+ m?: number;
50
+ n?: number;
51
+ pubkeys?: Buffer[];
52
+ signatures?: Buffer[];
53
+ }
54
+ export interface P2WPKHPayment extends BasePayment {
55
+ name: PaymentType.P2WPKH;
56
+ hash?: Buffer;
57
+ pubkey?: Buffer;
58
+ signature?: Buffer;
59
+ }
60
+ export interface P2WSHPayment extends BasePayment {
61
+ name: PaymentType.P2WSH;
62
+ hash?: Buffer;
63
+ redeem?: ScriptRedeem;
64
+ }
65
+ export interface P2TRPayment extends BasePayment {
66
+ name: PaymentType.P2TR;
67
+ pubkey?: Buffer;
68
+ internalPubkey?: Buffer;
69
+ hash?: Buffer;
70
+ scriptTree?: Taptree;
71
+ signature?: Buffer;
72
+ redeemVersion?: number;
73
+ redeem?: ScriptRedeem;
74
+ }
75
+ export interface P2OPPayment extends BasePayment {
76
+ name: PaymentType.P2OP;
77
+ program?: Buffer;
78
+ deploymentVersion: number | undefined;
79
+ hash160?: Buffer;
80
+ }
81
+ export interface P2OPPaymentParams extends Omit<P2OPPayment, 'name' | 'deploymentVersion'> {
82
+ deploymentVersion?: number;
83
+ }
84
+ export interface EmbedPayment extends BasePayment {
85
+ name: PaymentType.Embed;
86
+ data: Buffer[];
87
+ }
88
+ export type Payment = P2PKPayment | P2PKHPayment | P2SHPayment | P2MSPayment | P2WPKHPayment | P2WSHPayment | P2TRPayment | P2OPPayment | EmbedPayment | ScriptRedeem;
89
+ export type PaymentCreator = <T extends BasePayment>(a: T, opts?: PaymentOpts) => T;
90
+ export interface PaymentOpts {
91
+ validate?: boolean;
92
+ allowIncomplete?: boolean;
93
+ }
@@ -0,0 +1,13 @@
1
+ export var PaymentType;
2
+ (function (PaymentType) {
3
+ PaymentType["P2PK"] = "p2pk";
4
+ PaymentType["P2PKH"] = "p2pkh";
5
+ PaymentType["P2SH"] = "p2sh";
6
+ PaymentType["P2MS"] = "p2ms";
7
+ PaymentType["P2WPKH"] = "p2wpkh";
8
+ PaymentType["P2WSH"] = "p2wsh";
9
+ PaymentType["P2TR"] = "p2tr";
10
+ PaymentType["P2OP"] = "p2op";
11
+ PaymentType["Embed"] = "embed";
12
+ PaymentType["ScriptRedeem"] = "scriptRedeem";
13
+ })(PaymentType || (PaymentType = {}));
@@ -3,7 +3,6 @@ import { Taptree } from '../types.js';
3
3
  interface PsbtOutputWithScript extends PsbtOutput {
4
4
  script?: Buffer;
5
5
  }
6
- export declare const toXOnly: (pubKey: Buffer | Uint8Array) => Buffer;
7
6
  export declare function tapScriptFinalizer(inputIndex: number, input: PsbtInput, tapLeafHashToFinalize?: Buffer): {
8
7
  finalScriptWitness: Buffer | undefined;
9
8
  };
@@ -1,12 +1,8 @@
1
- import { isTapleaf, isTaptree } from '../types.js';
2
- import { Transaction } from '../transaction.js';
3
1
  import { LEAF_VERSION_TAPSCRIPT, MAX_TAPTREE_DEPTH, rootHashFromPath, tapleafHash, tweakKey, } from '../payments/bip341.js';
4
2
  import { p2tr } from '../payments/p2tr.js';
3
+ import { Transaction } from '../transaction.js';
4
+ import { isTapleaf, isTaptree } from '../types.js';
5
5
  import { isP2TR, pubkeyPositionInScript, signatureBlocksAction, witnessStackToScriptWitness, } from './psbtutils.js';
6
- export const toXOnly = (pubKey) => {
7
- const buffer = pubKey.length === 32 ? pubKey : pubKey.subarray(1, 33);
8
- return Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
9
- };
10
6
  export function tapScriptFinalizer(inputIndex, input, tapLeafHashToFinalize) {
11
7
  const tapLeaf = findTapLeafToFinalize(input, inputIndex, tapLeafHashToFinalize);
12
8
  try {
@@ -9,13 +9,6 @@ export declare const isP2TR: (script: Buffer) => boolean;
9
9
  export declare const isP2OP: (script: Buffer) => boolean;
10
10
  export declare const isP2A: (script: Buffer) => boolean;
11
11
  export declare function witnessStackToScriptWitness(witness: Buffer[]): Buffer;
12
- export interface UncompressedPublicKey {
13
- hybrid: Buffer;
14
- uncompressed: Buffer;
15
- }
16
- export declare function decompressPublicKey(realPubKey: Uint8Array | Buffer): UncompressedPublicKey | undefined;
17
- export declare function bigIntTo32Bytes(num: bigint): Buffer;
18
- export declare function pubkeysMatch(a: Buffer, b: Buffer): boolean;
19
12
  export declare function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number;
20
13
  export declare function pubkeyInScript(pubkey: Buffer, script: Buffer): boolean;
21
14
  export declare function checkInputForSig(input: PsbtInput, action: string): boolean;
@@ -1,4 +1,3 @@
1
- import { ProjectivePoint } from '@noble/secp256k1';
2
1
  import * as varuint from 'bip174/src/lib/converter/varint.js';
3
2
  import { hash160 } from '../crypto.js';
4
3
  import { p2ms } from '../payments/p2ms.js';
@@ -8,10 +7,10 @@ import { p2sh } from '../payments/p2sh.js';
8
7
  import { p2tr } from '../payments/p2tr.js';
9
8
  import { p2wpkh } from '../payments/p2wpkh.js';
10
9
  import { p2wsh } from '../payments/p2wsh.js';
10
+ import { p2op } from '../payments/p2op.js';
11
+ import { decompressPublicKey, pubkeysMatch, toXOnly } from '../pubkey.js';
11
12
  import * as bscript from '../script.js';
12
13
  import { Transaction } from '../transaction.js';
13
- import { toXOnly } from './bip371.js';
14
- import { p2op } from '../payments/p2op.js';
15
14
  function isPaymentFactory(payment) {
16
15
  return (script) => {
17
16
  try {
@@ -60,57 +59,6 @@ export function witnessStackToScriptWitness(witness) {
60
59
  writeVector(witness);
61
60
  return buffer;
62
61
  }
63
- export function decompressPublicKey(realPubKey) {
64
- if (realPubKey.length === 32) {
65
- return;
66
- }
67
- if (![33, 65].includes(realPubKey.length)) {
68
- console.warn(`Unsupported key length=${realPubKey.length}. Must be 33 (compressed) or 65 (uncompressed).`);
69
- return;
70
- }
71
- let point;
72
- try {
73
- point = ProjectivePoint.fromHex(realPubKey);
74
- }
75
- catch (err) {
76
- throw new Error('Invalid secp256k1 public key bytes. Cannot parse.');
77
- }
78
- const xBuf = bigIntTo32Bytes(point.x);
79
- const yBuf = bigIntTo32Bytes(point.y);
80
- const isEven = point.y % 2n === 0n;
81
- const prefix = isEven ? 0x06 : 0x07;
82
- const hybridPubKey = Buffer.alloc(65);
83
- hybridPubKey[0] = prefix;
84
- xBuf.copy(hybridPubKey, 1);
85
- yBuf.copy(hybridPubKey, 33);
86
- const uncompressedPubKey = Buffer.concat([Buffer.from([0x04]), xBuf, yBuf]);
87
- return {
88
- hybrid: hybridPubKey,
89
- uncompressed: uncompressedPubKey,
90
- };
91
- }
92
- export function bigIntTo32Bytes(num) {
93
- let hex = num.toString(16);
94
- hex = hex.padStart(64, '0');
95
- if (hex.length > 64) {
96
- hex = hex.slice(-64);
97
- }
98
- return Buffer.from(hex, 'hex');
99
- }
100
- export function pubkeysMatch(a, b) {
101
- if (a.equals(b))
102
- return true;
103
- if (a.length === 65 && b.length === 65) {
104
- const aCopy = Buffer.from(a);
105
- const bCopy = Buffer.from(b);
106
- if (aCopy[0] === 0x06 || aCopy[0] === 0x07)
107
- aCopy[0] = 0x04;
108
- if (bCopy[0] === 0x06 || bCopy[0] === 0x07)
109
- bCopy[0] = 0x04;
110
- return aCopy.equals(bCopy);
111
- }
112
- return false;
113
- }
114
62
  export function pubkeyPositionInScript(pubkey, script) {
115
63
  const decompiled = bscript.decompile(script);
116
64
  if (decompiled === null)
package/build/psbt.js CHANGED
@@ -4,10 +4,11 @@ const varuintDecode = varuint.decode;
4
4
  import { checkForInput, checkForOutput } from 'bip174/src/lib/utils.js';
5
5
  import { fromOutputScript, isUnknownSegwitVersion, toOutputScript } from './address.js';
6
6
  import { cloneBuffer, reverseBuffer } from './bufferutils.js';
7
- import { payments } from './index.js';
8
7
  import { bitcoin as btcNetwork } from './networks.js';
8
+ import * as payments from './payments/index.js';
9
9
  import { tapleafHash } from './payments/bip341.js';
10
- import { checkTaprootInputFields, checkTaprootInputForSigs, checkTaprootOutputFields, isTaprootInput, serializeTaprootSignature, tapScriptFinalizer, toXOnly, } from './psbt/bip371.js';
10
+ import { checkTaprootInputFields, checkTaprootInputForSigs, checkTaprootOutputFields, isTaprootInput, serializeTaprootSignature, tapScriptFinalizer, } from './psbt/bip371.js';
11
+ import { toXOnly } from './pubkey.js';
11
12
  import { checkInputForSig, isP2MS, isP2PK, isP2PKH, isP2SHScript, isP2TR, isP2WPKH, isP2WSHScript, pubkeyInScript, witnessStackToScriptWitness, } from './psbt/psbtutils.js';
12
13
  import * as bscript from './script.js';
13
14
  import { Transaction } from './transaction.js';
@@ -0,0 +1,8 @@
1
+ export declare const toXOnly: (pubKey: Buffer | Uint8Array) => Buffer;
2
+ export interface UncompressedPublicKey {
3
+ hybrid: Buffer;
4
+ uncompressed: Buffer;
5
+ }
6
+ export declare function bigIntTo32Bytes(num: bigint): Buffer;
7
+ export declare function decompressPublicKey(realPubKey: Uint8Array | Buffer): UncompressedPublicKey | undefined;
8
+ export declare function pubkeysMatch(a: Buffer, b: Buffer): boolean;
@@ -0,0 +1,56 @@
1
+ import { ProjectivePoint } from '@noble/secp256k1';
2
+ export const toXOnly = (pubKey) => {
3
+ const buffer = pubKey.length === 32 ? pubKey : pubKey.subarray(1, 33);
4
+ return Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
5
+ };
6
+ export function bigIntTo32Bytes(num) {
7
+ let hex = num.toString(16);
8
+ hex = hex.padStart(64, '0');
9
+ if (hex.length > 64) {
10
+ hex = hex.slice(-64);
11
+ }
12
+ return Buffer.from(hex, 'hex');
13
+ }
14
+ export function decompressPublicKey(realPubKey) {
15
+ if (realPubKey.length === 32) {
16
+ return;
17
+ }
18
+ if (![33, 65].includes(realPubKey.length)) {
19
+ console.warn(`Unsupported key length=${realPubKey.length}. Must be 33 (compressed) or 65 (uncompressed).`);
20
+ return;
21
+ }
22
+ let point;
23
+ try {
24
+ point = ProjectivePoint.fromHex(realPubKey);
25
+ }
26
+ catch (err) {
27
+ throw new Error('Invalid secp256k1 public key bytes. Cannot parse.');
28
+ }
29
+ const xBuf = bigIntTo32Bytes(point.x);
30
+ const yBuf = bigIntTo32Bytes(point.y);
31
+ const isEven = point.y % 2n === 0n;
32
+ const prefix = isEven ? 0x06 : 0x07;
33
+ const hybridPubKey = Buffer.alloc(65);
34
+ hybridPubKey[0] = prefix;
35
+ xBuf.copy(hybridPubKey, 1);
36
+ yBuf.copy(hybridPubKey, 33);
37
+ const uncompressedPubKey = Buffer.concat([Buffer.from([0x04]), xBuf, yBuf]);
38
+ return {
39
+ hybrid: hybridPubKey,
40
+ uncompressed: uncompressedPubKey,
41
+ };
42
+ }
43
+ export function pubkeysMatch(a, b) {
44
+ if (a.equals(b))
45
+ return true;
46
+ if (a.length === 65 && b.length === 65) {
47
+ const aCopy = Buffer.from(a);
48
+ const bCopy = Buffer.from(b);
49
+ if (aCopy[0] === 0x06 || aCopy[0] === 0x07)
50
+ aCopy[0] = 0x04;
51
+ if (bCopy[0] === 0x06 || bCopy[0] === 0x07)
52
+ bCopy[0] = 0x04;
53
+ return aCopy.equals(bCopy);
54
+ }
55
+ return false;
56
+ }
package/build/script.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { opcodes } from './opcodes.js';
2
- import { Stack } from './payments/index.js';
3
2
  import * as scriptNumber from './script_number.js';
4
3
  import * as scriptSignature from './script_signature.js';
4
+ import type { Stack } from './types.js';
5
5
  export { opcodes };
6
6
  export declare function isPushOnly(value: Stack): boolean;
7
7
  export declare function countNonPushOnlyOPs(value: Stack): number;
@@ -11,7 +11,6 @@ export declare function toASM(chunks: Buffer | Array<number | Buffer>): string;
11
11
  export declare function fromASM(asm: string): Buffer;
12
12
  export declare function toStack(chunks: Buffer | Array<number | Buffer>): Buffer[];
13
13
  export declare function isCanonicalPubKey(buffer: Buffer): boolean;
14
- export declare function isDefinedHashType(hashType: number): boolean;
15
14
  export declare function isCanonicalScriptSignature(buffer: Buffer): boolean;
16
15
  export declare const number: typeof scriptNumber;
17
16
  export declare const signature: typeof scriptSignature;
package/build/script.js CHANGED
@@ -152,10 +152,7 @@ export function toStack(chunks) {
152
152
  export function isCanonicalPubKey(buffer) {
153
153
  return types.isPoint(buffer);
154
154
  }
155
- export function isDefinedHashType(hashType) {
156
- const hashTypeMod = hashType & ~0x80;
157
- return hashTypeMod > 0x00 && hashTypeMod < 0x04;
158
- }
155
+ import { isDefinedHashType } from './script_signature.js';
159
156
  export function isCanonicalScriptSignature(buffer) {
160
157
  if (!Buffer.isBuffer(buffer))
161
158
  return false;
@@ -1,3 +1,4 @@
1
+ export declare function isDefinedHashType(hashType: number): boolean;
1
2
  interface ScriptSignature {
2
3
  signature: Buffer;
3
4
  hashType: number;
@@ -1,8 +1,11 @@
1
1
  import * as bip66 from './bip66.js';
2
- import { isDefinedHashType } from './script.js';
3
2
  import * as types from './types.js';
4
3
  const { typeforce } = types;
5
4
  const ZERO = Buffer.alloc(1, 0);
5
+ export function isDefinedHashType(hashType) {
6
+ const hashTypeMod = hashType & ~0x80;
7
+ return hashTypeMod > 0x00 && hashTypeMod < 0x04;
8
+ }
6
9
  function toDER(x) {
7
10
  let i = 0;
8
11
  while (x[i] === 0)