Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface CompilationEnvironment<TransactionContext, CompilerKeyOperations, CompilerSigningSerializationOperations, CompilerAddressDataOperations, CompilerWalletDataOperations, CompilerCurrentBlockHeightOperations, CompilerCurrentBlockTimeOperations>

The full context required to compile a given Bitauth Template script – everything required for the compiler to understand the CompilationData and generate the compiled bytecode (targeting a specific AuthenticationVirtualMachine).

remarks

A CompilationEnvironment must include a subset of the script's AuthenticationTemplate – all the variables and scripts referenced (including children of children) by the script in question.

The context must also include an object mapping of opcode identifiers to the bytecode they generate.

If keys are used, an implementation of sha256 and secp256k1 is required. If the script requires evaluations during compilation, the evaluating AuthenticationVirtualMachine must also be included.

Type parameters

  • TransactionContext

    additional data available to compiler operations, e.g. transaction signing serialization components

  • CompilerKeyOperations: string | false

    a list of valid compiler operations for Key and HdKey variables, e.g. 'public_key' | 'signature', or false if only a single compiler operation is used for all instances

  • CompilerSigningSerializationOperations: string | false

    a list of valid compiler operations for Key and HdKey variables, e.g. "version" | "transaction_outpoints" | ..., or false if only a single compiler operation is used for all signing_serialization instances

  • CompilerAddressDataOperations: string | false

    a list of valid compiler operations for AddressData variables or false if only a single compiler operation is used for all AddressData instances (default: false)

  • CompilerWalletDataOperations: string | false

    a list of valid compiler operations for WalletData variables or false if only a single compiler operation is used for all WalletData instances (default: false)

  • CompilerCurrentBlockHeightOperations: string | false

    a list of valid compiler operations for current_block_height variables or false if only a single compiler operation is used for all instances (default: false)

  • CompilerCurrentBlockTimeOperations: string | false

    a list of valid compiler operations for current_block_time variables or false if only a single compiler operation is used for all instances (default: false)

Hierarchy

  • CompilationEnvironment

Index

Properties

Optional createAuthenticationProgram

createAuthenticationProgram: undefined | ((evaluationBytecode: Uint8Array) => any)

A method which accepts the compiled bytecode contents of a BTL evaluation and produces the equivalent AuthenticationProgram to be evaluated by the VM. This method is used internally to compute BTL evaluations. See createAuthenticationProgramEvaluationCommon for details.

Optional entityOwnership

entityOwnership: undefined | {}

An object mapping template variable identifiers to the entity identifiers responsible for them. This is required for HdKey support, as each entity uses a single HD private key (provided in hdKeys.hdPrivateKeys) or HD public key (provided in hdKeys.hdPublicKeys) per compilation, and each HdKey variable is derived from this key.

To avoid compilation errors, this object must contain all HdKey variables referenced by the script being compiled (including in child scripts). To enable support for error handling like extractMissingVariables, it's recommended that all variables be provided here.

Optional lockingScriptTypes

lockingScriptTypes: undefined | {}

An object mapping the script identifiers of locking scripts to their locking script type, either standard or p2sh.

This is used to transform compilation results into the proper structure for P2SH locking and unlocking scripts.

When compiling locking scripts of type p2sh, the result will be placed in a P2SH "redeemScript" format: OP_HASH160 <$(<result> OP_HASH160)> OP_EQUAL

When compiling unlocking scripts which unlock locking scripts of type p2sh, the result will be transformed into the P2SH unlocking format: result <locking_script> (where locking_script is the compiled bytecode of the locking script, without the "redeemScript" transformation.)

By default, all scripts are assumed to have the type standard.

Optional opcodes

opcodes: undefined | {}

An object mapping opcode identifiers to the bytecode they generate.

Optional operations

operations: undefined | { addressData?: CompilerAddressDataOperations extends string ? {} : CompilerOperation<TransactionContext>; currentBlockHeight?: CompilerCurrentBlockHeightOperations extends string ? {} : CompilerOperation<TransactionContext>; currentBlockTime?: CompilerCurrentBlockTimeOperations extends string ? {} : CompilerOperation<TransactionContext>; hdKey?: CompilerKeyOperations extends string ? {} : CompilerOperation<TransactionContext>; key?: CompilerKeyOperations extends string ? {} : CompilerOperation<TransactionContext>; signingSerialization?: CompilerSigningSerializationOperations extends string ? {} : CompilerOperation<TransactionContext>; walletData?: CompilerWalletDataOperations extends string ? {} : CompilerOperation<TransactionContext> }

An object specifying the operations made available by this compilation environment for each variable type. For example, keys typically support public key derivation (.public_key) and several signature types.

Compiler operations can be specified as a single operation for all instances of a variable type (as is the default for AddressData or WalletData), or they can be specified as an object, where each key is a valid operation name (as is the default for Key and HdKey).

Optional ripemd160

ripemd160: undefined | { hash: Ripemd160["hash"] }

An implementation of ripemd160 is required for any scripts which include HdKeys. This can be instantiated with instantiateRipemd160.

Optional scenarios

scenarios: undefined | {}

An object mapping scenario identifiers to the AuthenticationTemplateScenarios they represent.

scripts

scripts: {}

An object mapping script identifiers to the text of script in Bitauth Templating Language.

To avoid compilation errors, this object must contain all scripts referenced by the script being compiled (including children of children).

Type declaration

  • [scriptId: string]: string

Optional secp256k1

secp256k1: undefined | { addTweakPrivateKey: (privateKey: Uint8Array, tweakValue: Uint8Array) => Uint8Array; addTweakPublicKeyCompressed: (publicKey: Uint8Array, tweakValue: Uint8Array) => Uint8Array; derivePublicKeyCompressed: Secp256k1["derivePublicKeyCompressed"]; signMessageHashDER: Secp256k1["signMessageHashDER"]; signMessageHashSchnorr: Secp256k1["signMessageHashSchnorr"] }

An implementation of secp256k1 is required for any scripts which include signatures. This can be instantiated with instantiateSecp256k1.

Optional sha256

sha256: undefined | { hash: Sha256["hash"] }

An implementation of sha256 is required for any scripts which include signatures. This can be instantiated with instantiateSha256.

Optional sha512

sha512: undefined | { hash: Sha512["hash"] }

An implementation of sha512 is required for any scripts which include HdKeys. This can be instantiated with instantiateSha512.

Optional sourceScriptIds

sourceScriptIds: string[]

Only for use when recursively calling compileScript (e.g. in compiler operations).

The "breadcrumb" path of script IDs currently being compiled, including the current script. (E.g. ["grandparentId", "parentId", "scriptId"])

BTL identifier resolution must be acyclic. To prevent an infinite loop, IdentifierResolutionFunctions must abort resolution if they encounter their own id while resolving another identifier. Likewise, child scripts being resolved by a parent script may not reference any script which is already in the process of being resolved.

Optional unlockingScriptTimeLockTypes

unlockingScriptTimeLockTypes: undefined | {}

An object mapping the identifiers of unlocking scripts to their timeLockType.

The timestamp type indicates that the transaction's locktime is provided as a UNIX timestamp (the locktime value is greater than or equal to 500000000).

The height type indicates that the transaction's locktime is provided as a block height (the locktime value is less than 500000000).

See AuthenticationTemplateScript.timeLockType for details.

Optional unlockingScripts

unlockingScripts: undefined | {}

An object mapping the identifiers of unlocking scripts to the identifiers of the locking scripts they unlock. This is used to identify the coveredBytecode used in signing serializations, and it is required for all signature operations and many signing serialization operations.

Optional variables

variables: undefined | {}

An object mapping template variable identifiers to the AuthenticationTemplateVariable describing them.

To avoid compilation errors, this object must contain all variables referenced by the script being compiled (including in child scripts).

Optional vm

The AuthenticationVirtualMachine on which BTL evaluation results will be computed.

Generated using TypeDoc