Data Structures
Commit Structure
Overview
- Definition: In the Haircomb system, a commit is a cryptographic proof representing a state change in the blockchain. It records essential transitions, ensuring data integrity and providing cryptographic evidence of a transaction or event that has modified the ledger.
- Purpose: Commits are crucial for maintaining the verifiable history of transactions, providing integrity and security for the blockchain by ensuring all changes are recorded and linked in an immutable sequence.
Components
- Commit Header: The commit header contains metadata about the commit, including:
- Block height: Specifies the block in which the commit resides, linking it to the blockchain history.
- Commit number: A unique number assigned to each commit within the block, incremented for every non-unique P2WSH (Pay-to-Witness-Script-Hash).
- Transaction number: Refers to the transaction within the block where the commit occurs.
- Output number: Identifies which output in the transaction contains the commit.
- Commit Body: Contains the actual data being committed, such as:
- Commit Data: A 256-bit hash representing the cryptographic proof of the transaction or event.
Format
- Schema: The commit structure is composed of a header (block height, commit number, transaction number, output number) and a body (commit data hash). Each of these elements is required to create a valid commit.
- Examples:
- A commit might consist of the following fields:
- Block height: 543210
- Commit number: 3
- Transaction number: 5
- Output number: 0
- Commit data: A 256-bit hash like
9a3c06d2e68a1bdfcb54bc2a7f0c6d...
Handling and Storage
- Processing: Commits are processed by harvesting transaction outputs from the Bitcoin chain and ensuring that each new commit is completely unique in the chain. Once validated, the commit is added to the database.
- Storage: Commits are stored in a LevelDB or Pebble database. These databases map commits to their respective positions in the blockchain, ensuring quick lookups and integrity verification.
Key and Transaction Data
Keys
- Key Types: Two primary types of keys are used in Haircomb:
- Public Keys: Used for identifying users and verifying transaction signatures.
- Private Keys: Used for signing transactions, ensuring ownership and security.
- Structure: Public keys are derived using haircomb cryptography and are typically represented as 256-bit numbers.
- Management: Keys are generated using cryptographic algorithms and managed by the users themselves. Public keys are shared, while private keys must remain secret.
Transactions
- Transaction Structure: A Haircomb transaction includes several fields:
- Sender: The public key of the sender.
- Receiver: The public key of the receiver.
- Amount: The amount of Haircomb being transferred.
- Signature: A digital signature generated by the sender using their private key, authorizing the transaction.
- Transaction Types: Different types of transactions exist, such as regular transfers, contract executions, and liquidity operations in the liquidity graph.
- Validation: Transactions are validated by verifying the sender’s digital signature and ensuring the funds or resources being transferred are available. This prevents double-spending and unauthorized transactions.
Examples
- Key Example: A public key might look like:
8EA876642920736D1DE897831BDB509EE899B4D078F74CAD9E97FFC77A62A8D7
- Transaction Example:
- Sender:
8EA876642920736D1DE897831BDB509EE899B4D078F74CAD9E97FFC77A62A8D7
- Receiver:
90020F39C376AF15B3DE48939719BA92A0F2D0880923EC039A67F5D38B580AD8
- Amount: 10 COMB
- Signature: A cryptographic signature generated by the sender.
Further Reading
- Technical Papers: You can refer to technical papers that delve into cryptographic commit structures and their role in blockchain-based systems.
- Documentation: For more detailed information, consult the Haircomb technical documentation and API references related to data structures.
References
- Citations: Any sources used to explain the commit structures, transaction validation, and key management.
- External Links: Useful links to blockchain or cryptographic resources that further explain the concepts used in Haircomb.