@btc-vision/transaction 1.8.0-beta.1 → 1.8.0-beta.3

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.
@@ -18,7 +18,7 @@ import { ContractAddress } from '../transaction/ContractAddress.js';
18
18
  import { BitcoinUtils } from '../utils/BitcoinUtils.js';
19
19
  import { TimeLockGenerator } from '../transaction/mineable/TimelockGenerator.js';
20
20
  import { P2WDADetector } from '../p2wda/P2WDADetector.js';
21
- import { sha256 } from '@noble/hashes/sha2';
21
+ import { sha256 } from '@noble/hashes/sha2.js';
22
22
  export class Address extends Uint8Array {
23
23
  constructor(mldsaPublicKey, publicKeyOrTweak) {
24
24
  super(ADDRESS_BYTE_LENGTH);
@@ -2,10 +2,10 @@ import * as ecc from '@bitcoinerlab/secp256k1';
2
2
  import bip32, { BIP32Factory, MLDSASecurityLevel, QuantumBIP32Factory, } from '@btc-vision/bip32';
3
3
  import bitcoin, { address, fromOutputScript, initEccLib, networks, opcodes, payments, script, toXOnly, } from '@btc-vision/bitcoin';
4
4
  import { ECPairFactory } from 'ecpair';
5
- import { secp256k1 } from '@noble/curves/secp256k1';
6
- import { mod } from '@noble/curves/abstract/modular';
7
- import { sha256 } from '@noble/hashes/sha2';
8
- import { bytesToNumberBE, concatBytes, randomBytes, utf8ToBytes } from '@noble/curves/utils.js';
5
+ import { secp256k1 } from '@noble/curves/secp256k1.js';
6
+ import { mod } from '@noble/curves/abstract/modular.js';
7
+ import { sha256 } from '@noble/hashes/sha2.js';
8
+ import { bytesToNumberBE, concatBytes, randomBytes } from '@noble/curves/utils.js';
9
9
  import { Buffer } from 'buffer';
10
10
  initEccLib(ecc);
11
11
  const BIP32factory = typeof bip32 === 'function' ? bip32 : BIP32Factory;
@@ -14,7 +14,7 @@ if (!BIP32factory) {
14
14
  }
15
15
  const Point = secp256k1.Point;
16
16
  const CURVE_N = Point.Fn.ORDER;
17
- const TAP_TAG = utf8ToBytes('TapTweak');
17
+ const TAP_TAG = Buffer.from('TapTweak', 'utf-8');
18
18
  const TAP_TAG_HASH = sha256(TAP_TAG);
19
19
  function tapTweakHash(x) {
20
20
  return sha256(concatBytes(TAP_TAG_HASH, TAP_TAG_HASH, x));
@@ -112,7 +112,7 @@ export class EcKeyPair {
112
112
  static tweakPublicKey(pub) {
113
113
  if (typeof pub === 'string' && pub.startsWith('0x'))
114
114
  pub = pub.slice(2);
115
- const P = Point.fromHex(pub);
115
+ const P = Point.fromHex(Buffer.from(pub).toString('hex'));
116
116
  const Peven = (P.y & 1n) === 0n ? P : P.negate();
117
117
  const xBytes = Buffer.from(Peven.toBytes(true).subarray(1));
118
118
  const tBytes = tapTweakHash(xBytes);
@@ -123,7 +123,7 @@ export class EcKeyPair {
123
123
  static tweakBatchSharedT(pubkeys, tweakScalar) {
124
124
  const T = Point.BASE.multiply(tweakScalar);
125
125
  return pubkeys.map((bytes) => {
126
- const P = Point.fromHex(bytes);
126
+ const P = Point.fromHex(Buffer.from(bytes).toString('hex'));
127
127
  const P_even = P.y % 2n === 0n ? P : P.negate();
128
128
  const Q = P_even.add(T);
129
129
  return Q.toBytes(true);