[
  {
    "path": "LICENSE-CC-BY-SA.md",
    "content": "Attribution-ShareAlike 4.0 International\n\n=======================================================================\n\nCreative Commons Corporation (\"Creative Commons\") is not a law firm and\ndoes not provide legal services or legal advice. Distribution of\nCreative Commons public licenses does not create a lawyer-client or\nother relationship. Creative Commons makes its licenses and related\ninformation available on an \"as-is\" basis. Creative Commons gives no\nwarranties regarding its licenses, any material licensed under their\nterms and conditions, or any related information. Creative Commons\ndisclaims all liability for damages resulting from their use to the\nfullest extent possible.\n\nUsing Creative Commons Public Licenses\n\nCreative Commons public licenses provide a standard set of terms and\nconditions that creators and other rights holders may use to share\noriginal works of authorship and other material subject to copyright\nand certain other rights specified in the public license below. The\nfollowing considerations are for informational purposes only, are not\nexhaustive, and do not form part of our licenses.\n\n     Considerations for licensors: Our public licenses are\n     intended for use by those authorized to give the public\n     permission to use material in ways otherwise restricted by\n     copyright and certain other rights. Our licenses are\n     irrevocable. Licensors should read and understand the terms\n     and conditions of the license they choose before applying it.\n     Licensors should also secure all rights necessary before\n     applying our licenses so that the public can reuse the\n     material as expected. Licensors should clearly mark any\n     material not subject to the license. This includes other CC-\n     licensed material, or material used under an exception or\n     limitation to copyright. More considerations for licensors:\n\twiki.creativecommons.org/Considerations_for_licensors\n\n     Considerations for the public: By using one of our public\n     licenses, a licensor grants the public permission to use the\n     licensed material under specified terms and conditions. If\n     the licensor's permission is not necessary for any reason--for\n     example, because of any applicable exception or limitation to\n     copyright--then that use is not regulated by the license. Our\n     licenses grant only permissions under copyright and certain\n     other rights that a licensor has authority to grant. Use of\n     the licensed material may still be restricted for other\n     reasons, including because others have copyright or other\n     rights in the material. A licensor may make special requests,\n     such as asking that all changes be marked or described.\n     Although not required by our licenses, you are encouraged to\n     respect those requests where reasonable. More_considerations\n     for the public:\n\twiki.creativecommons.org/Considerations_for_licensees\n\n=======================================================================\n\nCreative Commons Attribution-ShareAlike 4.0 International Public\nLicense\n\nBy exercising the Licensed Rights (defined below), You accept and agree\nto be bound by the terms and conditions of this Creative Commons\nAttribution-ShareAlike 4.0 International Public License (\"Public\nLicense\"). To the extent this Public License may be interpreted as a\ncontract, You are granted the Licensed Rights in consideration of Your\nacceptance of these terms and conditions, and the Licensor grants You\nsuch rights in consideration of benefits the Licensor receives from\nmaking the Licensed Material available under these terms and\nconditions.\n\n\nSection 1 -- Definitions.\n\n  a. Adapted Material means material subject to Copyright and Similar\n     Rights that is derived from or based upon the Licensed Material\n     and in which the Licensed Material is translated, altered,\n     arranged, transformed, or otherwise modified in a manner requiring\n     permission under the Copyright and Similar Rights held by the\n     Licensor. For purposes of this Public License, where the Licensed\n     Material is a musical work, performance, or sound recording,\n     Adapted Material is always produced where the Licensed Material is\n     synched in timed relation with a moving image.\n\n  b. Adapter's License means the license You apply to Your Copyright\n     and Similar Rights in Your contributions to Adapted Material in\n     accordance with the terms and conditions of this Public License.\n\n  c. BY-SA Compatible License means a license listed at\n     creativecommons.org/compatiblelicenses, approved by Creative\n     Commons as essentially the equivalent of this Public License.\n\n  d. Copyright and Similar Rights means copyright and/or similar rights\n     closely related to copyright including, without limitation,\n     performance, broadcast, sound recording, and Sui Generis Database\n     Rights, without regard to how the rights are labeled or\n     categorized. For purposes of this Public License, the rights\n     specified in Section 2(b)(1)-(2) are not Copyright and Similar\n     Rights.\n\n  e. Effective Technological Measures means those measures that, in the\n     absence of proper authority, may not be circumvented under laws\n     fulfilling obligations under Article 11 of the WIPO Copyright\n     Treaty adopted on December 20, 1996, and/or similar international\n     agreements.\n\n  f. Exceptions and Limitations means fair use, fair dealing, and/or\n     any other exception or limitation to Copyright and Similar Rights\n     that applies to Your use of the Licensed Material.\n\n  g. License Elements means the license attributes listed in the name\n     of a Creative Commons Public License. The License Elements of this\n     Public License are Attribution and ShareAlike.\n\n  h. Licensed Material means the artistic or literary work, database,\n     or other material to which the Licensor applied this Public\n     License.\n\n  i. Licensed Rights means the rights granted to You subject to the\n     terms and conditions of this Public License, which are limited to\n     all Copyright and Similar Rights that apply to Your use of the\n     Licensed Material and that the Licensor has authority to license.\n\n  j. Licensor means the individual(s) or entity(ies) granting rights\n     under this Public License.\n\n  k. Share means to provide material to the public by any means or\n     process that requires permission under the Licensed Rights, such\n     as reproduction, public display, public performance, distribution,\n     dissemination, communication, or importation, and to make material\n     available to the public including in ways that members of the\n     public may access the material from a place and at a time\n     individually chosen by them.\n\n  l. Sui Generis Database Rights means rights other than copyright\n     resulting from Directive 96/9/EC of the European Parliament and of\n     the Council of 11 March 1996 on the legal protection of databases,\n     as amended and/or succeeded, as well as other essentially\n     equivalent rights anywhere in the world.\n\n  m. You means the individual or entity exercising the Licensed Rights\n     under this Public License. Your has a corresponding meaning.\n\n\nSection 2 -- Scope.\n\n  a. License grant.\n\n       1. Subject to the terms and conditions of this Public License,\n          the Licensor hereby grants You a worldwide, royalty-free,\n          non-sublicensable, non-exclusive, irrevocable license to\n          exercise the Licensed Rights in the Licensed Material to:\n\n            a. reproduce and Share the Licensed Material, in whole or\n               in part; and\n\n            b. produce, reproduce, and Share Adapted Material.\n\n       2. Exceptions and Limitations. For the avoidance of doubt, where\n          Exceptions and Limitations apply to Your use, this Public\n          License does not apply, and You do not need to comply with\n          its terms and conditions.\n\n       3. Term. The term of this Public License is specified in Section\n          6(a).\n\n       4. Media and formats; technical modifications allowed. The\n          Licensor authorizes You to exercise the Licensed Rights in\n          all media and formats whether now known or hereafter created,\n          and to make technical modifications necessary to do so. The\n          Licensor waives and/or agrees not to assert any right or\n          authority to forbid You from making technical modifications\n          necessary to exercise the Licensed Rights, including\n          technical modifications necessary to circumvent Effective\n          Technological Measures. For purposes of this Public License,\n          simply making modifications authorized by this Section 2(a)\n          (4) never produces Adapted Material.\n\n       5. Downstream recipients.\n\n            a. Offer from the Licensor -- Licensed Material. Every\n               recipient of the Licensed Material automatically\n               receives an offer from the Licensor to exercise the\n               Licensed Rights under the terms and conditions of this\n               Public License.\n\n            b. Additional offer from the Licensor -- Adapted Material.\n               Every recipient of Adapted Material from You\n               automatically receives an offer from the Licensor to\n               exercise the Licensed Rights in the Adapted Material\n               under the conditions of the Adapter's License You apply.\n\n            c. No downstream restrictions. You may not offer or impose\n               any additional or different terms or conditions on, or\n               apply any Effective Technological Measures to, the\n               Licensed Material if doing so restricts exercise of the\n               Licensed Rights by any recipient of the Licensed\n               Material.\n\n       6. No endorsement. Nothing in this Public License constitutes or\n          may be construed as permission to assert or imply that You\n          are, or that Your use of the Licensed Material is, connected\n          with, or sponsored, endorsed, or granted official status by,\n          the Licensor or others designated to receive attribution as\n          provided in Section 3(a)(1)(A)(i).\n\n  b. Other rights.\n\n       1. Moral rights, such as the right of integrity, are not\n          licensed under this Public License, nor are publicity,\n          privacy, and/or other similar personality rights; however, to\n          the extent possible, the Licensor waives and/or agrees not to\n          assert any such rights held by the Licensor to the limited\n          extent necessary to allow You to exercise the Licensed\n          Rights, but not otherwise.\n\n       2. Patent and trademark rights are not licensed under this\n          Public License.\n\n       3. To the extent possible, the Licensor waives any right to\n          collect royalties from You for the exercise of the Licensed\n          Rights, whether directly or through a collecting society\n          under any voluntary or waivable statutory or compulsory\n          licensing scheme. In all other cases the Licensor expressly\n          reserves any right to collect such royalties.\n\n\nSection 3 -- License Conditions.\n\nYour exercise of the Licensed Rights is expressly made subject to the\nfollowing conditions.\n\n  a. Attribution.\n\n       1. If You Share the Licensed Material (including in modified\n          form), You must:\n\n            a. retain the following if it is supplied by the Licensor\n               with the Licensed Material:\n\n                 i. identification of the creator(s) of the Licensed\n                    Material and any others designated to receive\n                    attribution, in any reasonable manner requested by\n                    the Licensor (including by pseudonym if\n                    designated);\n\n                ii. a copyright notice;\n\n               iii. a notice that refers to this Public License;\n\n                iv. a notice that refers to the disclaimer of\n                    warranties;\n\n                 v. a URI or hyperlink to the Licensed Material to the\n                    extent reasonably practicable;\n\n            b. indicate if You modified the Licensed Material and\n               retain an indication of any previous modifications; and\n\n            c. indicate the Licensed Material is licensed under this\n               Public License, and include the text of, or the URI or\n               hyperlink to, this Public License.\n\n       2. You may satisfy the conditions in Section 3(a)(1) in any\n          reasonable manner based on the medium, means, and context in\n          which You Share the Licensed Material. For example, it may be\n          reasonable to satisfy the conditions by providing a URI or\n          hyperlink to a resource that includes the required\n          information.\n\n       3. If requested by the Licensor, You must remove any of the\n          information required by Section 3(a)(1)(A) to the extent\n          reasonably practicable.\n\n  b. ShareAlike.\n\n     In addition to the conditions in Section 3(a), if You Share\n     Adapted Material You produce, the following conditions also apply.\n\n       1. The Adapter's License You apply must be a Creative Commons\n          license with the same License Elements, this version or\n          later, or a BY-SA Compatible License.\n\n       2. You must include the text of, or the URI or hyperlink to, the\n          Adapter's License You apply. You may satisfy this condition\n          in any reasonable manner based on the medium, means, and\n          context in which You Share Adapted Material.\n\n       3. You may not offer or impose any additional or different terms\n          or conditions on, or apply any Effective Technological\n          Measures to, Adapted Material that restrict exercise of the\n          rights granted under the Adapter's License You apply.\n\n\nSection 4 -- Sui Generis Database Rights.\n\nWhere the Licensed Rights include Sui Generis Database Rights that\napply to Your use of the Licensed Material:\n\n  a. for the avoidance of doubt, Section 2(a)(1) grants You the right\n     to extract, reuse, reproduce, and Share all or a substantial\n     portion of the contents of the database;\n\n  b. if You include all or a substantial portion of the database\n     contents in a database in which You have Sui Generis Database\n     Rights, then the database in which You have Sui Generis Database\n     Rights (but not its individual contents) is Adapted Material,\n\n     including for purposes of Section 3(b); and\n  c. You must comply with the conditions in Section 3(a) if You Share\n     all or a substantial portion of the contents of the database.\n\nFor the avoidance of doubt, this Section 4 supplements and does not\nreplace Your obligations under this Public License where the Licensed\nRights include other Copyright and Similar Rights.\n\n\nSection 5 -- Disclaimer of Warranties and Limitation of Liability.\n\n  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE\n     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS\n     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF\n     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,\n     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,\n     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR\n     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,\n     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT\n     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT\n     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.\n\n  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE\n     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,\n     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,\n     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,\n     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR\n     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN\n     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR\n     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR\n     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.\n\n  c. The disclaimer of warranties and limitation of liability provided\n     above shall be interpreted in a manner that, to the extent\n     possible, most closely approximates an absolute disclaimer and\n     waiver of all liability.\n\n\nSection 6 -- Term and Termination.\n\n  a. This Public License applies for the term of the Copyright and\n     Similar Rights licensed here. However, if You fail to comply with\n     this Public License, then Your rights under this Public License\n     terminate automatically.\n\n  b. Where Your right to use the Licensed Material has terminated under\n     Section 6(a), it reinstates:\n\n       1. automatically as of the date the violation is cured, provided\n          it is cured within 30 days of Your discovery of the\n          violation; or\n\n       2. upon express reinstatement by the Licensor.\n\n     For the avoidance of doubt, this Section 6(b) does not affect any\n     right the Licensor may have to seek remedies for Your violations\n     of this Public License.\n\n  c. For the avoidance of doubt, the Licensor may also offer the\n     Licensed Material under separate terms or conditions or stop\n     distributing the Licensed Material at any time; however, doing so\n     will not terminate this Public License.\n\n  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public\n     License.\n\n\nSection 7 -- Other Terms and Conditions.\n\n  a. The Licensor shall not be bound by any additional or different\n     terms or conditions communicated by You unless expressly agreed.\n\n  b. Any arrangements, understandings, or agreements regarding the\n     Licensed Material not stated herein are separate from and\n     independent of the terms and conditions of this Public License.\n\n\nSection 8 -- Interpretation.\n\n  a. For the avoidance of doubt, this Public License does not, and\n     shall not be interpreted to, reduce, limit, restrict, or impose\n     conditions on any use of the Licensed Material that could lawfully\n     be made without permission under this Public License.\n\n  b. To the extent possible, if any provision of this Public License is\n     deemed unenforceable, it shall be automatically reformed to the\n     minimum extent necessary to make it enforceable. If the provision\n     cannot be reformed, it shall be severed from this Public License\n     without affecting the enforceability of the remaining terms and\n     conditions.\n\n  c. No term or condition of this Public License will be waived and no\n     failure to comply consented to unless expressly agreed to by the\n     Licensor.\n\n  d. Nothing in this Public License constitutes or may be interpreted\n     as a limitation upon, or waiver of, any privileges and immunities\n     that apply to the Licensor or You, including from the legal\n     processes of any jurisdiction or authority.\n\n\n=======================================================================\n\nCreative Commons is not a party to its public\nlicenses. Notwithstanding, Creative Commons may elect to apply one of\nits public licenses to material it publishes and in those instances\nwill be considered the “Licensor.” The text of the Creative Commons\npublic licenses is dedicated to the public domain under the CC0 Public\nDomain Dedication. Except for the limited purpose of indicating that\nmaterial is shared under a Creative Commons public license or as\notherwise permitted by the Creative Commons policies published at\ncreativecommons.org/policies, Creative Commons does not authorize the\nuse of the trademark \"Creative Commons\" or any other trademark or logo\nof Creative Commons without its prior written consent including,\nwithout limitation, in connection with any unauthorized modifications\nto any of its public licenses or any other arrangements,\nunderstandings, or agreements concerning use of licensed material. For\nthe avoidance of doubt, this paragraph does not form part of the\npublic licenses.\n\nCreative Commons may be contacted at creativecommons.org.\n"
  },
  {
    "path": "README.md",
    "content": "# Spring '83\n\nWelcome! This is a draft protocol intended to suggest new ways of relating online. If you are just discovering it, I recommend reading [this narrative description](https://www.robinsloan.com/lab/specifying-spring-83/). Don't miss my notes on [a summer spent operating the protocol with other people](https://www.robinsloan.com/lab/specifying-spring-83/#summer), either.\n\nThis is speculative software intended to invite consideration and imagination; it doesn't have any \"users\", only co-investigators.\n\nThis spec is now a historical artifact, but/and I hope it might prompt you to think about new ways of relating online.\n\nMost recent draft:\n\n* [Protocol specification](draft-20220629.md)\n\nPrevious drafts:\n\n* [20220619](draft-20220616.md)\n* [20220609](draf-20220609.md)\n\nHere are the implementations I know about currently:\n\n* [The Kingswood Palimpsest](https://cyborg.rodeo/palimpsest/), a client\n* [rdmurphy/spring-board-element](https://github.com/rdmurphy/spring-board-element), a web component\n* [rpj/spring83](https://github.com/rpj/spring83), in JavaScript\n* [royragsdale/s83](https://github.com/royragsdale/s83), in Go\n* [motevets/springboard](https://github.com/motevets/springboard), in Go (running [here](https://spring83.kindrobot.ca))\n* [michael-lazar/lets-dance](https://github.com/michael-lazar/lets-dance), in Python (with some great [notes](https://github.com/michael-lazar/lets-dance/blob/main/Notes.md))\n* [pteichman/ahoy](https://github.com/pteichman/ahoy), in Go\n* [cellu_cc/so83-gpu](https://gitlab.com/cellu_cc/so83-gpu), on GitLab, in OpenCL 🤯\n* [JohnB/spring83](https://github.com/JohnB/spring83), a client\n\nIf you've implemented a client, server, or utility, at any level of completeness, and you would like me to list it here, let me know.\n\nThis work is offered under a Creative Commons Attribution-ShareAlike license."
  },
  {
    "path": "draft-20220609.md",
    "content": "# Spring '83\n\n*Note: this is a first draft specification published in June 2022. You can find a narrative description of the protocol, and my contact information, [in this newsletter](https://www.robinsloan.com/lab/specifying-spring-83/).*\n\n*Note also: this draft has been superceded by the [June 16 version](https://github.com/robinsloan/spring-83-spec/blob/main/draft-20220616.md), which will be superceded in turn. But we are winding our way towards something final-ish...*\n\n## Introduction\n\nSpring '83 is a protocol that allows users to follow publishers on the internet -- who might be people, computer programs, or anything else -- in a way that's simple, expressive, and predictable.\n\nThe basic unit of the protocol is the board, which is an HTML fragment, limited to 2217 bytes, unable to execute JavaScript or load external resources, but otherwise unrestricted.\n\nEach publisher maintains just one board. There is no concept of a history; think instead of a whiteboard that is amended or erased.\n\nSpring '83 aspires to be:\n\n**Simple.** This means the protocol is easy to understand and implement, even for a non-expert programmer.\n\n**Expressive.** This means protocol embraces the richness, flexibility, and chaos of modern HTML and CSS. It does not formalize interactions and relationships into database schemas.\n\n(It also means the protocol doesn't provide any mechanism for replies, likes, favorites, or, indeed, feedback of any kind. Publishers are encouraged to use the full flexibility of HTML to develop their own approaches, inviting readers to respond via email, join a live chat, send a postcard... whatever!)\n\n**Predictable.** This means boards holds their place, maintaing a steady presence. It means also that clients only receive the boards they request, when they request them; there is no mechanism by which a server can \"push\" an unsolicited board.\n\nIn addition, Spring '83 is\n\n**Federated.** This means it spans a network of servers operated by different people. The protocol is not, however, \"trustless\"; in Spring '83, connection requires conversation.\n\nAlthough the transmission portion of the protocol operates over HTTP/1.1, its approach to HTML storage is very different. Rather than store different boards on different servers, Spring '83 stores ALL the boards on EVERY server. The network converges to a consistent global state -- eventually; maybe -- using a simple gossip algorithm.\n\nSpring '83 draws inspiration from many existing protocols and technologies; you can read about these in Discussion 1.\n\n## Implementation\n\nThe key words \"must\", \"must not\", \"required\", \"shall\", \"shall not\", \"should\", \"should not\", \"recommended\",  \"may\", and \"optional\" in this document are to be interpreted as described in RFC 2119.\n\nhttps://www.ietf.org/rfc/rfc2119.txt\n\n## Terminology\n\n*board*: a fragment of HTML -- not necessarily a valid HTML5 document -- not more than 2217 bytes long, encoded in UTF-8.\n\n*publisher*: the entity responsible for specifying a board's content.\n\n*key*: a public key on the Ed25519 curve, formatted as 64 hex characters.\n\n*signature*: a public key signature, formatted as 128 hex characters.\n\n*client*: an application, web or standalone, that publishes, retrieves, and displays boards.\n\n*server*: an application, reachable on the public internet using a domain name, that receives, stores, and provides boards.\n\n*peer*: another server.\n\n*difficulty factor*: a server's current requirement for new keys\n\n*realm*: a set of peers, listed together in a YAML document reachable on the public internet. The default *realm* is defined at TKTK.\n\n## Publishers and keys\n\nPublishers (who might be people, computer programs, or anything else) are identified and authorized by keypairs on the Ed25519 curve. The public part of the keypair, formatted as 64 hex characters, is the publisher's identifier, used to request their board from any available server. The secret part of the keypair allows the publisher alone to edit their board.\n\nEach keypair corresponds to exactly one board. Again, there is no concept of a history; think instead of a whiteboard that is amended or erased.\n\nBecause a publisher is identified by their public key, boards are easy to verify. When a client requests a board for a particular *key*, the server might send an incorrect or modified response -- appending an advertisement, perhaps -- but the client will detect the invalid signature, drop the board, and mark the server as untrustworthy.\n\nSee Discussion 2 for a consideration of the benefits (substantial) and drawbacks (likewise) of keypair identity schemes.\n\n### Format requirements\n\nKeys are generated randomly, but they must fit a particular format; this functions as a simple Hashcash variation, providing a rudimentary form of abuse mitigation. Concocting a compatible key isn't instantaneous; it takes between a few seconds and a few minutes on modern hardware.\n\nTo be used in Spring '83, a key's final six hex characters must match this regex:\n\n```\n/ed[0-9]{4}$/\n```\n\nFurthermore, the final four characters, interpreted as a decimal number, must fall in the range 2022 .. 2099.\n\nThat number has teeth. Keys are only valid in two calendar years: the year specified in their final four digits, and the year previous. For example, the key\n\n```\n1c6ffef2825b294274478bad8c80a7a610d38245a9fded18cd004c4a67ed2023\n```\n\nis valid between 2022-01-01T00:00:00:00Z and 2023-12-31T23:59:59Z.\n\nIn this way, a key's final four characters represent its \"expiration date\".\n\nThis requirement makes key rotation mandatory over the long term. Clients may implement features that make the process more convenient, but the recurring \"stress test\" on the publisher-follower link is a feature, not a bug. The goal is to keep Spring '83 relationships \"live\" and engaged, rather than weigh publishers down with zombie followers.\n\n(TKTK is this too much? I like it, but...)\n\n## Boards in the client\n\nMuch of the burden of the protocol falls on the client: to make requests on the user's behalf, store keypairs securely, and display boards safely.\n\nThe client must:\n\n* limit incoming boards to 2217 bytes\n* validate each board's cryptographic signature\n* situate each board inside its own Shadow DOM\n\nThe client must not:\n\n* execute any JavaScript included in the board\n* load any images, media, or fonts linked by the board\n\nThese two requirements should be satisfied with a Content Security Policy.\n\nThe client should:\n\n* allow users to manage a collection of followed keys\n* display each board in a region with an aspect ratio of either 1:sqrt(2) or sqrt(2):1\n* make available to boards the Spring '83 suite of CSS variables, listed in TKTK\n* open links in new windows or tabs\n\nOther than the byte-size threshold and a timestamp requirement discussed below, Spring '83 places no limitations on the HTML content of a board. Knowing that the client will not execute JavaScript, publishers will probably not want to spend their precious bytes on inert code... but they are free to do so.\n\nBoards might be:\n\n* mini home pages, updated regularly with new work\n* lists of links to web pages recently read, perhaps with brief notes\n* daily logs, wiped clean each morning\n* yawlps to the universe\n\nBeyond the standards described above, Spring '83 doesn't specify how the client should display boards. For example, the client may:\n\n* allow users to explore overflowing boards by scrolling\n* apply post-processing effects to boards (e.g., a limited color palette)\n* organize boards according to an abstruse algorithm\n* handle links to Spring '83 keys in a helpful way\n\nPublishers should expect their boards to be placed on a 2D canvas alongside many others.\n\n## Boards on the server\n\nSpring '83 servers are, in operation, very similar to \"plain old web\" servers, with a few additional behaviors.\n\nThe server must\n\n* maintain a persistent store of boards\n* enforce a TTL, dropping boards over 28 days old\n* share newly-received boards with peers\n\nThe transmission portion of Spring '83 operates over HTTP/1.1, using TLS, so it can be implemented easily using existing tools.\n\nA Spring '83 server must respond at the following HTTP endpoints:\n\n```\nPUT /<key>\nGET /\nGET /<key>\n```\n\nA server that provides boards to browsers will also need an appropriate OPTIONS endpoint to satisfy CORS, but that's not part of this specification.\n\nIt's a pretty small API surface! We'll go through the endpoints one by one.\n\n### Publishing boards: PUT /`<key>`\n\nTo publish a board, a client must send a request of this form:\n\n```\nPUT /<key> HTTP/1.1\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nIf-Unmodified-Since: <date and time in HTTP format>\nAuthorization: Spring-83 Signature=<signature>\n\n<board>\n```\n\nUpon receipt, servers should validate the non-cryptographic part of the PUT request immediately, and, if necessary, respond with an error code.\n\n#### Verifying boards\n\n##### Size\n\nIf the board is larger than 2217 bytes, the server must reject the request with 413 Payload Too Large.\n\n##### Timestamp\n\nThe client must include the publishing timestamp in the If-Unmodified-Since header. If this value is older or equal to the timestamp of the server's version of the board, the server must reject the request with 409 Conflict.\n\nThe If-Unmodified-Since header is transmitted as a convenience, to allow the server to \"fail fast\" if the request is out of date. However, because it's not cryptographically signed, the server can't rely on it entirely.\n\nThe client must also include a last-modified meta tag in the board's HTML:\n\n```\n<meta http-equiv=\"last-modified\" content=\"<date and time in HTTP format>\">\n```\n\nIt's important that the timestamp is transmitted this way, because it needs to be signed along with the rest of the board's HTML. The client may add the meta tag automatically, just before signing and transmitting the board.\n\nThe server must reject the PUT request, returning 400 Bad Request, if\n\n* the board is transmitted without a last-modified meta tag; or\n* it is transmitted with more than one last-modified meta tag; or\n* its last-modified meta tag isn't parsable as an HTTP-format date and time; or\n* its last-modified meta tag is set to a date in the future.\n\nThese criteria are EXTREMELY important. The last-modified meta tag modulates a board's change over time; if it gets screwed up, the publisher could lose the ability to update their board.\n\n##### Cryptographic validity\n\nThe server must verify that `<signature>` is a valid signature for the entire request body, exactly as transmitted. If the board isn't signed properly, the server should reject it, returning 401 Unauthorized.\n\n##### Cryptographic difficulty\n\nIf the current four-digit year is YYYY, and the previous four-digit year is YYYX, the server must only accept PUTs for keys that end with the four digits YYYY or YYYX, preceded in turn by the two hex digits \"ed\". This is the years-of-use requirement.\n\nThe server must reject other keys with 400 Bad Request.\n\nAdditionally, if the server doesn't have any board stored for `<key>`, then it must apply another check. The key, interpreted as a 256-bit number, must be less than a threshold defined by the server's difficulty factor:\n\n```\nMAX_SIG = (2**256 - 1)\nkey_threshold = MAX_SIG * ( 1.0 - difficulty_factor)\n```\n\nThis check is not applied to keys for which the server already has a board stored. You can read more about the difficulty factor later in this document.\n\n##### Final considerations\n\nSpring '83 specifies a test keypair:\n\n```\npublic: fad415fbaa0339c4fd372d8287e50f67905321ccfd9c43fa4c20ac40afed1983\nsecret: a7e4d1c8be858d683ab9cb15574bd0bc3a87e6c846cdaf848da498909cb574f7\n```\n\nServers must not accept PUTs for this key, returning 401 Unauthorized. (See the section detailing GET /`<key>`, below, for more guidance.)\n\nThe server may also use a denylist to block certain keys, rejecting all PUTs for those keys.\n\nIf all the preceding checks are met, the server must store the board and share it with peers.\n\n### Sharing boards: peer to peer PUT /`<key>`\n\nA realm is a set of Spring '83 servers, specified by a YAML document reachable on the public internet. (The format of this document is TKTK.) There is no automatic or \"trustless\" way to join a realm; as with BGP, the foundational routing protocol of the internet, you gotta talk to somebody! \n\nWithin a realm, Spring '83 servers communicate directly with each other, sharing new boards using a simple gossip algorithm. Their aim is to converge on a shared state of the realm, each server's copy exactly the same. In the froth of real activity, that will never actually happen -- but we can get pretty close.\n\nAfter receiving and verifying a new board from a client, the server must share it with N peers selected randomly from the realm. N is\n\n```\nmin(round(total_peer_count * 0.5), 5)\n```\n\nNew boards should be transmitted to peers asynchronously. The server must wait at least five minutes before sharing, but it may wait longer. In this way, the server acts as a buffer, absorbing and \"compacting\" rapid PUTs.\n\nTo share a board with a peer, the server must transmit a PUT request similar to the one described above. Note the addition of the `Prefer: respond-async` header:\n\n```\nPUT /<key> HTTP/1.1\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nPrefer: respond-async\nIf-Unmodified-Since: <timestamp>\nAuthorization: Spring-83 Signature=<signature>\n\n<board>\n```\n\nWhen the server receives a PUT with the `respond-async` preference, it should respond immediately with 202 Accepted and place the board into a queue for asynchronous validation. (If the server doesn't have a task queue, it may respond synchronously.)\n\nIf a peer is not reachable or responds with an error code, the server must wait for a minimum timeout of 5 minutes before attempting to contact that peer again. If the peer is still not reachable, the server must apply jittered exponential backoff, calculating each new timeout in this way:\n\n```\nnew_timeout = current_timeout + current_timeout * random(0.0 .. 1.0)\n```\n\nThe server should cap this timeout at some maximum; 7 days is recommended.\n\n#### Forgetting boards\n\nThe server must store boards with a TTL. One week is recommended; the maximum TTL is 28 days.\n\nThe server must provide identical responses to requests for\n\n* `<key A>`, for which it once stored a board, now deleted, and\n* `<key B>`, for which it never stored any board.\n\nFinally, the server must not enumerate keys or boards for any requester; the server must only respond to requests for specific keys.\n\n## Difficulty factor: GET /\n\nDisk space is a concern for a protocol that allows anyone on the internet with a trivially-concocted cryptographic key to store a chunk of data, \"for free\", on a network of servers. Accordingly, a Spring '83 realm is limited to 10 million boards, for a maximum possible disk size of 22.17 gigabytes. (Ambitious servers might keep the whole thing in RAM!)\n\nThis limit is enforced through a difficulty factor that draws inspiration from the mining difficulty factor used in many cryptocurrencies.\n\nSpring '83's difficulty factor ranges from 0.0 to 1.0, calculated in this way:\n\n```\ndifficulty_factor = ( num_boards_stored / 10_000_000 )**4\n```\n\n(TKTK is that the right exponent? Explain it, I suppose.)\n\nIn normal operation, the server's difficulty factor is very close to 0.0, and boards for new keys are freely accepted. As the difficulty factor rises, the concoction of a suitable key becomes more time-consuming for prospective publishers. This has the effect of both (1) slowing the introduction of new keys, and (2) dissuading some publishers entirely.\n\nWhen the server's database maxes out at 10 million boards, the difficulty factor is 1.0, and the server does not accept any boards for keys it doesn't already know.\n\nLet's consider the example of a server that is already storing 8.5 million boards.\n\n```\ndifficulty_factor = ( 8_500_000 / 10_000_000 )**4 = 0.52\n```\n\nUsing that difficulty factor, we can calculate the key threshold:\n\n```\nMAX_KEY = (2**256 - 1)\nkey_threshold = MAX_KEY * ( 1.0 - 0.52 ) = <an inscrutable gigantic number>\n```\n\nThe server must reject PUT requests for new keys that are not less than `<an inscrutable gigantic number>`.\n\nA client should determine a server's current difficulty factor using a request of this form:\n\n```\nGET / HTTP/1.1\nSpring-Version: 83\n```\n\nThe server's response must take the form:\n\n```\nHTTP/1.1 200 OK\nContent-Length: <length>\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nSpring-Difficulty: <difficulty factor>\n\n<arbitrary HTML greeting>\n```\n\nUsing that information, the client can choose either to spend the time required to concoct a suitable key... or give up, and perhaps try another time.\n\n### Retrieving boards: GET /`<key>`\n\nServers are not obligated to provide this endpoint for all requesters; they might provide it only to users of a particular client, or only to users who have paid for access, or according to any other scheme. Such schemes are beyond the scope of this specification, which describes the behavior of a publicly-available server.\n\nTo retrieve the board for `<key>`, a client must choose one or more servers to which it has access and transmit a request of this form:\n\n```\nGET /<key> HTTP/1.1\nSpring-Version: 83\nIf-Modified-Since: <HTTP formatted timestamp>\n```\n\nIf the server has a board for `<key>` but it is not newer than the timestamp specified in If-Modified-Since, it must respond with 304 Not Modified.\n\nIf the client omits If-Modified-Since, the server should return whatever board it has for `<key>`, if it has one.\n\nThe server's response must take the form:\n\n```\nHTTP/1.1 200 OK\nContent-Length: <length>\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nAuthorization: Spring-83 Signature=<signature>\n\n<board>\n```\n\nThe client must verify that the `<signature>` is valid for `<key>` and `<board>` before processing or displaying the board. If the signature is not valid, the client must drop the response and remove the server from its list of trustworthy peers.\n\n(TKTK clients should assist servers with out-of-date boards.)\n\nSpring '83 specifies a test keypair:\n\n```\npublic: fad415fbaa0339c4fd372d8287e50f67905321ccfd9c43fa4c20ac40afed1983\nsecret: a7e4d1c8be858d683ab9cb15574bd0bc3a87e6c846cdaf848da498909cb574f7\n```\n\nServers should respond to GETs for this key with an ever-changing board, generated internally, with a timestamp set to the time of the request. This board is provided to help client developers understand and troubleshoot their applications. \n\n## Error code quick reference\n\n* 400: Board was submitted with impromper meta timestamp tags.\n* 401: Board was submitted without a valid signature.\n* 404: No board for this key found on this server.\n* 403: Board was submitted for a key that does not meet the difficulty factor.\n* 409: Board was submitted with a timestamp older than the server's timestamp for this key.\n* 513: Board is larger than 2217 bytes.\n\n## Discussions\n\n### 1: Inspirations\n\nThis protocol draws inspiration\n\n* from Secure Scuttlebutt: the power of cryptographic keypairs as identities\n* from Hashcash: the notion of guarding server resources with client puzzles\n* from Ethereum: the gonzo strategy of storing the whole universe in one place\n* from ZeroTier: the spirit of \"decentralize until it hurts, then centralize until it works\".\n\nand, most of all,\n\n* from [the Quote of the Day Protocol](https://datatracker.ietf.org/doc/html/rfc865), defined by Jon Postel in May 1983: the vision of simplicity\n\nFor those not familiar: QOTD operates over both TCP and UDP; the server responds to a TCP connection or a UDP datagram with a single brief message.\n\nIn fact, I very badly wanted Spring '83 to operate over UDP -- responding to a request with, in some cases, a single datagram packet: beautiful -- but the architecture of the modern internet makes that much more difficult today than it was in 1983, and, anyway, there's a universe of capable tooling for HTTP. \n\nSo, not without regret, Spring '83 goes with the flow.\n\n### 2: The agony and ecstasy of public key cryptography\n\nThere are a lot of reasons NOT to use cryptographic keypairs as identities, not least of which: the certainty that a user will eventually lose their secret key.\n\nBut the profound magic trick of the signature: that it allows a piece of content to flow around the internet, handed from peer to peer, impossible to tamper with... it's too good to pass up.\n\nAnd the way public key cryptography allows anyone to \"join\" the system, without registering anywhere, simply by generating an appropriate keypair -- again, it's a trick so good it seems like it shouldn't work.\n\nThe trapdoor function at the heart of public key cryptography is mirrored in the trapdoor of its user experience: once a secret key is lost or compromised, the identity is done. Game over. The system offers no customer support, because the system is math, and all the angels are busy assisting other callers.\n\nIt's one of the harshest if/thens in all of computing, and a steep price to pay for the magic trick. Spring '83, given its other priorities and constraints, is willing to pay that price -- but only barely.\n\nThe compromise is mandatory key rotation, enforced with the years-of-use requirement. This policy suggests, \"you're going to lose your private key eventually... why not lose it now?\" and uses that loss as a mechanism to strengthen, rather than weaken, the network.\n\nBeyond that, there is plenty of space for Spring '83 clients to offer hosted (\"custodial\") private keys, abstracting the keypair behind a more traditional username/password."
  },
  {
    "path": "draft-20220616.md",
    "content": "# Spring '83\n\n> *Discussion: This is an updated draft specification published in June 2022. You can find a narrative description of the protocol, and my contact information, [in this newsletter](https://www.robinsloan.com/lab/specifying-spring-83/).*\n\n## Introduction\n\nSpring '83 is a protocol that allows users to follow publishers on the internet -- who might be people, computer programs, or anything else -- in a way that's simple, expressive, and predictable.\n\nThe basic unit of the protocol is the board, which is an HTML fragment, limited to [2217 bytes](http://info.cern.ch/hypertext/WWW/TheProject.html), unable to execute JavaScript or load external resources, but otherwise unrestricted.\n\nEach publisher maintains just one board. There is no concept of a history; think instead of a whiteboard that is amended or erased.\n\nSpring '83 aspires to be:\n\n**Simple.** This means the protocol is easy to understand and implement, even for a non-expert programmer.\n\n**Expressive.** This means the protocol embraces the richness, flexibility, and chaos of modern HTML and CSS. It does not formalize interactions and relationships into database schemas.\n\n(It also means the protocol doesn't provide any mechanism for replies, likes, favorites, or, indeed, feedback of any kind. Publishers are encouraged to use the flexibility of HTML to develop their own approaches, inviting readers to respond via email, join a live chat, send a postcard... whatever!)\n\n**Predictable.** This means boards holds their place, maintaining a steady presence. It means also that clients only receive the boards they request, when they request them; there is no mechanism by which a server can \"push\" an unsolicited board.\n\nIn addition, Spring '83 is\n\n**Federated.** This means boards live on different servers operated by different people. It means also that groups of peers share boards with one another, a strategy intended to support exploration and analysis of the full \"board flow\".\n\nSpring '83 draws inspiration from many existing protocols and technologies; you can read about these in Discussion 1.\n\n## Implementation\n\nThe key words \"must\", \"must not\", \"required\", \"shall\", \"shall not\", \"should\", \"should not\", \"recommended\",  \"may\", and \"optional\" in this document are to be interpreted as described in RFC 2119.\n\nhttps://www.ietf.org/rfc/rfc2119.txt\n\n## Terminology\n\n*board*: a fragment of HTML, not necessarily a valid HTML5 document, not more than 2217 bytes long, encoded in UTF-8.\n\n*publisher*: the entity responsible for specifying a board's content.\n\n*key*: a public key on the Ed25519 curve, formatted as 64 hex characters.\n\n*signature*: a public key signature, formatted as 128 hex characters.\n\n*client*: an application, web or standalone, that publishes, retrieves, and displays boards.\n\n*server*: an application, reachable on the public internet, that accepts requests from clients to publish and retrieve boards.\n\n*listener*: an application, reachable on the public internet, that receives boards not from clients but from servers, subscribing to the full \"board flow\" through a realm. (The listener's possible reasons for doing this are described later.)\n\n*peer*: a server or listener.\n\n*realm*: a group of peers who have agreed to circulate the full \"board flow\" using a simple gossip algorithm.\n\n*difficulty factor*: a server's current requirement for new boards.\n\n## Publishers, keys, and servers\n\nPublishers -- who might be people, computer programs, or anything else -- are identified and authorized by keypairs on the Ed25519 curve. The public part of the keypair, formatted as 64 hex characters, is the publisher's identifier, used to request their board from the server. The secret part of the keypair allows the publisher alone to edit their board.\n\nSee Discussion 2 for a consideration of the benefits (substantial) and drawbacks (likewise) of keypair identity schemes.\n\nEach keypair corresponds to exactly one board. Again, there is no concept of a history; think instead of a whiteboard that is amended or erased.\n\nEvery publisher has a home server to which they transmit their board, and from which clients generally retrieve it. Publishers can always migrate to a new home server, taking their key with them. (This process is described in the section on clients, below.)\n\nBecause a publisher is identified by their key, boards are easy to verify. When a client requests a board for a particular key, the server might send an incorrect or modified response -- inserting an advertisement, perhaps -- but the client will detect the invalid signature, drop the board, and mark the server as untrustworthy.\n\nKeys are globally unique, and they act as \"coordination-free\" identifiers, similar to UUIDs. Publishers don't need to register with any central authority. Instead, they need only to generate a keypair on the Ed25519 curve that conforms to a format requirement and then select, or start, a home server.\n\n> *Aside:* The use of keys for identification and authorization is, like many things in this protocol, motivated partially by a desire to keep implementation easy and stateless for server programmers and operators. Who wants to manage a complete login system? And send password reset emails? Not me!\n\nA server is identified by a domain name and, optionally, a path. The transmission protocol is an HTTP API over TLS; therefore, the full URL for a board is\n\n```\nhttps://<host>/<path>/<key>\n```\n\nFor example, a board currently hosted on the server `bogbody.biz` would be identified as\n\n```\nhttps://bogbody.biz/ca93846ae61903a862d44727c16fed4b80c0522cab5e5b8b54763068b83e0623\n```\n\n> Discussion: A client may allow users to follow Spring '83 publishers alongside RSS feeds and other resources. In these situations, the client should distinguish Spring '83 URLs with a regex that recognizes conforming keys, or simply by making a request and noting the presence of a Spring-Version header.\n> The ambiguity of Spring '83 URLs is somewhat intentional; they are just HTML fragments, and users can always preview them in a web browser.\n\n### Generating conforming keys\n\nThe protocol imposes a format requirement on keys. The content of Ed25519 keypairs is mostly (but not totally) random, so conforming keys can only be generated by trial and error.\n\nThe format requirement accomplishes two things at once:\n\n1. It presents a \"client puzzle\" which requires a one-time investment of compute resources to \"solve\". Like [Hashcash](http://www.hashcash.org/), this provides a rudimentary form of abuse mitigation: a malicious publisher cannot generate conforming keys instantly and endlessly.\n\n2. It \"bakes\" some useful metadata into the key itself.\n\nA conforming key's final seven hex characters must be `83e` followed by four characters that, interpreted as MMYY, express a valid month and year in the range 01/00 .. 12/99. Formally, the key must match this regex:\n\n```\n/83e(0[1-9]|1[0-2])(\\d\\d)$/\n```\n\nAgain, a conforming keypair can only be generated by trial and error. On a single thread in an Apple M1 chip, this is accomplished in tens of minutes, not seconds or less.\n\n> *Aside:* I am not totally sure it's impossible to \"program\" the content of an Ed25519 public key, particularly if you abandon security considerations. My impression is that [it can't be done](https://crypto.stackexchange.com/questions/3596/is-it-possible-to-pick-your-ed25519-public-key), but I could be wrong. If you have any insight into this, let me know. This format requirement could always be applied instead to the SHA-256 hash of the key.\n\nThe date \"encoded\" in those final four characters has teeth: the key is only valid in the two years preceding it, and expires at the end of the last day of the month specified. (This is analogous to a [credit card expiration date](https://en.wikipedia.org/wiki/ISO/IEC_7813#Physical_characteristics).)\n\nFor example, the key\n\n```\nca93846ae61903a862d44727c16fed4b80c0522cab5e5b8b54763068b83e0623\n```\n\nhas an encoded expiration date of 0623, or 06/2023. This key is valid between 2021-06-01T00:00:00:00Z and 2023-07-01T00:00:00Z.\n\nThis expiration policy makes key rotation mandatory over the long term. Clients may implement features that make the process more convenient, even automatic, but the recurring \"stress test\" on the publisher-follower link is a feature, not a bug. The goal is to keep Spring '83 relationships \"live\" and engaged, with fresh opt-ins every two years at most.\n\nThe policy suggests, \"you're going to lose your secret key eventually... why not lose it now?\" and uses that loss as a mechanism to strengthen, rather than weaken, the network.\n\n### Discovering keys\n\nThe process of discovering a particular publisher's key, or discovering keys to follow generally, is not part of this specification.\n\nHowever, it is presumed that a home page or profile page might contain a `<link>` element analogous to the kind used to specify RSS feeds. A client scanning a web page for an associated board should look for `<link>` elements with the `type` attribute set to `text/board+html`.\n\n```\n<link rel=\"alternate\" type=\"text/board+html\" href=\"https://bogbody.biz/ca93846ae61903a862d44727c16fed4b80c0522cab5e5b8b54763068b83e0623\" />\n```\n\n## Boards in the client\n\nMuch of the burden of the protocol falls on the client: to store a user's keypair securely, allow them to manage a collection of followed keys, and display boards safely.\n\nThe client must:\n\n* limit incoming boards to 2217 bytes\n* verify each board's cryptographic signature\n* situate each board inside its own Shadow DOM\n\nThe client must not:\n\n* execute any JavaScript included in the board\n* load any images, media, or fonts linked by the board\n\nThese two requirements should be satisfied with a [Content Security Policy](https://content-security-policy.com/). The design of this policy is not part of this specification, but here's an example that works for a simple web-based client:\n\n```\ndefault-src 'none';\nstyle-src 'self' 'unsafe-inline';\nfont-src 'self';\nscript-src 'self';\nform-action *;\nconnect-src *;\n```\n\nIt's important to allow `unsafe-inline` CSS so boards can style themselves!\n\n> *Aside:* Yes, HTML forms are allowed -- unless someone explains to me why this is a horrible idea 😝\n\n> *Aside:* The prohibition against images and other external resources is a matter of privacy and safety. Privacy, because it prevents the use of tracking pixels and other \"transponders\". Safety, because it lowers the stakes for malicious and illegal content. However, it is totally possible to imagine a future version of this protocol, Spring '84 or beyond, in which\n> * a particular domain could be added to the CSP, providing a shared image catalog, analogous to the funky clip art choices offered to purchasers of classified ads. \"You can use any pic you want, as long as it's on [bukk.it](https://bukk.it/)!\"\n> * or, images and other external resources could simply be permitted.\n\nThe client should:\n\n* display each board in a region with an aspect ratio of either 1:sqrt(2) or sqrt(2):1\n* make available to boards the Spring '83 suite of CSS variables, listed in TKTK\n* open links in new windows or tabs\n\nSpring '83 places no limitations on the HTML content of a board. Knowing that the client will not execute JavaScript, publishers will probably not want to spend their precious bytes on inert code... but they are free to do so.\n\nBoards might be:\n\n* mini home pages, updated regularly with new work\n* lists of links to web pages recently read, perhaps with brief notes\n* daily logs, wiped clean each morning\n* yawlps to the universe\n\nBeyond the standards described above, Spring '83 doesn't specify how the client should display boards. For example, the client may:\n\n* allow users to explore overflowing boards by scrolling\n* organize boards according to an abstruse algorithm\n* handle links to boards in a helpful way, even \"transcluding\" them (!)\n\nPublishers should expect their boards to be placed on a 2D canvas alongside many others.\n\n### Boards with special client instructions\n\nClients should scan for the `<link rel=\"next\">` element:\n\n```\n<link rel=\"next\" href=\"<URL>\">\n```\n\nThis element is used by publishers to migrate from key to key and server to server. When the client finds a `<link rel=\"next\">` element, it should retrieve the board at the URL, verify it normally, and update its record of the publisher's home server and/or key accordingly.\n\nThe board should contain only one one `<link rel=\"next\">` element. If it contains more than one, the client must honor the first and ignore the rest.\n\nThe client may also scan for arbitrary data stored in `data-spring-*` attributes throughout the board. These attributes and their uses will be defined by publishers and client developers.\n\n## Boards on the server\n\nSpring '83 servers are, in operation, very similar to \"plain old web\" servers, with a few additional behaviors.\n\nThe server must\n\n* maintain a persistent store of boards\n* enforce a TTL, dropping boards over 22 days old\n* share newly-received boards with listeners\n\nThe transmission portion of Spring '83 operates over HTTP, using TLS, so it can be implemented easily using existing tools.\n\nA Spring '83 server must respond at the following HTTP endpoints:\n\n```\nOPTIONS\nPUT /<key>\nGET /\nGET /<key>\n```\n\nThat's a pretty small API surface! We'll go through the endpoints one by one.\n\n### Serving clients: OPTIONS\n\nMany clients will, by dint of being web apps, depend on CORS to retrieve boards from non-origin servers. Servers must support preflight OPTIONS requests to all endpoints, replying with:\n\n```\nHTTP/1.1 204 No Content\nAccess-Control-Allow-Methods: GET, PUT, OPTIONS\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Headers: Content-Type, If-Modified-Since, Spring-Signature, Spring-Version\nAccess-Control-Expose-Headers: Content-Type, Last-Modified, Spring-Difficulty, Spring-Signature, Spring-Version\n```\n\n### Publishing boards: PUT /`<key>`\n\nTo publish a board, a client must send a request of this form:\n\n```\nPUT /<key> HTTP/1.1\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nSpring-Signature: <signature>\n\n<board>\n```\n\nUpon receipt, servers should check the non-cryptographic part of the PUT request immediately, and, if necessary, respond with an error code.\n\n#### Checking boards\n\n##### Size\n\nIf the board is larger than 2217 bytes, the server must reject the PUT request with 413 Payload Too Large.\n\n##### Timestamp\n\nThe timestamp is transmitted as part of the board HTML. The client must include a `<time>` element with its `datetime` attribute set to a UTC timestamp in ISO 8601 format, without milliseconds: `YYYY-MM-DDTHH:MM:SSZ`.\n\nFor the convenience of server implementers, the `<time>` element must fit the following format exactly; \"valid HTML\" is not sufficient:\n\n```\n<time datetime=\"YYYY-MM-DDTHH:MM:SSZ\"></time>\n```\n\nThe client should append the `<time>` element to the beginning of the board, allowing the server to \"match fast\".\n\nThe `<time>` element should have a closing tag. It may have text content. The client should include default CSS that hides the element; a publisher may choose to override that CSS, revealing it.\n\n> *Aside:* Is this too fiddly? I am trying to save server implementers the trouble of running full HTML parsers!\n\nIt's important that the timestamp is transmitted this way, because it needs to be signed along with the rest of the board's HTML. The client should add the `<time>` element automatically, just before signing and transmitting the board.\n\nThe server must reject the PUT request, returning 400 Bad Request, if\n\n* the request is transmitted without a `<time>` element; or\n* its `<time>` element's `datetime` attribute is not a UTC timestamp in ISO 8601 format; or\n* its `<time>` element's `datetime` attribute is set to a timestamp in the future.\n\nThe board should contain only one `<time>` element. If it contains more than one, the server must honor the first and ignore the rest.\n\nIf the board's timestamp is older than or equal to the timestamp of the server's version of the board, the server must reject the request, returning 409 Conflict.\n\nThese criteria are EXTREMELY important. The `<time>` element modulates a board's change over time; if it gets screwed up, the publisher could lose the ability to update their board.\n\n##### Cryptographic validity\n\nThe server must verify that `<signature>` is `<key>`'s valid signature for the board, exactly as transmitted. If the board isn't properly signed, the server must reject the request, returning 401 Unauthorized.\n\n##### Conforming keys\n\nThe key format requirements are described earlier in this specification, and reproduced here for convenience.\n\nA conforming key's final seven hex characters must be \"83e\" followed by four characters that, interpreted as MMYY, express a valid month and year in the range 01/00 .. 12/99. Formally, the key must match this regex:\n\n```\n/83e(0[1-9]|1[0-2])(\\d\\d)$/\n```\n\nIf the key does not match that regex, the server must reject the request, returning 403 Forbidden.\n\nThe key is only valid in the two years preceding its encoded expiration date, and expires at the end of the last day of the month specified. For example, the key\n\n```\nc761fd8e4abc6ee4ca6d0883a95b7f0c88d33835a085b382dfbfb435283e0623\n```\n\nhas an encoded expiration date of 0623, or 06/2023. This key is valid between 2021-06-01T00:00:00:00Z and 2023-07-01T00:00:00Z.\n\nIf the key has expired or is set to a date more than two years in the future, the server must reject the request, returning 403 Forbidden.\n\n##### Difficulty factor\n\nIf the server doesn't yet have any board stored for the key, then it must apply an additional check. The key's first 16 hex characters, interpreted as a 64-bit number, must be less than a threshold defined by the server's difficulty factor:\n\n```\nMAX_KEY_64 = (2**64 - 1)\nkey_64_threshold = round(MAX_KEY_64 * ( 1.0 - difficulty_factor))\n```\n\nIf the key fails this check, the server must reject the PUT request, returning 403 Forbidden.\n\nThis check is not applied to keys for which the server already has a board stored. (You can read more about the difficulty factor later in this specification.)\n\nIf the difficulty factor is `1.0`, the server must reject all PUT requests for new boards.\n\n> *Aside:* The difficulty factor check only operates on the key's first 64 bits for convenience, avoiding the use of special \"big number\" data types. JavaScript developers will, however, still have to use BigInt.\n\n##### Final considerations\n\nSpring '83 defines a test keypair:\n\n```\npublic: ab589f4dde9fce4180fcf42c7b05185b0a02a5d682e353fa39177995083e0583\nsecret: 3371f8b011f51632fea33ed0a3688c26a45498205c6097c352bd4d079d224419\n```\n\nServers must reject PUT requests for this key, returning 401 Unauthorized. (See the section detailing GET /`<key>`, below, for additional guidance.)\n\nThe server may use a denylist to block certain keys, rejecting all PUTs for those keys.\n\n> *Aside:* It's likely this would be a shared denylist, but I don't yet have a proposal for how that would operate. It fits into the realm, of course, and feels like part of the contract: you get to be included in the \"board flow\", but/and you need to honor this shared denylist. Where is the list stored? How is it updated? Does efficient matching become a problem if a denylist has 100,000 entries? Lots of puzzles here.\n\nIf the preceding checks are all met, the server must store the board and share it with listeners in its realm.\n\n### Listeners and realms: peer-to-peer PUT /`<key>`\n\n> *ALERT:* This section is extremely fiddly, and none of it is implemented in my demo server. I am leaving the text intact for the sake of discussion, but feel free to skip it.\n\nA realm is a group of Spring '83 servers and listeners who have agreed to circulate new boards using a simple gossip algorithm. It provides a framework for aggregating \"the whole network\" in one place, something that's otherwise difficult to do in a federated system.\n\nWhy would a listener want to join a realm and receive all its PUT requests? Well, with access to full \"board flow\", the listener could\n\n* scan boards and produce a report of top links across the realm\n* calculate algorithmic “who to follow” recommendations and offer them to anyone who might be interested\n* scan for malicious or illegal content and alert server operators\n\nIn this way, listeners can add new \"features\" to the protocol.\n\nA realm is described by a UTF-8 text document reachable on the public internet. Each of the document's lines lists one server. Lines containing only whitespace must be ignored. Lines that begin with `#` are comments and must be ignored. For example, the file `https://spring83.net/supreme.txt` might describe a very small realm:\n\n```\n# behold, the Realm Supreme\n# to join, email robin@robinsloan.com\n\nbogbody.biz\nworking.directory\npublisher.pizza\n\n# well, maybe it's not so Supreme\n```\n\n> *Aside:* This is where I got frustrated and gave up on this section, at least for the time being. I feel like servers and listeners in a realm really ought to be able to authenticate each other's requests... but does that require each to have a public key listed in this text document? And to calculate an additional signature for all the boards they circulate? Suddenly, this is feeling sort of \"heavy\" and, perhaps, stupid.\n\nThere is no automatic or \"trustless\" way to join a realm. As with BGP, the foundational routing protocol of the internet: you gotta talk to somebody! \n\nIn the section below, the term \"peer\" means servers, who receive PUT requests from clients, AND listeners, who receive PUT requests from servers.\n\nThe peer should belong to one realm. It may belong to zero or many, but the protocol's design favors one. A server that belongs to zero realms can still store a publisher's board without any problem, providing it to clients of all kinds; it just won't provide that board to any listeners.\n\nAfter receiving and verifying a new board, the peer must share it with N listeners selected randomly from the realm. N is\n\n```\nmin(round(total_peer_count * 0.5), 5)\n```\n\nNew boards should be transmitted to listeners asynchronously. The server should wait at least five minutes before sharing, and it may wait longer. In this way, the server can act as a buffer, absorbing and \"compacting\" rapid PUTs.\n\nTo share a board with a listener, the server must transmit a PUT request exactly like the one described above.\n\nWhen the listener receives a PUT, it should respond immediately with 202 Accepted and place the board into a queue for asynchronous processing. (If the listener doesn't have a queue, it may respond synchronously.)\n\nIf a listener is not reachable or responds with an error code, the server must wait for a minimum timeout of 5 minutes before attempting to contact that listener again. If the listener is still not reachable, the server must apply a jittered backoff strategy. The server should cap its timeout at some maximum; one hour is recommended.\n\n> *Relief*: It's over. Thank goodness.\n\n### Difficulty factor: GET /\n\nSpring '83 is intended to invite participation from people with \"normal\" compute resources, whether that means a home server with a public IP address or a free-tier cloud instance. The protocol includes, therefore, a mechanism to apply \"backpressure\" to publishers, slowing or stopping the creation of new boards.\n\nThe difficulty factor is a decimal number in the range 0.0 .. 1.0, and is calculated based on the maximum number of boards the server would like to store. As described earlier in this specification, the difficulty factor is used to apply an extra (and potentially quite stringent) check on new boards.\n\n> *Aside:* It's very possible that none of this is needed. Instead, when a server is under stress, it could just flip the sign on the door: CLOSED! Aha, yes, there's an elegant algorithm for you.\n> Besides, the format requirement already imposes a substantial \"cost\" on the creation of new boards. Ugh, but this was so CLEVER. We are in \"kill your darlings\" territory here...\n\nThe calculation of the difficulty factor is not part of this specification, but here's an example formula that works well:\n\n```\ndifficulty_factor = ( num_boards_stored / max_boards )**4\n```\n\nThe exponent is included because the difficulty factor is only intended to dissuade new boards \"at the margin\"; after all, we're here to store and provide HTML, aren't we?\n\nLet's consider the example of a server that is currently storing 60,000 boards and would like to store, at most, 100,000.\n\n```\ndifficulty_factor = ( 60_000 / 100_000 )**4 = 0.1296\n```\n\nUsing that difficulty factor, we can calculate the key threshold:\n\n```\nMAX_KEY_64 = (2**64 - 1)\nkey_64_threshold = MAX_KEY_64 * ( 1.0 - 0.1296 ) = <a 64-bit number>\n```\n\nThe server must check the key's first 64 bits against that 64-bit number, as described earlier in this specification.\n\nA client should determine a server's current difficulty factor using a request of this form:\n\n```\nGET / HTTP/1.1\nSpring-Version: 83\n```\n\nThe server's response must take the form:\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nSpring-Difficulty: <difficulty factor>\n\n<server greeting>\n```\n\nUsing that information, the client can choose either to spend the time required to generate a conforming key... or give up, and perhaps try later.\n\n### Retrieving boards: GET /`<key>`\n\nTo retrieve the board for `<key>` from its home server, the client must transmit a request of this form:\n\n```\nGET /<key> HTTP/1.1\nSpring-Version: 83\nIf-Modified-Since: <date and time in UTC, RFC 5322 format>\n```\n\nIf the server has a board for `<key>` but it is not newer than the timestamp specified in If-Modified-Since, it must respond with 304 Not Modified.\n\nIf the client omits If-Modified-Since, the server should return whatever board it has for `<key>`, if it has one.\n\nThe server's response must take the form:\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nLast-Modified: <date and time in UTC, HTTP (RFC 5322) format>\nSpring-Signature: <signature>\n\n<board>\n```\n\nThe client must verify that `<signature>` is `<key>`'s valid signature for the board, exactly as transmitted. If the board isn't signed properly, the client must drop the response. It should communicate to the user that the server is either faulty or dishonest.\n\nSpring '83 specifies a test keypair:\n\n```\npublic: ab589f4dde9fce4180fcf42c7b05185b0a02a5d682e353fa39177995083e0583\nsecret: 3371f8b011f51632fea33ed0a3688c26a45498205c6097c352bd4d079d224419\n```\n\nThe server should respond to GET requests for this key with an ever-changing board, generated internally, with a timestamp set to the time of the request. This board is provided to help client developers understand and troubleshoot their applications. \n\n#### Forgetting boards\n\nThe server must store boards with a TTL of, at most, 22 days.\n\nThe server must provide identical responses to requests for\n\n* `<key A>`, for which it once stored a board, now deleted, and\n* `<key B>`, for which it never stored any board.\n\nFinally, the server must not enumerate keys or boards for any requester; the server must only respond to requests for specific keys.\n\n## Error code quick reference\n\n* 400: Board was submitted with an impromper timestamp.\n* 401: Board was submitted without a valid signature.\n* 403: Board was submitted for a non-conforming key.\n* 404: No board for this key found on this server.\n* 409: Board was submitted with a timestamp older than the server's timestamp for this key.\n* 413: Board is larger than 2217 bytes.\n\n## Discussions\n\n### 1: Inspirations\n\nThis protocol draws inspiration\n\n* from Secure Scuttlebutt: the power of cryptographic keypairs as identities\n* from Hashcash: the notion of guarding server resources with client puzzles\n* from ZeroTier: the spirit of \"decentralize until it hurts, then centralize until it works\".\n\nand, most of all,\n\n* from [the Quote of the Day Protocol](https://datatracker.ietf.org/doc/html/rfc865), defined by Jon Postel in May 1983: the vision of simplicity\n\nFor those not familiar: QOTD operates over both TCP and UDP; the server responds to a TCP connection or a UDP datagram with a single brief message.\n\nIn fact, I very badly wanted Spring '83 to operate over UDP -- responding to a request with, in some cases, a single datagram packet: beautiful -- but the architecture of the modern internet makes that much more difficult today than it was in 1983, and, anyway, there's a universe of capable tooling for HTTP. \n\nSo, not without regret, Spring '83 goes with the flow.\n\n### 2: The agony and ecstasy of public key cryptography\n\nThere are a lot of reasons NOT to use cryptographic keypairs as identities, not least of which: the certainty that a user will eventually lose their secret key.\n\nBut the profound magic trick of the signature: that it allows a piece of content to move through the internet, handed from server to server, impossible to tamper with... it's too good to pass up.\n\nAnd the way public key cryptography allows anyone to \"join\" the system, without registering anywhere, simply by generating an appropriate keypair -- again, it's a trick so good it seems like it shouldn't work.\n\nThe trapdoor function at the heart of public key cryptography is mirrored in the trapdoor of its user experience: once a secret key is lost or compromised, the identity is done. Game over. The system offers no customer support, because the system is math, and all the angels are busy assisting other callers.\n\nIt's one of the harshest if/thens in all of computing, and a steep price to pay for the magic trick. Spring '83, given its other priorities and constraints, is willing to pay that price -- but only barely.\n\nThe compromise is mandatory key rotation, enforced with the time-of-use requirement. This policy suggests, \"you're going to lose your secret key eventually... why not lose it now?\" and uses that loss as a mechanism to strengthen, rather than weaken, the network.\n\nBeyond that, there is plenty of space for Spring '83 clients to offer hosted (\"custodial\") secret keys, abstracting the keypair behind a more traditional username and password."
  },
  {
    "path": "draft-20220629.md",
    "content": "# Spring '83\n\n> *Note:* This is an updated draft specification published at the tail end of June 2022. It's the result of lots of correspondence, some private, some public, that resulted in many clarifications... and just as many deletions. That's good editing!\n\n> This is being posted for discussion -- definitely do not implement anything in here yet!\n\n## Introduction\n\nSpring '83 is a protocol that allows users to follow publishers on the internet -- who might be people, computer programs, or anything else -- in a way that's simple, expressive, and predictable.\n\nThe basic unit of the protocol is the board, which is an HTML fragment, limited to 2217 bytes, unable to execute JavaScript or load external resources, but otherwise unrestricted.\n\n> *Aside:* If 2217 bytes is enough for [the first web page](http://info.cern.ch/hypertext/WWW/TheProject.html), it's enough for us.\n\nEach publisher maintains just one board. There is no concept of a history; think instead of a whiteboard that is amended or erased.\n\nSpring '83 aspires to be:\n\n**Simple.** This means the protocol is easy to understand and implement, even for a non-expert programmer.\n\n**Expressive.** This means the protocol embraces the richness, flexibility, and chaos of modern HTML and CSS. It does not formalize interactions and relationships into database schemas.\n\n**Predictable.** This means boards holds their place, maintaining a steady presence. It means also that clients only receive the boards they request, when they request them; there is no mechanism by which a server can \"push\" an unsolicited board.\n\n(Going further, the protocol doesn't provide any mechanism for replies, likes, favorites, or, indeed, feedback of any kind. Publishers are invited to use the flexibility of HTML to develop their own approaches, inviting readers to respond via email, submit a form, mail a postcard... whatever!)\n\nIn addition, Spring '83 is\n\n**Federated.** This means boards are stored on different servers operated by different people.\n\nSpring '83 draws inspiration from many existing protocols and technologies; you can read about these in Discussion 1.\n\n## Implementation\n\nThe key words \"must\", \"must not\", \"required\", \"shall\", \"shall not\", \"should\", \"should not\", \"recommended\",  \"may\", and \"optional\" in this document are to be interpreted as described in RFC 2119.\n\nhttps://www.ietf.org/rfc/rfc2119.txt\n\n## Terminology\n\n*board*: a fragment of HTML5, not necessarily a valid HTML5 document, not more than 2217 bytes long, encoded in UTF-8.\n\n*publisher*: the entity responsible for specifying a board's content.\n\n*key*: a public key on the Ed25519 curve, formatted as 64 hex characters.\n\n*signature*: a public key signature, formatted as 128 hex characters.\n\n*client*: an application, web or standalone, that publishes, retrieves, and displays boards.\n\n*server*: an application, reachable on the public internet, that accepts requests from clients to publish and retrieve boards.\n\n## Publishers, keys, and servers\n\nPublishers -- who might be people, computer programs, or anything else -- are identified and authorized by keypairs on the Ed25519 curve. The public part of the keypair, formatted as 64 hex characters, is the publisher's identifier, used to request their board from the server. The secret part of the keypair allows the publisher alone to edit their board.\n\nSee Discussion 2 for a consideration of the benefits (substantial) and drawbacks (likewise) of keypair identity schemes.\n\nEach keypair corresponds to exactly one board. Again, there is no concept of a history; think instead of a whiteboard that is amended or erased.\n\nBecause a publisher is identified by their key, boards are easy to verify. When a client requests a board for a particular key, the server might send a modified response -- inserting an advertisement, perhaps -- but the client will detect the invalid signature and ignore the board.\n\nKeys are globally unique, and they act as \"coordination-free\" identifiers, similar to UUIDs. Publishers don't need to register with any central authority. Instead, they need only to generate a keypair on the Ed25519 curve that conforms to a format requirement, and then publish their first board to the server of their choice.\n\nIn this way, the keypair provides the identity and authorization \"API\" for the protocol, and the key becomes a consistent identity that publishers can move between servers.\n\n> *Aside:* The choice of the keypair is also, like several features of this protocol, motivated by a desire to keep implementation easy and stateless. Who wants to manage a complete login system? And send password reset emails? Not me!\n\nA server is identified by a hostname and, optionally, a path. Spring '83 is an HTTP API over TLS; therefore, the URL used to retrieve a board is\n\n```\nhttps://<hostname>/<path?>/<key>\n```\n\nFor example, a board hosted on the server `bogbody.biz` is available at this URL:\n\n```\nhttps://bogbody.biz/ca93846ae61903a862d44727c16fed4b80c0522cab5e5b8b54763068b83e0623\n```\n\n### Generating conforming keys\n\nThe protocol imposes a format requirement on keys. The content of Ed25519 keypairs is mostly random, so conforming keys can only be generated by trial and error.\n\nThe format requirement accomplishes two things at once:\n\n1. It presents a \"client puzzle\" which requires a one-time investment of compute resources to \"solve\". Like [Hashcash](http://www.hashcash.org/), this provides a rudimentary form of abuse mitigation: a malicious publisher cannot generate conforming keys instantly and endlessly.\n\n2. It \"bakes\" some useful metadata into the key itself.\n\nA conforming key's final seven hex characters must be `83e` followed by four characters that, interpreted as MMYY, express a valid month and year in the range 01/00 .. 12/99. Formally, the key must match this regex:\n\n```\n/83e(0[1-9]|1[0-2])(\\d\\d)$/\n```\n\nAgain, a conforming keypair can only be generated by trial and error. Using a single thread in an Apple M1 chip, this is accomplished in tens of minutes. Using many threads, it is accomplished in minutes, not seconds.\n\nThe date \"encoded\" in those final four characters has teeth: the key is only valid in the two years preceding it, and expires at the end of the last day of the month specified. (This is analogous to a [credit card expiration date](https://en.wikipedia.org/wiki/ISO/IEC_7813#Physical_characteristics).)\n\nFor example, the key\n\n```\nca93846ae61903a862d44727c16fed4b80c0522cab5e5b8b54763068b83e0623\n```\n\nhas an encoded expiration date of 0623, or 06/2023. This key is valid between 2021-06-01T00:00:00:00Z and 2023-07-01T00:00:00Z.\n\nThis expiration policy makes key rotation mandatory over the long term. Clients may implement features that make the process more convenient, even automatic, but the recurring \"stress test\" on the publisher-follower link is a feature, not a bug. The goal is to keep Spring '83 relationships \"live\" and engaged, with fresh opt-ins every two years at most.\n\nThe policy suggests to publishers, \"You're going to lose your secret key eventually... why not lose it now?\" and uses that loss as a mechanism to strengthen, rather than weaken, the network.\n\n### Discovering keys\n\nThe process of discovering a particular publisher's board URL, or discovering board URLs to follow generally, is not part of this specification.\n\nHowever, it is presumed that a home page or profile page might contain a `<link>` element analogous to the kind used to specify RSS feeds. A client scanning a web page for an associated board should look for `<link>` elements with the `type` attribute set to `text/board+html`.\n\n```\n<link rel=\"alternate\" type=\"text/board+html\" href=\"https://bogbody.biz/ca93846ae61903a862d44727c16fed4b80c0522cab5e5b8b54763068b83e0623\" />\n```\n\n## Boards in the client\n\nMuch of the burden of the protocol falls on the client: to store a user's keypair securely, allow them to manage a collection of followed board URLs, and display boards safely.\n\nThe client must:\n\n* reject boards larger than 2217 bytes\n* verify each board's cryptographic signature\n* situate each board inside its own Shadow DOM\n\nThe client must not:\n\n* execute any JavaScript included in the board\n* load any images, media, or fonts linked by the board\n\nThese two requirements should be satisfied with a [Content Security Policy](https://content-security-policy.com/). The design of this policy is not part of this specification, but here's an example that works for a simple web-based client:\n\n```\ndefault-src 'none';\nstyle-src 'self' 'unsafe-inline';\nfont-src 'self';\nscript-src 'self';\nform-action *;\nconnect-src *;\n```\n\nIt's important to allow `unsafe-inline` CSS so boards can style themselves!\n\n> *Aside:* The prohibition against images and other external resources is a matter of privacy, safety, and charisma. Privacy, because it prevents the use of tracking pixels and other \"transponders\". Safety, because it lowers the stakes for malicious and illegal content. Charisma, because images are so rich and appealing, they blot out everything else!\n> A future version of this protocol (Spring '84?) will support images, video, and/or audio, but I think it's worthwhile, at this time, to explore new \"ways of relating\" with those particular nozzles still shut.\n> Once they open, there's no going back!\n\nThe element that encloses the Shadow DOM must be set to `display: block`.\n\nPreparing each board for display in its Shadow DOM, the client should prepend this default CSS:\n\n```\n<style>\n  :host {\n    position: relative;\n    background-color: <some light, desaturated color>;\n    box-sizing: border-box;\n    padding: 2rem;\n  }\n  time { display: none; }\n  p, h1, h2, h3, h4, h5 { margin: 0 0 2rem 0; }\n</style>\n```\n\nThe board's inline CSS may override any of those rules. It may also \"reset the world\":\n\n```\n:host {\n  all: initial;\n}\n```\n\nThe client should:\n\n* provide at least one mode in which boards are juxtaposed on a 2D canvas\n* present boards in an aspect ratio of roughly `1:sqrt(2)` or `sqrt(2):1`\n* open links in new windows or tabs\n\nBeyond the standards described above, Spring '83 doesn't specify how the client should display boards. For example, the client may:\n\n* provide a mode in which boards can be viewed one at a time\n* organize boards according to an abstruse algorithm\n* handle links to board URLs in a helpful way, even \"transcluding\" them (!)\n\nThe protocol places no limitations on the HTML content of a board. Yes, forms are allowed! Knowing that the client will not execute JavaScript, publishers will probably not want to spend their precious bytes on inert code... but they are free to do so.\n\nBoards might be:\n\n* ephemeral notes about web pages recently read\n* weekly logs, wiped clean on Monday morning\n* yawlps to the universe\n\nPublishers should expect their boards to be placed on a 2D canvas alongside many others. They should also expect their boards to be presented in an aspect ratio of `1:sqrt(2)` or `sqrt(2):1`, although clients may display them differently.\n\n### Boards with special instructions\n\nClients should scan board HTML for the `<link rel=\"next\">` element:\n\n```\n<link rel=\"next\" href=\"<board URL>\">\n```\n\nThis element is used by publishers to migrate from key to key and server to server. When the client finds a `<link rel=\"next\">` element, it should retrieve the board at the URL specified, verify it normally, and either (a) notify the user, or (b) automatically update its record of the board's URL.\n\nA board should contain only one `<link rel=\"next\">` element. If it contains more than one, the client must honor the first and ignore the rest.\n\nThe new board specified by a `<link rel=\"next\">` element must not, itself, have a `<link rel=\"next\">` element. If it does, the client must cancel the migration, ignoring the new board.\n\nThe client may also scan for data stored in `meta` tags and `data-spring-*` attributes throughout the board. These fields and their uses will be defined by publishers and client developers.\n\n## Boards on the server\n\nSpring '83 servers are, in operation, very similar to \"plain old web\" servers, with a few additional behaviors.\n\nThe server must maintain a persistent store of boards and enforce a TTL, which must be not less than 7 days and not more than 22 days.\n\nThe transmission portion of Spring '83 operates over HTTP, using TLS, so it can be implemented easily using existing tools. The examples below use HTTP/1.1, but transmission over HTTP/2 and HTTP/3 is permitted.\n\nA Spring '83 server must respond at the following HTTP endpoints:\n\n```\nOPTIONS\nGET /\nPUT /<key>\nGET /<key>\nDELETE /<key>\n```\n\nThat's a pretty small API surface! We'll go through the endpoints one by one.\n\n### Serving clients: OPTIONS\n\nMany clients will, by dint of being web apps, depend on CORS to retrieve boards from non-origin servers. Servers must (1) support preflight OPTIONS requests, and (2) add the appropriate CORS headers to all responses:\n\n```\nHTTP/1.1 204 No Content\nAccess-Control-Allow-Methods: GET, OPTIONS, PUT\nAccess-Control-Allow-Origin: *\nAccess-Control-Allow-Headers: Content-Type, If-Modified-Since, Spring-Signature, Spring-Version\nAccess-Control-Expose-Headers: Content-Type, Last-Modified, Spring-Signature, Spring-Version\n```\n\n### Introducing yourself: GET /\n\nThe server must provide a valid HTML page at its base URL containing, at minimum:\n\n* its operator's contact information\n* its current board TTL\n* a rough assessment of its robustness and availability\n* an articulation of its publishing standards\n\n### Publishing boards: PUT /`<key>`\n\nPublishers will generally select a home server that they consider reliable and trustworthy. To publish a board, the client must send that server a request of this form:\n\n```\nPUT /<key> HTTP/1.1\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nSpring-Signature: <signature>\n\n<board>\n```\n\nUpon receipt, the server must check the non-cryptographic part of the PUT request immediately, and, if necessary, return an error code.\n\n#### Checking boards\n\n##### Size\n\nIf the board is larger than 2217 bytes, the server must reject the PUT request with 413 Payload Too Large.\n\n##### Timestamp\n\nThe timestamp is transmitted as part of the board HTML. The client must include a `<time>` element with its `datetime` attribute set to a UTC timestamp in ISO 8601 format, sans milliseconds: `YYYY-MM-DDTHH:MM:SSZ`.\n\nFor the convenience of server implementers, the `<time>` element's opening tag must fit the following format exactly; \"valid HTML\" is not sufficient:\n\n```\n<time datetime=\"YYYY-MM-DDTHH:MM:SSZ\">\n```\n\nThe `<time>` element may have text content, or it may be empty. Clients should hide the element by default; the board may include CSS that reveals it.\n\nIt's important that the timestamp is transmitted this way, because it needs to be signed along with the rest of the board's HTML. The client should add the `<time>` element automatically, just before signing and transmitting the board.\n\nThe board should contain only one `<time>` element. If it contains more than one, the server must honor the first and ignore the rest.\n\nThe server must reject the PUT request, returning 400 Bad Request, if\n\n* the request is transmitted without a `<time>` element; or\n* the element's `datetime` attribute is not a UTC timestamp in the ISO 8601 format described above; or\n* the element's `datetime` attribute contains a timestamp in the future; or\n* the element's `datetime` attribute contains a timestamp more than 22 days in the past.\n\nIf the incoming board's timestamp is older than or equal to the timestamp of the server's version of the board, the server must reject the request, returning 409 Conflict.\n\nThese criteria are EXTREMELY important. The `<time>` element modulates a board's change over time; if it gets screwed up, the publisher could lose the ability to update their board.\n\n##### Key format\n\nThe key format requirements are described earlier in this specification, and reproduced here for convenience.\n\nA conforming key's final seven hex characters must be \"83e\" followed by four characters that, interpreted as MMYY, express a valid month and year in the range 01/00 .. 12/99. Formally, the key must match this regex:\n\n```\n/83e(0[1-9]|1[0-2])(\\d\\d)$/\n```\n\nIf the key does not match that regex, the server must reject the request, returning 403 Forbidden.\n\nThe key is only valid in the two years preceding its encoded expiration date, and expires at the end of the last day of the month specified. For example, the key\n\n```\nc761fd8e4abc6ee4ca6d0883a95b7f0c88d33835a085b382dfbfb435283e0623\n```\n\nhas an encoded expiration date of 0623, or 06/2023. This key is valid between 2021-06-01T00:00:00:00Z and 2023-07-01T00:00:00Z.\n\nIf the key has expired, or indicates a date more than two years in the future, the server must reject the request, returning 403 Forbidden.\n\n##### Cryptographic validity\n\nThe server must verify that `<signature>` is `<key>`'s valid signature for the board, exactly as transmitted. If the board isn't properly signed, the server must reject the request, returning 401 Unauthorized.\n\n##### A special case\n\nSpring '83 defines a test keypair:\n\n```\npublic: ab589f4dde9fce4180fcf42c7b05185b0a02a5d682e353fa39177995083e0583\nsecret: 3371f8b011f51632fea33ed0a3688c26a45498205c6097c352bd4d079d224419\n```\n\nServers must reject PUT requests for this key, returning 401 Unauthorized. (See the section on GET /`<key>`, below, for more guidance.)\n\n#### Denying boards\n\nThe server must implement a denylist. If `<key>` is on the server's denylist, it must reject the request, returning 403 Forbidden.\n\nThe protocol defines an infernal key:\n\n```\nd17eef211f510479ee6696495a2589f7e9fb055c2576749747d93444883e0123\n```\n\nwhich the server must deny, returning 403 Forbidden. This is to validate it has implemented a denylist.\n\n#### Storing boards\n\nIf the preceding checks are all met, the server must store the board with a TTL of, at most, 22 days.\n\nIf the server is busy, it may decline the PUT request, returning 429 Too Many Requests.\n\n#### \"Deleting\" boards\n\nThe protocol does not provide a DELETE endpoint.\n\nInstead, the publisher should transmit a PUT request for a board containing nothing except the `<time>` element, as described above.\n\n> *Aside:* This limitation has to do with the protocol's cryptographic infrastructure. A malicious user can replace a deleted board with a copy of a previous version. To prevent this, we need a \"tombstone\" with a proper timestamp: the empty board.\n\nThe server should interpret a stored board containing nothing but a `<time>` element as \"missing\" and return 404 Not Found.\n\nThe server may provide this empty board to requesters until it expires -- at most, 22 days later -- at which point, the server must return 404 Not Found.\n\n#### Displaying boards\n\nOutside the context of a specific PUT request, the server must not display or enumerate boards unless those boards, or their publishers, have been reviewed and approved by its operator.\n\nSo, for example, if the operator wishes to display a list of recently updated boards on the server's home page, they may do so -- if they (a) have reviewed those boards, or (b) know and trust their publishers.\n\n> *Aside:* The logic here is simple: an unknown board from an unknown publisher might contain anything! Displaying arbitrary -- possibly malicious -- content goes against the protocol's value of predictability, its \"pull-only\" design.\n\n### Retrieving boards: GET /`<key>`\n\nThe client must transmit a request of this form:\n\n```\nGET /<key> HTTP/1.1\nSpring-Version: 83\nIf-Modified-Since: <date and time in UTC, RFC 5322 format>\n```\n\nIf the server does not have a board for `<key>`, it must return 404 Not Found.\n\nIf the server has a board for `<key>` but it is not newer than the timestamp specified in If-Modified-Since, it must return 304 Not Modified.\n\nIf the client omits If-Modified-Since, the server should return whatever board it has for `<key>`, if it has one.\n\nThe server's response must take the form:\n\n```\nHTTP/1.1 200 OK\nContent-Type: text/html;charset=utf-8\nSpring-Version: 83\nLast-Modified: <date and time in UTC, HTTP (RFC 5322) format>\nSpring-Signature: <signature>\n\n<board>\n```\n\nThe client must verify that `<signature>` is `<key>`'s valid signature for the board, exactly as transmitted. If the board isn't signed properly, the client must drop the response. It should communicate to the user that the server is either faulty or dishonest.\n\nThe `Last-Modified` header is provided for proxies that \"speak HTTP\"; the client should not consider it authoritative, attending instead to the `<time>` element included in the board HTML.\n\nIf the server is busy, it may decline the GET request, returning 429 Too Many Requests.\n\nIf the server is unreachable, or returns an error code, the client must wait for a minimum timeout of 5 minutes before attempting to contact that peer again. If the server is still not reachable, the client must apply a jittered backoff strategy. The client should cap its timeout at some maximum; one hour is recommended.\n\n#### Serving web browsers\n\nIf the server receives a request without a `Spring-Version` header -- indicating it did not come from a client aware of the protocol -- it may serve the requested board \"wrapped\" in a simple, informative HTML document.\n\n> *Aside:* Yes, this \"tempers\" with the board's HTML... but the web browser wasn't going to verify its signature anyway! A scrap of context -- \"This is a Spring '83 board; here's a link to an appropriate client\" -- helps bring viewers into the Spring '83 ecosystem.\n\nThis is optional; the server may also provide the raw board HTML.\n\n#### Forgetting boards\n\nThe server must store boards with a TTL of, at most, 22 days.\n\n> *Aside:* 22 is a magic number.\n\nThe server must provide identical responses to requests for\n\n* `<key A>`, for which it once stored a board, now expired or deleted, and\n* `<key B>`, for which it never stored any board.\n\n#### Helping developers\n\nSpring '83 specifies a test keypair:\n\n```\npublic: ab589f4dde9fce4180fcf42c7b05185b0a02a5d682e353fa39177995083e0583\nsecret: 3371f8b011f51632fea33ed0a3688c26a45498205c6097c352bd4d079d224419\n```\n\nThe server should respond to GET requests for this key with an ever-changing board, generated internally, signed appropriately, with a timestamp set to the time of the request. This board is provided to help client developers understand and troubleshoot their applications.\n\n> *Aside:* This test keypair technically expired a long time ago, so servers will have to add special logic to recognize and handle it.\n\n## Error code quick reference\n\n* 400: Board was submitted with an impromper timestamp.\n* 401: Board was submitted without a valid signature.\n* 403: Board was submitted for a non-conforming, expired, or blocked key.\n* 404: No board for this key found on this server.\n* 409: Board was transmitted with a timestamp older than the server's timestamp for this board.\n* 413: Board is larger than 2217 bytes.\n\n## Discussions\n\n### 1: Inspirations\n\nThis protocol draws inspiration\n\n* from Secure Scuttlebutt: the power of cryptographic keypairs as identities\n* from Hashcash: the notion of guarding server resources with client puzzles\n* from ZeroTier: the spirit of \"decentralize until it hurts, then centralize until it works\".\n\nand, most of all,\n\n* from [the Quote of the Day Protocol](https://datatracker.ietf.org/doc/html/rfc865), defined by Jon Postel in May 1983: the vision of simplicity\n\nFor those not familiar: QOTD operates over both TCP and UDP; the server responds to a TCP connection or a UDP datagram with a single brief message.\n\nIn fact, I very badly wanted Spring '83 to operate over UDP -- responding to a request with, in some cases, a single datagram packet: beautiful -- but the architecture of the modern internet makes that much more difficult today than it was in 1983, and, anyway, there's a universe of capable tooling for HTTP. \n\nSo, not without regret, Spring '83 goes with the flow.\n\n### 2: The agony and ecstasy of public key cryptography\n\nThere are a lot of reasons NOT to use cryptographic keypairs as identities, not least of which: the certainty that a user will eventually lose their secret key.\n\nBut the profound magic trick of the signature: that it allows a piece of content to move through the internet, handed from server to server, impossible to tamper with... it's too good to pass up.\n\nAnd the way public key cryptography allows anyone to \"join\" the system, without registering anywhere, simply by generating an appropriate keypair -- again, it's a trick so good it seems like it shouldn't work.\n\nThe trapdoor function at the heart of public key cryptography is mirrored in the trapdoor of its user experience: once a secret key is lost or compromised, the identity is done. Game over. The system offers no customer support, because the system is math, and all the angels are busy assisting other callers.\n\nIt's one of the harshest if/thens in all of computing, and a steep price to pay for the magic trick. Spring '83, given its other priorities and constraints, is willing to pay that price -- but only barely.\n\nThe compromise is mandatory key rotation, enforced with the expiration policy.\n\nBeyond that, there is plenty of space for Spring '83 clients to offer hosted (\"custodial\") secret keys, abstracting the keypair behind a more traditional username and password."
  },
  {
    "path": "simulate.cr",
    "content": "struct Peer\n  property data\n  property already_shared\n  property num_inbound\n  property evil\n\n  def initialize(\n    @data : Int32,\n    @already_shared : Bool,\n    @num_inbound : Int32,\n    @evil : Bool\n  )\n  end\nend\n\nmodule Sim\n  extend self\n  DESIRED_DATA =   99\n  NUM_PEERS    = 1000\n  NUM_SAMPLED  =    5\n\n  PROPORTION_EVIL = 0.1\n\n  @@peers = Array(Peer).new\n\n  def convergence_ratio\n    num_with_data = 0\n    @@peers.each do |peer|\n      if peer.data == DESIRED_DATA\n        num_with_data += 1\n      end\n    end\n\n    return (num_with_data.to_f / NUM_PEERS.to_f).significant(2)\n  end\n\n  def propagate\n    bandwidth = 0\n    wasted = 0\n    new_peers = @@peers.dup\n\n    NUM_PEERS.times do |index|\n      peer = @@peers[index]\n\n      if peer.data == DESIRED_DATA && !peer.already_shared && !peer.evil\n        # Share with sampled peers\n        NUM_SAMPLED.times do\n          r_index = (Random.rand * NUM_PEERS).to_i\n          bandwidth += 1\n          if @@peers[r_index].data == DESIRED_DATA\n            wasted += 1\n\n            new_peers[r_index] = Peer.new(\n              @@peers[r_index].data,\n              @@peers[r_index].already_shared,\n              @@peers[r_index].num_inbound + 1,\n              @@peers[r_index].evil\n            )\n          else\n            new_num_inbound = @@peers[r_index].num_inbound + 1\n            new_peers[r_index] = Peer.new(\n              DESIRED_DATA,\n              @@peers[r_index].already_shared,\n              new_num_inbound,\n              @@peers[r_index].evil\n            )\n          end\n        end\n\n        # Mark that I shared with sampled peers\n        new_peers[index] = Peer.new(DESIRED_DATA, true, peer.num_inbound, peer.evil)\n      end\n    end\n\n    @@peers = new_peers\n    return {bandwidth, wasted}\n  end\n\n  def run\n    avg_steps = 0\n    avg_bandwidth = 0\n    avg_inbound_per_peer = 0\n    avg_wasted = 0\n    did_not_converge = 0\n\n    max_inbound_per_peer = 0\n\n    50.times do |n|\n      puts \"---\"\n      puts \"Run #{n}\"\n\n      @@peers = Array(Peer).new\n\n      NUM_PEERS.times do |i|\n        evil = Random.rand < PROPORTION_EVIL ? true : false\n        new_peer = Peer.new(0, false, 0, evil)\n        @@peers.push(new_peer)\n      end\n\n      @@peers[0] = Peer.new(DESIRED_DATA, false, 0, false)\n\n      steps = 0\n      bandwidth = 0\n      wasted = 0\n\n      while steps < 100\n        added_bandwidth, added_wasted = propagate\n        bandwidth += added_bandwidth\n        wasted += added_wasted\n        convergence = convergence_ratio\n        puts \"Step #{steps}: #{convergence}\"\n        if convergence >= 1.0\n          break\n        end\n        steps += 1\n      end\n\n      if steps >= 100\n        did_not_converge += 1\n      end\n\n      inbound_per_peer = 0\n\n      @@peers.each do |peer|\n        inbound_per_peer += peer.num_inbound\n        if (peer.num_inbound > max_inbound_per_peer)\n          max_inbound_per_peer = peer.num_inbound\n        end\n      end\n\n      inbound_per_peer /= @@peers.size\n\n      if (avg_inbound_per_peer == 0)\n        avg_inbound_per_peer = inbound_per_peer\n      else\n        avg_inbound_per_peer = (avg_inbound_per_peer + inbound_per_peer) / 2.0\n      end\n\n      if (avg_steps == 0)\n        avg_steps = steps\n      else\n        avg_steps = (avg_steps + steps) / 2.0\n      end\n\n      if (avg_bandwidth == 0)\n        avg_bandwidth = bandwidth\n      else\n        avg_bandwidth = (avg_bandwidth + bandwidth) / 2.0\n      end\n\n      if (avg_wasted == 0)\n        avg_wasted = wasted\n      else\n        avg_wasted = (avg_wasted + wasted) / 2.0\n      end\n    end\n\n    puts \"Num did not converge: #{did_not_converge}\"\n    puts \"Avg inbound reqs per peer: #{avg_inbound_per_peer}\"\n    puts \"Max inbound reqs for any peer, in any run: #{max_inbound_per_peer}\"\n    puts \"Avg time steps: #{avg_steps}\"\n    puts \"Avg bandwidth: #{avg_bandwidth}\"\n    puts \"Avg wasted bandwidth: #{avg_wasted}\"\n    puts \"which is multiplier of #{(avg_bandwidth / NUM_PEERS).significant(1)}X direct\"\n  end\nend\n\nSim.run\n"
  }
]