Skip to content

Commit 997f31b

Browse files
Cosmodudeyijun-lee
andauthored
Blockchain: Bitcoin, Ethereum + SHA (#82)
* SHA added * bitcoin added * added SHA to list * Ethreum added + Blockchain list * added ECC file * Bitcoin: shortend ECC part * added image to ECC + shortened Bitcoin * added hash functions * Bitcoin: shorten Hash functions and Digital Signatures * Bitcoin: ZKP + Quantum examples * fixed links + Ethereum updates * added links to Bitcoin and ETH --------- Co-authored-by: Yijun Lee <[email protected]>
1 parent 785692c commit 997f31b

File tree

7 files changed

+444
-2
lines changed

7 files changed

+444
-2
lines changed

content/Basic Cryptography/Basic Cryptography.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
- [[Merkle Tree]]
2222
- [[Digital Signature]]
2323
- [[Schnorr Signature]]
24+
- [[SHA]]
25+
- [[ECC]]
26+
- [[Hash Functions]]
2427
- [[General LWE]]
2528
- [[Rabin Cryptosystem]]
2629
- [[Nonce]]
2730
- [[ChaCha20]]
28-
- [[General LWE]]
2931
- [[Feistel cipher]]

content/Basic Cryptography/ECC.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Elliptic Curve Cryptography (ECC)
2+
3+
Elliptic Curve Cryptography (ECC) is a modern public-key cryptography system that leverages the algebraic structure of [[Elliptic Curves]] over finite fields. Its security is based on the difficulty of solving the **Elliptic Curve Discrete Logarithm Problem ([[ECDLP]])**, making it a powerful alternative to traditional systems like RSA—with the significant benefit of much smaller key sizes for equivalent security.
4+
5+
---
6+
7+
## 1. Overview
8+
9+
**Key security properties of ECC:**
10+
11+
1. **Difficulty of the Elliptic Curve Discrete Logarithm Problem ([[ECDLP]])**
12+
- Given an elliptic curve, a base point \( G \), and a point \( Q = kG \), it is computationally infeasible to determine the scalar \( k \) (the private key).
13+
14+
2. **Versatility in Cryptographic Operations**
15+
- **Key Agreement:** Used in protocols like Elliptic Curve [[Diffie-Hellman]] (ECDH) for secure key exchange.
16+
- **Digital Signatures:** Underpins schemes such as the Elliptic Curve Digital Signature Algorithm ([[ECDSA]]) to ensure authenticity and integrity.
17+
18+
3. **Compact Key Sizes**
19+
- ECC achieves high security with smaller keys compared to [[RSA]], resulting in faster computations and lower resource requirements.
20+
21+
---
22+
23+
## 2. Key Generation and Operations (Conceptual)
24+
25+
### 2.1 Curve Selection
26+
- **Elliptic Curve Equation:**
27+
Typically expressed in the form
28+
\[
29+
y^2 = x^3 + ax + b
30+
\]
31+
over a finite field defined by a large prime \( p \) (or over binary fields).
32+
33+
- **Base Point (\( G \)):**
34+
A predefined point on the curve used as the starting point for all key operations.
35+
36+
### 2.2 Key Generation
37+
- **Private Key:**
38+
A randomly chosen integer \( k \) within a specified range.
39+
- **Public Key:**
40+
Computed as \( Q = kG \), where multiplication refers to repeated elliptic curve point addition.
41+
42+
### 2.3 Encryption/Key Exchange (ECDH)
43+
- **Key Exchange Process:**
44+
- **Alice:** Chooses a private key \( k_A \) and computes her public key \( Q_A = k_A G \).
45+
- **Bob:** Chooses a private key \( k_B \) and computes his public key \( Q_B = k_B G \).
46+
- **Shared Secret:**
47+
- Alice computes \( S_A = k_A Q_B \).
48+
- Bob computes \( S_B = k_B Q_A \).
49+
- Due to elliptic curve properties, \( S_A = S_B \), establishing a common secret key.
50+
51+
### 2.4 Digital Signatures ([[ECDSA]])
52+
- **Signature Generation:**
53+
A signer uses their private key and a random ephemeral key to sign a message.
54+
- **Signature Verification:**
55+
The verifier uses the signer’s public key to confirm the signature's validity, ensuring both message authenticity and integrity.
56+
57+
---
58+
59+
## 3. Example with ECC (Conceptual)
60+
61+
Consider a simplified scenario:
62+
63+
1. **Curve and Base Point Selection:**
64+
- Assume a curve defined by \( y^2 = x^3 + ax + b \) over a prime field \( \mathbb{F}_p \) with a base point \( G \).
65+
66+
![Elliptic Curve](ECC.png)
67+
68+
2. **Key Generation:**
69+
- **Alice's Private Key:** \( k_A \)
70+
- **Alice's Public Key:** \( Q_A = k_A \times G \)
71+
- **Bob's Private Key:** \( k_B \)
72+
- **Bob's Public Key:** \( Q_B = k_B \times G \)
73+
74+
3. **Key Agreement (ECDH):**
75+
- Alice computes \( S_A = k_A \times Q_B \)
76+
- Bob computes \( S_B = k_B \times Q_A \)
77+
- Both arrive at the same shared secret, \( S = S_A = S_B \).
78+
---
79+
80+
## 4. Usage in Modern Cryptography
81+
82+
ECC is widely used across various applications:
83+
84+
- **Secure Communications:**
85+
Protocols like TLS/SSL incorporate ECC for efficient key exchange and authentication.
86+
- **Mobile and Embedded Systems:**
87+
Its reduced key sizes and lower computational overhead make ECC ideal for resource-constrained environments.
88+
- **Cryptocurrency:**
89+
ECC, particularly through [[ECDSA]], is a cornerstone in blockchain technology for securing transactions.
90+
91+
---
92+
93+
## 5. Summary
94+
95+
- **Elliptic Curve Cryptography (ECC)** leverages the mathematical properties of [[Elliptic Curves]] to enable secure public-key cryptographic systems.
96+
- The **Elliptic Curve Discrete Logarithm Problem ([[ECDLP]])** forms the basis of its security, making it infeasible to derive private keys from public keys.
97+
- ECC supports critical operations such as key exchange (ECDH) and digital signatures (ECDSA), making it highly versatile.
98+
- With its efficient, compact key sizes, ECC offers significant advantages over traditional systems like [[RSA]], particularly in environments with limited computational resources.

content/Basic Cryptography/SHA.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# SHA (Secure Hash Algorithm)
2+
3+
The **Secure Hash Algorithm (SHA)** is a family of cryptographic hash functions designed by the National Security Agency (NSA) and standardized by the National Institute of Standards and Technology (NIST). SHA functions take an input of arbitrary length and produce a fixed-length output called a **hash** (or **message digest**).
4+
5+
---
6+
7+
## 1. Overview
8+
9+
**Key security properties of SHA:**
10+
11+
1. **Preimage Resistance**
12+
It is computationally infeasible, given a hash value, to find an original input message that produces this hash.
13+
2. **Second Preimage Resistance**
14+
It is computationally infeasible, given an input message, to find a different message with the same hash.
15+
3. **Collision Resistance**
16+
It is computationally infeasible to find two different messages that produce the same hash value.
17+
18+
The most widely used variants today include **SHA-256** and **SHA-512** (from the SHA-2 family), and **SHA-3**.
19+
20+
---
21+
22+
## 2. Hash Generation Process (Conceptual)
23+
24+
While SHA doesn’t involve keys (unlike [[RSA]]), the process of creating a hash from a message can be summarized as follows:
25+
26+
1. **Padding the Message**
27+
- The original message is padded with a `1` bit, followed by enough `0` bits to reach a particular boundary.
28+
- This ensures the message length is congruent to a specified block size (e.g., 512 bits for SHA-256).
29+
30+
2. **Appending the Message Length**
31+
- The 64-bit (for SHA-256) representation of the original message length is appended to the padded message.
32+
- This step helps prevent certain structural attacks and is essential for internal block processing.
33+
34+
3. **Initialization**
35+
- SHA uses a set of **initial hash values** (also called initialization vectors).
36+
- For SHA-256, these are eight 32-bit words, denoted as `H0, H1, H2, ... H7`.
37+
38+
4. **Block Processing**
39+
- The padded message is split into fixed-size blocks (512 bits for SHA-256).
40+
- A **compression function** processes each block using bitwise operations, modular arithmetic, and constants to update the hash state.
41+
42+
5. **Finalization**
43+
- After processing all blocks, the final values of `H0, H1, ... H7` are concatenated to form the **digest**.
44+
- For SHA-256, this digest is **256 bits** (or 32 bytes).
45+
46+
6. **Output**
47+
- The resulting fixed-size output is the **hash** (or **message digest**).
48+
49+
---
50+
51+
## 3. Usage in Verification
52+
53+
SHA doesn’t encrypt or decrypt but is used to verify **integrity**:
54+
55+
1. **Hash Creation (Sender)**
56+
- The sender computes the hash of the message using SHA.
57+
- The resulting hash can be sent alongside the message or used in a digital signature scheme.
58+
59+
2. **Verification (Receiver)**
60+
- The receiver calculates the hash of the received message.
61+
- If the computed hash matches the sender’s hash, it is highly likely the message was not altered.
62+
63+
---
64+
65+
## 4. Example with SHA-256
66+
67+
Let’s illustrate with a short message: `"HI"`.
68+
69+
1. **Message**: `"HI"`
70+
- ASCII values:
71+
- `H` = `0x48`
72+
- `I` = `0x49`
73+
- In hexadecimal, `"HI"` is `0x48 0x49`.
74+
75+
2. **Padding**
76+
- SHA-256 operates on 512-bit blocks.
77+
- We append a `1` bit (`0x80`) and then enough `0` bits until the length is `448 mod 512`.
78+
- Finally, we append a 64-bit representation of the original message length (16 bits, since "HI" is 2 bytes).
79+
80+
3. **Block Processing**
81+
- The message block is processed with the SHA-256 compression function.
82+
- This involves a series of bitwise operations, additions, and mixing with internal state variables.
83+
84+
4. **Hash Output**
85+
- After processing, we get a 256-bit digest.
86+
- For example (shown in shortened form):
87+
```
88+
SHA-256("HI") = d3755b0e86e2...c96b8ecdb
89+
```
90+
- The full output would be 64 hexadecimal characters (32 bytes).
91+
92+
---
93+
94+
## 5. Summary
95+
96+
- **SHA** is a **one-way hash function** used for data integrity and message authentication.
97+
- **[[RSA]]** addresses confidentiality and authentication through **public-key encryption** and **[[Digital Signature]]s**, whereas SHA ensures the **integrity** of a message.
98+
- **SHA-2** (SHA-256, SHA-512) and **SHA-3** are standard and widely used in modern cryptographic applications.
99+
100+
Like [[RSA]] relies on factoring being hard, SHA relies on the infeasibility of finding collisions (two distinct messages producing the same hash) or preimages (an input that hashes to a specific target). Both RSA and SHA are fundamental to modern cryptography, but they solve different problems.
388 KB
Loading

content/Blockchain/Bitcoin.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Bitcoin Cryptography
2+
3+
## Introduction
4+
5+
Bitcoin is a decentralized digital currency that operates on a peer-to-peer network. It was introduced in 2009 by an anonymous individual or group and since then became the most recognized and widely used cryptocurrencies in the world. It remains the largest cryptocurrency by market capitalization.
6+
7+
Bitcoin leverages asymmetric encryption, cryptographic hash functions, and digital signatures to enable secure transactions without requiring a trusted intermediary.
8+
At the core of Bitcoin's security are two fundamental cryptographic constructs: **[[Elliptic Curves]] cryptography ([[ECC]])** for public and private keys, and **[[SHA]]-256**, a cryptographic hash function used for mining and transaction validation.
9+
10+
---
11+
12+
## Cryptographic Components in Bitcoin
13+
14+
### 1. **Elliptic Curve Cryptography ([[ECC]])**
15+
Bitcoin uses the **secp256k1** curve for key generation and digital signatures. [[ECC]] enables:
16+
- **Key Generation:** Deriving public keys from 256-bit private keys.
17+
- **Digital Signatures:** Ensures that only the owner of the private key can authorize a transaction.
18+
- **Transaction Validation:** Verifiers use the public key to confirm the authenticity of a signature.
19+
---
20+
### 2. **[[Hash function]]s**
21+
Bitcoin relies heavily on cryptographic hash functions, primarily **[[SHA]]-256** (Secure Hash Algorithm 256-bit), to ensure the security and integrity of data. The function is primaraly used for:
22+
- **Mining:** Proof-of-work requires finding a valid nonce such that the double SHA-256 hash of a block header starts with a certain number of leading zeroes (proof-of-work).
23+
- **Transaction Verification:** Bitcoin transactions within a block are SHA-256 hashed and arranged in a [[Merkle Tree]] to enable efficient verification of them.
24+
- **Address Generation:** Bitcoin addresses are derived by applying **[[SHA]]-256** and **RIPEMD-160** to the public key.
25+
26+
Hashes ensure security by making reversal infeasible, preventing collisions, and maintaining data integrity.
27+
28+
---
29+
30+
### 3. **[[Digital Signature]]s**
31+
32+
Bitcoin uses the **Elliptic Curve Digital Signature Algorithm ([[ECDSA]])** for transaction signing.
33+
34+
#### How It Works:
35+
1. A sender signs a transaction with their private key.
36+
2. The recipient and network nodes use the sender's public key to verify the signature.
37+
38+
39+
#### Example in Bitcoin:
40+
When Alice sends Bitcoin to Bob, she signs the transaction using her private key. The network verifies the signature using Alice's public key before adding the transaction to the blockchain.
41+
42+
---
43+
44+
### 4. **Proof-of-Work (PoW)**
45+
46+
Proof-of-work is a consensus mechanism that secures the Bitcoin blockchain and ensures that blocks are added only through significant computational effort.
47+
48+
#### Steps:
49+
1. Miners compete to find a nonce such that the hash of the block header satisfies a difficulty target.
50+
2. The winning miner broadcasts the block to the network.
51+
3. Other nodes verify the solution and append the block to their copy of the blockchain.
52+
53+
#### Role of Cryptography:
54+
- **Security**: PoW relies on the computational infeasibility of reversing [[SHA]]-256 hashes.
55+
- **Immutability**: Modifying a block would require re-mining all subsequent blocks, making attacks impractical.
56+
57+
---
58+
59+
## Implications of Bitcoin Cryptography
60+
61+
### Strengths:
62+
1. **Decentralization**: Bitcoin's cryptography eliminates the need for a trusted third party.
63+
2. **Security**: Cryptographic techniques ensure the network's resistance to tampering and fraud.
64+
3. **Transparency and Privacy**: Transactions are publicly recorded on the blockchain, but cryptography ensures that only authorized parties can spend funds.
65+
66+
### Limitations and Challenges:
67+
1. **Quantum Computing Threat**: While classical cryptography is secure, the advent of quantum computing could potentially break [[ECDSA]] and SHA-256.
68+
2. **Key Management**: Users must securely store private keys, as losing them results in the permanent loss of funds.
69+
70+
---
71+
72+
## Cryptographic Advancements in Bitcoin
73+
74+
Bitcoin developers and researchers are exploring advanced cryptographic techniques to improve privacy, scalability, and quantum resistance.
75+
76+
### 1. **Taproot and Schnorr Signatures**
77+
- **Taproot** enhances transaction privacy by allowing complex scripts to appear identical to simple transactions on-chain.
78+
- **[[Schnorr Signature]]s** improve efficiency and enable signature aggregation, reducing transaction size and enhancing scalability.
79+
80+
### 2. **[[Zero Knowledge Proofs]]**
81+
Although not natively supported, Bitcoin sidechains and layer-2 solutions are exploring zero-knowledge proofs to enable private transactions.
82+
83+
#### Examples:
84+
- **Taproot & Scriptless Scripts**: Use ZKPs (e.g., [[Schnorr Signature]]s) to enhance privacy in multi-signature and smart contracts.
85+
- **Sidechains (RSK, StarkNet experiments)**: Exploring zk-Rollups for scalability and privacy.
86+
- **Mercury Statechains**: Enables off-chain Bitcoin transfers with enhanced privacy.
87+
- **zk-Bitcoin (Future Research)**: Investigating [[ZK-SNARK]]s/STARKs for shielded transactions.
88+
89+
### 3. **Quantum Resistance**
90+
Efforts are underway to evaluate quantum-resistant algorithms, such as lattice-based cryptography, for potential integration into Bitcoin in the distant future.
91+
92+
#### Examples:
93+
- **Bitcoin Layer-2 Solutions**: Sidechains and second-layer protocols exploring quantum-safe cryptographic primitives.
94+
- **Soft Fork Proposals**: Discussions on introducing quantum-resistant key pairs as optional upgrades for Bitcoin users.
95+
96+
---
97+
98+
## Conclusion
99+
100+
Bitcoin cryptography forms the backbone of its trustless, decentralized system, enabling secure and transparent transactions without intermediaries. By combining elliptic curve cryptography, hash functions, and digital signatures, Bitcoin achieves unparalleled security and immutability. As threats like quantum computing emerge, ongoing research into advanced cryptographic methods ensures that Bitcoin will continue to adapt and remain secure.

content/Blockchain/Blockchain.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
> In the [[Blockchain]] section, the application of cryptography within blockchain is explored, focusing on advanced cryptographic methods designed to protect user privacy. It covers various cryptographic applications, including fhEVM, zero-knowledge proofs, secure multi-party computation, and homomorphic encryption.
33
44

5-
- [[fhEVM]]
5+
- [[fhEVM]]
6+
- [[Bitcoin]]
7+
- [[Ethereum]]

0 commit comments

Comments
 (0)