Skip to content

Commit 4043ae7

Browse files
committed
Deprecate BCH_2022_05, add BCH_2023_05, BCH_2025_05, and BCH_SPEC, update vmb_tests
1 parent b4fbd00 commit 4043ae7

131 files changed

Lines changed: 20772 additions & 19896 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/great-ducks-roll.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@bitauth/libauth': minor
3+
---
4+
5+
Deprecate `BCH_2022_05` VM, add `BCH_2023_05`, `BCH_2025_05`, and `BCH_SPEC` VMs, update vmb_tests
6+
7+
Additionally, all exports have been renamed to more consistently adhere to the `camelCase` capitalization style, without exceptions for abbreviations. For example `assembleBytecodeBCH` is now `assembleBytecodeBch`. To ensure backwards-compatibility, aliases (marked with `@deprecated` TSdoc tags) are also exported using the old capitalization. These aliases will be removed in a future major version.

.cspell.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"authchain",
1818
"authchains",
1919
"authhead",
20-
"BCHCHIPs",
2120
"bchn",
2221
"bchreg",
2322
"bchtest",

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -333,26 +333,26 @@ High-level utilities are composed from lower-level utilities which are also expo
333333

334334
#### Built-In VMs
335335

336-
- [`createInstructionSetBCH`](https://libauth.org/functions/createInstructionSetBCH.html)
337-
- [`createInstructionSetBCH2022`](https://libauth.org/functions/createInstructionSetBCH2022.html)
338-
- [`createInstructionSetBCH2023`](https://libauth.org/functions/createInstructionSetBCH2023.html)
339-
- [`createInstructionSetBCHCHIPs`](https://libauth.org/functions/createInstructionSetBCHCHIPs.html)
340-
- [`createInstructionSetXEC`](https://libauth.org/functions/createInstructionSetXEC.html)
336+
- [`createInstructionSetBch`](https://libauth.org/functions/createInstructionSetBch.html)
337+
- [`createInstructionSetBch2023`](https://libauth.org/functions/createInstructionSetBch2023.html)
338+
- [`createInstructionSetBch2025`](https://libauth.org/functions/createInstructionSetBch2025.html)
339+
- [`createInstructionSetBchSpec`](https://libauth.org/functions/createInstructionSetBchSpec.html)
340+
- [`createInstructionSetXec`](https://libauth.org/functions/createInstructionSetXec.html)
341341
- [`createVirtualMachine`](https://libauth.org/functions/createVirtualMachine.html)
342-
- [`createVirtualMachineBCH`](https://libauth.org/functions/createVirtualMachineBCH.html)
343-
- [`createVirtualMachineBCH2022`](https://libauth.org/functions/createVirtualMachineBCH2022.html)
344-
- [`createVirtualMachineBCH2023`](https://libauth.org/functions/createVirtualMachineBCH2023.html)
345-
- [`createVirtualMachineBCHCHIPs`](https://libauth.org/functions/createVirtualMachineBCHCHIPs.html)
346-
- [`createVirtualMachineXEC`](https://libauth.org/functions/createVirtualMachineXEC.html)
342+
- [`createVirtualMachineBch`](https://libauth.org/functions/createVirtualMachineBch.html)
343+
- [`createVirtualMachineBch2023`](https://libauth.org/functions/createVirtualMachineBch2023.html)
344+
- [`createVirtualMachineBch2025`](https://libauth.org/functions/createVirtualMachineBch2025.html)
345+
- [`createVirtualMachineBchSpec`](https://libauth.org/functions/createVirtualMachineBchSpec.html)
346+
- [`createVirtualMachineXec`](https://libauth.org/functions/createVirtualMachineXec.html)
347347

348348
#### Debugging
349349

350350
- [`assembleBytecode`](https://libauth.org/functions/assembleBytecode.html)
351-
- [`assembleBytecodeBCH`](https://libauth.org/functions/assembleBytecodeBCH.html)
352-
- [`assembleBytecodeBTC`](https://libauth.org/functions/assembleBytecodeBTC.html)
353-
- [`disassembleBytecode`](https://libauth.org/functions/disassembleBytecodeBCH.html)
354-
- [`disassembleBytecodeBCH`](https://libauth.org/functions/disassembleBytecodeBCH.html)
355-
- [`disassembleBytecodeBTC`](https://libauth.org/functions/disassembleBytecodeBTC.html)
351+
- [`assembleBytecodeBch`](https://libauth.org/functions/assembleBytecodeBch.html)
352+
- [`assembleBytecodeBtc`](https://libauth.org/functions/assembleBytecodeBtc.html)
353+
- [`disassembleBytecode`](https://libauth.org/functions/disassembleBytecode.html)
354+
- [`disassembleBytecodeBch`](https://libauth.org/functions/disassembleBytecodeBch.html)
355+
- [`disassembleBytecodeBtc`](https://libauth.org/functions/disassembleBytecodeBtc.html)
356356
- [`generateBytecodeMap`](https://libauth.org/functions/generateBytecodeMap.html)
357357
- [`summarizeDebugTrace`](https://libauth.org/functions/summarizeDebugTrace.html)
358358
- [`stringifyDebugTraceSummary`](https://libauth.org/functions/stringifyDebugTraceSummary.html)
@@ -399,7 +399,7 @@ High-level utilities are composed from lower-level utilities which are also expo
399399
- [`stringifyErrors`](https://libauth.org/functions/stringifyErrors.html)
400400
- [`verifyCashAssemblyEvaluationState`](https://libauth.org/functions/verifyCashAssemblyEvaluationState.html)
401401
- [`walletTemplateToCompilerConfiguration`](https://libauth.org/functions/walletTemplateToCompilerConfiguration.html)
402-
- [`walletTemplateToCompilerBCH`](https://libauth.org/functions/walletTemplateToCompilerBCH.html)
402+
- [`walletTemplateToCompilerBch`](https://libauth.org/functions/walletTemplateToCompilerBch.html)
403403

404404
#### Multi-Party Compilation
405405

docs/verify-transactions.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ Libauth includes extensive support for verifying transactions and debugging Virt
44

55
## Simple Verification
66

7-
To verify a transaction using Bitcoin Cash's latest standard VM, use `createVirtualMachineBCH` with the initial `standard` parameter set to `true`. (For details on the difference between standard and non-standard VMs, see [`Standard Vs. Non-Standard VMs`](../src/lib/vmb-tests/readme.md#standard-vs-non-standard-vms).)
7+
To verify a transaction using Bitcoin Cash's latest standard VM, use `createVirtualMachineBch` with the initial `standard` parameter set to `true`. (For details on the difference between standard and non-standard VMs, see [`Standard Vs. Non-Standard VMs`](../src/lib/vmb-tests/readme.md#standard-vs-non-standard-vms).)
88

99
```ts
1010
import {
1111
assertSuccess,
1212
decodeTransaction,
1313
decodeTransactionOutputs,
14-
createVirtualMachineBCH,
14+
createVirtualMachineBch,
1515
} from '@bitauth/libauth';
1616

17-
const vm = createVirtualMachineBCH(true);
17+
const vm = createVirtualMachineBch(true);
1818
/* Example transaction from Virtual Machine Bytecode (VMB) test ID: "dv5k4" */
1919
const vmbTest = {
2020
description:
@@ -91,17 +91,17 @@ import type { AuthenticationProgramStateStack } from '@bitauth/libauth';
9191
import {
9292
assertSuccess,
9393
binToHex,
94-
createInstructionSetBCH,
94+
createInstructionSetBch,
9595
createVirtualMachine,
96-
OpcodesBCH,
96+
OpcodesBch,
9797
pushToStack,
9898
stringifyDebugTraceSummary,
9999
summarizeDebugTrace,
100100
useThreeStackItems,
101-
walletTemplateToCompilerBCH,
101+
walletTemplateToCompilerBch,
102102
} from '@bitauth/libauth';
103103

104-
const instructionSet = createInstructionSetBCH(true);
104+
const instructionSet = createInstructionSetBch(true);
105105
/**
106106
* A hypothetical "OP_UNROT" which rotates the top stack items in the
107107
* direction opposite that of OP_ROT. (The generic `<State extends ...>`
@@ -113,7 +113,7 @@ const opUnRot = <State extends AuthenticationProgramStateStack>(state: State) =>
113113
);
114114

115115
/* We assign "OP_UNROT" at the index held by "OP_RESERVED1" */
116-
const opcode = OpcodesBCH.OP_RESERVED1;
116+
const opcode = OpcodesBch.OP_RESERVED1;
117117
/* All other features of the BCH instruction set are unmodified: */
118118
const vm = createVirtualMachine({
119119
...instructionSet,
@@ -125,7 +125,7 @@ const vm = createVirtualMachine({
125125

126126
const OP_UNROT = `0x${binToHex(Uint8Array.of(opcode))}`;
127127
/* A compiler for a simple wallet template to test the new opcode: */
128-
const compiler = walletTemplateToCompilerBCH({
128+
const compiler = walletTemplateToCompilerBch({
129129
entities: {},
130130
scripts: {
131131
lock: {
@@ -146,7 +146,7 @@ const { program } = assertSuccess(
146146
const trace = vm.debug(program);
147147
const summary = summarizeDebugTrace(trace);
148148
const formatted = stringifyDebugTraceSummary(summary, {
149-
opcodes: { ...OpcodesBCH, [opcode]: 'OP_UNROT' },
149+
opcodes: { ...OpcodesBch, [opcode]: 'OP_UNROT' },
150150
});
151151
console.log(formatted); /*
152152

src/lib/compiler/compiler-bch/compiler-bch-operations.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import test from 'ava';
22

3-
import type { CompilationContextBCH } from '../../lib.js';
4-
import { compilerOperationSigningSerializationFullBCH } from '../../lib.js';
3+
import type { CompilationContextBch } from '../../lib.js';
4+
import { compilerOperationSigningSerializationFullBch } from '../../lib.js';
55

6-
test('compilerOperationSigningSerializationFullBCH: requires an algorithm', (t) => {
6+
test('compilerOperationSigningSerializationFullBch: requires an algorithm', (t) => {
77
t.deepEqual(
8-
compilerOperationSigningSerializationFullBCH(
8+
compilerOperationSigningSerializationFullBch(
99
'',
10-
{ compilationContext: {} as CompilationContextBCH },
10+
{ compilationContext: {} as CompilationContextBch },
1111
{
1212
scripts: { lock: '' },
1313
sha256: { hash: () => Uint8Array.of() },
@@ -22,11 +22,11 @@ test('compilerOperationSigningSerializationFullBCH: requires an algorithm', (t)
2222
},
2323
);
2424
});
25-
test('compilerOperationSigningSerializationFullBCH: error on unknown algorithms', (t) => {
25+
test('compilerOperationSigningSerializationFullBch: error on unknown algorithms', (t) => {
2626
t.deepEqual(
27-
compilerOperationSigningSerializationFullBCH(
27+
compilerOperationSigningSerializationFullBch(
2828
'signing_serialization.full_unknown_serialization',
29-
{ compilationContext: {} as CompilationContextBCH },
29+
{ compilationContext: {} as CompilationContextBch },
3030
{
3131
scripts: { lock: '' },
3232
sha256: { hash: () => Uint8Array.of() },

src/lib/compiler/compiler-bch/compiler-bch.e2e.built-in-variables.spec.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import test from 'ava';
22

33
import type {
4-
AuthenticationProgramStateBCH,
4+
AuthenticationProgramStateBch,
55
BytecodeGenerationResult,
6-
CompilerConfigurationBCH,
6+
CompilerConfigurationBch,
77
} from '../../lib.js';
88
import {
9-
compilerConfigurationToCompilerBCH,
10-
compilerOperationsBCH,
9+
compilerConfigurationToCompilerBch,
10+
compilerOperationsBch,
1111
createAuthenticationProgramEvaluationCommon,
1212
createCompilationContextCommonTesting,
13-
createVirtualMachineBCH,
13+
createVirtualMachineBch,
1414
dateToLocktime,
1515
generateBytecodeMap,
1616
hexToBin,
17-
OpcodesBCH2022,
17+
OpcodesBch,
1818
sha256,
1919
} from '../../lib.js';
2020

@@ -43,7 +43,7 @@ test(
4343
},
4444
],
4545
success: false,
46-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
46+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
4747
);
4848

4949
test(
@@ -78,7 +78,7 @@ test(
7878
},
7979
],
8080
success: false,
81-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
81+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
8282
);
8383

8484
test(
@@ -113,7 +113,7 @@ test(
113113
},
114114
],
115115
success: false,
116-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
116+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
117117
{},
118118
{ unlockingScriptTimeLockTypes: { test: 'height' } },
119119
);
@@ -142,7 +142,7 @@ test(
142142
},
143143
],
144144
success: false,
145-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
145+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
146146
{},
147147
{ unlockingScriptTimeLockTypes: { test: 'timestamp' } },
148148
);
@@ -180,7 +180,7 @@ test(
180180
},
181181
],
182182
success: false,
183-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
183+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
184184
{},
185185
{ unlockingScriptTimeLockTypes: { test: 'height' } },
186186
);
@@ -205,7 +205,7 @@ test(
205205
},
206206
],
207207
success: false,
208-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
208+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
209209
);
210210

211211
test(
@@ -228,7 +228,7 @@ test(
228228
},
229229
],
230230
success: false,
231-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
231+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
232232
);
233233

234234
/**
@@ -280,7 +280,7 @@ test(
280280
},
281281
],
282282
success: false,
283-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
283+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
284284
);
285285

286286
test(
@@ -303,7 +303,7 @@ test(
303303
},
304304
],
305305
success: false,
306-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
306+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
307307
);
308308

309309
test(
@@ -637,7 +637,7 @@ test(
637637
},
638638
],
639639
success: false,
640-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
640+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
641641
{},
642642
{
643643
unlockingScripts: {},
@@ -664,7 +664,7 @@ test(
664664
},
665665
],
666666
success: false,
667-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
667+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
668668
{},
669669
{
670670
unlockingScripts: {
@@ -693,7 +693,7 @@ test(
693693
},
694694
],
695695
success: false,
696-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
696+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
697697
{},
698698
{
699699
scripts: {
@@ -723,7 +723,7 @@ test(
723723
},
724724
],
725725
success: false,
726-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
726+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
727727
);
728728

729729
test(
@@ -746,19 +746,19 @@ test(
746746
},
747747
],
748748
success: false,
749-
} as BytecodeGenerationResult<AuthenticationProgramStateBCH>,
749+
} as BytecodeGenerationResult<AuthenticationProgramStateBch>,
750750
);
751751

752752
test.failing(
753753
'[BCH compiler] signing_serialization.corresponding_output and signing_serialization.corresponding_output_hash - returns empty bytecode if no corresponding output',
754754
(t) => {
755-
const compiler = compilerConfigurationToCompilerBCH<
756-
CompilerConfigurationBCH,
757-
AuthenticationProgramStateBCH
755+
const compiler = compilerConfigurationToCompilerBch<
756+
CompilerConfigurationBch,
757+
AuthenticationProgramStateBch
758758
>({
759759
createAuthenticationProgram: createAuthenticationProgramEvaluationCommon,
760-
opcodes: generateBytecodeMap(OpcodesBCH2022),
761-
operations: compilerOperationsBCH,
760+
opcodes: generateBytecodeMap(OpcodesBch),
761+
operations: compilerOperationsBch,
762762
scripts: {
763763
// eslint-disable-next-line camelcase
764764
corresponding_output:
@@ -773,7 +773,7 @@ test.failing(
773773
type: 'Key',
774774
},
775775
},
776-
vm: createVirtualMachineBCH(),
776+
vm: createVirtualMachineBch(),
777777
});
778778

779779
const data = {

0 commit comments

Comments
 (0)