Skip to main content

Differences from Bitcoin Layer 1

This document outlines the key differences between OP_CAT and Bitcoin's layer 1 implementation.

Overview

OP_CAT introduces several modifications to the standard Bitcoin protocol to enhance functionality and support advanced smart contract capabilities.

Key Differences

ComponentOP_CATBitcoin
Transaction StructureExtended with data field for each transaction output and witness is removedLegacy/witness transaction format
Transaction HashHash of TxHashPreimageHash of raw transaction
SigHashPreimageEnhanced sighash preimage for smart contract supportTraditional sighash format
BVM (Bitcoin Virtual Machine)Restore all opcodes and support bigintDisable lots of opcodes

Detailed Explanations

Transaction Structure Modifications

OP_CAT implements significant changes to the transaction structure:

  1. Witness Removal: The witness structure is completely removed, simplifying the transaction format and reducing complexity compared to Bitcoin's witness-based approach.

  2. Output Extension: Each transaction output is extended with a data field, enabling:

    • Additional data storage capabilities
    • Enhanced smart contract functionality
    • More flexible transaction output handling

Transaction Structure Field Comparison

The following table shows which fields are present in OP_CAT vs Bitcoin transaction structures:

FieldOP_CATBitcoinDescription
VersionTransaction version number
SegWit MarkerSegregated Witness marker
SegWit FlagSegregated Witness flag
Input CountNumber of transaction inputs
Input[0].prevoutPrevious output reference
Input[0].scriptSigInput locking script (script signature)
Input[1]...Additional inputs (if any)
Output CountNumber of transaction outputs
Output[0].amountOutput value in satoshis
Output[0].scriptPubKeyOutput script (script public key)
Output[0].dataAdditional data field (OP_CAT only)
Output[1]...Additional outputs (if any)
WitnessWitness data for SegWit
LockTimeTransaction lock time

Legend: ✓ = Present, ✗ = Not present

These modifications streamline transaction processing while providing enhanced functionality for smart contract operations.

Transaction Hashing

  • OP_CAT: Uses TxHashPreimage for transaction hashing, which provides more flexibility in hash computation and enables advanced smart contract features
  • Bitcoin: Uses the raw transaction data directly for hash calculation, following the traditional Bitcoin protocol

TxHashPreimage Structure

The TxHashPreimage contains the following fields for transaction hashing. All hash values are computed using SHA256:

FieldDescription
versionTransaction version number
input countNumber of transaction inputs
input[0].prevoutPrevious output reference (hash + index)
input[0].unlockScriptHashSHA256 hash of the unlocking script
input[0].sequenceInput sequence number
input[1]...Additional inputs (if any)
output countNumber of transaction outputs
output[0].satoshisOutput value in satoshis
output[0].scriptHashSHA256 hash of the output script
output[0].dataHashSHA256 hash of the output data field
output[1]...Additional outputs (if any)
locktimeTransaction lock time

SigHashPreimage Enhancement

OP_CAT implements an improved sighash preimage structure specifically designed to support smart contract functionality. This enhancement provides better control over signature verification and enables more sophisticated contract interactions.

SigHashPreimage Structure (when sighash type is SIGHASH_ALL)

FieldDescription
nVersionTransaction version
hashPrevoutsDouble SHA256 of the serialization of all input outpoints
spentScriptHashSHA256 of scriptPubKey of the previous output spent by this input
spentDataHashSHA256 of the data field of the previous output spent by this input
valueValue of the previous output spent by this input
nSequenceSequence number of this input
hashSpentAmountsDouble SHA256 of the serialization of all spent output amounts
hashSpentScriptHashesDouble SHA256 of all spent outputs' script hashes
hashSpentDataHashesDouble SHA256 of all spent outputs' data hashes
hashSequencesDouble SHA256 of the serialization of all input sequences
hashOutputsDouble SHA256 of the serialization of all outputs
inputIndexIndex of the current input being signed
nLocktimeTransaction lock time
sighashTypeSignature hash type

Bitcoin Virtual Machine (BVM) Enhancements

OP_CAT significantly enhances the Bitcoin Virtual Machine by restoring all opcodes that were previously disabled in Bitcoin:

  • OP_CAT: Restores all opcodes to enable full smart contract functionality
  • Bitcoin: Disables many opcodes for security and stability reasons

This restoration enables:

  • Advanced smart contract development
  • Complex cryptographic operations
  • Enhanced data manipulation capabilities
  • More flexible scripting possibilities

Technical Implications

These architectural differences provide OP_CAT with several advantages:

  1. Simplified Transaction Structure: The removal of witness data reduces transaction complexity and processing overhead
  2. Enhanced Flexibility: TxHashPreimage allows for more sophisticated hash computation methods
  3. Extended Functionality: The additional data field enables advanced smart contract features and data storage
  4. Improved Smart Contract Support: Enhanced sighash preimage provides better contract interaction capabilities
  5. Reduced Transaction Size: Elimination of SegWit components results in smaller transaction sizes
  6. Optimized Hashing: TxHashPreimage structure enables more efficient transaction hash computation using SHA256
  7. Consistent Hash Algorithm: All hash computations use SHA256, ensuring consistency and security
  8. Advanced Signature Verification: Enhanced SigHashPreimage structure provides more sophisticated signature verification capabilities
  9. Full Opcode Support: BVM restoration enables complete smart contract functionality

Compatibility Considerations

While OP_CAT maintains compatibility with Bitcoin's core principles, these modifications may affect:

  • Transaction validation processes
  • Block structure and size calculations
  • Smart contract deployment and execution
  • Signature verification mechanisms
  • Legacy transaction format compatibility
  • SegWit transaction handling
  • Hash computation methods and validation
  • Opcode availability and script execution