aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-07-07 09:30:34 -0500
committerChristian Cleberg <hello@cleberg.net>2025-07-07 09:30:34 -0500
commitdb4c99af282f3aea9e207c30db983e53203513eb (patch)
tree9927d49ac907f972a9fbafb5bb33cb103b1c46ce
parentefe21deadd5f14d6bb5647fbb98df063c3d8fb9f (diff)
downloadcleberg.net-db4c99af282f3aea9e207c30db983e53203513eb.tar.gz
cleberg.net-db4c99af282f3aea9e207c30db983e53203513eb.tar.bz2
cleberg.net-db4c99af282f3aea9e207c30db983e53203513eb.zip
fix: ignore draft posts when publishing
-rw-r--r--build.py15
-rw-r--r--content/blog/2025-06-27-how-blockchain-works.org197
2 files changed, 211 insertions, 1 deletions
diff --git a/build.py b/build.py
index 59118fb..0b08bd8 100644
--- a/build.py
+++ b/build.py
@@ -115,6 +115,7 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3):
"date": re.compile(r"^#\+date:\s*<(\d{4}-\d{2}-\d{2})"),
"slug": re.compile(r"^#\+slug:\s*(.+)$", re.IGNORECASE),
"filetags": re.compile(r"^#\+filetags:\s*(.+)$", re.IGNORECASE),
+ "draft": re.compile(r"^#\+draft:\s*(.+)$", re.IGNORECASE),
}
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):
date_str = None
slug = None
tags = []
+ is_draft = False
with org_path.open("r", encoding="utf-8") as f:
for line in f:
@@ -153,17 +155,28 @@ def get_recent_posts_html(content_dir="./content/blog", num_posts=3):
tags = [t for t in raw.split(":") if t]
continue
+ m = header_patterns["draft"].match(line)
+ if m:
+ draft_value = m.group(1).strip().lower()
+ if draft_value != "nil":
+ is_draft = True
+ break
+ continue
+
# Stop scanning once we have all required fields
if title and date_str and slug and tags:
break
+ if is_draft:
+ continue
+
if title and date_str and slug:
try:
date_obj = datetime.strptime(date_str, "%Y-%m-%d")
except ValueError:
# Skip files with invalid date format
continue
-
+
posts.append(
{
"title": title,
diff --git a/content/blog/2025-06-27-how-blockchain-works.org b/content/blog/2025-06-27-how-blockchain-works.org
new file mode 100644
index 0000000..c31e5a8
--- /dev/null
+++ b/content/blog/2025-06-27-how-blockchain-works.org
@@ -0,0 +1,197 @@
+#+date: <2025-07-07 Mon 00:00:00>
+#+title: Blockchain Series #1: How Blockchain Works Under the Hood: Hashes, Keys, and Signatures Explained
+#+description: Dive into blockchain's cryptographic foundations. Explore how hash functions, Merkle trees, and digital signatures secure distributed, tamper-resistant ledgers.
+#+slug: how-blockchain-works
+#+filetags: :blockchain:encryption:
+#+draft: t
+
+/This is Part 1 of a series I'm writing on blockchain. Stay tuned for further
+editions./
+
+Blockchain is one of those technologies that seems to generate more marketing
+buzz than real understanding. Everywhere you look, people talk about
+decentralization, trustless systems, and the next big disruption. But beneath
+the hype, blockchain systems rely on well-understood cryptographic building
+blocks to do something very specific: maintain a secure, tamper-resistant ledger
+without needing a central authority.
+
+If you're serious about understanding blockchain, it's critical to understand
+the cryptographic primitives that make it work. Hash functions, digital
+signatures, and public-key cryptography aren't just jargon—they're the core
+mechanisms that let a distributed network agree on a shared history no one can
+easily rewrite.
+
+This post is Part 1 of a multi-part series on blockchain. Here, we'll focus on
+these fundamental building blocks—how they work, why they're used, and how they
+fit together to provide the security and trust that blockchain promises.
+
+* What is Blockchain?
+
+At its core, a blockchain is a distributed, append-only ledger shared among
+participants in a network.
+
+What does this mean? Essentially, we can think of a standard, non-technical
+ledger (book of accounts where transactions are recorded against accounts). When
+introductin the idea of a blockchain, let's extend the idea of a standard ledger
+and make a few connections:
+
+- Each block of transactions is connected cryptographically to the block before
+ it, via a [[https://en.wikipedia.org/wiki/Cryptographic_hash_function][cryptographic hash]]. This is what forms a =chain= of blocks, or
+ records.
+- Each block consists of:
+ - A list of validated transactions
+ - A timestamp
+ - A cryptographic hash of the previous block (ensuring immutability)
+- Each transaction within a block is initiated between addresses, signed with
+ cryptographic keys, and sent to the blockchain for validation (e.g.,
+ proof-of-work, proof-of-staking, etc.).
+- The blockchain is shared amongst nodes in the network, who agree on the state
+ of the blockchain through consensus mechanisms.
+
+As we can see, the decentralized nature and cryptographic linking of
+transactions and blocks ensures that modifying the history is infeasible.
+
+If you're more of a visual person, here's a very basic diagram of a standard
+blockchain structure.
+
+#+begin_example
++------------+ +------------+ +------------+
+| Block 1 | -> | Block 2 | -> | Block 3 |
+|------------| |------------| |------------|
+| Data | | Data | | Data |
+| Prev Hash: | | Prev Hash: | | Prev Hash: |
+| 00000000 | | <hash1> | | <hash2> |
+| Hash: | | Hash: | | Hash: |
+| <hash1> | | <hash2> | | <hash3> |
++------------+ +------------+ +------------+
+#+end_example
+
+* What Problems is Blockchain Trying to Solve?
+
+I will be diving into the technical details of blockchains later in this post,
+but what exactly is the reason blockchain exists?
+
+You may know of cryptocurrencies, such as Bitcoin, but that is only one of many
+use cases for blockchains.
+
+As we learned in the section above, a blockchain can be equated to a ledger.
+With this in mind, let's dive into a few interesting use cases:
+
+** Immutable record-keeping
+
+If you simply need a ledger that cannot be modified easily and can establish a
+decentralized network to support that, blockchain is a great technology.
+
+** Trust without central authority
+
+The use of a decentralized system means that we do not need to rely on a
+centralized authority (e.g., Social Security, a bank, etc.) to store and provide
+access to information you need to record.
+
+Think of the US Social Security Number (SSN) system. Each time you want to
+perform actions that require verifying your identify (e.g., opening bank
+accounts, investment accounts, child birth, etc.), you are currently required to
+provide your SSN.
+
+However, this is a singular number - which means that if someone learns it, they
+can (essentially) now act as you.
+
+Now imagine a scenario where the SSN system is a blockchain where you have both
+your private key for providing evidence to people that you are you. For example,
+you open a bank account and sign your form with your private key. Now, the bank
+can take that and use your public key to decrypt the message and verify that you
+are you, without needing to know your private key.
+
+Another scenario is that, during a background check, a company could use your
+public key and consult the related blockchain to validate specific pieces of
+information. For example, if your identity alone is in one block, you could
+provide that information to your employer without providing your full SSN and
+all related personal information for as long as they keep your SSN on file.
+
+** Double-spending problem
+
+With the introduction of digital assets, such as cryptocurrencies and
+non-fungible tokens, a new risk is introduced: without control, these assets
+could be copied and reused at-will.
+
+To solve this problem, digital assets are transacted on a blockchain to ensure
+that the decentralized system of nodes provide consensus on validating
+transactions, transactions are recorded in a transparent and tamper-resistant
+manner, and cryptographic functions are performed to order the transactions
+logically on chain.
+
+* The Role of Cryptography in Blockchain
+- Why cryptography matters
+- Confidentiality vs. integrity/authenticity
+- Core goals:
+ - Tamper-evidence
+ - Secure identification
+ - Non-repudiation
+
+* Hash Functions
+- What is a cryptographic hash?
+- Properties:
+ - Collision resistance
+ - Pre-image resistance
+- How blockchain uses hashes:
+ - Chaining blocks together
+ - Block headers
+ - Transactions
+- Example command:
+ #+begin_src bash
+ echo -n "Hello, Blockchain" | sha256sum
+ #+end_src
+- Optional diagram: chain of blocks with hashes
+
+* Merkle Trees
+- Summarizing many transactions in a single root hash
+- Use case: efficient inclusion proofs
+- Example diagram (ASCII art if desired)
+- Why Merkle roots are in block headers
+
+* Public Key Cryptography
+- Quick refresher
+- Public/private keypairs
+- Addresses derived from public keys
+- Importance of keeping private keys secret
+
+* Digital Signatures
+- Purpose: proving authorship without revealing private key
+- Mention ECDSA / EdDSA
+- How transactions are signed
+- Example snippet:
+ #+begin_example
+ Alice signs transaction with her private key
+ → Anyone can verify with her public key
+ #+end_example
+- Why signatures prevent forgery
+
+* Bringing it All Together: Blockchain Data Structures
+- Block structure:
+ - Block header with previous block's hash
+ - Merkle root
+ - Timestamp, nonce
+- How the chain ensures immutability
+- Example flow:
+ 1. User creates a transaction
+ 2. Signs it
+ 3. Transaction included in block
+ 4. Block hash links to previous block
+
+* Proof of Work (Optional)
+- Hash puzzles to add blocks
+- Why it's hard to modify history
+- Keep this section simple
+
+* Conclusion
+- Summarize how these primitives work together
+- Tease next post: "Next, we'll explore security threats and how blockchain
+ networks mitigate them."
+- Optional links to further reading:
+ - Bitcoin whitepaper
+ - Ethereum docs
+ - Cryptography references
+
+* Optional Extras
+- Glossary box with terms (hash, signature, Merkle tree)
+- External references (e.g., NIST docs on hashes)