@scure/btc-signer 1.0.1 โ†’ 1.1.1

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.
package/README.md CHANGED
@@ -2,29 +2,30 @@
2
2
 
3
3
  Audited & minimal library for creating, signing & decoding Bitcoin transactions.
4
4
 
5
+ - ๐Ÿ”’ [**Audited**](#security) by an independent security firm
5
6
  - โœ๏ธ Create transactions, inputs, outputs, sign them
6
7
  - ๐Ÿ“ก No network code: simplified audits and offline usage
7
8
  - ๐ŸŽป Classic & SegWit: P2PK, P2PKH, P2WPKH, P2SH, P2WSH, P2MS
8
9
  - ๐Ÿงช Schnorr & Taproot BIP340/BIP341: P2TR, P2TR-NS, P2TR-MS
9
10
  - ๐Ÿ“จ BIP174 PSBT
10
11
  - ๐Ÿ‘ฅ Multisig support
11
- - ๐Ÿ”’ [**Audited**](#security) by an independent security firm
12
12
  - ๐Ÿชถ ~2600 lines
13
13
 
14
14
  Initial development has been funded by [Ryan Shea](https://shea.io). Check out [the demo](https://signerdemo.micro-btc.dev/) & [its github](https://github.com/shea256/micro-btc-web-demo).
15
15
 
16
16
  ### This library belongs to _scure_
17
17
 
18
- > **scure** โ€” secure, independently audited packages for every use case.
18
+ > **scure** โ€” audited micro-libraries.
19
19
 
20
- - All releases are signed with PGP keys
21
- - Check out all libraries:
20
+ - Zero or minimal dependencies
21
+ - Highly readable TypeScript / JS code
22
+ - PGP-signed releases and transparent NPM builds
23
+ - Check out [homepage](https://paulmillr.com/noble/#scure) & all libraries:
22
24
  [base](https://github.com/paulmillr/scure-base),
23
25
  [bip32](https://github.com/paulmillr/scure-bip32),
24
26
  [bip39](https://github.com/paulmillr/scure-bip39),
25
- [btc-signer](https://github.com/paulmillr/scure-btc-signer)
26
-
27
- *Check out all web3 utility libraries:* [ETH](https://github.com/paulmillr/micro-eth-signer), [BTC](https://github.com/paulmillr/scure-btc-signer), [SOL](https://github.com/paulmillr/micro-sol-signer), [micro-web3](https://github.com/paulmillr/micro-web3), [tx-tor-broadcaster](https://github.com/paulmillr/tx-tor-broadcaster)
27
+ [btc-signer](https://github.com/paulmillr/scure-btc-signer),
28
+ [starknet](https://github.com/paulmillr/scure-starknet)
28
29
 
29
30
  ## Usage
30
31
 
@@ -36,7 +37,7 @@ For React Native, you may need a [polyfill for crypto.getRandomValues](https://g
36
37
 
37
38
  ```ts
38
39
  import * as btc from '@scure/btc-signer';
39
- // import * as btc from "npm:@scure/btc-signer@0.5.0"; // Deno
40
+ // import * as btc from "npm:@scure/btc-signer@1.0.0"; // Deno
40
41
  ```
41
42
 
42
43
  ### Table of Contents
@@ -530,7 +531,7 @@ type TransactionOutput = {
530
531
 
531
532
  tx.addOutput(o: TransactionOutput): number;
532
533
  tx.updateOutput(idx: number, output: TransactionOutput);
533
- tx.addOutputAddress(address: string, amount: string | bigint, network = NETWORK): number;
534
+ tx.addOutputAddress(address: string, amount: bigint, network = NETWORK): number;
534
535
 
535
536
  const compressed = hex.decode(
536
537
  '030000000000000000000000000000000000000000000000000000000000000001'
@@ -621,10 +622,10 @@ const epriv =
621
622
  'tprv8ZgxMBicQKsPd9TeAdPADNnSyH9SSUUbTVeFszDE23Ki6TBB5nCefAdHkK8Fm3qMQR6sHwA56zqRmKmxnHk37JkiFzvncDqoKmPWubu7hDF';
622
623
  const hdkey = bip32.HDKey.fromExtendedKey(epriv, testnet.bip32);
623
624
  // const seed = 'cUkG8i1RFfWGWy5ziR11zJ5V4U4W3viSFCfyJmZnvQaUsd1xuF3T';
624
- const tx = new btc.Transaction(2);
625
+ const tx = new btc.Transaction();
625
626
  // A creator creating a PSBT for a transaction which creates the following outputs:
626
- tx.addOutput({ script: '0014d85c2b71d0060b09c9886aeb815e50991dda124d', amount: '1.49990000' });
627
- tx.addOutput({ script: '001400aea9a2e5f0f876a588df5546e8742d1d87008f', amount: '1.00000000' });
627
+ tx.addOutput({ script: '0014d85c2b71d0060b09c9886aeb815e50991dda124d', amount: btc.Decimal.decode('1.49990000') });
628
+ tx.addOutput({ script: '001400aea9a2e5f0f876a588df5546e8742d1d87008f', amount: btc.Decimal.decode('1.00000000') });
628
629
  // and spends the following inputs:
629
630
  tx.addInput({
630
631
  txid: '75ddabb27b8845f5247975c8a5ba7c6f336c4570708ebe230caf6db5217ae858',
@@ -696,7 +697,7 @@ const psbt2 = tx2.toPSBT();
696
697
  // An updater which adds SIGHASH_ALL to the above PSBT must create this PSBT:
697
698
  const tx3 = btc.Transaction.fromPSBT(psbt2);
698
699
  for (let i = 0; i < tx3.inputs.length; i++)
699
- tx3.updateInput(i, { sighashType: btc.SignatureHash.ALL });
700
+ tx3.updateInput(i, { sighashType: btc.SigHash.ALL });
700
701
  const psbt3 = tx3.toPSBT();
701
702
  /*
702
703
  Given the above updated PSBT, a signer that supports SIGHASH_ALL for P2PKH and P2WPKH spends and uses RFC6979 for nonce generation and has the following keys:
@@ -836,16 +837,36 @@ deepStrictEqual(
836
837
 
837
838
  ## Security
838
839
 
839
- The library has been audited on Feb 21, 2023 by an independent security firm cure53: [PDF](./audit/2023-02-21-cure53-audit-report.pdf). The audit has been funded by Ryan Shea.
840
-
841
- Target was v0.3.0 (commit 397ed56), see [changes since audit](https://github.com/paulmillr/scure-btc-signer/compare/0.3.0..main).
842
-
843
- We consider infrastructure attacks like rogue NPM modules very important; that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings. If your app uses 500 dependencies, any dep could get hacked and you'll be downloading malware with every `npm install`. Our goal is to minimize this attack vector. As for dependencies used by the library:
844
-
845
- - noble-curves, noble-hashes are audited cryptography libraries also developed by us and follow the same practices
846
- - scure-base is used for bech32 / base64 and was also audited
847
- - micro-packed is used for binary encoding, has not been audited
848
- - devDependencies contain scure-bip32, micro-packed-debugger, micro-should (our packages). Locked versions of prettier (linter) and typescript which are rarely updated. Every update is checked with `npm-diff`. They are only used if you clone the git repo and want to add some feature to it. End-users won't use them
840
+ The library has been independently audited:
841
+
842
+ - at version 0.3.0, in Feb 2023, by [cure53](https://cure53.de)
843
+ - PDFs: [online](https://cure53.de/audit-report_micro-btc-signer.pdf), [offline](./audit/2023-02-21-cure53-audit-report.pdf)
844
+ - [Changes since audit](https://github.com/paulmillr/scure-btc-signer/compare/0.3.0..main).
845
+ - The audit has been funded by [Ryan Shea](https://shea.io)
846
+
847
+ ### Supply chain security
848
+
849
+ 1. **Commits** are signed with PGP keys, to prevent forgery. Make sure to verify commit signatures.
850
+ 2. **Releases** are transparent and built on GitHub CI. Make sure to verify [provenance](https://docs.npmjs.com/generating-provenance-statements) logs
851
+ 3. **Rare releasing** is followed.
852
+ The less often it is done, the less code dependents would need to audit
853
+ 4. **Dependencies** are minimal:
854
+ - All deps are prevented from automatic updates and have locked-down version ranges. Every update is checked with `npm-diff`
855
+ - Updates themselves are rare, to ensure rogue updates are not catched accidentally
856
+ - [noble-hashes](https://github.com/paulmillr/noble-hashes) provides hashing functionality
857
+ - [noble-curves](https://github.com/paulmillr/noble-curves) provides elliptic curve cryptography
858
+ - [scure-base](https://github.com/paulmillr/scure-base) provides bech32 / base64
859
+ - [micro-packed](https://github.com/paulmillr/micro-packed) provides binary encoding - it has not been audited
860
+ 5. devDependencies are only used if you want to contribute to the repo. They are disabled for end-users:
861
+ - scure-bip32, micro-packed-debugger and micro-should are developed by the same author and follow identical security practices
862
+ - prettier (linter), fast-check (property-based testing) and typescript are used for code quality, vector generation and ts compilation. The packages are big, which makes it hard to audit their source code thoroughly and fully
863
+
864
+ We consider infrastructure attacks like rogue NPM modules very important;
865
+ that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings.
866
+ If your app uses 500 dependencies, any dep could get hacked and you'll be
867
+ downloading malware with every install. Our goal is to minimize this attack vector.
868
+
869
+ If you see anything unusual: investigate and report.
849
870
 
850
871
  ## License
851
872