on master help sign in
Inline Ed25519 hex length invariants as literals
commit38cf8db2e37dece7409317b644c328ada979596a authoriko <mail@iko.soy> dateSat 9 May 2026, 21:14 (5 months ago) parent7ca3e27
1 file changed+2−8
server.knot+2−8
server.knot+2−8
@@ -48,15 +48,9 @@ federationScheme = "https://"
4848-- long after `receivedAt`; expired rows are pruned by `pruneExpired` (30 days).
4949messageMaxAge : Int<Ms>
5050messageMaxAge = 2592000000
51−-- Length (chars) of a hex-encoded Ed25519 pubkey (32 bytes → 64 hex).
52−pubkeyLen : Int
53−pubkeyLen = 64
5451-- Max length of a hex-encoded message body / opaque blob (40 MiB hex ≈ 20 MiB bytes).
5552maxBlobLen : Int
5653maxBlobLen = 41943040
57−-- Length of a hex-encoded Ed25519 signature (64 bytes → 128 hex).
58−signatureLen : Int
59−signatureLen = 128
6054-- Cap on items in a batched send request.
6155maxBatchSize : Int
6256maxBatchSize = 100
@@ -195,11 +189,11 @@ isValidBoundedHex = \maxLen s -> not tooLong s maxLen && isValidHex s
195189isValidExactHex : Int -> Text -> Bool
196190isValidExactHex = \exactLen s -> count (chars s) == exactLen && isValidHex s
197191-- Hex-encoded Ed25519 public key (32 bytes → 64 chars exact).
198−type PubkeyHex = Text where isValidExactHex pubkeyLen
192+type PubkeyHex = Text where isValidExactHex 64
199193-- Hex-encoded ciphertext or opaque blob; capped at `maxBlobLen` (~20 MiB).
200194type BlobHex = Text where isValidBoundedHex maxBlobLen
201195-- Hex-encoded Ed25519 signature (64 bytes → 128 chars exact).
202−type SignatureHex = Text where isValidExactHex signatureLen
196+type SignatureHex = Text where isValidExactHex 128
203197-- Normalized hostname (lowercased, no trailing dot, length-bounded). The SSRF
204198-- deny-list (`isBadServerName`) is enforced separately at federation egress
205199-- (`handleRecvGossip`); keeping it out of the type predicate lets the default