<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://pmanderson.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://pmanderson.dev/" rel="alternate" type="text/html" /><updated>2026-05-26T17:42:38+00:00</updated><id>https://pmanderson.dev/feed.xml</id><title type="html">Patrick Anderson</title><subtitle>Engineering leader, occasional writer. Based in Seattle.</subtitle><author><name>Patrick Anderson</name></author><entry><title type="html">Building Ledger: A Personal Finance App Built With Claude</title><link href="https://pmanderson.dev/software/Building-Ledger/" rel="alternate" type="text/html" title="Building Ledger: A Personal Finance App Built With Claude" /><published>2026-05-19T00:00:00+00:00</published><updated>2026-05-19T00:00:00+00:00</updated><id>https://pmanderson.dev/software/Building-Ledger</id><content type="html" xml:base="https://pmanderson.dev/software/Building-Ledger/"><![CDATA[<p>This site exists, per my own about page, as a vehicle for me to explore and organize things I’ve learned by writing about them. This post is about building Ledger, a self-hosted personal finance dashboard, and what I learned doing it almost entirely with Claude as a development partner.</p>

<p>For a few years my wife and I tracked our finances using a Google Sheet built by Money With Katie, a personal finance resource connected to Morning Brew where my wife works. It was a great starting point - got us paying attention to our finances and actually talking about money in a useful way. I’d recommend it to anyone getting started.</p>

<p>After three years the cracks started to show - not in the spreadsheet, but in how we were using it. Our priorities had shifted toward investment tracking: allocations, savings rate, risk exposure across a portfolio. The spreadsheet had a lot of machinery for things we didn’t need anymore and not enough of what we did: a macro view of net worth, portfolio composition, and savings rate over time. The monthly update also took about an hour. Too many accounts, tedious entry, and we kept putting it off until we stopped altogether.</p>

<p>My first instinct was to hack the spreadsheet apart. I spent about 45 minutes on this before giving up and deciding to build something from scratch. And since I wanted to use this as a testbed for working more seriously with AI assisted development - something increasingly relevant professionally - I treated it as an opportunity to figure out how to build something real with Claude rather than just using it as a smarter autocomplete.</p>

<h1 id="the-process">The Process</h1>

<h2 id="planning-before-building">Planning Before Building</h2>

<p>The first thing I did was not write any code. On walks with my dog I had planning conversations with Claude in a Project. Brain dumps about what I wanted, what I disliked about existing finance tools, what features were necessary vs. not. Claude interviewed me, I rambled, we worked backward toward requirements.</p>

<p>Those requirements got formalized into a PRD that lived in the repo. Not just features but constraints:</p>

<ul>
  <li><strong>Tech stack:</strong> Python and Flask. Things I’ve worked with and can read.</li>
  <li><strong>Code structure:</strong> How the project should be organized, what patterns to follow.</li>
  <li><strong>Framework decisions:</strong> Claude helped evaluate options. We landed on Bootstrap 5.</li>
</ul>

<p>The goal was that by the time an agent was writing code it had enough context to not produce something unreadable or architecturally bizarre.</p>

<h2 id="iterative-development">Iterative Development</h2>

<p>From there:</p>

<ol>
  <li>Build something minimal</li>
  <li>Get it running, use it</li>
  <li>Note what’s missing or broken</li>
  <li>Planning conversation to scope the fix or feature</li>
  <li>Build it</li>
  <li>Repeat</li>
</ol>

<p>The UI went through a few passes. I’d look at Fidelity, Schwab, Wealthfront - not to copy them but to understand what information hierarchies made sense for finance dashboards. Feed those observations back into planning sessions, do some rough mocking, land on something I liked.</p>

<p>I also ran agent “personas” to critique the product - a financial advisor, a high net worth individual, a UI/UX designer. The financial advisor and HNW personas were useful for identifying requirements around net worth projections, FI calculations, and industry standard approaches I wasn’t familiar with. The UI/UX designer surfaced interface patterns and practices I wouldn’t have thought to include. More on this below.</p>

<p>When I started using the app for real I kept a running dialogue in the same chat context. “This is what I noticed. Here’s what I don’t like. Here’s what I want.” That became the backlog. Prioritize with the agent, let it execute.</p>

<h2 id="shipping-from-a-phone">Shipping from a Phone</h2>

<p>With a newborn, sitting down at a laptop for hobby projects essentially stopped being an option. I was on paternity leave at a moment when AI tooling was moving fast and I wanted something more engaging to do during contact naps than watch TV - so by necessity, essentially all of this development happened on my phone. Claude helped me set up CI/CD scripts so the Raspberry Pi serving the app would pick up changes from GitHub and automatically redeploy. That meant I could start a development session from my phone, describe what I wanted, review a PR, and see the result running on the home network within minutes - no laptop required.</p>

<p>The other thing I hadn’t anticipated: you can offload more than just the interesting work. I’d been treating Claude as a tool for creative and architectural tasks - feature design, planning, writing code. What I hadn’t done was hand over the friction tasks: debugging, log triage, merge conflicts. All of those are things the model can handle when it already has the codebase and PR context loaded. Once I started doing that, I stopped having backlogs of unmerged branches and undiagnosed errors sitting around waiting for me to find time at a computer.</p>

<h1 id="what-i-built-and-what-i-didnt">What I Built (And What I Didn’t)</h1>

<h2 id="the-app">The App</h2>

<p><img src="https://pmanderson.dev/assets/images/ledger_hero.png" alt="Ledger Dashboard" class="align-center" /></p>

<p>Ledger is a self-hosted personal finance dashboard. Monthly net worth tracking across account types (cash, retirement, investments, real estate, mortgage) with calculated metrics for savings rate and net worth change. There’s a holdings system for tracking individual securities, a projections view for modeling portfolio growth and FI timeline, and a dividends view for understanding portfolio income.</p>

<p><img src="https://pmanderson.dev/assets/images/ledger_projections.png" alt="Projections — Path to FI" class="align-center" /></p>

<p><img src="https://pmanderson.dev/assets/images/ledger_charts.png" alt="Reports — Portfolio Allocation &amp; Asset Drift" class="align-center" /></p>

<p>Tech stack:</p>
<ul>
  <li><strong>Backend:</strong> Python, Flask, SQLAlchemy, SQLite</li>
  <li><strong>Frontend:</strong> Bootstrap 5, Plotly for charts, vanilla JS</li>
  <li><strong>AI integration:</strong> Anthropic API (Haiku) for holdings classification; Yahoo Finance for price data</li>
</ul>

<p>The architecture I’m most happy with: Haiku owns reasoning and classification tasks, Yahoo Finance owns price data. Clean separation, keeps costs low.</p>

<h2 id="what-i-left-out">What I Left Out</h2>

<p>Ledger has no budgeting features. No spending categories. No “you overspent $12 on groceries” notifications. No debt payoff calculator.</p>

<p>Monthly cash flow entry is intentionally blunt: total income, total expenses. I look at my credit card bills, add them up, enter the number. I look at my paycheck, enter the number. Five minutes, no categorization.</p>

<p><img src="https://pmanderson.dev/assets/images/ledger_monthly_update.png" alt="Monthly Data Entry" class="align-center" /></p>

<p>Most personal finance apps are built around budgeting and debt management - that’s a real and important problem for a lot of people. Ledger is built for a different use case: savings rate, risk exposure, asset allocation, and portfolio performance over time. Anything else would have been scope creep.</p>

<p>The holdings classification feature is a good example of what I built instead. Enter a ticker symbol, the Anthropic API pulls information about the fund and classifies it automatically - domestic equity, international, bonds, market cap, sector. Building this required stitching together Yahoo Finance and the Anthropic API in a way I might have dismissed as too difficult or time intensive without going through a planning session first. Planning with Claude made the path obvious, then we built it.</p>

<h1 id="what-i-learned-about-working-with-llms">What I Learned About Working With LLMs</h1>

<p>Before this project I used LLMs carefully and formally - writing prompts like drafting an email to a senior colleague. Part of this was that I wasn’t used to voice dictation, which is actually how I do most of my planning with Claude now: walking the dog, dictating into my phone. Once I started doing that the whole interaction changed. Stream of consciousness works. Clarity comes faster when you’re not spending energy on formality.</p>

<p>The other shift was around iteration. Failing fast and cheap iteration have always been hallmarks of software engineering - that’s part of what makes it different from traditional engineering. In professional contexts I’d internalized that. What I hadn’t applied it to was personal projects, where my time is genuinely limited and I’m not going to try five different approaches to see what sticks. Working with Claude changed that calculus for hobby development specifically. I can explore more ideas, move faster, and throw things away without it costing me a weekend.</p>

<p>A few things that made the process work:</p>

<p><strong>Use a tech stack you know.</strong> The reason I could maintain engineering judgment over what the agent was producing - catch bad patterns, question architectural decisions, understand what was being built - is that I know Python and Flask. If I’d let Claude pick the stack I might have ended up with something I couldn’t read or maintain. Your expertise is what makes AI-assisted development more than just vibe coding.</p>

<p><strong>Keep context alive.</strong> Using a persistent Project meant planning conversations, backlog items, and architectural decisions built on each other over time. The agent knew the codebase, knew the constraints, knew why decisions had been made. That’s what makes it a development partner rather than a code generator.</p>

<p><strong>Use agent teams for perspectives you don’t have.</strong> Running a prompt through a single agent gives you one perspective. Running it through a team of agents with different personas gives you something closer to a real design review. I used this a few different ways: software engineer personas for code reviews (useful for catching things I’d let slide because I was moving fast), finance professional and HNW user personas for feature feedback and sanity checking the financial accuracy of the app, and to surface industry standard features I’d internalized from years of using finance apps but hadn’t thought to articulate as explicit requirements - the kind of thing you only notice when it’s missing.</p>

<h1 id="where-it-stands">Where It Stands</h1>

<p>Ledger runs on a Raspberry Pi on my home network. CI/CD pipeline. Test suite. Backlog is alive and I’m still adding to it.</p>

<p>The five-minutes-a-month target is still a little aspirational - I’m working on it. The unexpected win has been the dividends view. I knew the portfolio generated some passive income but had never looked at it closely in aggregate. Seeing that number tracked over time was more clarifying than I expected. That’s the thing about building your own tools: sometimes you learn something about your finances just by making the data legible.</p>

<p>The Google Sheet is archived but not deleted.</p>

<hr />

<p><em>Ledger is open source at <a href="https://github.com/panderson54/ledger_finance">github.com/panderson54/ledger_finance</a>. Self-hosted, no authentication layer, designed for use on a trusted local network.</em></p>]]></content><author><name>Patrick Anderson</name></author><category term="software" /><category term="software" /><category term="ai" /><category term="journal" /><summary type="html"><![CDATA[This site exists, per my own about page, as a vehicle for me to explore and organize things I’ve learned by writing about them. This post is about building Ledger, a self-hosted personal finance dashboard, and what I learned doing it almost entirely with Claude as a development partner.]]></summary></entry><entry><title type="html">Modes of Nuclear Proliferation</title><link href="https://pmanderson.dev/nuclear/Modes-Of-Nuclear-Proliferation/" rel="alternate" type="text/html" title="Modes of Nuclear Proliferation" /><published>2025-06-22T00:00:00+00:00</published><updated>2025-06-22T00:00:00+00:00</updated><id>https://pmanderson.dev/nuclear/Modes-Of-Nuclear-Proliferation</id><content type="html" xml:base="https://pmanderson.dev/nuclear/Modes-Of-Nuclear-Proliferation/"><![CDATA[<p>Nations seeking a nuclear weapon follow a few set paths to ‘the bomb’ ; these paths are a product of a given geopolitical, security, and domestic environment and dictate the speed, openness, and in most cases success of a nuclear program seeking a weapon. This is highly relevant today given the current citation in Iran and what I think will be a shift in strategy by the Iranians due to the failure of their deterrence model. All credit for these various models goes to Vipin Narang’s book ‘Seeking the Bomb; Strategies of Nuclear Proliferation’</p>

<h2 id="passive-nuclear-proliferation-strategies">Passive Nuclear Proliferation Strategies</h2>
<p><strong>Technical Hedging:</strong></p>
<blockquote>
  <p>““explicitly not now, but implicitly not never.””</p>
</blockquote>

<p>Puts in place technological capabilities to enable a military program at a future date but no explicit military or weaponization programs are underway. Examples of technical hedges would be inclusive of civilian energy programs and infrastructure including enrichment of non weapons grade fissile materials. This is really nuclear latency, it’s a technical capability with a lack of intent for weaponization. Technical hedgers may have internal elements that would seek a bomb but lack the political consensus to do so.</p>

<p><strong>Insurance  Hedging:</strong></p>
<blockquote>
  <p>““explicitly not now, but explicitly in the future if X happens.””</p>
</blockquote>

<p>Insurance hedgers take steps to reduce breakout time should a threat (often specific) emerge. These steps include theoretical weaponization work, domestic nuclear fuel production and advanced enrichment capabilities, and work on dual use devices like delivery systems (typically ballistic missiles).  Users of this strategy typically use the latent threat of breakout either as a deterrent effect on a potential adversary or a coercive measure to allies to ensure protection. A good example of an insurance hedger is South Korea, who uses its hedge to both deter the DPRK and ensure continued US involvement in the region.</p>

<p><strong>Hard Hedging:</strong></p>
<blockquote>
  <p>““explicitly not now, but explicitly not never.””</p>
</blockquote>

<p>Threshold nuclear states with all/many of the pieces for a functional weapons program but that stop short of taking the final steps towards weaponization. They have the capabilities to produce weapons grade fissile material, weapon designs, delivery vehicles, and political/military command and control organizations to manage nuclear weapons. Nuclear armament for these states is part of mainstream political debate with some committing to a path of proliferation (India) while some abandon the pursuit (Sweden) and others remain in limbo (Iran).</p>

<h2 id="active-nuclear-proliferation-strategies">Active Nuclear Proliferation Strategies</h2>

<p><strong>Sprinting:</strong></p>

<p>An open and determined effort to develop nuclear weapons as quickly as possible. This is the strategy that most people think of when discussing nuclear weapons proliferation and is best exemplified by the Manhattan Project. This is an all out effort by which states seek to develop capabilities to enrich fissile material expressly for military reasons, delivery vehicles and command &amp; control (C2) for the management of nuclear arms. If, like in the US, China and the USSR, a state is economically capable and geopolitically immune from attempts to halt these efforts, sprinting is very effective. That said successful sprints are rare as the immunity to counter proliferation efforts required has thus far only been present for first generation proliferators (P5 members).</p>

<p><strong>Sheltered Pursuit:</strong></p>

<p>Sheltered pursuit is the development of a nuclear weapon shielded by the tolerance of a major power. The major power not only does not seek to counter proliferate but also deters other powers from doing so shielding the proliferator from military, diplomatic and economic actions. The client state attempts to achieve a nuclear breakout prior to their period of shelter ending. It’s worth noting that it is rarely in the sheltering state’s interests for proliferation to occur, super powers often want to be the only ally with nukes in order to control the escalatory ladder, but proliferation may be seen by the sheltering state as preferable to some other outcome. Classic examples of sheltered pursuit are North Korea, China preferred a nuclear DPRK over a fallen north, and Israel/Pakistan with US regional interests overriding US non-proliferation interests.</p>

<p>Sheltered pursuit has a high chance of success if the sheltered state can complete development prior to that shelter eroding.</p>

<p><strong>Hidden:</strong></p>

<p>Secret bases and hidden efforts hiders attempt to develop nuclear capabilities in the shadows often due to fear of coercion or military action by regional or major powers. Hiders trade speed for stealth and often use methods that are slower but easier to hide (typically uranium rather than plutonium enrichment) and seek either to gain a significant head start or ideally complete a weapon prior to discovery. Notably, hiding has only ever worked for one nation, South Africa, a nation that is also noteworthy for being the only country to ever give up its nuclear capability entirely. Other examples of this strategy include Iraq, Syria, Taiwan, Iran (until 2003) and many more, oftentimes these efforts meet kinetic or coercive ends.</p>

<h2 id="iran">Iran:</h2>
<p><img src="https://pmanderson.dev/assets/images/pro_flow.PNG" alt="Proliferation Flow Chart" /></p>

<p>Dr. Narang’s flow chart is a great tool here and I want to look at it in light of recent events in Iran. As noted above Iran was, at time or writing, classified as a hard hedger, a strategy characterized by a nation having all pieces in place for weapons development but not having made that last step to actively acquire a weapon.</p>

<p>Indeed Iran has all the pieces in place:</p>
<ul>
  <li>A robust and well known enrichment program for fissile material capable of high levels of enrichment</li>
  <li>Known weapons designs including fairly advanced implosion designs suitable for missile use.</li>
  <li>Sophisticated ballistic missile program for delivery, mostly IRBMs and SRBMs</li>
  <li>C2 practices for management of weapons and delivery systems</li>
</ul>

<p>Despite all of this remained a hedger because they did not have a political consensus around the development of nuclear weapons (despite conventional wisdom to the contrary).  Iran was (at time of writing) a signatory of the NPT (non proliferation treaty) and domestically under a <a href="https://en.wikipedia.org/wiki/Ali_Khamenei%27s_fatwa_against_nuclear_weapons">fatwa issued by Ali Khamenei</a> preventing the development of nuclear arms and most significantly had signed and complied with the <a href="https://en.wikipedia.org/wiki/Joint_Comprehensive_Plan_of_Action">JCPOA</a> until the <a href="https://bsky.app/profile/armscontrolwonk.bsky.social/post/3lrgf3vvkt22i">Trump Administration pulled out</a> of the deal during his first term (plug for <a href="https://www.middlebury.edu/deal-podcast">The Deal</a> a podcast on the JCPOA).</p>

<p>So where are we going? Iranian deterrence has utterly failed, their network of proxies has been mostly neutered in the last year with Hamas, Syria (Assad), Hezbollah, and the Houthis more or less being taken off the board and Iran’s conventional ballistic missile and drone capabilities have proved to be relatively ineffective against Israeli and US air and missile defence systems. Given that conventional and proxy deterrence has failed it would be logical for Iran to seek a more significant deterrent in the form of nuclear armament. Additionally in light of Iran’s current security situation it is not far-fetched to assume that Iranian political thought towards nuclear armament has likely changed in the last few days.</p>

<p>The next step on the flow chart above is sprinting, you’ll remember that sprinting requires permissive security and economic environments to work typically but I would not be so quick to discount an Iranian sprint. Short of a ground invasion the seizure and destruction of all Iranian nuclear material is, from my view, impossible. A ground invasion is politically unpalatable to the US and numerically impossible for the IDF; given the state of sanctions economic coercion probably can’t get much worse either. It seems possible that Iran could perform a ‘hidden sprint’ using its, currently unlocated, stockpile of HEU, distributed centrifuge systems, and existing nuclear knowledge to quickly produce a nuclear device.</p>

<p>Let’s say that the sprint is not possible given the total air dominance Israel and the US enjoy over Iran. We’ll skip sheltered pursuit, Russia and China have made no effort to support Iran in the current conflict, Russia’s lack of support went as far as this <a href="https://x.com/DillyHussain88/status/1936740430865215754">weird statement</a> from Putin about Israeli russian speakers. Our final stop is a hidden program, a place Iran was in 2003, success in this is unlikely but not impossible and this time Iran is starting with more knowledge and more material.</p>

<p>Most importantly with either outcome it is likely Iran has moved from the latent proliferator camp into the active proliferation camp. The US and IDF by showing that conventional and proxy  deterrence are insufficient to shelter Iran have ironically made a compelling case for nuclear deterrence. Probably should have stuck with the JCPOA.</p>

<p><strong>Books Mentioned in this post:</strong></p>
<ul>
  <li><a href="https://www.goodreads.com/en/book/show/57866207-seeking-the-bomb">Seeking the Bomb; Strategies of Nuclear Proliferation by  Vipin Narang</a></li>
</ul>]]></content><author><name>Patrick Anderson</name></author><category term="nuclear" /><category term="nuclear" /><summary type="html"><![CDATA[Nations seeking a nuclear weapon follow a few set paths to ‘the bomb’ ; these paths are a product of a given geopolitical, security, and domestic environment and dictate the speed, openness, and in most cases success of a nuclear program seeking a weapon. This is highly relevant today given the current citation in Iran and what I think will be a shift in strategy by the Iranians due to the failure of their deterrence model. All credit for these various models goes to Vipin Narang’s book ‘Seeking the Bomb; Strategies of Nuclear Proliferation’]]></summary></entry><entry><title type="html">Always/Never Paradox and Platform Trust &amp;amp; Safety</title><link href="https://pmanderson.dev/software/nuclear/Always-Never/" rel="alternate" type="text/html" title="Always/Never Paradox and Platform Trust &amp;amp; Safety" /><published>2023-05-18T00:00:00+00:00</published><updated>2023-05-18T00:00:00+00:00</updated><id>https://pmanderson.dev/software/nuclear/Always-Never</id><content type="html" xml:base="https://pmanderson.dev/software/nuclear/Always-Never/"><![CDATA[<p>Always/never is a concept coined in the midst of the Cold War as the US grappled with how to safely manage its nuclear weapons while keeping them ready for immediate use as a deterrent. The problem is how to ensure that an accidental nuclear use cannot happen, whether through negligence, sabotage, or even unauthorized use while making sure that an authorized user could launch a live warhead in minutes if needed.</p>

<blockquote>
  <p>“The need for a nuclear weapon to be safe and the need for it to be reliable were often in conflict. A safety mechanism that made a bomb less likely to explode during an accident could also, during wartime, render it more likely to be a dud. The contradiction between these two design goals was succinctly expressed by the words “always/never.” Ideally, a nuclear weapon would always detonate when it was supposed to—and never detonate when it wasn’t supposed to.””</p>
</blockquote>

<p>- <em>Eric Schlosser, Command And Control</em></p>

<p>Technologies or procedures that enable one end of the always/never spectrum typically move you away from the other. A code needed to launch a missile introduces some mechanism to render said missile inert should the code not be present, that is a failure point as well as an introduction of a delay. Keeping nuclear bombs strapped to planes on the flight line reduces the time needed to respond to an attack, it also means that a pilot could hop in and fly it off, starting World War III. In a bit of family history my paternal grandfather was the custodian of such weapons mounted to F-86Fs in West Germany at the height of the Cold War.</p>

<p><img src="https://pmanderson.dev/assets/images/F84.jpg" alt="F84 in flight" class="align-center" /></p>

<blockquote>
  <p>“At a NATO base in Germany, Agnew looked out at the runway and, in his own words, “nearly wet my pants.” The F-84F fighter planes on alert, each carrying a fully assembled Mark 7 bomb, were being guarded by a single American soldier. Agnew walked over and asked the young enlisted man, who carried an old-fashioned, bolt-action rifle, what he’d do if somebody jumped into one of the planes and tried to take off. Would he shoot at the pilot—or the bomb? The soldier had never been told what to do”</p>
</blockquote>

<p>- <em>Eric Schlosser, Command And Control</em></p>

<p>We actually deal with this concept in less extreme forms all the time, ‘fail-safe’ is the common word for engineering something to default to a safe rather than dangerous state. For example my space heater when moved, tilted or knocked over, shuts off. This is a value consideration by the engineers who built the device, it means that they’ve decided it’s better to render a device inoperable in certain instances than it is to allow it to function potentially dangerously, placing them firmly on the never end of the always/never spectrum.</p>

<p>In the perverse world of nuclear arms we have the concept of  ‘fail-deadly’, which describes policies and practices that without outside inputs reach a deadly state, in this case usually a launch order. The most shocking example of this is found in the Soviet ‘Dead Hand’ or ‘Perimeter’ system, which you can read more about in <em>The Dead Hand</em> by David E Hoffman, this is an extreme example of the always end of the spectrum.</p>

<blockquote>
  <p>“The Strategic Air Command wanted bombs that were safe and reliable. But most of all, it wanted bombs that worked. A willingness to take personal risks was deeply embedded in SAC’s institutional culture […] they would not be pleased, amid the chaos of thermonuclear warfare, to learn that the bombs they dropped didn’t detonate because of a safety device. Civilian weapon designers, on the other hand, were bound to have a different perspective—to think about the peacetime risk of an accident and err on the side of never.”</p>
</blockquote>

<p>- <em>Eric Schlosser, Command And Control</em></p>

<h2 id="where-does-this-concept-intersect-with-platform-trust-and-safety">Where does this concept intersect with platform trust and safety?</h2>

<p><img src="https://pmanderson.dev/assets/images/always_never.png" alt="Always Never" /></p>

<p>The removal of speech from social media platforms is, to put it lightly, a hot button issue. In the US we have two political blocks both feeling that platforms are falling down on the job, but from opposite ends of the spectrum. I’m not going to touch Section 230, which shields platforms from liability for the speech they host, or the 1st Amendment, which does not require a platform to carry your speech, other than to say the mix of public feelings around freedom of expression and platforms relative immunity to the consequences of hosting that speech have created a lose-lose situation for social media platforms in the United States.</p>

<p>Platform trust and safety teams must wrestle with the always/never paradox when it comes to regulation of speech. In an ideal world we’d have a perfect system that always found and eliminated harmful speech on a platform (CSAM, terrorism, calls for violence, disinformation etc…) while never touching legitimate speech about those same subjects. A real world example would be the removal of ISIS recruitment videos while leaving up legitimate discourse or journalism that uses those same videos. This perfect system is a fantasy, careful moderation by discerning individuals does not scale to billions of users so we try to solve these problems at scale with technology but technology, just like people, has built in values.</p>

<p>When building systems to deal with speech on platforms you need to choose which end of the spectrum you are comfortable defaulting to, do you fail-safe or fail-deadly? Failing safe (biasing towards harm reduction) will mean the removal of more speech and the potential suppression of legitimate discourse on incredibly important subjects, failing deadly (biasing towards freedom of expression) will allow for and potentially promote harmful content with real world consequences. Any system will be imperfect, but we can choose how some of those imperfections manifest.</p>

<p>I am not going to express a viewpoint on how an ideal system would walk this line, the issues are complex and I am no expert in the problem set technically or socially. I don’t work directly in trust and safety and I am not a lawyer, but I like this framework for thinking about these issues and it’s an easy connection to make between my hobbies and professional life. If you want to listen to vastly more competent people talk about these difficult issues I’d encourage you to check out the following podcasts and publications.</p>

<ul>
  <li><a href="https://law.stanford.edu/directory/evelyn-douek/moderated-content/">Moderated Content from Stanford Law School</a> a podcast content about content moderation, moderated by assistant professor Evelyn Douek. The community standards of this podcast prohibit anything except the wonkiest conversations about the regulation—both public and private—of what you see, hear and do online.</li>
  <li><a href="https://www.lawfareblog.com/topic/arbiters-truth">Lawfare’s Arbiters of Truth</a> an occasional Lawfare podcast series on the online information ecosystem featuring interviews with experts about the legal and policy aspects of the debates around political discourse, online speech and social media platforms.</li>
  <li><a href="https://www.brookings.edu/research/dual-use-regulation-managing-hate-and-terrorism-online-before-and-after-section-230-reform/">Dual-use regulation: Managing hate and terrorism online before and after Section 230 reform</a> by Brian Fishman. Brian’s article was published by Brookings and then he was interviewed by Quinta Jurecic on Arbiters of Truth. His interview and article percipitated the above train of thought.</li>
</ul>

<p>Books Mentioned in this post:</p>
<ul>
  <li><a href="https://www.goodreads.com/book/show/6452798-command-and-control?ac=1&amp;from_search=true&amp;qid=vKEvjiinaF&amp;rank=1">Command and Control: Nuclear Weapons, the Damascus Accident, and the Illusion of Safety  by Eric Schlosser </a></li>
  <li><a href="https://www.goodreads.com/book/show/6623920-the-dead-hand?ref=nav_sb_ss_2_13">The Dead Hand: The Untold Story of the Cold War Arms Race and its Dangerous Legacy  by David E. Hoffman</a></li>
</ul>]]></content><author><name>Patrick Anderson</name></author><category term="software" /><category term="nuclear" /><category term="nuclear" /><category term="platforms" /><summary type="html"><![CDATA[Always/never is a concept coined in the midst of the Cold War as the US grappled with how to safely manage its nuclear weapons while keeping them ready for immediate use as a deterrent. The problem is how to ensure that an accidental nuclear use cannot happen, whether through negligence, sabotage, or even unauthorized use while making sure that an authorized user could launch a live warhead in minutes if needed.]]></summary></entry><entry><title type="html">Adventures with TidByt</title><link href="https://pmanderson.dev/software/TidByt-Hacking/" rel="alternate" type="text/html" title="Adventures with TidByt" /><published>2023-01-25T00:00:00+00:00</published><updated>2023-01-25T00:00:00+00:00</updated><id>https://pmanderson.dev/software/TidByt-Hacking</id><content type="html" xml:base="https://pmanderson.dev/software/TidByt-Hacking/"><![CDATA[<p>TitByt is this pixel based display with a set of dev tools allowing you to make your own apps for it. Basically it’s a fancy clock that you can program. I like how it looks and I’d been wanting to mess with a connected display for my home office for a while and to be honest I’m much handier with code than I am with a soldering iron so this seemed like a good fit.</p>

<p>https://tidbyt.com/</p>

<p>This is just going to be a stream of me trying to get some stuff to work, if anything get published to the TidByt app store I’ll link all source code here. If not I either gave up or am running it locally and so embarrassed of my <del>hack job</del> code I didn’t link it.</p>

<h2 id="12423">1/24/23</h2>
<p>Installed Pixlet CLI and got starlark syntax highlighting functioning on VSCode. I’d clearly not done any python development on this machine in a long time as pip was super out of date. Luckily powershell seems to have come a long way, I don’t have a non-work unix machine lying around currently so this will all be done on windows for bonus points.</p>

<p>Pixlet’s CLI works really seamlessly, point it at a starlark file and it runs and prints the output locally to http://127.0.0.1:8080</p>

<p><a href="https://tidbyt.dev/docs/build/build-for-tidbyt">Dev Documentation</a></p>

<p>I’ve got a couple ideas of applets to build</p>

<p><strong>Specific NCAA Basketball Teams:</strong> There are a bunch of sports scoring apps on the marketplace but I want to only show scores on the day my college basketball team is playing. The only other NCAA applet just shows either the top 25 or an entire conference, frankly unless it’s Gonzaga I could care less so one option would be to build my ideal NCAA Basketball display. There are a few things to solve here, there is a scheduling tool within the TidByt config app but it’s date driven, the calendar applet has an option to hide it in your display order if there are no other events that day, I’d like to build a similar function to hide my potential app if my team is not playing.</p>

<p><strong>Book Progress:</strong> A goodreads based progress tracker for my current book. Kindle -&gt; Goodreads -&gt; TidByt. I’ve been wanting to use the goodreads API to drive a display for a while but ran into some issues with getting cover art from their API, I might just go with a stats display for the current year.</p>

<p><strong>NASDAQ Composite Tracker:</strong> The only trackers in game right now are stock specific, I’d like to be able to have updates on the S&amp;P500 + NASDAQ as well. This might be my first go as it’s a very straight forward display to build.</p>

<p>I’ll take a look at some existing apps and see what’s already been done: 
<a href="https://github.com/tidbyt/community/tree/main/apps">GitHub: tidbyt/community</a></p>

<h2 id="12523">1/25/23</h2>
<p>Spent a lot of time trying to find a stock API will serve me index scores like NASDAQ, DJI, S&amp;P500 etc.. There appears to be one <a href="https://site.financialmodelingprep.com/developer/docs/indexes-in-stock-market-free-api">Financial Modeling Prep - Indexes</a> but it looks like the index tickers are all in a premium tier. This probably won’t work as all users of the applet will need to provide their own API key, this is a pattern I’ve seen across other apps in the community apps repo. I may have to code something up with static numbers and come back to the API problem as the pattern for fetching some JSON from an endpoint is simple.</p>

<p>In other news the Pixlet APIs provide some cool features with regard to caching and encryption of things like API keys. All apps actually run on the TidByt servers and push frames out to your device forcing a refresh if the cache has been invalidated. Likewise any data pulled from other sources is cached with a TTL set within the app code. The part I’m most worried about is the visuals, the code is easy but my art skills are lacking.</p>

<h2 id="12923">1/29/23</h2>
<p>I decided to skip to hacking around in pixlet and I’ll come back to finding an API that provides something I want to display. I used the tutorial + reading through some community code to make a stock app that takes in a few parameters (symbol, shares and an API key for alphavantage) and returns the value of the stock multiplied by the number of shares. This exact app is already in the community repo but for some reason it was not working on my TidByt device. I added in some caching and checks to make sure the cached price data is for the current stock symbol, we throw out the cached data if the symbol changes in the config. As expected the actual formatting of the output involved the most trial and error, not because the docs are bad but because I’m not particularly frontend minded. I think I’ll move onto trying to use Goodreads/Kindle’s API to display my reading progress, not a useful app but I like tracking my reading goals and it’s not something anyone else has built. I’ll need to pull the community repo to get started.</p>

<p><img src="https://pmanderson.dev/assets/images/tidbyt-1-29.png" alt="My First Output" /></p>

<h2 id="13123">1/31/23</h2>
<p>I embarked on my Goodreads journey without realizing that Goodreads had killed off its public API in 2020. Not to be deterred, I decided to use this as a reason to learn a little more Starlark and built a web scraper aftering sorting out where the data I wanted lived publicly on Goodreads. Turns out , given what I am calling a challenge ID (not a user ID) Goodreads will serve up any public profile yearly reading challenge at https://www.goodreads.com/user_challenges/ . Using this I set up an applet to take in the challenge ID, make a GET request and parse the returned HTML to show how far along any given user is on their reading goals.</p>

<p>This is what it looks like in Starlark</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> challenge_page = http.get(GOODREADS_PROGRESS_URL + config.str("user_challenge_id", DEFAULT_CHALLENGE_ID))


        if challenge_page.status_code != 200:
            fail("Request failed with status %d", challenge_page.status_code)


        body = challenge_page.body()
        progress_div = re.findall(r"&lt;div class='progressText'&gt;([\s\S]*?)&lt;/div&gt;", body)


        if not progress_div:
             fail("No challenge found at {}".format(config.str("user_challenge_id", DEFAULT_CHALLENGE_ID)))


        progress_nums = re.findall(r"\d+", progress_div[0])
        progress = progress_nums[0]
        goal = progress_nums[1]
</code></pre></div></div>

<p>It’s pretty readable as it’s basically python, including a ported over regular expressions library. I then did basically 0 work to display it as such. There is a toggle for an as of yet un implemented “are you on track function” which I’ll do later.</p>

<p><img src="https://pmanderson.dev/assets/images/tidbyt-1-30.png" alt="My SecondOutput" /></p>

<p>All in all not bad for a evening messing around, most information was either from the previously linked TidByt docs and the <a href="https://github.com/bazelbuild/starlark/blob/master/spec.md">Starlark spec</a></p>

<h2 id="2223">2/2/23</h2>
<p>I decided I wanted to work on the visuals of this goodreads applet and thought it’d be fun if your little bookshelf filled up as you read books over the course of the year. This gave me a good chance to sort out how the different render functions worked and how to position things on the screen. I made a bunch of book art using <a href="pixelart.com">PixelArt</a> as my editor (see my files here: <a href="https://www.pixilart.com/larkin54/gallery">gallery</a>) and wrote a very dumb if statement that takes in the number of completed books from my Goodreads scraper and renders between 0 and 13 books. The average adult reads 12 books a year and my art skills ran out of steam so displaying more than that is task for later (if ever). What I was left with is a fun display that will update once a day if this app is running on your TidByt. I used some basic transformations to keep my 4 assets fresh-ish despite a lot of reuse.</p>

<p><img src="https://pmanderson.dev/assets/images/bookdemo.gif" alt="Book Demo" /></p>

<p>You can render your applet locally and then push that asset to your TidByt from the Pixlet CLI to see how it will look! This is a good time to talk about how this code will eventually be executed. The TidByt device does not run anything locally, rather it gets frames pushed to it from TidByts servers and the device simply renders the frame. This has some obvious limits to it, you’re not going to be doing a bunch of computation on TidByt’s dime and thus they have app efficiency requirements prior to merging into their community app repos. Additionally they enforce quality standards for caching and encryption of API keys. This is good in that everything that can run on your device is open sourced and adheres to similar standards. If you really wanted to leave the ecosystem you can flash the firmware on the device itself and do whatever you like.</p>

<p><img src="https://pmanderson.dev/assets/images/tidbyt-books1.jpg" alt="Books IRL" /></p>

<h2 id="21923">2/19/23</h2>
<p>I polished up what I had written the other week and forked <a href="https://github.com/tidbyt/community">tidbyt’s community repo</a>. Running the pixlet create script sets up a folder and does some basic scaffolding for you, I copy and pasted my code into the generated file and did a little clean up. First on the agenda was to remove all testing code and any references to my own account. In order to make this run out of the box for people I encrypted my personal challenge ID using pixlet’s encrypt command from the CLI. This (I’m guessing here) encrypts the passed data with a public key from Tidbyt and is only able to be decrypted by a private key, at runtime, which resides with them. Because apps all ultimately run on tidbyt’s servers this is a sensible way to let developers store API keys and other data with them without revealing it in code.</p>

<p>I ran pixlet’s code profiling, formatting, linting and checking commands to make sure things were running properly and up to TidByt’s style standards and submitted a <a href="https://github.com/tidbyt/community/pull/1149">PR</a>. I give my PR a 50/50 chance of being accepted. While I don’t think my solution is terrible (or I’d not have submitted it) the use of what is essentially a web scraper to get the progress data is not a great practice and certainly not something I’d let go into production for any sort of real service. That said there is no public API to get this data and short of reverse engineering Goodreads’ private API it’s the best option I’ve got.</p>

<p>I’ll check back in when I get feedback on my PR from the pixlet community.</p>

<h2 id="22223">2/22/23</h2>
<p>Turns out the cache keys are on a per app basis, all users of the app share a cache, this means that my storing of progress and goal are global unless we append some sort of unique indentifier to the cache key. To solve this I just appened the challenge ID when cacheing progress and goals. The shared cache per app makes a ton of sense if you are doing something like stock prices or other data that would be the same regardless of user but still requires some sort of calculation or API call.</p>

<h2 id="3223">3/2/23</h2>
<p>My PR was merged! The Goodreads Challenge Tracker will appear in the next version of the TidByt app released. I’ll update this post when that happens but for now I’m considering this little project done. If I build something next it’ll be an NCAA basketball scoreboard for specific teams but seeing as March Madness is about to start that is probably a project for the ‘23-‘24 season. I don’t often code outside of work as usually that itch is scratched (and then some) by my day to day contributions at Meta but this was a fun project where I got to learn something new and publish it out to a wider community.</p>

<h2 id="3623">3/6/23</h2>
<p>My app is live in the TidByt app! Happy reading.</p>]]></content><author><name>Patrick Anderson</name></author><category term="software" /><category term="journal" /><category term="software" /><summary type="html"><![CDATA[TitByt is this pixel based display with a set of dev tools allowing you to make your own apps for it. Basically it’s a fancy clock that you can program. I like how it looks and I’d been wanting to mess with a connected display for my home office for a while and to be honest I’m much handier with code than I am with a soldering iron so this seemed like a good fit.]]></summary></entry><entry><title type="html">Let’s talk Crypto[graphy]</title><link href="https://pmanderson.dev/software/Lets-talk-crypto/" rel="alternate" type="text/html" title="Let’s talk Crypto[graphy]" /><published>2023-01-18T00:00:00+00:00</published><updated>2023-01-18T00:00:00+00:00</updated><id>https://pmanderson.dev/software/Lets-talk-crypto</id><content type="html" xml:base="https://pmanderson.dev/software/Lets-talk-crypto/"><![CDATA[<p>Cryptography, while increasingly in the news, is not something most people think about affecting their day to day lives that said I believe cryptography is something that more people should be passingly familiar with as knowingly or not you have placed a great deal of trust in modern cryptography. The art of code making and code breaking has been the primary enabler of the wholesale move of many facets of life online, from online banking, social media, shopping, medical records and increasingly your communications with family and friends are able to be transmitted and stored securely thanks to the ubiquity of very strong cryptography.</p>

<p>The desire of people to keep secrets, and to read the secrets of others, is an urge that has helped shape history. We can find uses of codes and ciphers dating back thousands of years, generals, kings, advisors, spies and diplomats all needed ways to communicate safely without fear of their message being read by prying eyes. The word cryptography comes from the Greek word kryptos meaning hidden. Cryptography is the practice of hiding the meaning of a message, not the message itself. The process by which this is done is called encryption, the aim of encryption is to take a message and render it unintelligible to all but the intended recipient. Anyone who reads an encrypted message that does not know how the message was scrambled will be unable to decipher it.</p>

<h1 id="basics">BASICS</h1>

<p>Encryption falls into two general camps, transposition, the act of moving characters around, and substitution, the act of swamping one character for another in the alphabet.</p>

<p>Some quick terminology:
Plaintext: The unscrambled, original, message.</p>

<p>Ciphertext: Then scrambled message, this is the result of using an encryption process on a plaintext.</p>

<p>Algorithm: The method by which something is encrypted</p>

<p>Key: The details of a particular  encryption, this could be the number of places a letter is shifted or the substitution alphabet (aka a cipher alphabet).</p>

<p><img src="https://pmanderson.dev/assets/images/singh_diagram.png" alt="A great diagram provided by Simon Singh in The Code Book" /></p>

<p>Classic examples of both types are rail fence cypher (transposition) and the Caesar cipher (substitution). Both are quite simple, the rail fence involves creating two strings from alternating letters and then combining the two strings as a ciphertext.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Plaintext: THIS IS  A SECRET:
String 1: T I I A E R T
String 2:  H S S S C E
Ciphertext: TIIAERTHSSSCE
</code></pre></div></div>

<p>The Caesar cipher is similarly simple, it involves shifting the alphabet a predetermined number of spaces and substituting the letters of the plaintext with the letters in the cipher alphabet. The classic example, used by Caesar himself, was 3 places.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Plain Alphabet:    ABCDEFGHIJKLMNOPQRSTUVWXYZ 
Cipher Alphabet: XYZABCDEFGHIJKLMNOPQRSTUVW 
Plaintext: THIS IS A SECRET
Ciphertext: WKLV LV D VHFUHW
</code></pre></div></div>

<p>You are probably familiar with these from grade school, they are fun, easy to learn and use and for thousands of years were state of the art. Both of these are kept secret not by knowing the algorithm by which they were encrypted but by the key used to do the encryption. This brings us to a core tenet of cryptography, know as Kerckhoff’s principle, which can be paraphrased as:</p>

<blockquote>
  <p>A cryptosystem should be secure, even if everything about the system, except the key, is public knowledge.</p>
</blockquote>

<p>The assumption is that a potential snooper can know everything about how a message was encrypted, except the key, and they will be no closer to the plaintext. This is core to how all modern encryption works. When data is sent securely over the internet, anyone can intercept those messages but only the person holding the proper key can actually read them.</p>

<h1 id="history">HISTORY</h1>

<p>We are all familiar with famous historical examples like Enigma from World War 2, the Zimmerman Telegram, or Mary Queen of Scots’ hidden messages to her supporters. But the stories that are told about these uses of cryptography are not how effective they were but rather how they were broken.</p>

<p>Code breaking books date back to 9th century Baghdad where Arab thinkers such as Al-Kindi (author of A Manuscript on Deciphering Cryptographic Messages) pioneered the field of cryptanalysis. Al-Kindi wrote about a method now known as frequency analysis, this is a method that uses linguistics and statistics to determine how a given letter was substituted based on the frequency of that letter’s occurrence. In any language some letters occur more than others, in english e is the most commonly used letter, by taking a ciphertext and counting the occurrence of each letter a code breaker can start to reveal the underlying key.</p>

<p>The Arab codebreakers kicked off a cycle of attack and defense that lasts to this day, at various points in history one side or the other has held the upper hand. Following the breaking of simple substitution and transposition ciphers there was a period of relatively little secrecy with code breakers able to read secret messages with impunity (provided you had a code breaker on staff that is, not exactly a common medieval profession). This battle has continued throughout history, Phelippes vs Mary Queen of Scots, Babbage &amp; Kasiski vs the Vignere Cipher, ADFGX vs Painvin and Turing vs Enigma. During some periods cryptographers had the upper hand but for the most part search for an unbreakable code was driven by cryptanalysts ability to break codes with greater and greater efficiency. This all culminates in the invention of a truly unbreakable, and truly unwieldy, form of encryption called a One-Time Pad (OTP).</p>

<h1 id="otp">OTP</h1>
<p>Rules for unbreakable cryptography:</p>
<ul>
  <li>The key must be at least as long as the plaintext.</li>
  <li>The key must be random</li>
  <li>The key must never be reused in whole or in part.</li>
  <li>The key must be kept completely secret by the communicating parties.</li>
</ul>

<p>These rules describe a technique called a One-Time Pad, this is essentially a substitution cipher that uses a cipher alphabet made of entirely random letters once and then never again. The only instances of one-time pads being broken involved American cryptanalysts sifting through burned scraps of Soviet one-time pads and after painstaking work finding that the soviet cryptographers had messed up and reused some pads.</p>

<p>Randomness is key here, random number generators found in standard programming libraries are not sufficiently random for this purpose. In brief the number of bits of entropy in the cipher alphabet must be equal to the bits in the plain text. Specific methods for truly random number generation are complex and beyond our scope but they’re interesting and you should look them up. Now this all sounds great, congrats everyone we have unbreakable codes!</p>

<p>Well yes and no. If the key must be as long as the plaintext and you can secretly get a key to someone why not just send the plaintext? Additionally the total number of plaintext characters you can send is limited to the number of characters on the pads after that a new pad must be created and distributed. Modern encryption algorithms trade some security for usability at scale. One time pads are still very much used but their requirements for physical security and transportation of the pad make them impractical for general use or use between parties that don’t already know each other. This last problem is what needed to be solved for secure communication to be useful in the internet age.</p>

<p>The age of computing has created a revolution in cryptography with modern cryptosystems becoming incredibly complex and math heavy. They are not ‘perfect’ in the same way that an OTP can be; modern cryptosystems’ strength is that the work required to break them is simply unobtainable (for most actors), typically strong modern encryption measures it’s strength in millennia of computing time needed to brute force a given key. At least until the next great leap in computing is made the defense currently has the high ground.</p>

<p>All of the cryptosystems we’ve talked about thus far hinge on two parties agreeing on a key and then using that shared knowledge to encode and decode messages. Obviously this is easy to do in person but how do you agree on a key, securly, without ever meeting someone?</p>

<h1 id="meet-alice-bob-and-eve">MEET ALICE, BOB, AND EVE</h1>

<p>The entire story about how this was solved is fascinating and I encourage you to read both Steven Levy’s book Crypto about the development of Key Exchanges, PGP, and RSA. The story involves MIT, British spies from GCHQ, American spooks at Ft. Mead, and some radical dudes in California.</p>

<p>What we know about encryption so far is that keeping a key secret is the most important part of keeping a message secure, but keys are needed to encrypt and decrypt a message which is something both parties need. The solution is called public key cryptography and the problem was solved in two ways by two different teams on opposite coasts of the US around the same time. Here are the two initial approaches:</p>

<ul>
  <li>Two parties establish a shared key independently prior to sending information that needs to be secured.</li>
  <li>Everyone brings their own lock and their own key</li>
</ul>

<p>The solution to both of these comes down to math. There is a mathematical concept called a one-way function, this is a function that is very easy to compute in one direction and very difficult to invert. Given the output of one of these functions you are (practically) unable to determine what the inputs are.</p>

<h2 id="diffie-hellman-key-exchange">Diffie-Hellman Key Exchange</h2>

<p>Diffie-Hellman Key Exchange allows two people to develop a shared secret key while never communicating that secret key between one another. The shared key is then used to encrypt and decrypt messages between the two parties. The development of the shared key is easily illustrated as follows:</p>

<p><img src="https://pmanderson.dev/assets/images/dhke_wikipedia.png" alt="Wikipedia DHKE paint example" /></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1) Both communicate in the open to choose some base numbers for their shared function p and g
2) Alice selects a secret number a and computes A = g^a mod p
3) Alice selects a secret number b and computes B = g^b mod p
4) Alice sends Bob A in the clear 
5) Bob sends Alice B in the clear
6) Alice computes S = B^a mod p 
7) Bob computes S = A^b mod p 
8) Both now have secret key S
</code></pre></div></div>

<p>The underlying one-way function at work here is called the Diffie-Hellman Problem. Our eves dropper, Eve, does not have enough information, even if they monitor the entire exchange, to compute the key S.</p>

<p>Diffie-Hellman is still widely used in various permutations and parts of it are how apps like Signal and WhatsApp secure their communications (aka the Signal protocol). The disadvantage of Diffie-Hellman is that  symmetric key encryption is that it is generally less secure than asymmetric key encryption and that it is not asynchronous.</p>

<h2 id="rsa">RSA</h2>
<p>RSA attacks this problem in a different way, what if everyone distributed their own locks for free but kept their keys private? There is a subset of one-way functions called trapdoor functions, a trapdoor function is a one-way function that has once caveat, there exists an additional value (the trapdoor) that makes determining the original values trivial. This trapdoor function is key to what is known as asymmetric key encryption.</p>

<p>Asymmetric keys have two components: a public key used for encrypting data and a private key for decrypting data. Everything talked about previously would fall into the category of symmetric key encryption where both parties use a single shared key. The private key is our trapdoor and must be kept secret, but the public key can be shared to anyone who wants to send you a message. Messages encrypted using your public key can only be decrypted by your private key. The exchange works as follows:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1) Alice wants to send Bob a message 
2) Alice requests Bob's public key 
3) Bob sends Alice his private key in the open
3) Alice write's her message to Bob and encrypts it using Bob's public key 
4) Bob receives Alice's encrypted message and decrypts using his private key 
</code></pre></div></div>

<p>RSA relies on the Prime Factorization Problem for it’s security, simply put it’s very difficult to find the factors from the product of two very large prime numbers. In this case Eve has Alice and Bob’s public keys but no information about their private key and thus cannot read their messages.</p>

<p>Asymmetric key encryption is generally viewed as very secure but it’s a slower process and thus not suitable for all use cases. Asymmetric key encryption also has a major advantage because it does not require the active exchange of data  (provided you already know someone’s public key) it can be used asynchronously.</p>

<h1 id="end">END</h1>

<p>Cryptography is fascinating both for its history and for its modern advancements. Without public key cryptography the modern secure communications that power our everyday lives would simply not be possible. Ubiquitous secure communications also have a lot of civil implications. We’ve seen spats between the FBI and tech companies like Apple due to their secure devices. The US Government has a long history of limiting the export of cryptographic tools (under ITAR) lest it harm their ability to gather intelligence internationally. Some countries have key escrow services where keys are held by a ‘trusted’ third party and eligible to be seized by the government should they deem it necessary to read certain communications. The security of data and how it’s transported, stored, and secured should be of interest to all of us. If you’re interested in learning more I would point you to the main sources for this post.</p>

<p><strong>Sources:</strong></p>
<ul>
  <li><a href="https://www.goodreads.com/book/show/984428.Crypto?ac=1&amp;from_search=true&amp;qid=1r8JO4wv7r&amp;rank=3">Crypto by Steven Levy</a></li>
  <li><a href="https://www.goodreads.com/book/show/17994.The_Code_Book?from_search=true&amp;from_srp=true&amp;qid=zkH5EUKNNd&amp;rank=1">The Code Book by Simon Singh</a></li>
  <li><a href="https://www.goodreads.com/book/show/36265193-serious-cryptography?ac=1&amp;from_search=true&amp;qid=rxwHOXTPaI&amp;rank=1">Serious Cryptography: A Practical Introduction to Modern Encryption by Jean-Philippe Aumasson</a></li>
  <li><a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Diffie-Hellman Key Exchange - Wikipedia</a></li>
  <li><a href="https://en.wikipedia.org/wiki/RSA_(cryptosystem)">RSA - Wikipedia</a></li>
</ul>]]></content><author><name>Patrick Anderson</name></author><category term="software" /><category term="cryptography" /><category term="software" /><summary type="html"><![CDATA[Cryptography, while increasingly in the news, is not something most people think about affecting their day to day lives that said I believe cryptography is something that more people should be passingly familiar with as knowingly or not you have placed a great deal of trust in modern cryptography. The art of code making and code breaking has been the primary enabler of the wholesale move of many facets of life online, from online banking, social media, shopping, medical records and increasingly your communications with family and friends are able to be transmitted and stored securely thanks to the ubiquity of very strong cryptography.]]></summary></entry><entry><title type="html">Blockchain Basics</title><link href="https://pmanderson.dev/software/Blockchain-basics-copy/" rel="alternate" type="text/html" title="Blockchain Basics" /><published>2022-04-01T00:00:00+00:00</published><updated>2022-04-01T00:00:00+00:00</updated><id>https://pmanderson.dev/software/Blockchain-basics%20copy</id><content type="html" xml:base="https://pmanderson.dev/software/Blockchain-basics-copy/"><![CDATA[<p>I’m not a blockchain guy. Having written that in the immutable ink of the internet I can have it forever held against me when we all eventually upload our collective consciousness onto the great ledger in the sky. Criticism, skepticism, or even gentle probing of the relevance of blockchain technologies in all facets of life is typically met with a mixture of shock and pity by its evangelists. That said I am not alone in my skepticism and there is a growing counter weight to the “common knowledge” that the blockchain will revolutionize everything.</p>

<p>I wanted to write down some of my thoughts on the facts, as I understand them, of distributed ledger tech and draw some conclusions. Unlike when writing about nukes, on this subject I don’t have the shield of amateurism to protect me from my hot takes. I have a degree in computer science, I have been a professional software engineer for 8 years, and I should be generally better equipped than the average person off the street to understand these topics. If you disagree with my conclusions, do it with the happy knowledge that I should have known better.</p>

<p>I am going to write this with the goal of being both accurate and understandable. That said accuracy means we are not going to gloss over some of the underlying computer science or cryptographic underpinnings of these systems. What’s happening under the hood is what drives much of my skepticism. I’ll try and quickly define relevant concepts but some tangential items are beyond our scope.</p>

<p>Caveat: I am aware that there are blockchain implementations that are not distributed (ie Git is basically on a blockchain) but the common vernacular has conflated the term blockchain with crpytocurrencies and distributed ledgers so that is the terminology I am using.</p>

<h1 id="what-is-a-blockchain">What is a Blockchain?</h1>

<p>A blockchain, for the purposes of this discussion, is a distributed ledger. Ledgers keep a chronological record of transactions between accounts, it’s a concept as old as writing and ancient ledgers can give us fascinating glimpse into how people in the past lived. To put it obviously a blockchain is, as it sounds, a chain of blocks. Each block contains some data and a reference to the previous block in the chain. If you’ve studied computer science we have a name for this structure, it’s called a linked list.</p>

<p><img src="https://pmanderson.dev/assets/images/linkedlist.png" alt="Linked List Diagram" /></p>

<p>One of the core components of a ledger is trust. When looking up an account in a ledger you look for that account’s latest balance. Inherent in this operation is your trust that the ledger, up to this point, has kept an accurate accounting of all transactions such that the balance you see for any given account is accurate. The way we build trust into this structure is through cryptography, hence “crypto” being a moniker for these structures.</p>

<p>Finally the “distributed” part of distributed ledgers is in how they are managed. Traditionally you have a single entity that is responsible for the upkeep of the ledger, this might be a bank or a government. The community relying on the ledger places their trust in that entity to determine if a transaction is valid (does Bob have 10 coins to pay Alice) and keep the ledger up to date. A distributed ledger does the opposite, it places the responsibility of validating transactions and adding valid transactions to the ledger onto the community. The core issues, and strengths, of distributed ledgers are in how they deal with this problem of trust.</p>

<p>So let’s talk about how blockchains are put together focusing on the most famous of them, Bitcoin.</p>

<h1 id="the-structure-of-a-block">The structure of a block:</h1>

<p>In the case of a Bitcoin’s blockchain each block has a header that is made up of three main components (there are additional components):</p>
<ul>
  <li>The previous blocks hash</li>
  <li>The current blocks data (in the form of a <a href="https://en.wikipedia.org/wiki/Merkle_tree">Merkle tree</a>)</li>
  <li>A nonce</li>
  <li>Target hash</li>
</ul>

<p>The first component is the hash of the previous block in the chain. This serves as a link to the rest of the ledger, in the linked list diagram above we’d call this a pointer as it points back down the chain. Hashes are the output of a hash function, these functions (think math formula) can take in multiple pieces of information and output a string (a series of characters) that is representative of the input but often shorter and of a fixed length. Hashes are used for a variety of reasons including storage and access of data and encryption.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1600 Pennsylvania Avenue NW
Washington, D.C. 20500
U.S.
</code></pre></div></div>

<p><a href="https://en.wikipedia.org/wiki/SHA-2">SHA256 hash</a> of the above data:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>2c76193c4ead6909afa629eda14e6d176dfddfdbb0ebad58c68dcbc8e14a19b4
</code></pre></div></div>

<p>Second we have the data of the current block, for Bitcoin this contains a list of transactions that are to be added to the ledger. Alice gives Bob 10 coins, Bob gives Kelly 2 coins etc.. Before being added to the ledger these transactions have to be validated, Alice can’t give Bob 10 coins they don’t have.</p>

<p>Finally we have a nonce and the target hash. A nonce is a “Number Used Once”, they are arbitrary numbers used a single time in cryptography. The target hash is a number (in hexadecimal) that the resulting hash of the block must be lower than. In blockchain’s that use a proof of work system (like Bitcoin) the nonce combined with the target hash are the underpinning of the entire system.</p>

<h1 id="trust">Trust:</h1>
<p>The integrity of the Bitcoin blockchain relies on an idea called “proof of work”, this system relies on the difficulty of adding new blocks to the chain to keep the entire chain honest.</p>

<blockquote>
  <p>“Proof-of-work is essentially one-CPU-one-vote. The majority decision is represented by the longest chain, which has the greatest proof-of-work effort invested in it. If a majority of CPU power is controlled by honest nodes, the honest chain will grow the fastest and outpace any competing chains. To modify a past block, an attacker would have to redo the proof-of-work of the block and all blocks after it and then catch up with and surpass the work of the honest nodes.”</p>
</blockquote>

<p>- <em>Bitcoin: A Peer-to-Peer Electronic Cash System</em></p>

<p>The idea is that the effort required to add a new block containing a fraudulent transaction to the chain and then to keep adding new blocks, such that your fraudulent transaction is on the longest chain, is prohibitive. The work in this case is artificial, the actual validation of transactions is relatively trivial for a computer.</p>

<blockquote>
  <p>“The proof-of-work involves scanning for a value that when hashed, such as with SHA-256, the hash begins with a number of zero bits. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.”</p>
</blockquote>

<p>- <em>Bitcoin: A Peer-to-Peer Electronic Cash System</em></p>

<p>This is where we get to cryptography, one way functions like SHA256 are designed such that determining the input from a given output is impossible short of guessing all possible inputs. Any change in the input will produce wildly different outputs meaning the guesser has no idea if they are close to or far from the original value. The only way to find a nonce that when included in the blocks data produces a hash of the correct value is to guess and check. Nonce’s are 32 bits in size and can hold a value between 0 and 2^32.</p>

<p>To give you an idea of how much work goes into finding a valid hash currently:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Time = difficulty * (2^32) / hashrate
</code></pre></div></div>

<p>As of 4/1/2022 Bitcoin’s difficulty is = 27,452,707,696,466</p>

<p>Using a rough hashrate (this number depends on a lot of factors) for my computer of 30,000,000 guesses a second (30Mh/s) if I were the only person trying to find a valid hash it would take:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>((((27,452,707,696,466 * 2^32) / (30,000,000)) /60) /60)/8760 =  124,628,447.64 years
</code></pre></div></div>

<p>It’s important to remember that the number is “years of computer work” and that number has real world costs attached to it in terms of power consumption and hardware. In reality this workload is spread across all computers on the network but the sum total of their efforts in a worst case scenario will be the same as above. Additionally difficulty is adjusted by the network every 2 weeks such that time = 10m/block, as more computing power works on the chain the difficulty must increase in order to keep the rate at 10m per block added.</p>

<p>In short, in order to insert a fraudulent transaction into the blockchain the fraudster not only needs to be faster than every other validator they need to keep being faster in order to maintain the longest chain. Unless a single entity controls &gt; 50% of the computing power on a chain the ledger should be secure. This is so incredibly difficult to do that the longest chain can be trusted based on the mathematical likelihood of its validity.</p>

<p>Finally here is a summary of the entire trust workflow from the Bitcoin whitepaper:</p>

<blockquote>
  <p>“The steps to run the network are as follows: 
1) New transactions are broadcast to all nodes.
2) Each node collects new transactions into a block. 
3) Each node works on finding a difficult proof-of-work for its block. 
4) When a node finds a proof-of-work, it broadcasts the block to all nodes. 
5) Nodes accept the block only if all transactions in it are valid and not already spent. 
6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.”</p>
</blockquote>

<p>- <em>Bitcoin: A Peer-to-Peer Electronic Cash System</em></p>

<h1 id="so-where-are-the-coins">So where are the coins?</h1>

<p>We’ve established a few facts above:</p>
<ul>
  <li>In order for the blockchain to be trustworthy, creating new blocks must meet a threshold of difficulty.</li>
  <li>Distributed ledgers require many nodes working together to be secure</li>
  <li>There are real world monetary costs to finding a valid hash</li>
</ul>

<p>The question you should be asking is why would anyone want to run a node in this set up if it’s going to consume power (and therefore money) and hardware to do so? The answer is that the first node that finds a valid hash gets to add one last transaction to the block, this is a bounty for validating the block and grants a reward to the validator. This is where the term “mining” comes from, new coins are mined/created every time a block is added to the chain as an incentive for people to run a node (or many nodes).</p>

<p>So we’ve arrived at cryptocurrencies. A cryptocurrency is the incentive for individuals to contribute computing power to the ledger.</p>

<h1 id="wrapping-up">Wrapping up:</h1>

<p>There are a lot of things I’ve not touched on such as:</p>
<ul>
  <li>How difficulty is set and adjusted</li>
  <li>Nodes and how they coordinate/communicate</li>
  <li>How transactions are conducted and validated</li>
  <li>How data is stored and accessed on the chain</li>
  <li>Extra nonce and other steps for generating an valid hash aside from the nonce</li>
  <li>There are other systems of trust used in other distributed ledgers like proof of stake</li>
  <li>Privacy
etc..</li>
</ul>

<p>If you are interested in the inner workings of blockchains I would advise you to use sources that are as removed from the monetary aspects of the ecosystem as possible. I’d start with the source I’ve most referenced here which is the Bitcoin whitepaper.</p>

<p>Now that we’ve laid the groundwork I want to talk about why I don’t think blockchain is the wave of the future and what blockchains might actually be useful for. That said I don’t write these on a schedule so don’t hold your breath.</p>

<p><strong>Sources:</strong></p>
<ul>
  <li><a href="https://bitcoin.org/bitcoin.pdf">Bitcoin Whitepaper - Satoshi Nakamoto</a></li>
  <li><a href="https://blog.dshr.org/2022/02/ee380-talk.html">CEE380 Talk - Dr. David Rosenthal</a></li>
  <li><a href="https://www.youtube.com/watch?v=J9nv0Ol-R5Q">Computer Security 161 Cryptocurrency Lecture - Dr. Nicholas Weaver</a></li>
  <li><a href="https://www.youtube.com/watch?v=bBC-nXj3Ng4&amp;t=37s">But how does bitcoin actually work? - Youtube</a></li>
</ul>

<p><strong>Good books on cryptography:</strong></p>
<ul>
  <li><a href="https://www.goodreads.com/book/show/984428.Crypto?ac=1&amp;from_search=true&amp;qid=1r8JO4wv7r&amp;rank=3">Crypto by Steven Levy</a></li>
  <li><a href="https://www.goodreads.com/book/show/17994.The_Code_Book?from_search=true&amp;from_srp=true&amp;qid=zkH5EUKNNd&amp;rank=1">The Code Book by Simon Singh</a></li>
  <li><a href="https://www.goodreads.com/book/show/36265193-serious-cryptography?ac=1&amp;from_search=true&amp;qid=rxwHOXTPaI&amp;rank=1">Serious Cryptography: A Practical Introduction to Modern Encryption by Jean-Philippe Aumasson</a></li>
</ul>]]></content><author><name>Patrick Anderson</name></author><category term="software" /><category term="cryptography" /><category term="blockchain" /><category term="software" /><summary type="html"><![CDATA[I’m not a blockchain guy. Having written that in the immutable ink of the internet I can have it forever held against me when we all eventually upload our collective consciousness onto the great ledger in the sky. Criticism, skepticism, or even gentle probing of the relevance of blockchain technologies in all facets of life is typically met with a mixture of shock and pity by its evangelists. That said I am not alone in my skepticism and there is a growing counter weight to the “common knowledge” that the blockchain will revolutionize everything.]]></summary></entry><entry><title type="html">Nuclear Posture: A nuclear noobs intro</title><link href="https://pmanderson.dev/nuclear/Nuclear-Posture/" rel="alternate" type="text/html" title="Nuclear Posture: A nuclear noobs intro" /><published>2022-03-03T00:00:00+00:00</published><updated>2022-03-03T00:00:00+00:00</updated><id>https://pmanderson.dev/nuclear/Nuclear-Posture</id><content type="html" xml:base="https://pmanderson.dev/nuclear/Nuclear-Posture/"><![CDATA[<p>How do nations think about nuclear weapons?</p>

<p>Nukes are back in the news again as Vladimir Putin has ordered his tactical nuclear forces into a higher state of readiness. This came about after slower than expected progress made by Russian forces during their invasion of Ukraine and an increase in western sanctions as well as lethal support for the Ukrainian armed forces.</p>

<p>Most people don’t think very much about nuclear arms until they explode onto our headlines, seemingly at random, once or twice a year. Usually this is in the form of a North Korean test, or a new round of talks about the Iranian nuclear program. Luckily there exists a committed group of academics and experts, outside of a military or political apparatus, who do think about nuclear arms on a regular basis who we can learn from.</p>

<p>I want to write a series of posts for lay people, by a lay person, to talk about some of the different facets of the field in slightly more complexity, and hopefully with more competency, than your local news broadcast.</p>

<p>A couple of ground rules:</p>

<ul>
  <li>
    <p>Complexity isn’t to be shunned &amp; ambiguity isn’t a failing. Hard problems often don’t present absolute answers, this holds for the subject of nuclear arms.</p>
  </li>
  <li>
    <p>I will be pulling from the far deeper work of the academics and thinkers in this field, all sources will be cited.</p>
  </li>
  <li>
    <p>I am open to being wrong in my interpretations. I don’t understand this subject as well as many other people.</p>
  </li>
  <li>
    <p>I will try and use, as well as explain, the language used by experts in this field. Words have specific meanings in highly technical subjects. Sticking to those meanings and explaining them is better than reducing their precision by translating terminology into more common wording.</p>
  </li>
</ul>

<p>Cool, so where do we start?</p>

<h1 id="what-is-nuclear-posture">What is Nuclear Posture:</h1>

<p>I want to start here because it’s relevant to current events and frankly I need to start somewhere. What is nuclear posture? How can it be used to interpret current events?  Let’s start by defining the term. For this post I am going to rely on Dr. Vipin Narang’s Optimization Theory of Nuclear Posture.</p>

<blockquote>
  <p>“Nuclear posture is the incorporation of some number and type of nuclear warheads and delivery vehicles, the state’s overall military structure, the rules and procedures governing how those weapons are deployed, when and under what conditions they might be used, against what targets, and who has the authority to make those decisions. Nuclear posture is best thought of as the operational, rather than the declaratory, nuclear doctrine of a country; while the two can overlap, it is the operational doctrine that generates deterrent power against an opponent.”</p>
</blockquote>

<p>- <em>Vipin Narang, Nuclear Strategy in the Modern Era</em></p>

<p>That’s a lot of jargon right out of the gate, let’s try and reduce this very technical definition to its core components.</p>

<p>Nuclear posture is the combination of:</p>
<ol>
  <li>What a nation’s equipment allows its nuclear forces to do.</li>
  <li>How a nation’s policies and organizations allow for that equipment to be used.</li>
</ol>

<p>Additionally Dr. Narang notes that a nuclear posture and what a nation or government says about how it will use its nuclear weapons (aka declaratory nuclear doctrine) can be different. For example, proclaiming to your coworkers that you are going to ride a bike to work is a declaratory doctrine. The fact that you neither own or know how to ride a bike would indicate that your operational doctrine is in fact going to be car based.</p>

<p>The difference between these two is important and the effects of this gap are observable. North Korea’s declaration that it will use its nuclear arsenal against targets in the US doesn’t provide the same deterrent power as the same threat from Russia. The difference here is that Russia has a nuclear posture capable of making good on that threat, they have missiles capable of reaching the US, warheads that can survive the trip, and a reliable system for ordering the launch. On the other side there are questions about the reliability of North Korea ICBMs, their ability to make a small enough nuke, and if their warhead would survive reentry. In Dr. Narang’s words:</p>

<blockquote>
  <p>“To put it bluntly, states care more about what an adversary can credibly do with its nuclear weapons than what it says about them.”</p>
</blockquote>

<p>Nuclear posture provides us a way to understand the deterrent capability of a nation’s nuclear forces, and the components of a nuclear posture give us some insight into how a state thinks about its nuclear arms.</p>

<h2 id="types-of-nuclear-posture">Types of nuclear posture:</h2>

<table>
  <thead>
    <tr>
      <th style="text-align: left"> </th>
      <th style="text-align: center"><strong>Catalytic</strong></th>
      <th style="text-align: right"><strong>Assured Retaliation</strong></th>
      <th style="text-align: right"><strong>Asymmetric Escalation</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: left"><strong>Capabilities</strong></td>
      <td style="text-align: center">Ability to assemble a small number of weapons.</td>
      <td style="text-align: right">Survivable second strike forces.</td>
      <td style="text-align: right">First use capabilities.</td>
    </tr>
    <tr>
      <td style="text-align: left"><strong>Management</strong></td>
      <td style="text-align: center">Unknown/opaque</td>
      <td style="text-align: right">Assertive political control</td>
      <td style="text-align: right">Delegative (assets and authority and integrated into military forces)</td>
    </tr>
    <tr>
      <td style="text-align: left"><strong>Transparency</strong></td>
      <td style="text-align: center">Ambiguous capability and deployment</td>
      <td style="text-align: right">Unambiguous capability,ambiguous deployment</td>
      <td style="text-align: right">Unambiguous capability and deployment</td>
    </tr>
    <tr>
      <td style="text-align: left"><strong>Employment</strong></td>
      <td style="text-align: center">Leverage possibility of nuclear breakout to get 3rd party intervention.</td>
      <td style="text-align: right">Certain nuclear retaliation after a serious attack.</td>
      <td style="text-align: right">Nuclear first use against conventional forces.</td>
    </tr>
    <tr>
      <td style="text-align: left"><strong>Cost</strong></td>
      <td style="text-align: center">$</td>
      <td style="text-align: right">$$$</td>
      <td style="text-align: right">$$</td>
    </tr>
  </tbody>
</table>

<p style="text-align: center;"><sup>Table credit <em>Vipin Narang, Nuclear Strategy in the Modern Era</em><sup></sup></sup></p>

<h3 id="catalytic">Catalytic:</h3>
<p>Catalytic states use the ambiguity of their nuclear capabilities and their position as a client state to a major power to get prompt intercession by said power on their behalf. Typically a catalytic nuclear force is shrouded in secrecy with the number, types and operability of their nuclear weapons left deliberately ambiguous. The goal of a catalytic posture is not to actually use nuclear weapons directly but rather to use the threat of nuclear escalation to bring a more powerful patron state into a conflict as a mediator, supporter or belligerent.</p>

<p>Catalytic postures require a patron state to function and thus isn’t operational for the higher rungs of the geopolitical ladder. Additionally catalytic postures are relatively cheap, you don’t actually need to build an arsenal or complex systems for managing one, all you need is a few nukes and a friend in a high place.</p>

<p><img src="https://upload.wikimedia.org/wikipedia/en/1/10/South_African_nuclear_bomb_casings.jpg" alt="South African nuclear bomb casings" class="align-center" /></p>

<p style="text-align: center;"><sup><em>Bomb casings at South Africa’s abandoned nuclear bomb production facility near Pretoria, original source photojournalist Mungo Poore</em><sup></sup></sup></p>

<p><strong>Examples:</strong> Israel (pre-1990), South Africa</p>

<h3 id="assured-retaliation">Assured Retaliation:</h3>
<p>Assured retaliation envisions a survivable nuclear force that can credibly hit back after a nuclear first strike. This posture deters by demonstrating a near certain ability to deliver nuclear weapons into an adversary’s territory while at the same time concealing or fortifying it’s forces to a degree that an opponent cannot eliminate a retaliatory threat with a first strike.</p>

<p>States using this posture keep their arsenals under assertive political control. This centralized control minimizes the risk of an accidental launch by giving non military leadership the sole authority to fire nuclear weapons. Oftentime warheads and delivery systems are kept apart, launch codes or keys are likewise kept by separate agencies from those controlling the weapons themselves. The trade off of assertive control is speed, this is an acceptable tradeoff for a state planning on shooting second.</p>

<p>Assured retaliation is the most expensive posture listed here, it requires advanced technology and infrastructure such as long range missiles, ballistic missile submarines (SSBNs), hardened storage &amp; launch facilities like underground silos, or movable missiles on gigantic transporter/launchers (TELs). Most importantly this system needs a reliable system for launching missiles by a central authority, this means planning, drills, hardened communication lines, means of authentication etc.. Any one of these items are a significant investment of both money and time, systems like long range missiles take decades to develop, and places assured retaliation out of reach for many nations.</p>

<p><img src="https://english.cdn.zeenews.com/sites/default/files/2014/12/15/303178-arihant.jpg" alt="INS Arihant" class="align-center" /></p>

<p style="text-align: center;"><sup>
<em>Indian Arihant class balistic missile submarine, credit Zee News India</em></sup></p>
<p><sup></sup></p>

<p><strong>Examples:</strong> China, India</p>

<h3 id="asymmetric-escalation">Asymmetric Escalation:</h3>
<p>Asymmetric escalators threaten the use of nuclear weapons in response to any significant attack, conventional or otherwise. These states deter through the credible threat of immediate nuclear use should they come under attack.</p>

<p>Asymmetric escalators prize speed over security of nuclear forces and delegate launch authority and assets to military commanders. Nuclear weapons must be able to be launched quickly and with little warning so their usage is built into military doctrine and their systems integrated into military forces. The tradeoff of this speed is safety, accidental launch is a greater risk in delegatory systems as the decision making is “farmed out” to more individuals.</p>

<p>From a cost perspective asymmetric escalation is somewhat of a middle ground. Nuclear weapons need to be produced in quantity and systems for using them on the battlefield must be developed and deployed but these are much cheaper than the more advanced and hardened systems for a second strike force. Additionally there more complex apparatus for command and control seen in assured retaliatory states isn’t needed here.</p>

<p><img src="https://www.defencetalk.com/wp-content/uploads/2009/05/pakistani-nuclear-arms-missile.jpg" alt="Pakistani TEL" class="align-center" /></p>

<p style="text-align: center;"><sup><em>A Pakistani TEL (Transporter Erector Launcher), credit defencetalk.com</em><sup></sup></sup></p>

<p><strong>Examples:</strong> France, Pakistan, North Korea</p>

<p>You’ll notice that several major nuclear powers are not listed as examples, particularly the US and Russia. Both the US and Russian arsenals are so vast they essentially pursue both asymmetric escalation and assured retaliation simultaneously, however both maintain strong political control over their arsenal. If you are interested in why a state might select a specific posture and a deeper understanding of the Optimization Theory of Nuclear Posture please read Dr. Narangs book on the subject <em>Nuclear Strategy in the Modern Era</em> from which most of this information was gleaned.</p>

<h2 id="how-can-we-apply-this-today">How can we apply this today?</h2>
<p>Nuclear Posture can be a lens through which we interpret a state’s actions and declarations surrounding its nuclear force. An example of this are the various interpretations of recent developments in China. In July 2021 new satellite imagery taken by Planet and analyzed by arms control experts from the James Martin Center for Nonproliferation Studies at the Middlebury Institute of International Studies at Monterey (CNS/MIIS) revealed 120 silos under construction by China’s PLA Rocket Force (<a href="https://www.armscontrolwonk.com/archive/1212340/chinese-icbm-silos/">Article</a>).</p>

<p><img src="https://www.armscontrolwonk.com/files/2021/07/Overview-1024x684.jpg" alt="Chinese ICBM Silos" /></p>

<p style="text-align: center;"><sup><em>120 silos under construction in Yumen, China. Credit Planet &amp; James Martin Center for Nonproliferation Studies</em><sup></sup></sup></p>

<p>This represents a significant increase in the number of ICBM silos operated by China. On the surface building 100+ missile silos would seem to indicate an intent to threaten the would-be adversaries with a vast nuclear arsenal. Some pundits, lawmakers and observers were shocked by what they saw as a drastic and threatening move by China signaling a new more aggressive nuclear strategy to the west.</p>

<blockquote>
  <p>“Nicholas Burns, the Biden administration’s nominee to be US Ambassador to China, said during his confirmation hearing last month that the Chinese “are blasting past that definition (of a minimum nuclear deterrent), and they’re rapidly engaged in the buildup of their nuclear arsenal, including the disturbing reports of the hypersonic technology.”</p>
</blockquote>

<p>- <a href="https://www.cnn.com/2021/11/02/politics/china-suspected-silo-fields-report/index.html">CNN A change in China’s approach?</a></p>

<p>However when looking at this development through the lens of Chinese nuclear posture we can come to a different conclusion as to why these silos might be built.</p>

<p>Chinese declared nuclear posture is that of assured retaliation:</p>

<blockquote>
  <p>“The most recent Defense White Paper, alongside some Chinese texts, makes clear that China plans on using alert levels to signal resolve. ‘If China comes under a nuclear threat’ the 2013 paper states, ‘nuclear missile force will act upon the orders of the [Central Military Commission], go into higher level of readiness, and get ready for a nuclear counterattack to deter the enemy from using nuclear weapons against China.’ “</p>
</blockquote>

<p>- <em>Paper Tigers: China’s Nuclear Posture</em> by Jeffery Lewis</p>

<p>Navigating our grid above we can see that this means that China has:</p>
<ul>
  <li>Assertive political control of launch authority</li>
  <li>Survivable nuclear forces</li>
  <li>Unambiguous capabilities with ambiguous deployment strategies</li>
</ul>

<p>Silos are certainly not ambiguous deployments at first glance but the layout of the field, particularly the spacing (approx 3km) between silos, indicates that this may be a shell game approach to missile basing. Not every silo needs a missile, but every silo would have to be destroyed in order to assure China couldn’t strike back at an adversary. This aligns with current Chinese nuclear posture as these new silos would be an unambiguous capability with an ambiguous deployment strategy. I subscribe to this view especially given China’s relatively small arsenal of nuclear warheads which number around 350 in total (<a href="https://www.sipri.org/research/armament-and-disarmament/nuclear-disarmament-arms-control-and-non-proliferation/world-nuclear-forces">Source</a>).</p>

<p>While building more ICBM silos certainly isn’t a good thing by applying what we know about nuclear posture we can make a good argument that this is in fact not a drastic change from what China has been doing for decades and probably not cause for great alarm.</p>

<p>For further reading on the history and thinking behind Chinese nuclear forces I highly recommend <em>Paper Tigers: China’s Nuclear Posture</em> by Dr. Jeffery Lewis.</p>

<p>Hopefully this was relatively understandable, I’ll return to the subject of nuclear weapons in the near future. If you want to talk with other amateur (and some professional) arms control nerds come join an awesome OSINT community at the Arms Control Wonk slack channel. If you are interested in this stuff and want to hear from the actual experts I can highly recommend the following podcasts:</p>

<ul>
  <li><a href="https://www.armscontrolwonk.com/archive/author/podcast/">The Arms Control Wonk Podcast</a></li>
  <li><a href="https://podcasts.apple.com/us/podcast/the-diplomat-asia-geopolitics/id852773346">The Diplomat: Asian Geopolitcs Podcast</a></li>
  <li><a href="https://www.fpri.org/research/nationalsecurity/chain-reaction/">The Chain Reaction Podcast from FPRI</a></li>
  <li><a href="https://atthebrink.org/">At The Brink Podcast from the William J Perry Project</a></li>
</ul>

<p>Books Mentioned in this post:</p>
<ul>
  <li><a href="https://www.goodreads.com/en/book/show/23989461">Paper Tigers: China’s Nuclear Posture by Jeffery Lewis </a></li>
  <li><a href="https://www.goodreads.com/book/show/18730641-nuclear-strategy-in-the-modern-era">Nuclear Strategy in the Modern Era by Vipin Narang</a></li>
</ul>]]></content><author><name>Patrick Anderson</name></author><category term="Nuclear" /><category term="nuclear" /><category term="armscontrol" /><summary type="html"><![CDATA[How do nations think about nuclear weapons?]]></summary></entry><entry><title type="html">What’s this all about?</title><link href="https://pmanderson.dev/admin/About-This-Site/" rel="alternate" type="text/html" title="What’s this all about?" /><published>2022-02-24T00:00:00+00:00</published><updated>2022-02-24T00:00:00+00:00</updated><id>https://pmanderson.dev/admin/About%20-This-Site</id><content type="html" xml:base="https://pmanderson.dev/admin/About-This-Site/"><![CDATA[<blockquote>
  <p>“What is the last thing you taught yourself?”</p>
</blockquote>

<p>My wife mentioned that this was her new favorite question to ask during interviews. It’s a great question and thinking about it had me going back over what I’d tried, under my own initiative, to learn over the past year. The answer doesn’t need to be some serious or grand undertaking. Learning anything new is an achievement and the goal of the question is for the interviewee to teach the interviewer something, not to pass some arbitrary bar of scholarship.</p>

<p>Talking to others about things you’ve learned is often a sure way of sorting out how well you’ve actually learned something. The ability to explain, even to yourself, is a surer test of understanding than finishing a book or following a tutorial. That’s the entire reason this site exists, as a vehicle and a reason for me to explore, organize and relearn through writing.</p>

<p>Why not just keep a journal? If I’m being honest it’s mostly vanity (why anyone would want to read my musings is beyond me) but something about the act of writing and putting it up for people to see, even obscurely, scratches a creative itch.</p>

<p>So, this website is about whatever I feel like writing about. I’m not going to keep to a schedule or plan (shocking to those who know me). I’m not going to theme or otherwise confine it’s subjects. The content, or lack thereof, hosted here is a reflection of whatever catches my eye.</p>]]></content><author><name>Patrick Anderson</name></author><category term="Admin" /><category term="about" /><category term="why" /><summary type="html"><![CDATA[“What is the last thing you taught yourself?”]]></summary></entry></feed>