-
#127
e5c275f
Thanks @bitjson! - Add support for relative BIP32 derivationRelative BIP32 Hierarchical Deterministic (HD) derivation is now supported via the
deriveHdPathRelative
utility, and the Libauth compiler has been updated to explicitly use relative derivation by default forHdKey
s. Absolute derivation has also been enhanced to validate the expected depth of provided HD keys.If you application relies on relative derivation but uses
deriveHdPath
, you'll need to switch to using the newderiveHdPathRelative
, as absolute derivation will now fail if provided with a non-zero depth HD key.Fixes #49.
-
#127
e5c275f
Thanks @bitjson! - CashAssembly:.signature
is now.ecdsa_signature
All CashAssembly scripts using the
.signature
operation should instead call.ecdsa_signature
or switch to.schnorr_signature
.Additionally,
signing_serialization.token_prefix
is now available. -
#127
e5c275f
Thanks @bitjson! - Unify object parameters and error handling across libraryA number of existing Libauth utilities have been modified to adhere to Libauth's object parameter and error handling conventions:
- CashAddress utilities:
- BIP32 (HD Key) utilities:
crackHdPrivateNodeFromHdPublicNodeAndChildPrivateNode
decodeHdKey
(decodeHdKeyUnchecked
)decodeHdPrivateKey
/encodeHdPrivateKey
decodeHdPublicKey
/encodeHdPrivateKey
deriveHdPath
deriveHdPathRelative
deriveHdPrivateNodeFromSeed
deriveHdPrivateNodeIdentifier
/deriveHdPublicNodeIdentifier
deriveHdPrivateNodeChild
/deriveHdPublicNodeChild
deriveHdPublicKey
deriveHdPublicNode
hdKeyVersionIsPrivateKey
/hdKeyVersionIsPublicKey
hdPrivateKeyToIdentifier
/hdPublicKeyToIdentifier
- BIP39 (Mnemonic Phrase) Utilities:
- Key Utilities:
Please see the relevant guide(s) for usage examples:
-
#127
e5c275f
Thanks @bitjson! - Add usage guides and API overview -
#127
e5c275f
Thanks @bitjson! - Add P2PKH CashAddress utilitiesThe following utilities are now available:
hdPrivateKeyToP2pkhLockingBytecode
hdPrivateKeyToP2pkhCashAddress
hdPublicKeyToP2pkhLockingBytecode
hdPublicKeyToP2pkhCashAddress
privateKeyToP2pkhLockingBytecode
privateKeyToP2pkhCashAddress
publicKeyToP2pkhLockingBytecode
publicKeyToP2pkhCashAddress
For usage examples, see
wallets.md
. -
#127
e5c275f
Thanks @bitjson! - Validate all keys prior to compilation, exposevalidateCompilationData
The compiler now validates all compilation data (i.e. validate all public and private keys), prior to compilation, regardless of whether or not the offending public or private key material is used. This is intended to surface software defects (particularly in the software used by counterparties) as early as possible.
-
#127
e5c275f
Thanks @bitjson! - Add support fordecodeTransactionOutputs
-
#127
e5c275f
Thanks @bitjson! -generateRandomBytes
: always verify unique results across two runsFixes #119. Old behavior is available at
generateRandomBytesUnchecked
.
- #117
51c7ee3
Thanks @bitjson! - Use@changesets/cli
, removestandard-version
- #117
7ddad21
Thanks @bitjson! - Publish with provenance via GitHub Actions
Libauth is now a pure ESM package, simplifying the developer experience by allowing WASM crypto to be instantiated internally/automatically by default 🎉. This refactor also simplifies the usage of and types surrounding Libauth virtual machines and compilers, and several other APIs have been improved.
New, dedicated Telegram channels are also available for Libauth release announcements and Libauth developer discussions.
Previously, Libauth VMs were very strictly-typed such that error messages and opcodes used chain-specific enums (e.g. AuthenticationErrorBCH
and OpcodesBCH
). While this configuration did ensure that VMs and VM results were strictly-typed with chain information, the configuration ultimately made library components much harder to remix without deep knowledge of TypeScript's type system. In both cases, such type information rarely catches downstream implementation bugs:
- Differing opcode enums effectively only narrow the real-time type from
number
to0 | 1 | 2 | ... | 254 | 255
. - Differing error enums only offer a slight benefit in making error matching slightly simpler, and they present a significant disadvantage in that they preclude the contextualization of errors – each error string must be fully defined at compile time.
In both cases, the differing types offer only very marginal benefit at the cost of exceptional added complexity (widespread proliferation of generic types throughout the codebase). This refactor migrates the opcode type to number
and the error type to string | undefined
, leaving the opcode and error enums primarily as a form of documentation.
Transaction validation infrastructure is now a part of each VM instance, so transaction validation is as simple as vm.verify({ transaction, sourceOutputs })
(returning either true
or an error string
). This behavior offers individual VMs full control of transaction parsing and validation, allowing Libauth VMs to implement proposals for significant modifications like new transaction formats or high-level transaction validation changes.
Beginning with this version, Libauth will no longer maintain support for defunct VM versions. For example, BCH_2019_05
was an upgrade which enabled Schnorr signature support in CHECKSIG and CHECKDATASIG and a clean-stack exception for SegWit recovery. The BCH_2019_05
VM was replaced without a network split by the BCH_2019_11
upgrade, meaning BCH_2019_05
is no longer in use by any public network. As such, relevant code paths, flags, and other VM-specific functionality for BCH_2019_05
has been removed to simplify currently supported Libauth VMs. (Of course, historical implementations will always remain available in previously-released versions of Libauth.)
With this change, the existing VM implementations have been significantly simplified, removing unused code and reducing type complexity. Built-in VM instruction sets are now specified in a single file, making them easier to review and copy.
Several other improvements have been made:
- Default crypto interface instances – because Libauth is now pure ESM, all of Libauth's WebAssembly cryptography implementations can now be automatically instantiated internally by the library. All Libauth methods that require crypto now use these automatically-instantiated implementations by default (as a default parameter), but consumers can opt-out of the behavior by providing a replacement implementation (and build tools that support dead code elimination/tree shaking of default parameters can automatically drop the unused crypto implementations.) To support this functionality, the parameter ordering of many functions have been modified to shift crypto implementations to the end (as optional parameters).
Secp256k1
doesn't throw - theSecp256k1
interface previously threw errors, breaking from Libauth's convention of well-typed errors. AllSecp256k1
methods now return error messages asstring
s where applicable.- CashAssembly – is the new name for Bitauth Templating Language (BTL), the simple language used within Libauth templates.
- Consistent capitalization, miscellaneous corrections – some exports have been renamed to consistently use camelCase (for functions) or PascalCase (for types/interfaces), respectively. Several exports have been renamed for discoverability and consistency with other exports.
- Expanded state available to VMs and compilers – VM and compiler operations can now access all raw contents of transactions and source outputs.
- Expanded capabilities of template scenarios – scenarios can now represent any transaction shape and generate full, serializable transactions.
- New VM bytecode test vector generation – Libauth includes a new
vmb_tests
test vector generation system to produce sets of cross-implementation test vectors as serialized transactions; this allows for sets of test vectors that fully test all transaction validation infrastructure without making assumptions about implementation internals. - Improved CashAddress utilities – cash address utilities no longer require enums, hash lengths are measured in bytes rather than bits, and
type
is distinguished fromtypeBit
. - More consistent encoding/decoding utilities – Several decoding methods have been renamed and refactored to use the new ReadPosition API.
- More consistent error handling – all possible errors are surfaced in type signatures as
string
s.
2.0.0 (2024-01-12)
- exposes script source compilations in ResolvedScript and renames authenticationTemplate -> walletTemplate
- key generation utilities, utf8 normalization, API improvements (5ad6520)
1.19.1 (2022-02-01)
- secp256k1: prevent vulnerabilities in consumers which don't validate input lengths (7fc75c9)
2.0.0-alpha.8 (2023-01-10)
2.0.0-alpha.7 (2022-12-08)
- add dust and duplicate outpoint validation, vmb tests to BCH_2023 VM (01587f7)
- token signing serialization support (compiler, VM, tests) (9dfa6cc)
2.0.0-alpha.6 (2022-08-18)
- Several decoding methods have been renamed and refactored to use the new ReadPosition API.
- support CashTokens (8e99139)
- support decoding error messages, support token prefixes (fd9b4d2)
- support token-aware CashAddresses (5ee0fff)
2.0.0-alpha.5 (2022-06-27)
- Binary literals are now compiled as bytes rather than numbers.
- improve VM errors, correct binary literals, add vmb_tests (e146a94)
2.0.0-alpha.4 (2022-06-16)
- cash address utilities no longer require enums, hash lengths are measured in bytes rather than bits, and type is distinguished from typeBit
-
add hash160, hash256, and encodeLockingBytecode* utils (c2a787c)
-
simplify cash address utilities (be45abd)
2.0.0-alpha.3 (2022-05-20)
- add hash160, hash256, and encodeLockingBytecode* utils (c2a787c)
2.0.0-alpha.2 (2022-05-19)
2.0.0-alpha.1 (2022-05-19)
- improve BCH VMB tests, add basic P2PKH utils, export more aliases (087de5a)
- rename format utils for consistency, improve vmb_tests, fix issues in BCH vm (6f2e782)
2.0.0-alpha.0 (2022-05-14)
- requires esm, modifies some crypto interfaces, renames many exports for consistency, expands the program state available to vms and compilers
- switch to pure esm, simplify types, simplify crypto, update vms and compiler (c80044f), closes #31 #53 #72
- clarify endianness of outpointTransactionHash around library (04c8c52)
1.19.0 (2021-12-08)
1.18.1 (2021-02-26)
1.18.0 (2021-02-11)
1.17.3 (2020-10-23)
1.17.2 (2020-09-15)
1.17.1 (2020-08-08)
- OP_REVERSEBYTES: clone stack item before reversing (071f9cd)
1.17.0 (2020-08-07)
- update current BCH instruction set (d0bff0c)
1.16.0 (2020-07-21)
- scenarios: support "pushed" and "invalid" properties (a38544a)
1.15.4 (2020-07-14)
1.15.3 (2020-06-19)
1.15.2 (2020-06-19)
1.15.1 (2020-06-19)
1.15.0 (2020-06-18)
- compiler: add support for scenarios, binary literals, numeric separators, p2sh transformation, (17bfd1e)
- add compileBtl, more locktime utils (7657647)
- add serialization contents to compiler output and vm state (8592e9b)
- add transaction generation support, increase compiler coverage (2225f4b)
- improve authentication template validation, improve types (9fbec21)
- compiler: add built-in support for P2SH (d7ba2ef)
- compiler: add HdKey support to the compiler (0412caf)
- transaction: report missing variables during compilation (9eee817)
- compiler: better error messages for cyclical compilations (4bbd1bd)
- compiler: require evaluations to return exactly one stack item (86c4c19)
- parseBytesAsScriptNumber: accept options as an object (8a73752)
1.14.2 (2020-03-30)
- deriveHdPrivateNodeFromSeed: account for validity in return type (90848d9)
1.14.1 (2020-03-29)
1.14.0 (2020-03-29)
- add support for BIP32 HD keys and node derivation (c047e55)
- WIF: add support for Wallet Import Format (WIF) (87cfb6f)
- add locking bytecode <-> address utilities (2117181)
- Base58Address: add support for the Base58Address format (84cc241)
- format: add base58 support (9dec946)
- binToBigIntUintLE: use only BigInts internally (3842373)
- format: fix locktime format utilities, improve tests (58b2f73)
- format: utils -> format, fix number formatting methods and tests (3901ce6)
- stringify: improve types to get full coverage (c4359d5)
1.13.0 (2020-03-06)
- hmac: add HMAC support (HMAC-SHA256 and HMAC-SHA512) (27d08b0)
- key: add generatePrivateKey method (ccd26dc)
1.12.0 (2020-02-07)
- base64: improve base64 utils, tests, and docs (ac9d3e0)
- CashAddress: add support for CashAddress encoding, decoding, and error-correction (85f640f)
- utils: add time-related utils (e2c95d1)
- address: export address in lib (93e6d99)
- imports: clean up imports, expose bitcoin-abc-utils (312c667)
- vm: avoid throwing on undefined unlocking bytecode, add tests (339f1e5), closes #41
1.11.1 (2019-11-22)
- compiler: make correspondingOutput optional (in case it doesn't exist) (1803848)
- reduce wasm memory needed for tests (43c833c)
1.11.0 (2019-11-22)
- use preimages instead of hashes in VM, add preimage components to compiler (8949d5b)
1.10.0 (2019-11-21)
- compiler: add signing_serialization.covered_bytecode_prefix to operations (8989592)
1.9.0 (2019-11-21)
- compiler: add built-in variables (d68aea4)
- add tests for utf8 utils (0f73587)
1.8.2 (2019-11-15)
- compiler: stringify error messages inside resolved scripts (d147c75)
- parser: fix crash on improper negative BigIntLiterals, e.g. "42-" (5547ee7)
1.8.1 (2019-11-12)
- compiler: avoid crash if 0th sample is the error (06d86d8)
1.8.0 (2019-11-12)
- typo (5820369)
- compiler: add source property to ResolvedSegmentScriptBytecode (74d8625)
1.7.1 (2019-11-05)
- types: export ResolvedSegment types (830d63e)
1.7.0 (2019-11-05)
- compiler: include source type in all bytecode resolve segments (754ae88)
1.6.7 (2019-11-05)
- parser: make whitespace optional between recognized parsers (1f28d29)
1.6.6 (2019-11-02)
- compiler: use CompilerKeyOperationsMinimal by default (0d27b48)
1.6.5 (2019-11-01)
1.6.4 (2019-11-01)
1.6.3 (2019-10-31)
- compiler: only attempt to return bytecode on successful compilations (a987d54)
- deps: bump lodash.merge from 4.6.1 to 4.6.2 (#35) (fbd038d)
- deps: bump lodash.template from 4.4.0 to 4.5.0 (#36) (0cffd2f)
- deps: bump mixin-deep from 1.3.1 to 1.3.2 (#34) (c5c835f)
- scripts: add watch:module-only task (8ae64fe)
1.6.2 (2019-10-30)
- parser: fix several parser bugs, add parseScript tests (bf56ea9)
1.6.1 (2019-10-30)
- AuthenticationTemplate: add $schema as optional field on AuthenticationTemplate (875cc11)
- package: switch typings from main to module build (bccab5f)
1.6.0 (2019-10-30)
- compiler: correct use of "a" vs. "an" in error messages (4892685)
- hashes: pin sha256 of rustup docker image (98b2a13)
- add JSON schema for authentication templates (f054757)
1.5.5 (2019-08-23)
- opCheckMultiSig: fix potential undefined public key (dda926a)
- sampledEvaluateReductionTraceNodes: allow empty scripts to be debugged properly (f6f8347)
1.5.4 (2019-08-21)
- compiler: allow empty programs to be compiled (41275c0)
1.5.3 (2019-08-20)
- module: include parsimmon in module build (eab7b87)
1.5.2 (2019-08-20)
- stringify: improve docs, add tests (f599364)
1.5.1 (2019-08-15)
- schnorr: spelling (6a08fb4)
1.5.0 (2019-08-15)
- auth: complete BCH auth vm, schnorr, and BTL compiler (7d917e4)
- auth: draft authentication-related APIs (c9fdf8e)
1.4.0 (2018-11-12)
- secp256k1: Finalize implementation for tweak functions, compile new WASM (7726bae)
- secp256k1: prettier (54e20a5)
- secp256k1: Add public and private key tweaking functions (bcc639e)
- secp256k1: export tweak methods (f763916)
1.3.0 (2018-10-04)
1.2.0 (2018-07-08)
- utils: export common utility functions for working with libauth (0124a2e)
1.1.1 (2018-06-27)
1.1.0 (2018-06-27)
- hashes: expose WebAssembly sha256, sha512, and sha1 implementations (797f738)
- ripemd160: add a purely-functional, incremental, rust ripemd160 implementation (b7f4e37)
- ripemd160: expose a purely-functional, WebAssembly ripemd160 implementation (315bf23)
- ripemd160: include a rust ripemd160 implementation (792a01c)
- sha256: include a rust sha256 implementation (76d8a30)
1.0.3 (2018-06-04)
1.0.2 (2018-06-04)
- Secp256k1: copy the underlying buffer when returning values from Secp256k1 (62bfe06)
1.0.1 (2018-05-29)
- package: allow consumers to install libauth with npm (e7a0c37)
- secp256k1Wasm: expose a WebAssembly version of libsecp256k1 (31f768e)