hashing-and-security

Hashing and Security

Chain Hashing

Overview

  • Definition: Chain hashing refers to the SHA-256 hashing that secures the Bitcoin blockchain — the same chain Haircomb shares for consensus. Haircomb does not maintain its own independent blockchain; instead, it anchors commitments inside Bitcoin transaction outputs (P2WSH), inheriting Bitcoin’s proof-of-work security.
  • Purpose: By anchoring commitments in Bitcoin blocks, Haircomb transactions benefit from the same cryptographic integrity as Bitcoin. Any modification to a Bitcoin block would change its hash, breaking the chain and alerting the entire network.

Shared Chain Architecture

Haircomb transactions are not recorded as separate blocks. Instead, 21 commitment preimages are hashed into commitments and placed in P2WSH outputs within existing Bitcoin transactions. These outputs are ordered by block height, transaction number, and output number, forming a totally ordered sequence on top of Bitcoin’s chain.

  • Algorithm: Bitcoin’s SHA-256 proof-of-work is the underlying hashing mechanism. Haircomb uses the same algorithm for its commitment scheme.
  • Security Inheritance: Haircomb does not need its own miners or PoW — it relies on Bitcoin’s existing mining infrastructure to secure its commitments. Reorganizing a Haircomb commitment would require redoing Bitcoin’s cumulative proof-of-work.

Signature Security

Overview

  • Definition: Signature security refers to the use of digital signatures in the Haircomb network to ensure that transactions are authentic and have not been tampered with. Each transaction must be signed by the sender's private key, ensuring that only authorized users can initiate transactions.
  • Purpose: The main purpose of signature security is to protect the integrity and authenticity of transactions, ensuring that only the rightful owner of a private key can authorize the transfer of COMB. Signatures also ensure that data cannot be altered without detection.

Signature Algorithm

  • Algorithm Used: Haircomb uses the Hash based Haircomb Signature algorithm (Haircomb OTS), which is a widely used, efficient, and secure one-time signature algorithm based on the SHA256 hash used by bitcoin.
  • Key Components:
  • Private Key: A secret key used to generate the digital signature. It is kept secure by the user.
  • Public Key: The public counterpart of the private key, used by others to verify the digital signature.
  • Signature: A cryptographic proof generated from the private key and the transaction data.
  • Process:
    • 1) The user creates a hash of the transaction data (typically using SHA-256).
    • 2) The private key is used to generate a signature from this hash.
    • 3) The signature, along with the user’s public key, and the destination of funds, is included in the transaction.
    • 4) The signature is commited on chain.
    • 5) The recipient verifies the transaction by confirming the 21 commitment preimages match the on-chain commitments, and that the signature is valid against the sender's public key and the Txid.
    • 6) The recipient verifies the transaction by checking that no double-spend had occured - checks that no conflicting prior commits exist on chain.

Examples

  • Signature Example:
  • Verification Process:
    • 1) Take the transaction data and hash it (e.g., using SHA-256).
    • 2) Use the sender's public key to verify that the signature matches the hash of the transaction data.
    • 3) If the verification succeeds, the transaction is valid; otherwise, it is rejected.

Security Considerations

  • Resistance to Attacks:
  • Forgery: Haircomb is resistant to forgery, as it is near-infeasible to generate a valid signature without access to the private key.
  • Key Compromise: If a private key is compromised, an attacker could forge signatures. Thus, secure key management is crucial.
  • Best Practices:
    • Use strong, unique private keys and secure them in hardware wallets or secure storage.
    • Implement multi-signature schemes where applicable to require multiple authorizations for sensitive transactions.
    • Regularly rotate keys and monitor for any potential key compromise incidents.

Further Reading

References

  • Citations: References to the SHA-256 standard, as well as academic papers on cryptographic security.