{"number":333,"title":"BIP324 One-Byte Message Type ID Alias Assignment","authors":["Anthony Towns"],"status":"Draft","type":"Specification","layer":"Peer Services","created":"2026-10-28","license":"BSD-2-Clause","requires":[324,434],"replaces":[],"replacedBy":[],"discussion":["https://gnusha.org/pi/bitcoindev/aq9ADn7GscMHWc19@erisian.com.au/T/#u"],"abstract":"Provides a new set324alias message that permits peers using BIP-324 encrypted transport to assign one-byte IDs as aliases for 12-byte ASCII message types to improve bandwidth usage for their outbound messages.","categories":["network"],"filename":"bip-0333.md","githubUrl":"https://github.com/bitcoin/bips/blob/master/bip-0333.md","format":"markdown","readingMinutes":6,"inbound":0,"revisions":1,"impact":0,"core":false,"references":[],"lastModified":"2026-09-17","html":"<h2 id=\"abstract\">Abstract</h2>\n<p>Provides a new <code>set324alias</code> message that permits peers using\n<a href=\"https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki\">BIP-324</a> encrypted transport to assign one-byte IDs as aliases\nfor 12-byte ASCII message types to improve bandwidth usage for their\noutbound messages.</p>\n<h2 id=\"motivation\">Motivation</h2>\n<p><a href=\"https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki\">BIP-324</a> assigns one-byte IDs (aka one-byte message type IDs) via\na fixed table, and adding additional entries to the table requires global\ncoordination with the potential for conflicts. Allowing peers to choose\ntheir own one-byte IDs at runtime for their own outgoing messages gives\nthe same benefit while avoiding the need for centralized coordination,\nand increases flexibility for experimentation at the peer-to-peer layer.</p>\n<h2 id=\"specification\">Specification</h2>\n<p>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;,\n&quot;RECOMMENDED&quot;, &quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be\ninterpreted as described in RFC 2119.</p>\n<p>If a node violates a REQUIRED, MUST or MUST NOT directive, its peer MAY\nclose the connection; beyond that, this BIP does not specify the peer&#39;s\nongoing behaviour. If a node violates a RECOMMENDED, SHOULD or SHOULD\nNOT directive, its peer SHOULD continue operation normally, but MAY close\nthe connection (eg if the violation creates resource usage concerns).</p>\n<h3 id=\"feature-advertisement\">Feature advertisement</h3>\n<p>Support for this feature is advertised via the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0434.md\">BIP-434</a> <code>feature</code>\nmessage.</p>\n<p>Nodes that support receiving <code>set324alias</code> messages MUST advertise\nsupport for the feature by sending a <code>feature</code> message with <code>featureid</code>\n<code>BIP333</code> and an empty <code>featuredata</code> after sending the <code>version</code> message\nand before sending the <code>verack</code> message.</p>\n<p>Nodes that support sending <code>set324alias</code> messages MUST treat the peer\nas having advertised support for this BIP after receiving a <code>feature</code>\nmessage with <code>featureid</code> <code>BIP333</code> (with any BIP-434 compliant <code>featuredata</code>\nvalue[^any-featuredata]) between <code>version</code> and <code>verack</code>.</p>\n<p>Nodes MAY selectively advertise support for this feature on only some\nconnections[^selective-advertise]. Nodes SHOULD NOT advertise support\nfor this feature on connections that do not support one-byte IDs.</p>\n<h3 id=\"set324alias-message\"><code>set324alias</code> message</h3>\n<p>The <code>set324alias</code> message allows extending or modifying the set of\naliases defined by <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki\">BIP-324</a>.</p>\n<p>The payload of the <code>set324alias</code> message is serialized as a vector of\naliases, that is a <code>CompactSize</code> encoded number of aliases being defined,\nfollowed by that number of aliases.</p>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Name</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>alias-vector</td>\n<td><code>aliases</code></td>\n<td>The new aliases</td>\n</tr>\n</tbody></table>\n<p>Each alias is serialized as the one-byte ID (with value 1 to 255),\nfollowed by the 12-byte ASCII message type it corresponds to.</p>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Name</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody><tr>\n<td><code>uint8_t</code></td>\n<td><code>id</code></td>\n<td>The one-byte ID (1-255)</td>\n</tr>\n<tr>\n<td><code>uint8_t[12]</code></td>\n<td><code>msg_type</code></td>\n<td>The corresponding 12-byte ASCII message type as per BIP-324</td>\n</tr>\n</tbody></table>\n<p>Nodes MUST NOT send <code>set324alias</code> before sending <code>verack</code>. Nodes MUST\nNOT send <code>set324alias</code> to a peer that has not advertised support for\nthe feature. Nodes MUST NOT send more than 255 elements in <code>aliases</code>,\nand MUST NOT define an alias with <code>id=0</code>[^id-zero].</p>\n<p>Nodes SHOULD NOT send <code>set324alias</code> on a connection that does not\nsupport one-byte IDs (such as p2pv1 connections). Nodes SHOULD NOT send\n<code>set324alias</code> with an empty <code>aliases</code> vector.</p>\n<p>Nodes SHOULD define an alias for all messages that they expect to\nsend multiple times over a connection. Nodes SHOULD NOT define an\nalias for any message that will only be sent at most once over the\nconnection. Nodes SHOULD NOT define aliases for messages that already have\nan alias defined in <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki\">BIP-324</a>. Nodes SHOULD send <code>set324alias</code>\nonly once per connection, and SHOULD send it as soon as possible (eg\nimmediately after receiving the <code>feature</code> message indicating support).\nOnce an alias is defined, a node SHOULD use that alias&#39;s one-byte ID\nfor all future messages of that type[^when-to-alias].</p>\n<p>Nodes MAY hardcode a bundle of aliases they prefer and send that bundle\nto all peers that support this feature[^bundling].</p>\n<p>Nodes MAY override any existing one-byte ID, including one-byte IDs\ndefined in BIP-324 or elsewhere.</p>\n<p>Nodes receiving a <code>set324alias</code> message MUST maintain a per-peer mapping\nof one-byte IDs to 12-byte ASCII message types, and future messages\nusing the one-byte ID MUST be interpreted as if the 12-byte <code>msg_type</code>\nhad been used instead[^directionality].</p>\n<p>A node receiving a <code>set324alias</code> message MUST update the mapping with\nthe new aliases immediately, as the very next message may make use of\naliases declared in that message.</p>\n<p>Nodes receiving a <code>set324alias</code> message MUST update the aliases in\norder[^update-ordering].</p>\n<p>If a peer specifies an unknown <code>msg_type</code> in an alias, the node\nreceiving the alias SHOULD record the <code>id</code> as corresponding to a generic\nunknown message type rather than tracking each unknown <code>msg_type</code>\ndistinctly. Nodes MUST NOT treat a <code>set324alias</code> message defining an\nalias for an unknown 12-byte ASCII message type as an error. Nodes\nMAY treat a later message using that one-byte ID as an error if they\nwould also have treated a message using the <code>msg_type</code> it aliases as\nan error[^unknown-msgtype].</p>\n<p>A node receiving a <code>set324alias</code> message MUST continue to accept\nand process messages that use the 12-byte <code>msg_type</code> rather than the\none-byte ID.</p>\n<h2 id=\"reference-implementation\">Reference implementation</h2>\n<p><strong>TODO</strong> See <a href=\"https://github.com/ajtowns/bitcoin/commits/202605-bip324-id/\">https://github.com/ajtowns/bitcoin/commits/202605-bip324-id/</a> in the meantime.</p>\n<h2 id=\"backward-compatibility\">Backward compatibility</h2>\n<p>Non-implementing peers never receive a <code>set324alias</code> (gated on their\nadvertisement), so they keep the default mapping and are unaffected.</p>\n<p>The 12-byte ASCII message type stays valid for every message, so messages\nwhose one-byte ID has been reassigned to a different message type can\nstill be sent.</p>\n<h2 id=\"copyright\">Copyright</h2>\n<p>This BIP is licensed under the 2-clause BSD license.</p>\n<h2 id=\"rationale\">Rationale</h2>\n<p>[^any-featuredata]: Supporting receiving any <code>featuredata</code> rather than\nrequiring it be empty allows for backwards-compatible updates to this\nBIP in future.</p>\n<p>[^selective-advertise]: Only advertising the feature on some connections\nmay be useful for privacy reasons, in cases where leaking additional\ninformation about what node software you are running may be undesirable.</p>\n<p>[^id-zero]: Due to the way BIP-324 encodes 12-byte ASCII message types,\nthe zero value alias is not usable.</p>\n<p>[^when-to-alias]: Defining an additional alias costs 13 bytes, and using\na one-byte ID saves 12 bytes, so defining an alias results in a saving\nfor messages that are sent more than once, but no saving for messages\nsent only once. Aliasing multiple one-byte IDs to the same message type\nis not harmful, but also provides no benefit. Once an alias is defined,\nusing the 12-byte ASCII message type instead of the one-byte ID simply\nwastes an additional 12 bytes per message.</p>\n<p>[^bundling]: Having a single set of aliases that is used for all peers\nmay make implementation simpler as it results in only needing to check\na single flag per-peer: &quot;should the aliases be used, or the BIP-324\ndefaults?&quot; rather than full per-peer mappings.</p>\n<p>[^directionality]: Note that aliases only affect messages being sent by\nthe node that sent the <code>set324alias</code> message; they do not affect messages\nreceived by that node. If the peer were to attempt to use those aliases\nfor its messages, then because messaging is asynchronous, it would not be\nclear to the node receiving those messages at which point the peer would\nhave received the <code>set324alias</code> message and applied the new mapping. The\nonly way to resolve that would be for the peer to also send some form of\n&quot;ack&quot; message indicating &quot;your message was received and my future messages\nwill use those aliases&quot;, but if a message has to be sent anyway, then\nit is simpler for the peer to just send its own <code>set324alias</code> mapping.</p>\n<p>[^update-ordering]: Updating the mapping in order removes the ambiguity\nif a single one-byte ID is assigned to multiple 12-byte ASCII message\ntypes. For example, if <code>set324alias [1:foo, 2:bar, 3:baz, 1:baz]</code> is\nreceived, subsequent messages with either of the one-byte IDs <code>1</code> or\n<code>3</code> will be interpreted as <code>baz</code> messages (rather than <code>foo</code>) by nodes\nimplementing this BIP.</p>\n<p>[^unknown-msgtype]: One way to efficiently implement the receive-side\nper-peer map is to use a small array with the index corresponding\nto the one-byte ID, and the value being an internal identifier for\neach supported message, which should only need one or, at most, two\nbytes. With this approach, unknown messages will get represented by a\nplaceholder identifier, and all unsupported messages will need to be\ntreated the same way.</p>\n","toc":[{"id":"abstract","title":"Abstract","level":2},{"id":"motivation","title":"Motivation","level":2},{"id":"specification","title":"Specification","level":2},{"id":"feature-advertisement","title":"Feature advertisement","level":3},{"id":"set324alias-message","title":"set324alias message","level":3},{"id":"reference-implementation","title":"Reference implementation","level":2},{"id":"backward-compatibility","title":"Backward compatibility","level":2},{"id":"copyright","title":"Copyright","level":2},{"id":"rationale","title":"Rationale","level":2}],"history":{"totalCommits":1,"firstCommit":"2026-09-17T18:42:37+10:00","lastUpdated":"2026-09-17T18:42:37+10:00","events":[{"sha":"cd3957c9890ac0ea9d887ab2a23aaa240607fe99","date":"2026-09-17T18:42:37+10:00","author":"Anthony Towns","message":"Add BIP333: BIP324 One-Byte Message Type ID Alias Assignment","url":"https://github.com/bitcoin/bips/commit/cd3957c9890ac0ea9d887ab2a23aaa240607fe99","kind":"edit"}]}}