Keys
Overview
A Key consists of a Public and Private key. The Haircomb Public key is also the address, where the money deposited into the address are stored.
The Private key is only used initially to compute the Public Key, and later used once to sign a Transaction, after which it can be discarded if necessary (it never needs to be revealed).
Creation and Structure
The Private key consists of 21 true random 256bit numbers. On mainnet, based on each of these 21 numbers, a hashchain (a leg) of 59213 hashes is calculated yielding 21 chain tips. The public key is then the hash of these 21 hashchain tips.
Key Generation
- Process: 21 hash-chains are extended from the 21 private key values. The 21 hash chain tips are then hashed to produce the public key.
- Algorithms: The SHA256 hashing algorithm is in use for public key generation.
- Security: The private key needs to be generated by invoking the system's true random number generator. Hash chains have the property that anyone can continue hashing a chain given a value in the chain, however only the private key holder can compute values earlier in the chain.
Key Formats
- Types of Keys: Public, Private
- Structure: The structure of public key - 256bit value. The structure of private key - 21 x 256bit values.
- Storage: Keys are stored using the wallet import format, in a wallet text file with an extension .dat.
Wallet import format - Mainnet
/wallet/data/{21 x uppercase hex private key values}\r\n
Wallet import format - Testnet
\wallet\data\{21 x uppercase hex private key values}\r\n
Signing and Verification
Signing Process
- Purpose: Explain why signing is necessary and what it accomplishes.
- Process: Describe the steps involved in signing data using keys.
- Tools and Libraries: Mention any tools or libraries used for signing.
Verification Process
- Purpose: Explain the importance of verification and what it ensures.
- Process: Describe the steps involved in verifying a signature.
- Validation: How the system validates signatures and what happens if validation fails.
Use Cases
Provide examples or scenarios demonstrating how keys are used in practice within the Haircomb system.
Example 1
- Description: Detail a specific use case for keys, such as securing transactions or user authentication.
- Process: Explain how keys are utilized in this example.
Example 2
- Description: Another example illustrating the application of keys.
- Process: Describe the key-related processes in this scenario.
Summary
Summarize the key aspects of creation, structure, signing, and verification. Emphasize the importance of keys in maintaining the security and functionality of the Haircomb system.