additional data available to compiler operations, e.g. transaction signing serialization components
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
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
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
)
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
)
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
)
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
)
Optional
createA method that accepts the compiled bytecode contents of a CashAssembly evaluation and produces the equivalent AuthenticationProgram to be evaluated by the VM. This method is used internally to compute CashAssembly evaluations. See createAuthenticationProgramEvaluationCommon for details.
Optional
entityAn 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
lockingAn object mapping the script identifiers of locking scripts to their
locking script type, either standard
or p2sh20
.
This is used to transform compilation results into the proper structure for P2SH20 locking and unlocking scripts.
When compiling locking scripts of type p2sh20
, the result will be placed
in a P2SH20 "redeemScript" format:
OP_HASH160 <$(<result> OP_HASH160)> OP_EQUAL
When compiling unlocking scripts that unlock locking scripts of type
p2sh20
, the result will be transformed into the P2SH20 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
opcodesAn object mapping opcode identifiers to the bytecode they generate.
Optional
operationsAn object specifying the operations made available by this compiler
configuration 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
addressOptional
currentOptional
currentOptional
hdOptional
key?: CompilerKeyOperations extends string ? { [ operationId in string]?: CompilerOperation<CompilationContext, false, CompilationData<CompilationContext>, CompilerConfiguration<CompilationContext, CompilerOperationsKeysCommon, CompilerOperationsSigningSerializationCommon, false, false, false, false>> } : CompilerOperation<CompilationContext, false, CompilationData<CompilationContext>, CompilerConfiguration<CompilationContext, CompilerOperationsKeysCommon, CompilerOperationsSigningSerializationCommon, false, false, false, false>>Optional
signingOptional
walletOptional
ripemd160An implementation of ripemd160 is required for any scripts that include
HdKey
s. This can be instantiated with instantiateRipemd160.
Returns the ripemd160 hash of the provided input.
To incrementally construct a ripemd160 hash (e.g. for streaming), use
init
, update
, and final
.
a Uint8Array to be hashed using ripemd160
Optional
scenariosAn object mapping scenario identifiers to the AuthenticationTemplateScenarios they represent.
An object mapping script identifiers to the text of script in CashAssembly.
To avoid compilation errors, this object must contain all scripts referenced by the script being compiled (including children of children).
Optional
secp256k1An implementation of secp256k1 is required for any scripts that include signatures. This can be instantiated with instantiateSecp256k1.
Tweak a privateKey by adding tweakValue
to it.
Returns an error message if the private key is invalid or if the addition fails.
a valid secp256k1 private key
256 bit value to tweak by (BE)
Tweak a publicKey
by adding tweakValue
times the generator to it.
Returns an error message if the provided public key could not be parsed or is not valid, or if the addition failed.
The returned public key will be in compressed format.
a public key.
256 bit value to tweak by (BE)
Derive a compressed public key from a valid secp256k1 private key.
Returns an error message if the provided private key is too large (see
validatePrivateKey
).
a valid secp256k1, 32-byte private key
Create an ECDSA signature in DER format. The created signature is always in lower-S form and follows RFC 6979.
Returns an error message if the provided private key is too large (see
validatePrivateKey
).
a valid secp256k1, 32-byte private key
the 32-byte message hash to be signed
Create a Secp256k1 EC-Schnorr-SHA256 signature (Bitcoin Cash construction).
Signatures are 64-bytes, non-malleable, and support both batch validation
and multiparty signing. Nonces are generated using RFC6979, where the
Section 3.6, 16-byte ASCII "additional data" is set to Schnorr+SHA256
.
This avoids leaking a private key by inadvertently creating both an ECDSA
signature and a Schnorr signature using the same nonce.
Returns an error message if the provided private key is too large (see
validatePrivateKey
).
a valid secp256k1, 32-byte private key
the 32-byte message hash to be signed
Optional
sha256An implementation of sha256 is required for any scripts that include signatures. This can be instantiated with instantiateSha256.
Returns the sha256 hash of the provided input.
To incrementally construct a sha256 hash (e.g. for streaming), use init
,
update
, and final
.
a Uint8Array to be hashed using sha256
Optional
sha512An implementation of sha512 is required for any scripts that include
HdKey
s. This can be instantiated with instantiateSha512.
Returns the sha512 hash of the provided input.
To incrementally construct a sha512 hash (e.g. for streaming), use init
,
update
, and final
.
a Uint8Array to be hashed using sha512
Optional
sourceOnly 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"]
)
CashAssembly 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 that is already in the process of being resolved.
Optional
unlockingAn 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
unlockingAn 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
variablesAn 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
vmThe AuthenticationVirtualMachine on which CashAssembly evaluation
results will be computed.
Generated using TypeDoc
The full context required to compile a given CashAssembly Template script – everything required for the compiler to understand the CompilationData and generate the compiled bytecode (targeting a specific AuthenticationVirtualMachine).
Remarks
A CompilerConfiguration 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
andsecp256k1
is required. If the script requires evaluations during compilation, the evaluating AuthenticationVirtualMachine must also be included.