<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title>Chemaclass - security</title><subtitle>Tech Lead sharing practical insights on software craftsmanship, TDD, leadership, Bitcoin, and AI. Blog posts, book summaries, and conference talks.</subtitle><link rel="self" type="application/atom+xml" href="https://chemaclass.com/tags/security/atom.xml"/><link rel="alternate" type="text/html" href="https://chemaclass.com"/><generator uri="https://www.getzola.org/">Zola</generator><updated>2024-12-11T00:00:00+00:00</updated><id>https://chemaclass.com/tags/security/atom.xml</id><entry xml:lang="en"><title>The Cypherpunks</title><subtitle>Pioneers of privacy in the digital age</subtitle><category term="privacy" scheme="https://chemaclass.com/tags/privacy/" label="Privacy"/><category term="bitcoin" scheme="https://chemaclass.com/tags/bitcoin/" label="Bitcoin"/><category term="cryptography" scheme="https://chemaclass.com/tags/cryptography/" label="Cryptography"/><category term="security" scheme="https://chemaclass.com/tags/security/" label="Security"/><category term="philosophy" scheme="https://chemaclass.com/tags/philosophy/" label="Philosophy"/><published>2024-12-11T00:00:00+00:00</published><updated>2024-12-11T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/the-cypherpunks/"/><id>https://chemaclass.com/blog/the-cypherpunks/</id><summary type="html">In the early '90s, with the internet on the rise, a group called the Cypherpunks emerged to defend digital privacy. They pushed for encryption and privacy tech, shaping our digital world with their vision and ideals.</summary><content type="html">&lt;p>In the early ’90s, with the internet on the rise, a group called the Cypherpunks emerged to defend digital privacy. They pushed for encryption and privacy, shaping our digital world with their vision.&lt;/p>
&lt;span id="continue-reading">&lt;/span>&lt;h2 id="who-were-the-cypherpunks">Who were the Cypherpunks?
&lt;a class="heading-anchor" href="#who-were-the-cypherpunks" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>The term “Cypherpunk” combines “cipher” (a reference to encryption) with “punk”, reflecting the group’s rebellious and anti-establishment spirit.&lt;/p>
&lt;p>Far from being a formal organization, the Cypherpunks were a diverse assembly of visionaries, technologists, and activists bonded by shared principles. The movement started in 1992 when Eric Hughes, Timothy May, and John Gilmore founded the cypherpunks mailing list. Some key figures:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Eric Hughes&lt;/strong> who wrote “A Cypherpunk’s Manifesto,” laying out the philosophical foundation for the movement.&lt;/li>
&lt;li>&lt;strong>Timothy C. May&lt;/strong> authored “The Crypto Anarchist Manifesto,” which imagined a society where cryptography could foster a new anarchistic order.&lt;/li>
&lt;li>&lt;strong>John Gilmore&lt;/strong>, a co-founder of the Electronic Frontier Foundation (EFF), was pivotal in early internet privacy advocacy.&lt;/li>
&lt;li>&lt;strong>Julian Assange&lt;/strong>, later known for WikiLeaks, participated in these discussions.&lt;/li>
&lt;li>&lt;strong>Phil Zimmermann&lt;/strong> revolutionized email privacy with his creation of PGP.&lt;/li>
&lt;li>&lt;strong>Jude Milhon&lt;/strong> (St. Jude), a hacker and writer, coined the term “cypherpunk” together with Eric Hughes.&lt;/li>
&lt;li>&lt;strong>Nick Szabo&lt;/strong> contributed significantly to digital contracts and currencies, conceptualizing “bit gold” before Bitcoin.&lt;/li>
&lt;li>&lt;strong>Hal Finney&lt;/strong>, an early Bitcoin developer, worked on cryptographic software including PGP, influencing the privacy tech landscape.&lt;/li>
&lt;li>&lt;strong>Adam Back&lt;/strong> introduced Hashcash, which later inspired Bitcoin’s proof-of-work, while actively engaging in cypherpunk dialogues on privacy.&lt;/li>
&lt;li>&lt;strong>Wei Dai&lt;/strong> proposed “b-money,” an early idea for anonymous digital cash systems, which influenced Bitcoin’s development.&lt;/li>
&lt;li>&lt;strong>Zooko Wilcox-O’Hearn&lt;/strong>, with his work on Zcash, brought advanced privacy to cryptocurrencies, having roots in cypherpunk discussions.&lt;/li>
&lt;li>&lt;strong>David Chaum&lt;/strong>, often called the “godfather of cypherpunks”, pioneered digital cash with DigiCash (1989). His work on electronic privacy predates and inspired the movement.&lt;/li>
&lt;li>&lt;strong>Bram Cohen&lt;/strong> developed BitTorrent, showcasing the cypherpunk ethos of decentralization in file sharing.&lt;/li>
&lt;/ul>
&lt;p>Their work built on foundational cryptographic research by &lt;strong>Whitfield Diffie&lt;/strong> and &lt;strong>Martin Hellman&lt;/strong>, who invented public-key cryptography in 1976, making secure communication between strangers possible.&lt;/p>
&lt;p>They gathered online on the cypherpunks mailing list, which at its peak had around 2000 subscribers exchanging 30+ messages per day. Their motto: &lt;strong>“Cypherpunks write code.”&lt;/strong> They didn’t just talk about privacy. They built it.&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-12-11/manifesto.jpg" alt="a cypherpunk’s manifesto" />&lt;/p>
&lt;h2 id="philosophy-and-goals">Philosophy and goals
&lt;a class="heading-anchor" href="#philosophy-and-goals" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>The core philosophy of the Cypherpunks was centered around privacy, freedom of speech, and the potential of cryptography to protect these rights. Their main tenets included:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Privacy as a fundamental right&lt;/strong>: They believed that privacy was essential for personal freedom and that digital communication should be private.&lt;/li>
&lt;li>&lt;strong>Decentralization&lt;/strong>: Suspicious of centralized control over information, they pushed for decentralized systems where individuals could control their own data.&lt;/li>
&lt;li>&lt;strong>Cryptography as a tool&lt;/strong>: They saw encryption not just as a means of securing data but as a political tool against surveillance and oppressive regimes.&lt;/li>
&lt;/ul>
&lt;h3 id="their-goals-were">Their goals were
&lt;a class="heading-anchor" href="#their-goals-were" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;ol>
&lt;li>To create and promote tools for encryption, anonymity, and digital cash.&lt;/li>
&lt;li>To educate the public on the importance of cryptography.&lt;/li>
&lt;li>To resist governmental and corporate efforts to control or monitor digital communications.&lt;/li>
&lt;/ol>
&lt;h2 id="impact-nowadays">Impact nowadays
&lt;a class="heading-anchor" href="#impact-nowadays" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="development-of-key-technologies">Development of key technologies
&lt;a class="heading-anchor" href="#development-of-key-technologies" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Cypherpunks built tools, not just theories:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>PGP&lt;/strong> (1991): Email encryption for everyone&lt;/li>
&lt;li>&lt;strong>Tor&lt;/strong> (2002): Anonymous browsing through onion routing&lt;/li>
&lt;li>&lt;strong>BitTorrent&lt;/strong> (2001): Decentralized file sharing&lt;/li>
&lt;li>&lt;strong>Bitcoin&lt;/strong> (2009): Digital money without banks&lt;/li>
&lt;li>&lt;strong>Signal Protocol&lt;/strong>: The encryption behind Signal, WhatsApp, and other messengers&lt;/li>
&lt;/ul>
&lt;p>When you send an encrypted message today, you’re using cypherpunk technology.&lt;/p>
&lt;h3 id="cultural-shift">Cultural shift
&lt;a class="heading-anchor" href="#cultural-shift" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>They changed how society views privacy. Before them, encryption was mostly for governments or experts. Today, it’s a standard part of tools like messaging apps and web browsers. By promoting encryption and anonymity, they made privacy a priority and encouraged people to take control of their data.&lt;/p>
&lt;h3 id="legal-and-policy-influence-the-crypto-wars">Legal and policy influence: The Crypto Wars
&lt;a class="heading-anchor" href="#legal-and-policy-influence-the-crypto-wars" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>The 1990s saw a real battle between cypherpunks and governments, known as the “Crypto Wars.” The US classified strong encryption as a weapon and banned its export. When Phil Zimmermann released PGP, he was investigated for “exporting munitions” because the software spread globally via the internet.&lt;/p>
&lt;p>The cypherpunks fought back creatively. They printed PGP source code in books, since books were protected speech. They wore t-shirts with encryption code. Eventually, they won. Export restrictions were relaxed in 2000. Today’s encrypted messaging exists because of that fight.&lt;/p>
&lt;h2 id="challenges-and-criticisms">Challenges and Criticisms
&lt;a class="heading-anchor" href="#challenges-and-criticisms" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>The Cypherpunks face these main criticisms:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Accessibility&lt;/strong>: Their tools are too complex for many people, so only tech-savvy individuals can use them, leaving others behind.&lt;/li>
&lt;li>&lt;strong>Misuse Risk&lt;/strong>: There’s concern that their encryption tech could be used by bad actors. While Cypherpunks believe privacy is a right for all, this view conflicts with security concerns from authorities who fear these tools could hide illegal acts.&lt;/li>
&lt;/ul>
&lt;p>This shows the ongoing struggle between promoting privacy and maintaining safety in the digital world.&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-12-11/btc-p2p.webp" alt="bitcoin peer-to-peer cash" />&lt;/p>
&lt;h2 id="precursors-to-bitcoin">Precursors to Bitcoin
&lt;a class="heading-anchor" href="#precursors-to-bitcoin" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin is the most well-known outcome of the cypherpunk philosophy, embodying their values of decentralization, privacy, and independence from government control over money. Created by the mysterious Satoshi Nakamoto, Bitcoin was first shared with the world through the cypherpunks’ mailing list in 2008.&lt;/p>
&lt;p>However, it is the result of many trials of other technologies also created within this group of people. It uses ideas like proof-of-work from Hashcash, and concepts from b-money and bit gold, all reflecting the cypherpunks’ dream of a currency not controlled by any single entity.&lt;/p>
&lt;h3 id="digicash-ecash">DigiCash (eCash)
&lt;a class="heading-anchor" href="#digicash-ecash" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Developed by David Chaum in the late 1980s and implemented in 1990, DigiCash was one of the earliest attempts at an electronic payment system. It used cryptography to ensure privacy in transactions but struggled with adoption and eventually failed due to issues like centralization and the double-spending problem.&lt;/p>
&lt;h3 id="b-money">B-Money
&lt;a class="heading-anchor" href="#b-money" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Proposed by Wei Dai in 1998, B-Money was a conceptual framework for anonymous, distributed electronic cash. It aimed to solve issues like double-spending without a central authority but was never implemented. Its ideas influenced Bitcoin’s design.&lt;/p>
&lt;h3 id="bit-gold">Bit Gold
&lt;a class="heading-anchor" href="#bit-gold" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Also conceptualized in 1998 by Nick Szabo, Bit Gold proposed a currency with properties similar to gold, using cryptographic proof-of-work. Like B-Money, it was never fully realized but contributed to Bitcoin’s development, particularly its proof-of-work system.&lt;/p>
&lt;h3 id="hashcash">Hashcash
&lt;a class="heading-anchor" href="#hashcash" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Introduced by Adam Back in 1997, Hashcash was not a currency but a system to counter email spam using proof-of-work. This concept was later adopted by Bitcoin for mining.&lt;/p>
&lt;blockquote>
&lt;p>These earlier projects and ideas, while not successful in creating a functional digital currency, were critical in laying the theoretical groundwork for Bitcoin. They tackled issues like double-spending, privacy, and decentralization, which were key problems Bitcoin aimed to solve.&lt;/p>
&lt;/blockquote>
&lt;h2 id="cypherpunk-legacy">Cypherpunk legacy
&lt;a class="heading-anchor" href="#cypherpunk-legacy" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin has revolutionized our understanding of money, privacy, and security:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Decentralized Control&lt;/strong>: Bitcoin isn’t run by any bank or government, which fits perfectly with the cypherpunk’s skepticism of centralized power.&lt;/li>
&lt;li>&lt;strong>Privacy&lt;/strong>: While not completely anonymous, Bitcoin transactions use pseudonyms, offering some protection from financial oversight.&lt;/li>
&lt;li>&lt;strong>Immutable Transactions&lt;/strong>: Once a transaction is on the blockchain, it’s nearly unchangeable, fostering trust in digital dealings.&lt;/li>
&lt;/ul>
&lt;p>Bitcoin has brought cypherpunk ideals to life, sparking global discussions on financial privacy, money’s nature, and cryptography’s transformative power. With developments like the &lt;a rel="external" href="https://en.wikipedia.org/wiki/Lightning_Network">Lightning Network&lt;/a> for faster, private transactions and &lt;a href="/blog/programmable-money/#p2tr-pay-to-taproot-taproot-up">Taproot&lt;/a> for enhanced transaction privacy, Bitcoin continues to evolve.&lt;/p>
&lt;h2 id="what-the-cypherpunks-left-behind">What the cypherpunks left behind
&lt;a class="heading-anchor" href="#what-the-cypherpunks-left-behind" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>The cypherpunks proved that a small group of people who write code can change the world. Every encrypted message you send, every Bitcoin transaction, every anonymous browse: their legacy.&lt;/p>
&lt;p>Privacy isn’t dead. They made sure of that.&lt;/p>
&lt;hr />
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/9vM0oIEhMag"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;hr />
&lt;p>&lt;strong>Related links&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Learn more: &lt;a href="/pgp">What is PGP encryption?&lt;/a> &lt;small>A 3-minute tutorial for beginners&lt;/small>&lt;/li>
&lt;li>Wikipedia Article: &lt;a rel="external" href="https://en.wikipedia.org/wiki/Cypherpunk">wikipedia.org/Cypherpunk&lt;/a>&lt;/li>
&lt;/ul></content></entry><entry xml:lang="en"><title>Verified Git Commits</title><subtitle>Boosting trust and security in your codebase</subtitle><category term="git" scheme="https://chemaclass.com/tags/git/" label="Git"/><category term="security" scheme="https://chemaclass.com/tags/security/" label="Security"/><category term="cryptography" scheme="https://chemaclass.com/tags/cryptography/" label="Cryptography"/><category term="open-source" scheme="https://chemaclass.com/tags/open-source/" label="Open Source"/><published>2024-11-17T00:00:00+00:00</published><updated>2024-11-17T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/verified-git-commits/"/><id>https://chemaclass.com/blog/verified-git-commits/</id><summary type="html">Sign your Git commits with GPG to prove they're really from you. Without signatures, anyone can fake commits using your email. It takes 5 minutes to set up and adds real trust to your codebase.</summary><content type="html">&lt;p>When it comes to software development, trust and security are very important. One easy way to level up both is by using verified commits.&lt;/p>
&lt;span id="continue-reading">&lt;/span>
&lt;p>Whether you’re working on an open-source project or in a private company, verified commits can make sure your contributions are legit. Let’s break down what they are, why they’re important, and how to start using them.&lt;/p>
&lt;h2 id="what-are-verified-commits">What are verified commits?
&lt;a class="heading-anchor" href="#what-are-verified-commits" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>A verified commit is basically a Git commit that is signed by the author using a digital signature. This signature proves that the commit actually came from the person who says they made it. Tools like &lt;a rel="external" href="https://gnupg.org/">GPG (GNU Privacy Guard)&lt;/a> let you attach this signature to your commits.&lt;/p>
&lt;p>If you’re using platforms like GitHub, you’ll notice a little “Verified” badge next to commits that are signed properly. It’s a quick way to show that the commit is authentic.&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-11-17/verified-commit-example.jpg" alt="blog-cover" />&lt;/p>
&lt;h2 id="why-are-they-important">Why Are They Important?
&lt;a class="heading-anchor" href="#why-are-they-important" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Signed commits help keep your contributions authentic and trustworthy. By adding a cryptographic signature to your commits, you prove that the changes came from you. This is especially important in collaborative environments, where maintaining trust and accountability is key.&lt;/p>
&lt;p>Without signed commits, anyone could fake a commit using someone else’s email. For example, they could use your email, and platforms like GitHub would link it to your profile, making it look like you made the changes, even if you didn’t… not good!&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-11-17/impersonating-commit.jpg" alt="blog-cover" />&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-11-17/impersonating-commit4.webp" alt="blog-cover" />&lt;/p>
&lt;p>By signing your commits, you show that the work is genuinely yours. It stops impersonation, builds trust in what you’ve done, and keeps everything transparent and accountable.&lt;/p>
&lt;blockquote>
&lt;p>&lt;small>Note: For this demo, I used a public email address belonging to Linus Torvalds. After pushing the commit to this repository, GitHub recognized the email and linked it to his profile. This impersonation is purely for demo purposes to highlight potential risks. Always use your own email for commits.&lt;/small>&lt;/p>
&lt;/blockquote>
&lt;hr />
&lt;h2 id="how-to-get-started-with-verified-commits">How to get started with verified commits
&lt;a class="heading-anchor" href="#how-to-get-started-with-verified-commits" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="set-up-a-gpg-key">Set up a GPG key
&lt;a class="heading-anchor" href="#set-up-a-gpg-key" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>First, you’ll need a GPG key to start signing commits. Here’s how:&lt;/p>
&lt;p>Generate a GPG key:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">gpg&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-full-generate-key&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>Find your key ID:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">gpg&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-list-secret-keys&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-keyid-format=long&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>Tell Git to use your key:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">git&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> config&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-global&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> user.signingkey&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">your-key-i&lt;/span>&lt;span>d&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>Make signing commits the default:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">git&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> config&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-global&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> commit.gpgsign&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> true&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;h3 id="add-your-key-to-github-gitlab">Add your key to &lt;a rel="external" href="https://github.com/settings/keys">GitHub&lt;/a>/&lt;a rel="external" href="https://docs.gitlab.com/user/project/repository/signed_commits/gpg/">GitLab&lt;/a>
&lt;a class="heading-anchor" href="#add-your-key-to-github-gitlab" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Export your public key:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">gpg&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-armor&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-export&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">your-key-i&lt;/span>&lt;span>d&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>Navigate to “Settings &amp;gt; SSH and GPG keys,” and paste your key.&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-11-17/gpg-keys.jpg" alt="blog-cover" />&lt;/p>
&lt;h3 id="start-signing-commits">Start signing commits
&lt;a class="heading-anchor" href="#start-signing-commits" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>From now on, Git will automatically sign your commits.&lt;/p>
&lt;p>If you want to sign a commit manually, just use the &lt;code>-S&lt;/code> flag:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">git&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> commit&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">S&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">m&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> &amp;quot;&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">Your commit message&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);">&amp;quot;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>You can &lt;strong>verify&lt;/strong> the commit signature with:&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">git&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> log&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-show-signature&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>And also when clicking on the “Verified” badge on GitHub directly.&lt;/p>
&lt;p>&lt;img src="/images/blog/2024-11-17/gpg-verify.jpg" alt="blog-cover" />&lt;/p>
&lt;p>Verified commits might seem like a small step, but they make your code more trustworthy. It’s an easy way to add an extra layer of protection to your work, and it’s worth it. Give it a try!&lt;/p>
&lt;hr />
&lt;h3 id="extra-full-setup-in-spanish-es">Extra: Full setup in Spanish 🇪🇸
&lt;a class="heading-anchor" href="#extra-full-setup-in-spanish-es" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/0DzQBu7U2f4"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;hr />
&lt;p>&lt;strong>Related links&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Learn more: &lt;a href="/pgp">What is PGP encryption?&lt;/a> &lt;small>A 3-minute tutorial for beginners&lt;/small>&lt;/li>
&lt;/ul></content></entry><entry xml:lang="en"><title>Pretty Good Privacy</title><subtitle>How PGP secures your digital communication</subtitle><category term="security" scheme="https://chemaclass.com/tags/security/" label="Security"/><category term="privacy" scheme="https://chemaclass.com/tags/privacy/" label="Privacy"/><category term="cryptography" scheme="https://chemaclass.com/tags/cryptography/" label="Cryptography"/><published>2024-07-13T00:00:00+00:00</published><updated>2024-07-13T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/pretty-good-privacy/"/><id>https://chemaclass.com/blog/pretty-good-privacy/</id><summary type="html">PGP is an encryption program that ensures privacy and authentication for data communication. It is used for signing, encrypting, and decrypting texts, emails, files, directories, and whole disk partitions, enhancing the security of email communications.</summary><content type="html">&lt;p>PGP (&lt;em>Pretty Good Privacy&lt;/em>) is an encryption program that ensures privacy and authentication for data communication. It is used for signing, encrypting, and decrypting texts, emails, files, directories, and whole disk partitions.&lt;/p>
&lt;span id="continue-reading">&lt;/span>&lt;h2 id="history">History
&lt;a class="heading-anchor" href="#history" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>PGP was developed by &lt;a rel="external" href="https://en.wikipedia.org/wiki/Phil_Zimmermann">Phil Zimmermann&lt;/a> out of concern for the lack of privacy in digital communications. He aimed to provide individuals with strong encryption tools. In 1991, PGP was released to the public for free, marking the beginning of a new era in digital security.&lt;/p>
&lt;h3 id="legal-challenges">Legal Challenges
&lt;a class="heading-anchor" href="#legal-challenges" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>In the early 1990s, strong encryption was classified as a weapon under U.S. export law. When PGP spread globally via the internet, Zimmermann faced a criminal investigation for “exporting munitions.”&lt;/p>
&lt;p>His defense was clever: he published the PGP source code in a book. Books are protected speech. The case was dropped in 1996, and encryption export restrictions were eventually relaxed in 2000.&lt;/p>
&lt;hr />
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/1-MPcUHhXoc"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;h2 id="key-features">Key Features
&lt;a class="heading-anchor" href="#key-features" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>Encrypts and decrypts data to ensure secure communication&lt;/li>
&lt;li>Provides authentication to verify the identity of senders and receivers&lt;/li>
&lt;li>Generates public and private keys for secure key exchange&lt;/li>
&lt;li>Supports various encryption algorithms and hash functions&lt;/li>
&lt;/ul>
&lt;p>Today, PGP lives on as &lt;strong>OpenPGP&lt;/strong> (the standard) and &lt;strong>GPG&lt;/strong> (GNU Privacy Guard, the free implementation). When you verify a software download or sign a git commit, you’re often using GPG.&lt;/p>
&lt;h2 id="how-it-works">How it works
&lt;a class="heading-anchor" href="#how-it-works" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>PGP uses a combination of &lt;a rel="external" href="https://en.wikipedia.org/wiki/Public-key_cryptography">public-key&lt;/a> and &lt;a rel="external" href="https://en.wikipedia.org/wiki/Symmetric-key_algorithm">symmetric-key&lt;/a> to ensure secure data transmission. It generates a keypair consisting of a public key and a private key. The public key is shared with others, while the private key is kept secret. When data is encrypted, it is encrypted with the public key, and only the corresponding private key can decrypt it.&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Symmetric Key Encryption&lt;/strong>: PGP generates a unique, one-time-use session key to encrypt the message. This method is fast and efficient but requires the sender and recipient to share the same key securely.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Asymmetric Key Encryption&lt;/strong>: PGP solves the key exchange problem with asymmetric encryption. Each user has a public key and a private key. The session key is encrypted with the recipient’s public key and can only be decrypted by the recipient’s private key.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Digital Signatures&lt;/strong>: PGP provides authentication through digital signatures. The sender signs the message with their private key, allowing the recipient to verify the sender’s identity using the sender’s public key, ensuring the message has not been tampered with.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/Lq-yKJFHJpk"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;hr />
&lt;h2 id="my-public-key">My public key
&lt;a class="heading-anchor" href="#my-public-key" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="fingerprint">Fingerprint
&lt;a class="heading-anchor" href="#fingerprint" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="plain">&lt;span class="giallo-l">&lt;span>56D5 D60B 0934 0999 199C 3750 E51B 5BF4 5F85 D160&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;h3 id="import-directly">Import directly
&lt;a class="heading-anchor" href="#import-directly" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="shellscript">&lt;span class="giallo-l">&lt;span style="color: light-dark(#6F42C1, #B392F0);">curl&lt;/span>&lt;span style="color: light-dark(#032F62, #9ECBFF);"> https://chemaclass.com/pgp.asc&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> |&lt;/span>&lt;span style="color: light-dark(#6F42C1, #B392F0);"> gpg&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> -&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">-import&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;h3 id="download-the-asc-file">Download the .asc file
&lt;a class="heading-anchor" href="#download-the-asc-file" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>&lt;a href="/pgp.asc" id="download-link">Download public PGP key&lt;/a>&lt;/p></content></entry><entry xml:lang="en"><title>Programmable Money</title><subtitle>The power of Bitcoin's Script</subtitle><category term="bitcoin" scheme="https://chemaclass.com/tags/bitcoin/" label="Bitcoin"/><category term="software" scheme="https://chemaclass.com/tags/software/" label="Software"/><category term="cryptography" scheme="https://chemaclass.com/tags/cryptography/" label="Cryptography"/><category term="security" scheme="https://chemaclass.com/tags/security/" label="Security"/><published>2024-07-06T00:00:00+00:00</published><updated>2024-07-06T00:00:00+00:00</updated><author><name>
Chemaclass</name></author><link rel="alternate" type="text/html" href="https://chemaclass.com/blog/programmable-money/"/><id>https://chemaclass.com/blog/programmable-money/</id><summary type="html">Bitcoin is often referred to as programmable money because it allows for the execution of programmable transactions through its scripting language, leveraging each bit for precision and functionality.</summary><content type="html">&lt;p>Bitcoin is often referred to as “programmable money” because it allows for the execution of programmable transactions through its scripting language.&lt;/p>
&lt;span id="continue-reading">&lt;/span>&lt;h2 id="understanding-programmable-money">Understanding Programmable Money
&lt;a class="heading-anchor" href="#understanding-programmable-money" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Programmable money is the ability to embed logic and conditions into financial transactions. This programmability allows transactions to be executed automatically based on predefined rules without intermediaries or manual intervention. It transforms money from a static medium of exchange into a dynamic tool capable of executing complex agreements and automating financial operations.&lt;/p>
&lt;h2 id="the-script-language">The Script Language
&lt;a class="heading-anchor" href="#the-script-language" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>Bitcoin’s programmability is powered by its built-in scripting language, &lt;a rel="external" href="https://en.bitcoin.it/wiki/Script">&lt;strong>Script&lt;/strong>&lt;/a>. Unlike traditional programming languages, Script is a stack-based, Forth-like language explicitly designed for Bitcoin transactions.&lt;/p>
&lt;p>It supports multi-signature, time-locked, and other conditional transfers that can be programmed into Bitcoin transactions. It is intentionally not Turing-complete, without loops.&lt;/p>
&lt;p>This video includes examples of the most commonly used locking/unlocking scripts.&lt;/p>
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/6Fa04MnURhw"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;h2 id="key-features-of-bitcoin-s-script">Key Features of Bitcoin’s Script
&lt;a class="heading-anchor" href="#key-features-of-bitcoin-s-script" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;h3 id="stack-based-execution">Stack-Based Execution
&lt;a class="heading-anchor" href="#stack-based-execution" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Script operates on a stack-based execution model where commands and data are pushed onto a stack and processed in a Last-In-First-Out (&lt;a rel="external" href="https://en.wikipedia.org/wiki/Stack_(abstract_data_type)">LIFO&lt;/a>) manner.&lt;/p>
&lt;h3 id="conditional-spending">Conditional Spending
&lt;a class="heading-anchor" href="#conditional-spending" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>A transaction that can only be spent if certain data is provided or specific criteria are met. This can be used for:&lt;/p>
&lt;ul>
&lt;li>escrow services&lt;/li>
&lt;li>atomic swaps&lt;/li>
&lt;li>and other complex financial arrangements&lt;/li>
&lt;/ul>
&lt;h3 id="multisignature">Multisignature
&lt;a class="heading-anchor" href="#multisignature" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Transactions can be set up to require multiple signatures from different private keys before they can be spent. Useful for:&lt;/p>
&lt;ul>
&lt;li>joint accounts&lt;/li>
&lt;li>corporate funds&lt;/li>
&lt;li>and enhancing security, as no single party can unilaterally spend the funds&lt;/li>
&lt;/ul>
&lt;h3 id="timelocking">Timelocking
&lt;a class="heading-anchor" href="#timelocking" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Transactions can include time-based conditions that prevent them from being spent until a certain time or block height is reached. This feature is useful for various purposes:&lt;/p>
&lt;ul>
&lt;li>delayed payments&lt;/li>
&lt;li>smart contracts&lt;/li>
&lt;li>and ensuring that funds are not spent prematurely (eg: with &lt;a rel="external" href="https://en.bitcoin.it/wiki/Lightning_Network">Lightning Network&lt;/a>)&lt;/li>
&lt;/ul>
&lt;h3 id="operation-codes">Operation Codes
&lt;a class="heading-anchor" href="#operation-codes" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>Bitcoin’s Script performs specific operations within transactions with its &lt;a rel="external" href="https://en.bitcoin.it/wiki/Script#Opcodes">OP_Codes&lt;/a>. Here are some of them:&lt;/p>
&lt;ul>
&lt;li>&lt;code>OP_DUP&lt;/code>: &lt;small>Duplicates the top stack item.&lt;/small>&lt;/li>
&lt;li>&lt;code>OP_HASH160&lt;/code>: &lt;small>Hashes the top stack item twice (SHA-256 followed by RIPEMD-160).&lt;/small>&lt;/li>
&lt;li>&lt;code>OP_EQUALVERIFY&lt;/code>: &lt;small>Verifies that the top two items are equal and removes them.&lt;/small>&lt;/li>
&lt;li>&lt;code>OP_CHECKSIG&lt;/code>: &lt;small>Verifies a signature against a public key.&lt;/small>&lt;/li>
&lt;li>&lt;a rel="external" href="https://en.bitcoin.it/wiki/OP_RETURN">&lt;code>OP_RETURN&lt;/code>&lt;/a>: &lt;small>Marks the transaction output as invalid, often used to store data.&lt;/small>&lt;/li>
&lt;/ul>
&lt;hr />
&lt;h2 id="common-bitcoin-address-types">Common Bitcoin address types
&lt;a class="heading-anchor" href="#common-bitcoin-address-types" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;p>In Bitcoin, different address types correspond to various ways to script transactions. Here, we’ll explore examples of Bitcoin Script for each major address type. Each address type has its own specific script format.&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2pk-pay-to-pubkey-earliest-legacy-address-up">&lt;strong>P2PK&lt;/strong>&lt;/a>: Earliest legacy transactions using full public keys directly.&lt;/li>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2pkh-pay-to-pubkey-hash-legacy-address-up">&lt;strong>P2PKH&lt;/strong>&lt;/a>: Begins with &lt;code>1&lt;/code>. &lt;strong>Legacy&lt;/strong> transactions using public key hashes.&lt;/li>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2sh-pay-to-script-hash-up">&lt;strong>P2SH&lt;/strong>&lt;/a>: Begins with &lt;code>3&lt;/code>. &lt;strong>Legacy&lt;/strong>, encapsulates complex scripts like multisig.&lt;/li>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2ms-pay-to-multisig-up">&lt;strong>P2MS&lt;/strong>&lt;/a>: It is typically a type of P2SH or P2WSH address.&lt;/li>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2wpkh-pay-to-witness-public-key-hash-segwit-up">&lt;strong>P2WPKH&lt;/strong>&lt;/a>: Begins with &lt;code>bc1&lt;/code>. Native &lt;strong>SegWit&lt;/strong>, more efficient transactions.&lt;/li>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2wsh-pay-to-witness-script-hash-segwit-up">&lt;strong>P2WSH&lt;/strong>&lt;/a>: Begins with &lt;code>bc1&lt;/code>. &lt;strong>SegWit&lt;/strong> for complex scripts.&lt;/li>
&lt;li>&lt;a href="https://chemaclass.com/blog/programmable-money/#p2tr-pay-to-taproot-taproot-up">&lt;strong>P2TR&lt;/strong>&lt;/a>: Begins with &lt;code>bc1p&lt;/code>. SegWit &lt;strong>Taproot&lt;/strong> addresses, improving privacy and efficiency for complex transactions.&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>Using native SegWit (P2WPKH and P2WSH) is preferable when possible, as it maximizes the benefits of the SegWit upgrade, but P2SH-SegWit can be useful for compatibility with older systems.&lt;/p>
&lt;/blockquote>
&lt;h3 id="p2pk-pay-to-pubkey-earliest-legacy-address-up">P2PK (Pay-to-PubKey) - Earliest Legacy Address &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2pk-pay-to-pubkey-earliest-legacy-address-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div class="status info">
Begins with "1" (e.g., 1A1zP1eP5QGefi2DMPTf...v7DivfNa)
&lt;/div>
&lt;p>Before P2PKH and P2SH became standard, Bitcoin addresses were not as flexible or feature-rich. Here are some considerations:&lt;/p>
&lt;ul>
&lt;li>Addresses starting with 1 but without hashing the public key.&lt;/li>
&lt;li>Not common in modern practice due to lack of privacy and efficiency.&lt;/li>
&lt;li>The P2PK format is largely &lt;strong>obsolete&lt;/strong> in favor of (at very least) P2PKH.&lt;/li>
&lt;/ul>
&lt;hr />
&lt;h3 id="p2pkh-pay-to-pubkey-hash-legacy-address-up">P2PKH (Pay-to-PubKey-Hash) - Legacy Address &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2pkh-pay-to-pubkey-hash-legacy-address-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div class="status info">
Begins with "1" (e.g., 1A1zP1eP5QGefi2DMPTf...v7DivfNa)
&lt;/div>
&lt;p>A typical P2PKH script consists of two main parts:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>ScriptPubKey&lt;/strong>: The locking script (also known as the output script) that specifies how funds can be spent.&lt;/li>
&lt;li>&lt;strong>ScriptSig&lt;/strong>: The unlocking script (also known as the input script) that provides the necessary data to unlock the funds.&lt;/li>
&lt;/ol>
&lt;h3 id="scriptpubkey-locking-script">ScriptPubKey (Locking Script)
&lt;a class="heading-anchor" href="#scriptpubkey-locking-script" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_DUP&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_HASH160&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubKHash&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_EQUALVERIFY&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_CHECKSIG&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>OP_DUP&lt;/code>: Duplicates the top stack item (the public key).&lt;/li>
&lt;li>&lt;code>OP_HASH160&lt;/code>: Hashes the public key with SHA-256 followed by RIPEMD-160.&lt;/li>
&lt;li>&lt;code>&amp;lt;PubKHash&amp;gt;&lt;/code>: The hashed public key (a 20-byte value).&lt;/li>
&lt;li>&lt;code>OP_EQUALVERIFY&lt;/code>: Checks if the hashed public key matches the hash in the script.&lt;/li>
&lt;li>&lt;code>OP_CHECKSIG&lt;/code>: Verifies the provided signature against the public key.&lt;/li>
&lt;/ul>
&lt;h3 id="scriptsig-unlocking-script">ScriptSig (Unlocking Script)
&lt;a class="heading-anchor" href="#scriptsig-unlocking-script" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>&amp;lt;sig&amp;gt;&lt;/code>: The digital signature generated by the private key.&lt;/li>
&lt;li>&lt;code>&amp;lt;PubK&amp;gt;&lt;/code>: The public key corresponding to the address.&lt;/li>
&lt;/ul>
&lt;h3 id="execution-flow">Execution Flow
&lt;a class="heading-anchor" href="#execution-flow" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;ol>
&lt;li>The &lt;code>ScriptSig&lt;/code> (unlocking script) is pushed onto the stack.&lt;/li>
&lt;li>The &lt;code>ScriptPubKey&lt;/code> (locking script) is executed.&lt;/li>
&lt;/ol>
&lt;p>&lt;img src="https://raw.githubusercontent.com/bitcoinbook/bitcoinbook/develop/images/mbc3_0703.png" alt="p2pkh script execution step 1" />
&lt;img src="https://raw.githubusercontent.com/bitcoinbook/bitcoinbook/develop/images/mbc3_0704.png" alt="p2pkh script execution step 2" />&lt;/p>
&lt;hr />
&lt;h3 id="p2sh-pay-to-script-hash-up">P2SH (Pay-to-Script-Hash) &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2sh-pay-to-script-hash-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div class="status info">
Begins with "3" (e.g., 3J2BtwzN2GEr6FCP.....81T2eiX8PVHh)
&lt;/div>
&lt;p>P2SH scripts are used for more complex scripts. The primary feature is that the address itself encodes a hash of a script, which will be used in the transaction.&lt;/p>
&lt;h3 id="scriptpubkey-locking-script-1">ScriptPubKey (Locking Script)
&lt;a class="heading-anchor" href="#scriptpubkey-locking-script-1" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_HASH160&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">ScriptHash&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_EQUAL&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>OP_HASH160&lt;/code>: Hashes the script with SHA-256 followed by RIPEMD-160.&lt;/li>
&lt;li>&lt;code>&amp;lt;ScriptHash&amp;gt;&lt;/code>: The hashed script (a 20-byte value).&lt;/li>
&lt;li>&lt;code>OP_EQUAL&lt;/code>: Checks if the hash matches the provided script hash.&lt;/li>
&lt;/ul>
&lt;h3 id="scriptsig-unlocking-script-1">ScriptSig (Unlocking Script)
&lt;a class="heading-anchor" href="#scriptsig-unlocking-script-1" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> ...&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">ScriptSig&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>&amp;lt;sig&amp;gt;&lt;/code>: The digital signature.&lt;/li>
&lt;li>&lt;code>&amp;lt;PubK&amp;gt;&lt;/code>: The public key.&lt;/li>
&lt;li>&lt;code>&amp;lt;ScriptSig&amp;gt;&lt;/code>: The actual script that matches the script hash, which itself will be executed by the Bitcoin network.&lt;/li>
&lt;/ul>
&lt;hr />
&lt;h3 id="p2ms-pay-to-multisig-up">P2MS (Pay-to-Multisig) &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2ms-pay-to-multisig-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;h3 id="script-format">Script Format
&lt;a class="heading-anchor" href="#script-format" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_M&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">M&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK1&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> ...&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubKN&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_N&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_CHECKMULTISIG&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>OP_M&lt;/code>: The minimum number of signatures required.&lt;/li>
&lt;li>&lt;code>&amp;lt;PubK1&amp;gt;, &amp;lt;PubK2&amp;gt;, ..., &amp;lt;PubKN&amp;gt;&lt;/code>: The public keys involved in the multisignature scheme.&lt;/li>
&lt;li>&lt;code>OP_N&lt;/code>: The total number of public keys provided.&lt;/li>
&lt;li>&lt;code>OP_CHECKMULTISIG&lt;/code>: The opcode that verifies the signatures against the provided public keys.&lt;/li>
&lt;/ul>
&lt;h3 id="scriptpubkey-locking-script-2">ScriptPubKey (Locking Script)
&lt;a class="heading-anchor" href="#scriptpubkey-locking-script-2" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK1&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK3&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_3&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_CHECKMULTISIG&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>This script means that any 2 out of 3 provided public keys are required to sign the transaction for it to be valid.&lt;/p>
&lt;h3 id="scriptsig-unlocking-script-2">ScriptSig (Unlocking Script)
&lt;a class="heading-anchor" href="#scriptsig-unlocking-script-2" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig1&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> ...&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sigN&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">SerializedScript&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>&amp;lt;sig1&amp;gt;, &amp;lt;sig2&amp;gt;, ..., &amp;lt;sigN&amp;gt;&lt;/code>: The public keys.&lt;/li>
&lt;li>&lt;code>&amp;lt;SerializedScript&amp;gt;&lt;/code>: The serialized script (the same as the locking script but without the &lt;code>OP_M&lt;/code> and &lt;code>OP_N&lt;/code>).&lt;/li>
&lt;/ul>
&lt;div class="status warning-orange">
&lt;b>NOTE&lt;/b>: There is an oddity in CHECKMULTISIG execution.
&lt;small>&lt;a href="#there-is-an-oddity-in-checkmultisig-execution-up">See note at the bottom.&lt;/a>&lt;/small>
&lt;/div>
&lt;hr />
&lt;h3 id="p2wpkh-pay-to-witness-public-key-hash-segwit-up">P2WPKH (Pay-to-Witness-Public-Key-Hash) - Segwit &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2wpkh-pay-to-witness-public-key-hash-segwit-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div class="status info">
Begins with "bc1q" (e.g., bc1qf0r2m0ck4psv6yrk9w.....kw8v5rj7ph3)
&lt;/div>
&lt;p>P2WPKH is a Segregated Witness (SegWit) address type that uses a different scripting format compared to legacy and P2SH addresses. Simplifies transactions by reducing data size and fees compared to legacy formats.&lt;/p>
&lt;h3 id="scriptpubkey-locking-script-3">ScriptPubKey (Locking Script)
&lt;a class="heading-anchor" href="#scriptpubkey-locking-script-3" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_0&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_PUSHBYTES_20&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubKHash&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>OP_0&lt;/code>: A single byte (0x00) indicating the version of the script.&lt;/li>
&lt;li>&lt;code>OP_PUSHBYTES_20&lt;/code>: Pushes 20 bytes (the public key hash) onto the stack.&lt;/li>
&lt;li>&lt;code>&amp;lt;PubKHash&amp;gt;&lt;/code>: The 20-byte hash of the public key.&lt;/li>
&lt;/ul>
&lt;h3 id="witness-data">Witness Data
&lt;a class="heading-anchor" href="#witness-data" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>For P2WPKH, the unlocking script is not required in the traditional sense (i.e., inside the unlocking script explicitly included in the transaction input). Instead, the unlocking information is provided as part of the witness data in the SegWit transaction format.&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>&amp;lt;sig&amp;gt;&lt;/code>: Digital signature for the transaction.&lt;/li>
&lt;li>&lt;code>&amp;lt;PubK&amp;gt;&lt;/code>: Public key used to generate the public key hash.&lt;/li>
&lt;/ul>
&lt;hr />
&lt;h3 id="p2wsh-pay-to-witness-script-hash-segwit-up">P2WSH (Pay-to-Witness-Script-Hash) - Segwit &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2wsh-pay-to-witness-script-hash-segwit-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div class="status info">
Begins with bc1q (e.g.: bc1q4a3h5sdg4cfkhftgd24tj9g2sg...yj57jmfckhkrw5gslr9g59)
&lt;/div>
&lt;h3 id="scriptpubkey-locking-script-4">ScriptPubKey (Locking Script)
&lt;a class="heading-anchor" href="#scriptpubkey-locking-script-4" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_0&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_PUSHBYTES_32&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">ScriptHash&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>OP_0&lt;/code>: Indicates a witness version 0 (SegWit).&lt;/li>
&lt;li>&lt;code>OP_PUSHBYTES_32&lt;/code>: Pushes the next 32 bytes (the script hash) onto the stack.&lt;/li>
&lt;li>&lt;code>&amp;lt;ScriptHash&amp;gt;&lt;/code>: 32-byte hash of the redeem script.&lt;/li>
&lt;/ul>
&lt;h3 id="witness-data-1">Witness Data
&lt;a class="heading-anchor" href="#witness-data-1" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig1&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> ...&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">RedeemScript&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>&amp;lt;sig1&amp;gt;, &amp;lt;sig2&amp;gt;&lt;/code>: Signatures required to unlock the transaction.&lt;/li>
&lt;li>&lt;code>&amp;lt;RedeemScript&amp;gt;&lt;/code>: The actual script that matches the script hash. This script will be executed as part of the witness data.&lt;/li>
&lt;/ul>
&lt;hr />
&lt;h3 id="p2tr-pay-to-taproot-taproot-up">P2TR (Pay-to-Taproot) - Taproot &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#common-bitcoin-address-types">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#p2tr-pay-to-taproot-taproot-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;div class="status info">
Begins with bc1p (e.g.: bc1pl9dfv7kvj4hj9s3a8l.....gjstmrpjl09g8ks3ukds70q4r2j5h)
&lt;/div>
&lt;p>Taproot combines &lt;a rel="external" href="https://en.bitcoin.it/wiki/Schnorr">Schnorr&lt;/a> signatures with &lt;a rel="external" href="https://en.bitcoin.it/wiki/BIP_0114#Merkelized_Abstract_Syntax_Tree">MAST&lt;/a>, enabling private, efficient spending conditions and making complex transactions &lt;strong>&lt;em>appear standard&lt;/em>&lt;/strong> unless conditions are revealed. It allows the efficient execution of complex transactions while hiding their details.&lt;/p>
&lt;h3 id="scriptpubkey-locking-script-5">ScriptPubKey (Locking Script)
&lt;a class="heading-anchor" href="#scriptpubkey-locking-script-5" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_1&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">x&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">-&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">only&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> PubK&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>OP_1&lt;/code>: Indicates a witness version 1 (Taproot).&lt;/li>
&lt;li>&lt;code>&amp;lt;x-only PubK&amp;gt;&lt;/code>: A 32-byte Schnorr public key (without the y-coordinate).&lt;/li>
&lt;/ul>
&lt;h3 id="witness-data-2">Witness Data
&lt;a class="heading-anchor" href="#witness-data-2" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;ul>
&lt;li>&lt;code>&amp;lt;sig&amp;gt;&lt;/code>: A Schnorr signature proving possession of the private key corresponding to the x-only pubkey.&lt;/li>
&lt;/ul>
&lt;hr />
&lt;div style="position:relative;aspect-ratio:16/9;width:100%;">
&lt;iframe
src="https://www.youtube-nocookie.com/embed/yU3Sr07Qnxg"
title="YouTube video"
width="560"
height="315"
loading="lazy"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
referrerpolicy="strict-origin-when-cross-origin"
style="position:absolute;inset:0;width:100%;height:100%;border:0;"
allowfullscreen>
&lt;/iframe>
&lt;/div>
&lt;hr />
&lt;h3 id="there-is-an-oddity-in-checkmultisig-execution-up">*There is an oddity in CHECKMULTISIG execution &lt;small>&lt;a href="https://chemaclass.com/blog/programmable-money/#scriptsig-unlocking-script-2">up&lt;/a>&lt;/small>
&lt;a class="heading-anchor" href="#there-is-an-oddity-in-checkmultisig-execution-up" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h3>
&lt;p>The implementation of &lt;code>OP_CHECKMULTISIG&lt;/code> pops one more item than it should. The extra item is disregarded when checking the signatures, so it has no direct effect on the OP itself. It must be present because if &lt;code>OP_CHECKMULTISIG&lt;/code> attempts to pop on an empty stack, it will cause a stack error and script failure.&lt;/p>
&lt;pre class="giallo" style="color-scheme: light dark; color: light-dark(#24292E, #E1E4E8); background-color: light-dark(#FFFFFF, #24292E);">&lt;code data-lang="php">&lt;span class="giallo-l">&lt;span style="color: light-dark(#005CC5, #79B8FF);">OP_0&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">sig3&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> 2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK1&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK2&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);"> &amp;lt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);">PubK3&lt;/span>&lt;span style="color: light-dark(#D73A49, #F97583);">&amp;gt;&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> 3&lt;/span>&lt;span style="color: light-dark(#005CC5, #79B8FF);"> OP_CHECKMULTISIG&lt;/span>&lt;/span>&lt;/code>&lt;/pre>
&lt;p>The input script in this multisig is not &lt;code>&amp;lt;sig2&amp;gt; &amp;lt;sig3&amp;gt;&lt;/code> but &lt;code>OP_0 &amp;lt;sig2&amp;gt; &amp;lt;sig3&amp;gt;&lt;/code>.&lt;/p>
&lt;p>It became the custom early on to use &lt;code>OP_0&lt;/code>, which later became a relay policy rule and eventually a consensus rule (&lt;a rel="external" href="https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki">BIP147&lt;/a>).&lt;/p>
&lt;p>It is possible that the original developer added the extra element in the original version of Bitcoin, so they could add a feature for allowing a map to be passed in a later soft fork (for performance reasons). However, that feature was never implemented, and the BIP147 update to the consensus rules in 2017 makes it impossible to add that feature in the future.&lt;/p>
&lt;p>Only Bitcoin’s original developer could tell whether the dummy stack element was the result of a bug or a plan for a future upgrade. From now on, if you see a multisig script, you should expect to see an extra &lt;code>OP_O&lt;/code> in the beginning, whose only purpose is as a workaround to an oddity in the consensus rules.&lt;/p>
&lt;hr />
&lt;h2 id="follow-ups">Follow-ups
&lt;a class="heading-anchor" href="#follow-ups" title="Copy link" aria-label="Link to this section">#&lt;/a>
&lt;/h2>
&lt;ul>
&lt;li>Official docs of &lt;a rel="external" href="https://en.bitcoin.it/wiki/Script">Script&lt;/a> in the Bitcoin Wiki.&lt;/li>
&lt;li>&lt;a rel="external" href="https://siminchen.github.io/bitcoinIDE/build/editor.html">Bitcoin IDE&lt;/a> is an online Bitcoin Script visual emulator. Great for learning purposes.&lt;/li>
&lt;li>&lt;a rel="external" href="https://coins.github.io/bitcoin-scripts/script-editor/">Script Editor&lt;/a> is product-driven research on Bitcoin scalability and usability.&lt;/li>
&lt;li>&lt;a rel="external" href="https://bitcoin.sipa.be/miniscript/">Miniscript&lt;/a> is a language for writing (a subset of) Bitcoin Scripts in a structured way, enabling analysis, composition, generic signing, and more.&lt;/li>
&lt;/ul></content></entry></feed>