From 41a5cfff19938557763fb30388fd06c11c3ce525 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 16 Dec 2025 09:01:06 +0200 Subject: [PATCH 1/8] KIP 17 initial draft --- kip-0017.md | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 kip-0017.md diff --git a/kip-0017.md b/kip-0017.md new file mode 100644 index 0000000..e5fe4e1 --- /dev/null +++ b/kip-0017.md @@ -0,0 +1,113 @@ +``` +  KIP: 17 +  Layer: Consensus, Script Engine +  Title: Covenants +  Authors: Ori Newman +  Status: Draft +``` + +## Abstract + +This proposal is a continuation of KIP 10, introducing full covenant support to Kaspa by extending the scripting language with introspection opcodes to all transaction fields, along with byte-string manipulation primitives. These additions enable scripts to inspect and constrain properties of the spending transaction, allowing validation of stateful transitions encoded directly in UTXOs. + +## Specification + +### 1. New Opcodes + +The following new opcodes are introduced to enhance script functionality: + +#### Transaction Level Introspection Opcodes: + +1. `OpTxVersion` (0xb2): Returns the version of the transaction. +2. `OpTxLockTime` (0xb5): Returns the locktime field of the transaction. +3. `OpTxSubnetId` (0xb6): Returns the subnetwork ID of the transaction. +4. `OpTxGas` (0xb7): Returns the gas field of the transaction. +5. `OpTxPayloadLen` (0xb8): Returns the payload length of the transaction. +6. `OpTxPayloadSubstr` (0xba): Returns the payload substring of the transaction (from `start` (inclusive) until `end` (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +7. `OpOutpointTxId(idx)` (0xbb): Returns the transaction ID of the outpoint. +8. `OpOutpointIndex` (0xbc): Returns the index of the outpoint. +9. `OpTxInputSeq` (0xbe): Returns the sequence number of the input. +10. `OpTxInputIsCoinbase` (0xc1): Returns whether the input is a coinbase. + +#### Input/Output Introspection Opcodes: + +1. `OpTxInputSpkLen(idx)`: Returns the script public key length of the specified input. +2. `OpTxInputSpkSubstr(idx, start, end)` (0xc0): Returns the script public key substring of the specified input (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +3. `OpTxOutputSpkLen(idx)`: Returns the script public key length of the specified output. +4. `OpTxOutputSpkSubstr(idx, start, end)`: Returns the script public key substring of the specified output (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +5. `OpTxInputScriptSigLen` (0xbd): Returns the script signature length of the input. +6. `OpTxInputScriptSigSubstr(start,end)`: Returns the script signature substring of the input (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. + +#### Other Opcodes: + +1. `OpCat(str1, str2)`: Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520`. +2. `OpSubstr(str, start, end)`: Returns the substring of a byte string (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +3. `OpBlake2bWithDomain(data, domain)`: Returns the Blake2b hash of the data with the specified domain separation tag. + +### 2. Activation + +The features introduced in this KIP are activated based on DAA score: + +1. Prior to activation: + - New opcodes are treated as invalid +2. After activation: + - All new opcodes become available + +## Rationale + +The combination of introspection opcodes and OP_CAT/OP_SUBSTR can be used to implictly attach state to UTXOs and enforce correct state transitions. + +For example, we can implement a simple covenant that requires us to increase a counter stored in the transaction payload every time the UTXO is spent, and forces us to send the new transaction to the same scriptPubKey: + +Given siganture script of the form: ` `, the scriptPubKey will be: + +``` +OpDup OpRot OpRot OpCat +"TransactionID" OpBlake2bWithDomain +OpTxInputIndex OpOutpointTxId OpEqualVerify +Op1Add +0 OpTxPayloadLen OpTxPayloadSubstr +OpEqualVerify +OpTxInputIndex OpTxInputSpk 0 OpOutputSpk +OpEqualVerify +OpTxOutputCount 1 OpEqual +``` + +This script can be written in pseudocode as: + +``` +validate(prev_tx,tx){ + return hash(prev_tx) == tx.inputs[curr_idx].prev_tx_id + AND tx.outputs[0].script_pub_key == prev_tx.inputs[curr_idx].script_pub_key + AND len(tx.outputs) == 1 + AND tx.payload == prev_tx.payload + 1; +} +``` + +In general, once we can encode some state transition function δ in script, we can validate that `δ(prev_payload,tx) = new_payload`, where δ can also introduce some constraints on `tx` using introspection op codes (checking its signautre, enforcing a locktime, etc). + +## Use Cases + +Covenants enable a variety of use cases, including but not limited to: + +1. Fungible and non-fungible tokens. +2. Vaults with time-locked withdrawals. +3. With the help of ZK opcodes, implement L1-L2 trustless bridges. + +See references [2] for more use cases. + +## Backwards Compatibility + +This proposal requires a hard fork, as it introduces new opcodes to the scripting language. Older software will require an update to support these new features. Existing scripts and addresses remain valid, but cannot use the new functionality without being updated. + +## Reference Implementation + +TBD + +## References + +1. `OP_CAT` BIP: [https://github.com/bip420/bip420](https://github.com/bip420/bip420) + +2. More covenants use cases: [https://utxos.org/uses/](https://utxos.org/uses/), [https://covenants.info/use-cases/](https://covenants.info/use-cases/) + +3. KIP 10: [kip-0010.md](kip-0010.md) From 17bf67667916b91620f395e48ae3808f17aa6de2 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 16 Dec 2025 10:53:28 +0200 Subject: [PATCH 2/8] ref changes --- kip-0017.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/kip-0017.md b/kip-0017.md index e5fe4e1..5c9d4f4 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -8,7 +8,7 @@ ## Abstract -This proposal is a continuation of KIP 10, introducing full covenant support to Kaspa by extending the scripting language with introspection opcodes to all transaction fields, along with byte-string manipulation primitives. These additions enable scripts to inspect and constrain properties of the spending transaction, allowing validation of stateful transitions encoded directly in UTXOs. +This proposal is a continuation of KIP 10 [1], introducing full covenant support to Kaspa by extending the scripting language with introspection opcodes to all transaction fields, along with byte-string manipulation primitives. These additions enable scripts to inspect and constrain properties of the spending transaction, allowing validation of stateful transitions encoded directly in UTXOs. ## Specification @@ -40,7 +40,7 @@ The following new opcodes are introduced to enhance script functionality: #### Other Opcodes: -1. `OpCat(str1, str2)`: Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520`. +1. `OpCat(str1, str2)`: Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520` [2]. 2. `OpSubstr(str, start, end)`: Returns the substring of a byte string (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. 3. `OpBlake2bWithDomain(data, domain)`: Returns the Blake2b hash of the data with the specified domain separation tag. @@ -53,7 +53,7 @@ The features introduced in this KIP are activated based on DAA score: 2. After activation: - All new opcodes become available -## Rationale +## Motivation The combination of introspection opcodes and OP_CAT/OP_SUBSTR can be used to implictly attach state to UTXOs and enforce correct state transitions. @@ -90,11 +90,11 @@ In general, once we can encode some state transition function δ in script, we c Covenants enable a variety of use cases, including but not limited to: -1. Fungible and non-fungible tokens. +1. Fungible and non-fungible tokens [3]. 2. Vaults with time-locked withdrawals. 3. With the help of ZK opcodes, implement L1-L2 trustless bridges. -See references [2] for more use cases. +See [4] for more use cases. ## Backwards Compatibility @@ -106,8 +106,10 @@ TBD ## References -1. `OP_CAT` BIP: [https://github.com/bip420/bip420](https://github.com/bip420/bip420) +1. KIP 10: [kip-0010.md](kip-0010.md) -2. More covenants use cases: [https://utxos.org/uses/](https://utxos.org/uses/), [https://covenants.info/use-cases/](https://covenants.info/use-cases/) +2. `OP_CAT` BIP: [https://github.com/bip420/bip420](https://github.com/bip420/bip420) -3. KIP 10: [kip-0010.md](kip-0010.md) +3. Cat Protocol for covenants based tokens: [https://catprotocol.org/](https://catprotocol.org/) + +4. More covenants use cases: [https://utxos.org/uses/](https://utxos.org/uses/), [https://covenants.info/use-cases/](https://covenants.info/use-cases/) From 673aa54a6107e9132c8dcff0e53be008ede2af2e Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 16 Dec 2025 11:13:14 +0200 Subject: [PATCH 3/8] Note on Transaction Encoding --- kip-0017.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kip-0017.md b/kip-0017.md index 5c9d4f4..b4b3357 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -84,7 +84,16 @@ validate(prev_tx,tx){ } ``` -In general, once we can encode some state transition function δ in script, we can validate that `δ(prev_payload,tx) = new_payload`, where δ can also introduce some constraints on `tx` using introspection op codes (checking its signautre, enforcing a locktime, etc). +In general, once we can encode some state transition function δ in script, we can validate that `δ(prev_payload,tx) = new_payload`, where δ can also introduce some constraints on `tx` using introspection opcodes (checking its signautre, enforcing a locktime, etc). + +### Note on Transaction Encoding + +Many covenant constructions require the spender to provide a full copy of the previous transaction as witness data in order to validate that +`tx.inputs[idx].prev_tx_id = hash(prev_tx)`. + +As a result, the transaction ID hashing algorithm implicitly defines a canonical transaction encoding that scripts can rely on. Covenant scripts may reconstruct or inspect this encoding to verify that a provided previous transaction matches the referenced outpoint. + +A reference implementation of the transaction ID hashing and encoding logic is provided in [5]. ## Use Cases @@ -113,3 +122,5 @@ TBD 3. Cat Protocol for covenants based tokens: [https://catprotocol.org/](https://catprotocol.org/) 4. More covenants use cases: [https://utxos.org/uses/](https://utxos.org/uses/), [https://covenants.info/use-cases/](https://covenants.info/use-cases/) + +5. Reference implemenation of transaction ID hashing: [https://github.com/kaspanet/rusty-kaspa/blob/2ccc9e4ca9aa184c62c4fb14dbb463834264e01d/consensus/core/src/hashing/tx.rs#L40](https://github.com/kaspanet/rusty-kaspa/blob/2ccc9e4ca9aa184c62c4fb14dbb463834264e01d/consensus/core/src/hashing/tx.rs#L40) From 9f5b1d73e806af384111eecaf1595553440dc6f6 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 16 Dec 2025 12:36:11 +0200 Subject: [PATCH 4/8] Note on Substring Opcodes, rename to OpBlake2bWithKey --- kip-0017.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kip-0017.md b/kip-0017.md index b4b3357..dffd337 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -23,7 +23,7 @@ The following new opcodes are introduced to enhance script functionality: 3. `OpTxSubnetId` (0xb6): Returns the subnetwork ID of the transaction. 4. `OpTxGas` (0xb7): Returns the gas field of the transaction. 5. `OpTxPayloadLen` (0xb8): Returns the payload length of the transaction. -6. `OpTxPayloadSubstr` (0xba): Returns the payload substring of the transaction (from `start` (inclusive) until `end` (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +6. `OpTxPayloadSubstr` (0xba): Returns the payload substring of the transaction from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. 7. `OpOutpointTxId(idx)` (0xbb): Returns the transaction ID of the outpoint. 8. `OpOutpointIndex` (0xbc): Returns the index of the outpoint. 9. `OpTxInputSeq` (0xbe): Returns the sequence number of the input. @@ -32,17 +32,21 @@ The following new opcodes are introduced to enhance script functionality: #### Input/Output Introspection Opcodes: 1. `OpTxInputSpkLen(idx)`: Returns the script public key length of the specified input. -2. `OpTxInputSpkSubstr(idx, start, end)` (0xc0): Returns the script public key substring of the specified input (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +2. `OpTxInputSpkSubstr(idx, start, end)` (0xc0): Returns the script public key substring of the specified input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. 3. `OpTxOutputSpkLen(idx)`: Returns the script public key length of the specified output. -4. `OpTxOutputSpkSubstr(idx, start, end)`: Returns the script public key substring of the specified output (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +4. `OpTxOutputSpkSubstr(idx, start, end)`: Returns the script public key substring of the specified output from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. 5. `OpTxInputScriptSigLen` (0xbd): Returns the script signature length of the input. -6. `OpTxInputScriptSigSubstr(start,end)`: Returns the script signature substring of the input (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +6. `OpTxInputScriptSigSubstr(start,end)`: Returns the script signature substring of the input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. + +##### Note on Substring Opcodes + +On all substring related opcodes, we consider the first byte to be at position 0, the start position is inclusive, and the end position is exclusive. #### Other Opcodes: 1. `OpCat(str1, str2)`: Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520` [2]. 2. `OpSubstr(str, start, end)`: Returns the substring of a byte string (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. -3. `OpBlake2bWithDomain(data, domain)`: Returns the Blake2b hash of the data with the specified domain separation tag. +3. `OpBlake2bWithKey(data, key)`: Returns the Blake2b hash of the data with the key used for domain separation. ### 2. Activation From 8d7a940958684d14a0683a5b732b78f2b353241b Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Tue, 16 Dec 2025 14:19:33 +0200 Subject: [PATCH 5/8] Add congestion control use case --- kip-0017.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kip-0017.md b/kip-0017.md index dffd337..3ee60d5 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -97,17 +97,18 @@ Many covenant constructions require the spender to provide a full copy of the pr As a result, the transaction ID hashing algorithm implicitly defines a canonical transaction encoding that scripts can rely on. Covenant scripts may reconstruct or inspect this encoding to verify that a provided previous transaction matches the referenced outpoint. -A reference implementation of the transaction ID hashing and encoding logic is provided in [5]. +A reference implementation of the transaction ID hashing and encoding logic is provided in [3]. ## Use Cases Covenants enable a variety of use cases, including but not limited to: -1. Fungible and non-fungible tokens [3]. -2. Vaults with time-locked withdrawals. -3. With the help of ZK opcodes, implement L1-L2 trustless bridges. +1. Fungible and non-fungible tokens [4]. +2. Smart Vaults for enhanced security [5]. +3. Congestion control mechanisms [6]. +4. With the help of ZK opcodes, implement L1-L2 trustless bridges. -See [4] for more use cases. +See [7] for more use cases. ## Backwards Compatibility @@ -121,10 +122,14 @@ TBD 1. KIP 10: [kip-0010.md](kip-0010.md) -2. `OP_CAT` BIP: [https://github.com/bip420/bip420](https://github.com/bip420/bip420) +2. `OP_CAT` BIP: https://github.com/bip420/bip420 -3. Cat Protocol for covenants based tokens: [https://catprotocol.org/](https://catprotocol.org/) +3. Reference implemenation of transaction ID hashing: https://github.com/kaspanet/rusty-kaspa/blob/2ccc9e4ca9aa184c62c4fb14dbb463834264e01d/consensus/core/src/hashing/tx.rs#L40 -4. More covenants use cases: [https://utxos.org/uses/](https://utxos.org/uses/), [https://covenants.info/use-cases/](https://covenants.info/use-cases/) +4. Cat Protocol for covenants based tokens: https://catprotocol.org/ -5. Reference implemenation of transaction ID hashing: [https://github.com/kaspanet/rusty-kaspa/blob/2ccc9e4ca9aa184c62c4fb14dbb463834264e01d/consensus/core/src/hashing/tx.rs#L40](https://github.com/kaspanet/rusty-kaspa/blob/2ccc9e4ca9aa184c62c4fb14dbb463834264e01d/consensus/core/src/hashing/tx.rs#L40) +5. Vaults: https://utxos.org/uses/vaults/ + +6. Congestion Control: https://utxos.org/uses/scaling/ + +7. More covenants use cases: https://utxos.org/uses/, https://github.com/sCrypt-Inc/awesome-op-cat#op_cat-use-cases, https://covenants.info/use-cases/ From 6a59956029229debe0a3804f19341685caaa6aca Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Fri, 19 Dec 2025 08:14:50 +0200 Subject: [PATCH 6/8] Update abstract --- kip-0017.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kip-0017.md b/kip-0017.md index 3ee60d5..096e537 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -8,7 +8,7 @@ ## Abstract -This proposal is a continuation of KIP 10 [1], introducing full covenant support to Kaspa by extending the scripting language with introspection opcodes to all transaction fields, along with byte-string manipulation primitives. These additions enable scripts to inspect and constrain properties of the spending transaction, allowing validation of stateful transitions encoded directly in UTXOs. +This proposal is a continuation of KIP 10 [1], introducing full covenant support to Kaspa by extending the scripting language with introspection opcodes to all transaction fields, along with byte-string manipulation primitives. These additions enable scripts to inspect and constrain properties of the spending transaction, allowing validation of stateful transitions encoded implicitly or explicitly in UTXOs. ## Specification From bc5f21a7410fd8becee203d759fd1f042a07f075 Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Thu, 25 Dec 2025 19:08:50 +0200 Subject: [PATCH 7/8] More opcodes + numbers --- kip-0017.md | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/kip-0017.md b/kip-0017.md index 096e537..ca140a2 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -1,7 +1,7 @@ ```   KIP: 17   Layer: Consensus, Script Engine -  Title: Covenants +  Title: Covenants and Improved Scripting Capabilities   Authors: Ori Newman   Status: Draft ``` @@ -22,21 +22,21 @@ The following new opcodes are introduced to enhance script functionality: 2. `OpTxLockTime` (0xb5): Returns the locktime field of the transaction. 3. `OpTxSubnetId` (0xb6): Returns the subnetwork ID of the transaction. 4. `OpTxGas` (0xb7): Returns the gas field of the transaction. -5. `OpTxPayloadLen` (0xb8): Returns the payload length of the transaction. -6. `OpTxPayloadSubstr` (0xba): Returns the payload substring of the transaction from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. -7. `OpOutpointTxId(idx)` (0xbb): Returns the transaction ID of the outpoint. -8. `OpOutpointIndex` (0xbc): Returns the index of the outpoint. -9. `OpTxInputSeq` (0xbe): Returns the sequence number of the input. -10. `OpTxInputIsCoinbase` (0xc1): Returns whether the input is a coinbase. +5. `OpTxPayloadLen` (0xc4): Returns the payload length of the transaction. +6. `OpTxPayloadSubstr` (0xb8): Returns the payload substring of the transaction from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. #### Input/Output Introspection Opcodes: -1. `OpTxInputSpkLen(idx)`: Returns the script public key length of the specified input. -2. `OpTxInputSpkSubstr(idx, start, end)` (0xc0): Returns the script public key substring of the specified input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. -3. `OpTxOutputSpkLen(idx)`: Returns the script public key length of the specified output. -4. `OpTxOutputSpkSubstr(idx, start, end)`: Returns the script public key substring of the specified output from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. -5. `OpTxInputScriptSigLen` (0xbd): Returns the script signature length of the input. -6. `OpTxInputScriptSigSubstr(start,end)`: Returns the script signature substring of the input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +1. `OpTxInputSpkLen(idx)`: (0xc5) Returns the script public key length of the specified input. +2. `OpTxInputSpkSubstr(idx, start, end)` (0xc6): Returns the script public key substring of the specified input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +3. `OpTxOutputSpkLen(idx)`: (0xc7) Returns the script public key length of the specified output. +4. `OpTxOutputSpkSubstr(idx, start, end)`: (0xc8) Returns the script public key substring of the specified output from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +5. `OpTxInputScriptSigLen(idx)` (0xc9): Returns the script signature length of the input. +6. `OpTxInputScriptSigSubstr(idx, start, end)`: (0xca) Returns the script signature substring of the input from `start` to `end`. Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +7. `OpOutpointTxId(idx)` (0xba): Returns the transaction ID of the outpoint. +8. `OpOutpointIndex` (0xbb): Returns the index of the outpoint. +9. `OpTxInputSeq(idx)` (0xbd): Returns the sequence number of the input. +10. `OpTxInputIsCoinbase(idx)` (0xc1): Returns whether the input is a coinbase. ##### Note on Substring Opcodes @@ -44,9 +44,16 @@ On all substring related opcodes, we consider the first byte to be at position 0 #### Other Opcodes: -1. `OpCat(str1, str2)`: Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520` [2]. -2. `OpSubstr(str, start, end)`: Returns the substring of a byte string (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. -3. `OpBlake2bWithKey(data, key)`: Returns the Blake2b hash of the data with the key used for domain separation. +1. `OpCat(str1, str2)`: (0x7e) Concatenates two byte strings. Returns error if the resulting string exceeds `MAX_SCRIPT_ELEMENT_SIZE = 520` [2]. +2. `OpSubstr(str, start, end)`: (0x7f) Returns the substring of a byte string (from start (inclusive) until end (exclusive)). Returns error for invalid ranges, or when `end-start > MAX_SCRIPT_ELEMENT_SIZE = 520`. +3. `OpBlake2bWithKey(data, key)`: (0xa7) Returns the Blake2b hash of the data with the key used for domain separation. +4. `OpInvert(str)` (0x83): Returns the bitwise NOT of a byte string. +5. `OpAnd(str1, str2)` (0x84): Returns the bitwise AND of two byte strings. Returns error if the two strings are of different lengths. +6. `OpOr(str1, str2)` (0x85): Returns the bitwise OR of two byte strings. Returns error if the two strings are of different lengths. +7. `OpXor(str1, str2)` (0x86): Returns the bitwise XOR of two byte strings. Returns error if the two strings are of different lengths. +8. `OpMul` (0x95): Returns the product of two numbers. Returns error on overflow. +9. `OpDiv` (0x96): Returns the quotient of two numbers. Returns error on division by zero. +10. `OpMod` (0x97): Returns the remainder of two numbers. Returns error on modulo by zero. ### 2. Activation From 6fc7a1b20bfe22a316dec76ebd20fe7d9e18722c Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Fri, 26 Dec 2025 13:59:41 +0200 Subject: [PATCH 8/8] Add reference impl --- kip-0017.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kip-0017.md b/kip-0017.md index ca140a2..5d3219b 100644 --- a/kip-0017.md +++ b/kip-0017.md @@ -123,7 +123,7 @@ This proposal requires a hard fork, as it introduces new opcodes to the scriptin ## Reference Implementation -TBD +https://github.com/kaspanet/rusty-kaspa/pull/797 ## References