Commit 99575d28c5

99575d28c574803e78084ac5ce0eb499e0e8fdce

parent: 037a40e4a5

Unsigned

cmc <hello@cleberg.net> · 2025-07-07 14:30 UTC

fix: ignore draft posts when publishing

Layout: unified · split

build.py +14 −1
@@ -115,6 +115,7 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3):
115115 "date": re.compile(r"^#\+date:\s*<(\d{4}-\d{2}-\d{2})"),
116116 "slug": re.compile(r"^#\+slug:\s*(.+)$", re.IGNORECASE),
117117 "filetags": re.compile(r"^#\+filetags:\s*(.+)$", re.IGNORECASE),
118 "draft": re.compile(r"^#\+draft:\s*(.+)$", re.IGNORECASE),
118119 }
119120
120121 for org_path in Path(content_dir).glob("*.org"):
@@ -122,6 +123,7 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3):
122123 date_str = None
123124 slug = None
124125 tags = []
126 is_draft = False
125127
126128 with org_path.open("r", encoding="utf-8") as f:
127129 for line in f:
@@ -153,17 +155,28 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3):
153155 tags = [t for t in raw.split(":") if t]
154156 continue
155157
158 m = header_patterns["draft"].match(line)
159 if m:
160 draft_value = m.group(1).strip().lower()
161 if draft_value != "nil":
162 is_draft = True
163 break
164 continue
165
156166 # Stop scanning once we have all required fields
157167 if title and date_str and slug and tags:
158168 break
159169
170 if is_draft:
171 continue
172
160173 if title and date_str and slug:
161174 try:
162175 date_obj = datetime.strptime(date_str, "%Y-%m-%d")
163176 except ValueError:
164177 # Skip files with invalid date format
165178 continue
166
179
167180 posts.append(
168181 {
169182 "title": title,
content/blog/2025-06-27-how-blockchain-works.org added +197
@@ -0,0 +1,197 @@
1#+date: <2025-07-07 Mon 00:00:00>
2#+title: Blockchain Series #1: How Blockchain Works Under the Hood: Hashes, Keys, and Signatures Explained
3#+description: Dive into blockchain's cryptographic foundations. Explore how hash functions, Merkle trees, and digital signatures secure distributed, tamper-resistant ledgers.
4#+slug: how-blockchain-works
5#+filetags: :blockchain:encryption:
6#+draft: t
7
8/This is Part 1 of a series I'm writing on blockchain. Stay tuned for further
9editions./
10
11Blockchain is one of those technologies that seems to generate more marketing
12buzz than real understanding. Everywhere you look, people talk about
13decentralization, trustless systems, and the next big disruption. But beneath
14the hype, blockchain systems rely on well-understood cryptographic building
15blocks to do something very specific: maintain a secure, tamper-resistant ledger
16without needing a central authority.
17
18If you're serious about understanding blockchain, it's critical to understand
19the cryptographic primitives that make it work. Hash functions, digital
20signatures, and public-key cryptography aren't just jargon—they're the core
21mechanisms that let a distributed network agree on a shared history no one can
22easily rewrite.
23
24This post is Part 1 of a multi-part series on blockchain. Here, we'll focus on
25these fundamental building blocks—how they work, why they're used, and how they
26fit together to provide the security and trust that blockchain promises.
27
28* What is Blockchain?
29
30At its core, a blockchain is a distributed, append-only ledger shared among
31participants in a network.
32
33What does this mean? Essentially, we can think of a standard, non-technical
34ledger (book of accounts where transactions are recorded against accounts). When
35introductin the idea of a blockchain, let's extend the idea of a standard ledger
36and make a few connections:
37
38- Each block of transactions is connected cryptographically to the block before
39 it, via a [[https://en.wikipedia.org/wiki/Cryptographic_hash_function][cryptographic hash]]. This is what forms a =chain= of blocks, or
40 records.
41- Each block consists of:
42 - A list of validated transactions
43 - A timestamp
44 - A cryptographic hash of the previous block (ensuring immutability)
45- Each transaction within a block is initiated between addresses, signed with
46 cryptographic keys, and sent to the blockchain for validation (e.g.,
47 proof-of-work, proof-of-staking, etc.).
48- The blockchain is shared amongst nodes in the network, who agree on the state
49 of the blockchain through consensus mechanisms.
50
51As we can see, the decentralized nature and cryptographic linking of
52transactions and blocks ensures that modifying the history is infeasible.
53
54If you're more of a visual person, here's a very basic diagram of a standard
55blockchain structure.
56
57#+begin_example
58+------------+ +------------+ +------------+
59| Block 1 | -> | Block 2 | -> | Block 3 |
60|------------| |------------| |------------|
61| Data | | Data | | Data |
62| Prev Hash: | | Prev Hash: | | Prev Hash: |
63| 00000000 | | <hash1> | | <hash2> |
64| Hash: | | Hash: | | Hash: |
65| <hash1> | | <hash2> | | <hash3> |
66+------------+ +------------+ +------------+
67#+end_example
68
69* What Problems is Blockchain Trying to Solve?
70
71I will be diving into the technical details of blockchains later in this post,
72but what exactly is the reason blockchain exists?
73
74You may know of cryptocurrencies, such as Bitcoin, but that is only one of many
75use cases for blockchains.
76
77As we learned in the section above, a blockchain can be equated to a ledger.
78With this in mind, let's dive into a few interesting use cases:
79
80** Immutable record-keeping
81
82If you simply need a ledger that cannot be modified easily and can establish a
83decentralized network to support that, blockchain is a great technology.
84
85** Trust without central authority
86
87The use of a decentralized system means that we do not need to rely on a
88centralized authority (e.g., Social Security, a bank, etc.) to store and provide
89access to information you need to record.
90
91Think of the US Social Security Number (SSN) system. Each time you want to
92perform actions that require verifying your identify (e.g., opening bank
93accounts, investment accounts, child birth, etc.), you are currently required to
94provide your SSN.
95
96However, this is a singular number - which means that if someone learns it, they
97can (essentially) now act as you.
98
99Now imagine a scenario where the SSN system is a blockchain where you have both
100your private key for providing evidence to people that you are you. For example,
101you open a bank account and sign your form with your private key. Now, the bank
102can take that and use your public key to decrypt the message and verify that you
103are you, without needing to know your private key.
104
105Another scenario is that, during a background check, a company could use your
106public key and consult the related blockchain to validate specific pieces of
107information. For example, if your identity alone is in one block, you could
108provide that information to your employer without providing your full SSN and
109all related personal information for as long as they keep your SSN on file.
110
111** Double-spending problem
112
113With the introduction of digital assets, such as cryptocurrencies and
114non-fungible tokens, a new risk is introduced: without control, these assets
115could be copied and reused at-will.
116
117To solve this problem, digital assets are transacted on a blockchain to ensure
118that the decentralized system of nodes provide consensus on validating
119transactions, transactions are recorded in a transparent and tamper-resistant
120manner, and cryptographic functions are performed to order the transactions
121logically on chain.
122
123* The Role of Cryptography in Blockchain
124- Why cryptography matters
125- Confidentiality vs. integrity/authenticity
126- Core goals:
127 - Tamper-evidence
128 - Secure identification
129 - Non-repudiation
130
131* Hash Functions
132- What is a cryptographic hash?
133- Properties:
134 - Collision resistance
135 - Pre-image resistance
136- How blockchain uses hashes:
137 - Chaining blocks together
138 - Block headers
139 - Transactions
140- Example command:
141 #+begin_src bash
142 echo -n "Hello, Blockchain" | sha256sum
143 #+end_src
144- Optional diagram: chain of blocks with hashes
145
146* Merkle Trees
147- Summarizing many transactions in a single root hash
148- Use case: efficient inclusion proofs
149- Example diagram (ASCII art if desired)
150- Why Merkle roots are in block headers
151
152* Public Key Cryptography
153- Quick refresher
154- Public/private keypairs
155- Addresses derived from public keys
156- Importance of keeping private keys secret
157
158* Digital Signatures
159- Purpose: proving authorship without revealing private key
160- Mention ECDSA / EdDSA
161- How transactions are signed
162- Example snippet:
163 #+begin_example
164 Alice signs transaction with her private key
165 → Anyone can verify with her public key
166 #+end_example
167- Why signatures prevent forgery
168
169* Bringing it All Together: Blockchain Data Structures
170- Block structure:
171 - Block header with previous block's hash
172 - Merkle root
173 - Timestamp, nonce
174- How the chain ensures immutability
175- Example flow:
176 1. User creates a transaction
177 2. Signs it
178 3. Transaction included in block
179 4. Block hash links to previous block
180
181* Proof of Work (Optional)
182- Hash puzzles to add blocks
183- Why it's hard to modify history
184- Keep this section simple
185
186* Conclusion
187- Summarize how these primitives work together
188- Tease next post: "Next, we'll explore security threats and how blockchain
189 networks mitigate them."
190- Optional links to further reading:
191 - Bitcoin whitepaper
192 - Ethereum docs
193 - Cryptography references
194
195* Optional Extras
196- Glossary box with terms (hash, signature, Merkle tree)
197- External references (e.g., NIST docs on hashes)