]> Cypherpunks repositories - keks.git/commitdiff
Various spec fixes
authorSergey Matveev <stargrave@stargrave.org>
Sat, 17 May 2025 11:00:18 +0000 (14:00 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 17 May 2025 11:00:18 +0000 (14:00 +0300)
44 files changed:
spec/INSTALL
spec/cm/dem/kuznechik-ctr-hmac-kr
spec/cm/dem/xchapoly-krkc
spec/cm/dem/xchapoly-krmr
spec/cm/encrypted/index
spec/cm/hashed/blake2b
spec/cm/hashed/blake3
spec/cm/hashed/shake
spec/cm/hashed/skein512
spec/cm/hashed/streebog
spec/cm/hashed/xxh3-128
spec/cm/kem/balloon-blake2b-hkdf
spec/cm/kem/gost3410-hkdf
spec/cm/kem/mceliece6960119-x25519-hkdf-shake256
spec/cm/kem/pbkdf2
spec/cm/kem/sntrup4591761-x25519-hkdf-blake2b
spec/cm/keywrap/kexp15
spec/cm/keywrap/xchapoly
spec/cm/prv/mceliece6960119-x25519
spec/cm/prv/sntrup4591761-x25519
spec/cm/prv/sphincs+-shake-256s
spec/cm/pub/ed25519-blake2b
spec/cm/pub/gost3410
spec/cm/pub/index
spec/cm/pub/mceliece6960119-x25519
spec/cm/pub/sntrup4591761-x25519
spec/cm/pub/sphincs+-shake-256s
spec/cm/signed/ed25519-blake2b
spec/cm/signed/ed25519ph-blake2b-merkle
spec/cm/signed/gost3410
spec/cm/signed/gost3410-merkle
spec/cm/signed/index
spec/cm/signed/sphincs+-shake-256s
spec/cm/signed/sphincs+-shake-256s-merkle
spec/encoding/FullTable
spec/encoding/INT
spec/encoding/MAP
spec/encoding/String
spec/encoding/TAI [moved from spec/encoding/TAI64 with 76% similarity]
spec/encoding/index
spec/schema/cmds
spec/schema/index
spec/schema/tcl
tcl/schemas/signed.tcl

index cfd68cdf6db0aacb8816c2333b5aeeea2a241d4a67529be5980a33510fb167c4..7c25dcdcd310cf8c1a94288a09a7abb530a667eb4b0b2bebaa95b38d3c886bd5 100644 (file)
@@ -13,5 +13,6 @@ git://git.stargrave.org/keks.git
 git://y.git.stargrave.org/keks.git
 git://y.git.cypherpunks.su/keks.git
 
-Also there is Yggdrasil accessible address: http://y.www.keks.cypherpunks.su/
+Also there is Yggdrasil accessible address:
+=> http://y.www.keks.cypherpunks.su/\r
 => https://yggdrasil-network.github.io/ Yggdrasil\r
index 7ce03f25a5ae93695843a01f4522d683c853b4eb5ad37d51ea721d234ea4ea1c..756b0af792ea0bce3f5fc254ed5951e488048cb449ea754b2b4d7554455f5f6a 100644 (file)
@@ -10,10 +10,11 @@ Data is split on 128 KiB chunks, each of which is encrypted the following way:
     IV = HKDF-Expand(H, prk=CKi, len=8, info="cm/encrypted/kuznechik-ctr-hmac-kr/iv")
     Kauth || KauthTail = HKDF-Expand(H, prk=CKi,
         info="cm/encrypted/kuznechik-ctr-hmac-kr/auth")
-    KauthTail = HKDF-Expand(H, prk=CKi,
-        info="cm/encrypted/kuznechik-ctr-hmac-kr/authTail")
-    CT = Kuznechik-CTR(key=Kenc, ctr=IV, data=chunk)
-    CT || HMAC(Streebog-256, key={Kauth|KauthTail}, data=CT)
+    CIPHERTEXT = Kuznechik-CTR(key=Kenc, ctr=IV, data=chunk)
+    CIPHERTEXT || HMAC(Streebog-256, key={Kauth|KauthTail}, data=CIPHERTEXT)
+
+Chaining key (CK) advances with every chunk. 256-bit encryption key and
+randomised 64-bit nonce (initialisation vector) are derived from it.
 
 KauthTail is used only in the last chunk to explicitly signal
 that it is the last one.
index 730141d1e5547492425354265f247c13177765e83c8a63b6deb9800ee446aa78..88f831d30fbaec1f995aa055489e15b7cfc25cd24ae6c9028e58ac54d9650fd6 100644 (file)
@@ -8,7 +8,7 @@ Data is split on 128 KiB chunks, each of which is encrypted the following way:
     CKi = HKDF-Extract(H, salt="", ikm=CK{i-1})
     KEY = HKDF-Expand(H, prk=CKi, info="cm/encrypted/xchapoly-krkc/key")
     IV = HKDF-Expand(H, prk=CKi, info="cm/encrypted/xchapoly-krkc/iv", len=24)
-    if last chunk { IV[23] |= 0x01 } else { IV[23] &= 0xFE }
+    if {last chunk} then { IV[23] |= 0x01 } else { IV[23] &= 0xFE }
     CIPHERTEXT || TAG = XChaCha20-Poly1305(key=KEY, ad="", nonce=IV, data=chunk)
     COMMITMENT = BLAKE2b-256(KEY || IV || TAG)
     CIPHERTEXT || TAG || COMMITMENT
@@ -21,7 +21,6 @@ Nonce's lowest bit is set only if this is the last chunk we encrypting.
 "/payload"'s chunk length equals to 128KiB+16+32 bytes.
 
 => https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
-=> https://www.blake2.net/ BLAKE2b is hashing algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, same\r
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
 => https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha XChaCha20-Poly1305 AEAD\r
 => https://datatracker.ietf.org/doc/html/rfc8439.html RFC 8439\r
index f505a4fb5e3692bcf4de7df0475fbbe5daac31e6b4be0d87896e7ab225832c19..e3ac53c1dd797b676caf5f5bea0f72d43bfed240f6113c6b23694ad16fbd95cd 100644 (file)
@@ -1,17 +1,17 @@
 XChaCha20-Poly1305 with key ratcheting and multi-recipient DEM.
 [cm/encrypted/]'s "/dem/a" equals to "xchapoly-krmr".
-CEK consists of common 64 bytes long part equal in all KEMs (@code{CEK} itself),
-and 64 bytes long per-KEM/per-recipient random MAC key (@code{prMAC}).
+CEK consists of common 64-bytes part equal in all KEMs (CEK itself),
+and 64 bytes long per-KEM/per-recipient random MAC key (prMACx).
 Data is split on 128 KiB chunks, each of which is encrypted the following way:
 
     H = BLAKE2b
     CK0, prMACx0 = CEK || prMACx
     CKi = HKDF-Extract(H, salt="", ikm=CK{i-1})
+    prMACxi = HKDF-Extract(H, salt="", ikm=prMACx{i-1})
     KEY = HKDF-Expand(H, prk=CKi, info="cm/encrypted/xchapoly-krmr/key")
     IV = HKDF-Expand(H, prk=CKi, info="cm/encrypted/xchapoly-krmr/iv", len=24)
-    if last chunk { IV[23] |= 0x01 } else { IV[23] &= 0xFE }
+    if {last chunk} then { IV[23] |= 0x01 } else { IV[23] &= 0xFE }
     CIPHERTEXT || TAG = XChaCha20-Poly1305(key=KEY, ad="", nonce=IV, data=chunk)
-    prMACxi = HKDF-Extract(H, salt="", ikm=prMACx{i-1})
     MACx = BLAKE2b-256-MAC(key=prMACxi, H(CIPHERTEXT || TAG))
     CIPHERTEXT || TAG || MACx || MAC{x+1} [|| MAC{x+2} ...]
 
@@ -26,7 +26,6 @@ MACs are ordered the same way as KEMs in the list.
 "/payload"'s chunk length equals to 128KiB+16+32*recipients bytes.
 
 => https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
-=> https://www.blake2.net/ BLAKE2b is hashing algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, same\r
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
 => https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha XChaCha20-Poly1305 AEAD\r
 => https://datatracker.ietf.org/doc/html/rfc8439.html RFC 8439\r
index 75d6326a152fc15f09e4bb42e924b34d3935ca0cfc5aed63e5d3e32ad6e5cbde..d5bd6cfbfba4f06397430b39c95f3829f8491ceed7557fff0c436e7c61d528e9 100644 (file)
@@ -41,6 +41,6 @@ identification. UUIDv4 is recommended.
 If absent, then null UUID is used in KDF.
 
 [cm/encrypted/authcrypt] -- authenticated public-key encryption
-[cm/keywrap/] -- key wrapping mechanisms
-[cm/dem/] -- data encapsulation mechanisms
-[cm/kem/] -- key encapsulation mechanisms
+[cm/keywrap/] | key wrapping mechanisms
+[cm/dem/]     | data encapsulation mechanisms
+[cm/kem/]     | key encapsulation mechanisms
index 364531d7585f48ba452b5e976e54a4ec60c783753685fdaaf7f799a55b953bc0..9f464fb3a43584e66ca2feab847c2ce61ccc9dbc913e79c32d5b37d396af0fd6 100644 (file)
@@ -1,5 +1,4 @@
 [cm/hashed/] with BLAKE2b.
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
 BLAKE2b with 512-bit output has "blake2b" algorithm identifier.
 256-bit output has "blake2b256" algorithm identifier.
-=> https://www.blake2.net/ BLAKE2b\r
-=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, same\r
index 80b44bd1c5008569c3cb19b672376101ef34b4b911a12d4207cc506ed95ba2aa..1ac13df3bbe86dd30b3424a437249b363d0de20682fd1b7ccc59037826645d49 100644 (file)
@@ -1,3 +1,3 @@
 [cm/hashed/] with BLAKE3.
-BLAKE3 with fixed 256-bit output has "blake3" algorithm identifier.
 => https://github.com/BLAKE3-team/BLAKE3/ BLAKE3\r
+BLAKE3 with fixed 256-bit output has "blake3" algorithm identifier.
index f82f1c0d6f63dd09cc3d564b86aa25dd7cb0aa03731a3fe51884c09740eb613e..b7eb4d78f152689c67bd82e3ad42c9e97926f0bd618d527fa6477a289b5c39c4 100644 (file)
@@ -1,4 +1,4 @@
 [cm/hashed/] with SHAKE.
+=> https://keccak.team/ SHAKE\r
 SHAKE XOF function with fixed 256 (SHAKE128) or 512 (SHAKE256) bit output.
 "shake128", "shake256" algorithm identifiers are used.
-=> https://keccak.team/ SHAKE\r
index feaf9dba3fc420ce2b71500530d218379df2f768484192699f2b02c748385bc8..4564a7fc297181eac1dd603091057b8a0b9c049bde716dd9c1ab52a1c4ef283c 100644 (file)
@@ -1,3 +1,3 @@
 [cm/hashed/] with Skein-512.
-"skein512" algorithm identifier is used.
 => https://www.schneier.com/academic/skein/ Skein-512\r
+"skein512" algorithm identifier is used.
index 5fb3a055d2fd6a466f027896efb4ed288c2e23e09acd27d7c6834402d9230400..ae72a9b11084b73ab3b322e492bad9adedc5c34a27fb814c5052b965d25ac4ea 100644 (file)
@@ -1,4 +1,4 @@
 [cm/hashed/] with GOST R 34.11-2012.
+=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986\r
 Streebog must be big-endian serialised.
 "streebog256", "streebog512" algorithm identifiers are used.
-=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986\r
index 1ebce9ed42793dabe1d4248623e55936753718503b5746d84cbbbce83fe96b07..989dcc37c542f4c7dc8e1eed6f8cf4d4ee973071e47ad05664f949c70641ead0 100644 (file)
@@ -1,4 +1,4 @@
 [cm/hashed/] with XXH3-128.
+=> https://xxhash.com/ XXH3\r
 128-bit XXH3 hash must be big-endian encoded.
 "xxh3-128" algorithm identifier is used.
-=> https://xxhash.com/ XXH3\r
index de5f4035ef38f7e9937cae4405d7b8ee7bfc3886d81f7e639099c204b26d26d9..27c36914cbf2e84778adbd80e83d904165849e81df502f285f30b0634f072001 100644 (file)
@@ -1,17 +1,14 @@
-Balloon-BLAKE2b+HKDF KEM.
+Balloon-BLAKE2b + HKDF KEM.
+=> https://crypto.stanford.edu/balloon/ Balloon\r
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
+=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
 
 <<    [schemas/kem-balloon-blake2b-hkdf.tcl]\r
 
-Balloon memory-hardened password hasher must be used with BLAKE2b hash.
-=> https://crypto.stanford.edu/balloon/ Balloon\r
-
     H = BLAKE2b
     KEK = HKDF-Expand(H,
-        prk=balloon(H, passphrase, /kem/salt, s, t, p),
+        prk=Balloon(H, passphrase, /kem/salt, s, t, p),
         info="cm/encrypted/balloon-blake2b-hkdf" || /id)
 
 "/kem/*/cek" is wrapped with [cm/keywrap/xchapoly] mechanism.
 
-=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
-=> https://www.blake2.net/ BLAKE2b is hashing algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, same\r
index b7938f0f65d5f79f6f363f254e4941e9e1d9f18ecc0ddd220927a92625ebadd4..888038026c3f48f363b10617325fb00b85cf625664574285bc25508c4075887b 100644 (file)
@@ -1,7 +1,13 @@
-GOST R 34.10+HKDF KEM.
+GOST R 34.10 + HKDF KEM.
+=> https://datatracker.ietf.org/doc/html/rfc7091.html RFC 7091, GOST R 34.10-2012\r
+=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
+=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986, Streebog, GOST R 34.11-2012\r
 
 <<    [schemas/kem-gost3410-hkdf.tcl]\r
 
+Recipient public key with [cm/pub/gost3410] algorithm must be used.
+It should have "kem" key usage set.
+
 GOST R 34.10-2012 VKO parameter set A/C ("gost3410-256A", "gost3410-512C")
 must be used for DH operation, with UKM taken from the structure. VKO's
 output is 512- or 1024-bit "BE(X)||BE(Y)" point, used in HKDF below:
@@ -9,12 +15,9 @@ output is 512- or 1024-bit "BE(X)||BE(Y)" point, used in HKDF below:
     H = Streebog-512
     DH(sk, pk) = GOSTR3410-VKO(prv=sk, pub=pk, ukm=UKM)
     PRK = HKDF-Extract(H, salt="", ikm=DH(e, s))
-    if specified(sender):
+    if {specified sender}
         PRK = HKDF-Extract(H, salt=PRK, ikm=DH(s, s))
     KEK = HKDF-Expand(H, prk=PRK, info="cm/encrypted/gost3410-hkdf" || /id)
 
 "/kem/*/cek" is wrapped with [cm/keywrap/kexp15] mechanism.
 
-=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
-=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986, Streebog, GOST R 34.11-2012 hashing algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7091.html RFC 7091, GOST R 34.10-2012 is signing/key-aggreement algorithm\r
index 3b502693b63df95f9d3eba9d86817661751c4708fb9654b8d1c7142ce5ff7704..fc88bca8918066ce41393f932c363833b52b81649934d2c23d96957f294144d6 100644 (file)
@@ -1,4 +1,8 @@
-Classic McEliece 6960-119+X25519+HKDF-SHAKE256 KEM.
+Classic McEliece 6960-119 + X25519 + HKDF-SHAKE256 KEM.
+=> https://classic.mceliece.org/ Classic McEliece\r
+=> https://datatracker.ietf.org/doc/html/rfc7748 X25519\r
+=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
+=> https://keccak.team/ SHAKE XOF function\r
 
 <<    [schemas/kem-with-encap.tcl]\r
 
@@ -6,9 +10,9 @@ Classic McEliece 6960-119+X25519+HKDF-SHAKE256 KEM.
 Recipient public key with [cm/pub/mceliece6960119-x25519]
 algorithm must be used. It should have "kem" key usage set.
 
-Recipient's map "/kem/*/encap" field is a concatenation of
-194 bytes of Classic McEliece 6960-119 ciphertext, containing
-ephemeral key, with 32 bytes of ephemeral X25519 public key.
+"/kem/*/encap" field is a concatenation of 194 bytes of
+Classic McEliece 6960-119 ciphertext, containing ephemeral key,
+with 32 bytes of ephemeral X25519 public key.
 
 Recipient performs X25519 and Classic McEliece computations to
 derive/decapsulate two 32-byte shared keys. Then it combines
@@ -19,18 +23,16 @@ them to get the KEK decryption key of the CEK.
         mceliece6960119-shared-key || es-x25519-shared-key ||
         H(mceliece6960119-sender-ciphertext || e-x25519-sender-public-key) ||
         H(mceliece6960119-recipient-public-key || s-x25519-recipient-public-key))
-    if specified(sender):
+    if {specified sender}
         PRK = HKDF-Extract(H, salt=PRK, ikm=
             ss-x25519-shared-key ||
             s-x25519-sender-public-key ||
             s-x25519-recipient-public-key)
     KEK = HKDF-Expand(H, prk=PRK,
-        info="cm/encrypted/mceliece6960119-x25519-hkdf-shake256" || /salt)
+        info="cm/encrypted/mceliece6960119-x25519-hkdf-shake256" || /id)
 
 "/kem/*/cek" is wrapped with [cm/keywrap/xchapoly] mechanism.
 
-=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
-=> https://keccak.team/ SHAKE XOF function\r
 KEM combiner nearly fully resembles:
 => https://datatracker.ietf.org/doc/draft-josefsson-chempat/ Chempat\r
 
index 5ef507c03afbcae5ee506272567861d2cdb778d32cc686ddf92e7d4b13cf50c0..6c883378d24332ae3f0e671acd8626b6371831b7111253d94806a13866c4f9e4 100644 (file)
@@ -1,11 +1,8 @@
 PBKDF2 KEM.
+=> https://datatracker.ietf.org/doc/html/rfc2898 RFC 2898, PBKDF2\r
 
 <<    [schemas/kem-pbkdf2.tcl]\r
 
-PBKDF2 is RFC 2898 algorithm.
-Key length equal to key wrapping algorithm requirements.
-=> https://datatracker.ietf.org/doc/html/rfc2898 RFC 2898\r
-
 Key wrapping algorithm may be one of:
 [cm/keywrap/xchapoly], [cm/keywrap/kexp15],
 depending on the hash chosen.
index 074ec2b17ded18e2f31554d0520e771f3a5a8df7bb3219d87d61e352ed1b2644..fc9a3d6ef0341ae022240384db20a1304ef6400b2fc71301d64ecb05b643546d 100644 (file)
@@ -1,4 +1,8 @@
-SNTRUP4591761+X25519+HKDF-BLAKE2b KEM.
+Streamlined NTRU Prime 4591^761 + X25519 + HKDF-BLAKE2b KEM.
+=> https://ntruprime.cr.yp.to/ Streamlined NTRU Prime KEM algorithm\r
+=> https://datatracker.ietf.org/doc/html/rfc7748 X25519\r
+=> https://datatracker.ietf.org/doc/html/rfc5869.html RFC 5869, HKDF\r
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
 
 <<    [schemas/kem-with-encap.tcl]\r
 
@@ -19,7 +23,7 @@ key of the CEK.
         sntrup4591761-shared-key || es-x25519-shared-key ||
         H(sntrup4591761-sender-ciphertext || e-x25519-sender-public-key) ||
         H(sntrup4591761-recipient-public-key || s-x25519-recipient-public-key))
-    if specified(sender):
+    if {specified sender}
         PRK = HKDF-Extract(H, salt=PRK, ikm=
             ss-x25519-shared-key ||
             s-x25519-sender-public-key ||
index 3f25302904e9c7f5602dea0667e404107019a9d8368a51ff33b8020db402fdbf..dd8bbb8443ad799f578e661d82a86e7bfbb524923a8a16f57cdd9c8fde8fd042 100644 (file)
@@ -5,6 +5,5 @@ cryptography algorithms. KEK is 32+8+32=72 bytes long.
     KExp15(Kenc, Kauth, IV, CEK) = Kuznechik-CTR(
         Kenc, CEK || Kuznechik-CMAC(Kauth, IV || CEK), IV=IV)
 
-Kuznechik is GOST R 34.12-2015 encryption algorithm, RFC 7801.
-=> https://datatracker.ietf.org/doc/html/rfc7801.html RFC 7801\r
+=> https://datatracker.ietf.org/doc/html/rfc7801.html RFC 7801, Kuznechik, GOST R 34.12-2015 \r
 CMAC (OMAC1) is described in GOST R 34.13-2015.
index ca8f69af9ce03f0e5cb188f467f2d1e0f500e8638745896c673d3cc2de2c9a7d..355d4cd9a200b83e6b848d5ce8f56ea4e04e8b63b56c94ede8003495cdeedd36 100644 (file)
@@ -1,5 +1,6 @@
 XChaCha20-Poly1305 key wrapping mechanism.
 Key is encrypted using XChaCha20-Poly1305 algorithm.
+=> https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha XChaCha20-Poly1305\r
 Random 192-bit nonce is prepended to the ciphertext.
 KEK has 256-bit length.
 
index 947e55ed4e6586ce804662def7d8579a5ef43874850604102a3c63f65fb382bb..06291938264550db0c82b3e7007f4ab6aa13e3c51e7edb0705ed8cd2e23b8789 100644 (file)
@@ -1,4 +1,6 @@
-[cm/prv/] with Classic McEliece 6960-119+X25519.
+[cm/prv/] with Classic McEliece 6960-119 + X25519.
+=> https://classic.mceliece.org/ Classic McEliece\r
+=> https://datatracker.ietf.org/doc/html/rfc7748 X25519\r
 Concatenation of Classic McEliece 6960-119 13948-byte private key
 and X25519's 32-byte one.
 "mceliece6960119-x25519" algorithm identifier is used.
index 34cfdd151eefe6390ba8676a97b353fee69b60cdd85083e62617ba504f037c89..79fc2ff445333f3afec064ba5231452a3b9fcb5cf5d34de499c68f5fbe57e327 100644 (file)
@@ -1,4 +1,5 @@
-[cm/prv/] with SNTRUP4591761+X25519.
-Concatenation of Streamlined NTRU Prime 4591^761's 1600-byte private key
-and X25519's 32-byte one.
+[cm/prv/] with Streamlined NTRU Prime 4591^761 + X25519.
+=> https://ntruprime.cr.yp.to/ NTRU Prime\r
+=> https://datatracker.ietf.org/doc/html/rfc7748 X25519\r
+It is a concatenation of SNTRUP's 1600-byte and X25519's 32-byte keys.
 "sntrup4591761-x25519" algorithm identifier is used.
index 2f54cb6ba6ed9e029aacf2e8d03b05d947e42d8dea41dbf2a2daabe20409f445..75af180e4449c8e9f9cb60a5492c9cfea45ee532fa5eb1c5df0ead0fd1d15c21 100644 (file)
@@ -1,6 +1,6 @@
 [cm/prv/] with SPHINCS+-SHAKE256-256s.
-255-bit security level, fast variant and simple parameters.
+255-bit security level, small variant and simple parameters.
 => https://sphincs.org/ SPHINCS+\r
 => https://keccak.team/ SHAKE256\r
 Value is concatenation of private and public keys (128+64 bytes).
-Algorithm identifier for the public key: "sphincs+-shake-256s".
+"sphincs+-shake-256s" algorithm identifier is used.
index a4996f660efb9f41bfa0ed197f2b05773018481e1e6505b607f4223ddd6ccc6c..5d391e8cc86205640c2b5ec9ac19d1e330eff77dc707072680927b41e26abd6c 100644 (file)
@@ -5,10 +5,6 @@ Same calculation and serialisation rules must be used as with
 
 Public key's fingerprint should be calculated using BLAKE2b hash
 with 256 bit output length specified.
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
 
 Algorithm identifier for the public key: "ed25519-blake2b".
-
-=> https://cr.yp.to/ecdh.html X2559, key-agreement algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7748.html RFC 7748, same\r
-=> https://www.blake2.net/ BLAKE2b hashing algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, same\r
index da2aa944a48acead6046864524389e662115186782dcf6be592dea39e99b681a..b097acf9770c1465173188b93b5e4f78c92145c915f8208fff070020d88991d0 100644 (file)
@@ -1,14 +1,4 @@
-[cm/pub/] with GOST R 34.10-2012.
-
-GOST R 34.10-2012 must be used with Streebog (GOST R 34.11-2012)
-hash function. Its digest must be big-endian serialised. Public key
-must be in "BE(X)||BE(Y)" format.
-
+[cm/pub/] with GOST R 34.10-2012 ([cm/signed/gost3410]).
+Public key must be in "BE(X)||BE(Y)" format.
 Algorithm identifiers for the public key: "gost3410-256A", "gost3410-512C".
-
-Public key's fingerprint should be calculated using big-endian Streebog-256 hash.
-
-Streebog is GOST R 34.11-2012 hashing algorithm.
-GOST R 34.10-2012 is signing/key-aggreement algorithm.
-=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986, GOST R 34.11-2012\r
-=> https://datatracker.ietf.org/doc/html/rfc7091.html RFC 7091, GOST R 34.10-2012\r
+Public key's fingerprint should be calculated using big-endian Streebog-256.
index a5ce71e42aa55a714ea93d29127742e22935767ec32cd14c387e2ab8fd8aee7d..ec16a972110c453fc5ccad8a840e0eeb28899d196c6c58e797596513ecc5e018 100644 (file)
@@ -8,24 +8,24 @@ Its "/load/t" equals to "pub". "/load/v" contains "cm/pub/load":
 
 sub:
     Subject is a map of arbitrary strings. Currently no constraints on
-    what fields must be present. Each application and usage context
-    defines it on his own. But you may mimic X.509's subject with keys
-    like "CN", "C", "O" and similar ones.
+    what fields must be present. Each application defines them on its
+    own. But you may mimic X.509's subject with keys like "CN", "C", "O"
+    and similar ones.
 pub:
     Public key container itself may contain multiple public keys.
     That is *solely* intended for tasks requiring more than single
     key usage. For example NNCP uses one X25519 for (DH) encryption, one
-    curve25519 for online authentication and one ed25519 for signing
-    purposes. All those three keys are used together. That public key's
-    key usage field must contain something like "nncp".
+    X25519 for online authentication and one ed25519 for signing purposes.
+    All those three keys are used together. That public key's key usage
+    field should contain something like "nncp".
     => http://www.nncpgo.org NNCP\r
     If your keypair is intended for general purposes like signing of
-    arbitrary data, then single public key @strong{should} be used, with
-    a key usage like "sig".
+    arbitrary data, then single public key *should* be used, with a key
+    usage like "sig".
 id:
     Public key(s)'s fingerprint *should* be generated as 256-bit
-    hash hash of the encoded "pub" field. If not stated otherwise
-    for specific algorithm.
+    hash over the encoded "pub" field, if not stated otherwise for
+    specific algorithm. Exact hash algorithm depends on the public keys.
 ku:
     Intended public key(s) usage.
     Application-specific example with multiple public keys is described
@@ -35,7 +35,7 @@ crit:
     ones may be placed outside that map, directly in cm/pub/load.
     It *must* be absent if empty. Values are extension specific.
 
-[cm/signed/]'s "sig-tbs" *must* contain additional fields:
+[cm/signed/]'s "tbs" *must* contain additional fields:
 
 <<    [schemas/pub-sig-tbs.tcl]\r
 
@@ -43,7 +43,6 @@ sid: Signing public key's fingerprint.
 cid: Certification unique identifier. UUIDv7 is a good choice.
      But it may be UUIDv4, or any desired method of generation.
 exp: Certification expiration period.
-     It *must* contain TAI64 datetime (no nanoseconds).
 
 Example minimal certified public key may look like:
 
index 35c17b46932ea40de5c7a87f8f4201dbd67c68ec642ebcb453749f73323667f7..3dedeb75739b122e847e11314ca2b7121c6b2cf45822c8afe6e7f8a79f7d1e80 100644 (file)
@@ -1,17 +1,15 @@
-[cm/pub/] with Classic McEliece 6960-119+X25519.
+[cm/pub/] with Classic McEliece 6960-119 + X25519.
+=> https://classic.mceliece.org/ Classic McEliece\r
+=> https://datatracker.ietf.org/doc/html/rfc7748 X25519\r
 
 Combined Classic McEliece 6960-119 and X25519 public keys are used
 for KEM purposes, so should have "kem" key usage set.
 
-Its algorithm identifier is "mceliece6960119-x25519". Its
-public key value is a concatenation of 1047319-byte
+Its algorithm identifier is "mceliece6960119-x25519".
+Its public key value is a concatenation of 1047319-byte
 mceliece6960119 public key and 32-byte X25519 one.
 
 Public key's fingerprint should be calculated using SHAKE128.
-
-=> https://cr.yp.to/ecdh.html X2559 key-agreement algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7748.html RFC 7748, same\r
-=> https://classic.mceliece.org/ Classic McEliece KEM algorithm\r
 => https://keccak.team/ SHAKE XOF function\r
 
 Optional "/load/v/prehash" field can contain the SHAKE256 hash
index 40247b2f0d30c9ed37a6271c631e9e6c4c905113327b12a11aec751550b9c303..42a0168c3e054dc194d6751993b541e3b806429b5539365bef69fd3555911b36 100644 (file)
@@ -1,15 +1,14 @@
-[cm/pub/] with SNTRUP4591761+X25519.
+[cm/pub/] with Streamlined NTRU Prime 4591^761 + X25519.
+=> https://ntruprime.cr.yp.to/ Streamlined NTRU Prime KEM algorithm\r
+=> https://datatracker.ietf.org/doc/html/rfc7748 X25519\r
 
 Combined Streamlined NTRU Prime 4591^761 and X25519 public keys are
 used for KEM purposes, so should have "kem" key usage set.
 
-Its algorithm identifier is "sntrup4591761-x25519". Its public
-key value is a concatenation of 1218-byte SNTRUP4591761 public key
-and 32-byte X25519 one.
+Its algorithm identifier is "sntrup4591761-x25519".
+Its public key value is a concatenation of 1218-byte
+SNTRUP4591761 public key and 32-byte X25519 one.
 
 Public key's fingerprint should be calculated using BLAKE2b hash
 with 256 bit output length specified.
-
-=> https://cr.yp.to/ecdh.html X2559, key-agreement algorithm\r
-=> https://datatracker.ietf.org/doc/html/rfc7748.html RFC 7748, same\r
-=> https://ntruprime.cr.yp.to/ Streamlined NTRU Prime KEM algorithm\r
+=> https://datatracker.ietf.org/doc/html/rfc7693.html RFC 7693, BLAKE2b\r
index 3df24b16def4ad071c8115ab9b26f640512b984d0ea4e1ec57de690b0c2d0786..7e8085f5c78748c260d6a92bc8895d229b3553672c9831df4dd1e039762fe288 100644 (file)
@@ -1,5 +1,5 @@
 [cm/pub/] with SPHINCS+-SHAKE256-256s.
-255-bit security level, fast variant and simple parameters.
+255-bit security level, small variant and simple parameters.
 => https://sphincs.org/ SPHINCS+\r
 => https://keccak.team/ SHAKE256\r
 "sphincs+-shake-256s" algorithm identifier is used.
index 8ecc9648c83f11deb12dca4528f5931f02685e3dbb33aec260bde3ec3d861d39..13245d8558b5b78d5d05e78112a647f96567114e255a0086bbf4abdd7d750744 100644 (file)
@@ -2,14 +2,14 @@
 
 EdDSA with Edwards25519 is used similarly as in RFC 8032.
 But BLAKE2b is used instead of SHA2-512 hash.
-Strict ZIP-0215 validation rules should be used while verifying the signature.
-
 => https://datatracker.ietf.org/doc/html/rfc8032 RFC 8032, EdDSA\r
+
+Strict ZIP-0215 validation rules should be used while verifying the signature.
 => https://zips.z.cash/zip-0215 ZIP-0215\r
 
-PureEdDSA *must" be used when no detached data exists and
-"ed25519-blake2b" algorithm identifier is used for signature.
+PureEdDSA *must* be used when no detached data exists and
+"ed25519-blake2b" algorithm identifier is used in signature.
 
-HashEdDSA *must" be used otherwise, using BLAKE2b-512 as a
+HashEdDSA *must* be used otherwise, using BLAKE2b-512 as a
 hash, using "ed25519ph-blake2b" algorithm identifier for
 signature.
index db38e956d63d4d24b8dc5a9c602c9f4db6afa959fe05391c061edcf6eda6aa04..447c7d3a07834867971cb840e1519219c2f871c924adb4c9b9fc30f4db2ac1e6 100644 (file)
@@ -1,4 +1,6 @@
 [cm/signed/] with Ed25519-BLAKE2b with Merkle-tree hashing.
-[cm/hashed/blake2b-merkle] hashing is used.
-HashEdDSA mode is used with "ed25519ph-blake2b-merkle"
-algorithm identifier for signature.
+
+It is similar to [cm/signed/ed25519-blake2b], but
+HashEdDSA mode is used with [cm/hashed/blake2b-merkle] hashing.
+
+"ed25519ph-blake2b-merkle" algorithm identifier is used in signature.
index 0ab49bc9b7c42b064c864276c0617f3ff4ec9dd2798e1ba07cbae7222ffb50a1..0bc7ccd03694b8bf7cac3b4317854b3a770684699e079ae1d1abf565db468a5a 100644 (file)
@@ -1,12 +1,9 @@
 [cm/signed/] with GOST R 34.10-2012.
+=> https://datatracker.ietf.org/doc/html/rfc7091.html RFC 7091, GOST R 34.10-2012\r
 
 GOST R 34.10-2012 must be used with Streebog (GOST R 34.11-2012)
 hash function. Its digest must be big-endian serialised. Signature
 is in "BE(R)||BE(S)" format.
+=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986, GOST R 34.11-2012\r
 
 Algorithm identifiers for the signature: "gost3410-256A", "gost3410-512C".
-
-Streebog is GOST R 34.11-2012 hashing algorithm.
-GOST R 34.10-2012 is signing/key-aggreement algorithm.
-=> https://datatracker.ietf.org/doc/html/rfc6986.html RFC 6986, GOST R 34.11-2012\r
-=> https://datatracker.ietf.org/doc/html/rfc7091.html RFC 7091, GOST R 34.10-2012\r
index afd506b5c8fb385902ad6a9df84751fe1d9474d7a54e98dcd63d7aa67b78936a..26c599a176659514f325e2453c7c6d71d6cbe2b704080ef69c83a7883219400a 100644 (file)
@@ -1,4 +1,7 @@
 [cm/signed/] with GOST R 34.10-2012 with Merkle-tree hashing.
-[cm/hashed/streebog-merkle] hashing is used.
+
+It is similar to [cm/signed/gost3410], but [cm/hashed/streebog-merkle]
+hashing is used.
+
 Algorithm identifiers for the signature:
 "gost3410-256A-merkle", "gost3410-512C-merkle".
index 0b910f0cc2fac65461c39b7fa8837535d9513243c098fcef7dae0b0545cf8c50..48d67820985aec5a5cc42db087afdcfddb80f68b2f5a77baeefd383215083157 100644 (file)
@@ -14,26 +14,26 @@ Signed container, some kind of analogue to ASN.1-based CMS SignedData.
 Stored in a file, it should begin with "cm/signed" [encoding/MAGIC],
 unless it is a [cm/pub/]lic key.
 
+<<    [schemas/signed.tcl]\r
 <<    [schemas/av.tcl]\r
 <<    [schemas/fpr.tcl]\r
-<<    [schemas/signed.tcl]\r
 
 Signature is created by signing the:
 
     [detached-data] || /load || sig-tbs
 
 If no "/load/v" is provided, then the data is detached from the
-"cm/signed" structure itself and it is fed into hasher before that
-structure. You can provide it any way you wish, but for keeping that
-detached data closely to the "cm/signed", you should use the
+"cm/signed" structure itself and is fed into hasher before that
+structure. You can provide it any way you wish, but for keeping
+that detached data closely to the "cm/signed", you should use the
 following approach:
 
-    cm/signed/prehash || BLOB(detached-data) || cm/signed
+    prehash || BLOB(detached-data) || cm/signed
 
 <<    [schemas/signed-prehash.tcl]\r
 
-With "cm/signed/prehash" you initialise your hashers used during signing
-process and feed BLOB's contents (not the encoded BLOB itself!) into the them.
+With "prehash" you initialise your hashers used during signing process
+and feed BLOB's contents (not the encoded BLOB itself!) into the them.
 
 "/sigs/*/tbs/when" is optional signing time.
 
index e38683430082e7ea63c0b6cd14f197e43d6e87fa31a1c23140cfcea03ffa89bc..84b0cf145fbc6bd6fda1c265aa3a4ba1f9df2ccd76092e1d1075fee4b2e83c43 100644 (file)
@@ -1,8 +1,8 @@
 [cm/signed/] with SPHINCS+-SHAKE256-256s.
-255-bit security level, fast variant,
-simple parameters and deterministic signatures.
+255-bit security level, small variant, simple parameters.
 => https://sphincs.org/ SPHINCS+\r
 => https://keccak.team/ SHAKE256\r
+
 "sphincs+-shake-256s" algorithm identifier
 must be used for the signature in pure signing mode.
 "sphincs+-shake-256s-ph" is used in prehash mode.
index 79a96b3481de71c3c132d2f2db6d6c9a2103e14d19027abc085433973ae677b1..0b48b41dc2fa4b2033a902ed31647cb283bb852a65aa104d2687155f2b63da9d 100644 (file)
@@ -1,3 +1,6 @@
 [cm/signed/] with SPHINCS+-SHAKE256-256s with Merkle-tree hashing.
+
+It is similar to [cm/signed/sphincs+-shake-256s], but
 [cm/hashed/shake-merkle] SHAKE256 Merkle-tree hashing is used.
-"sphincs+-shake-256s-merkle" algorithm identifier must be used for the signature.
+
+"sphincs+-shake-256s-merkle" algorithm identifier is used for the signature.
index a521744dcac17891686fa4cc3cf126c0d2e3d5a673380e45337105bb0172bee9..022ced64f7ce8b6399ebf17452cb3fcd224a96e1189eb7429452ee326ad0e028 100644 (file)
@@ -23,9 +23,9 @@ dec | hex | bin      | vlen |
 021 | 15  | 00010101 | 0    |
 022 | 16  | 00010110 | 0    |
 023 | 17  | 00010111 | 0    |
-024 | 18  | 00011000 | 8    | [encoding/TAI64]
-025 | 19  | 00011001 | 12   | [encoding/TAI64] N
-026 | 1A  | 00011010 | 16   | [encoding/TAI64] NA
+024 | 18  | 00011000 | 8    | [encoding/TAI]64
+025 | 19  | 00011001 | 12   | [encoding/TAI]64N
+026 | 1A  | 00011010 | 16   | [encoding/TAI]64NA
 027 | 1B  | 00011011 | 0    |
 028 | 1C  | 00011100 | 0    |
 029 | 1D  | 00011101 | 0    |
index 2a813ebce741c3de9ce4e4373877ae04c14526afa4011b963f97da3116f98a00..1717259504e2bb0438c9ca7ed3749ceef4458a3bfa2d5cc8eb554a411cf7f194 100644 (file)
@@ -1,9 +1,9 @@
-Integers are encoded as ordinary binary [encoding/String], that has
-prepended byte indicating is it positive or negative integer.
+Integers are encoded as ordinary binary big-endian [encoding/String],
+that has prepended byte indicating is it positive or negative integer.
 
-Negative integers store their absolute value the same way as positive
-integers. After decoding, their value is subtracted from -1. Negative
-value encoded as 0x02 means: -1 - 0x02 => -3.
+Negative integers store positive absolute value, minus one.
+After decoding, their value is subtracted from -1.
+Negative value encoded as 0x02 means: -1 - 0x02 => -3.
 
 Shortest possible form *must* be used, that means no leading zero
 byte. 0 and -1 values are empty strings, so even they won't have
index 6b45ab8a51be1683bfd27e0e0ebfd4ab36c7f0643b7c4a65bd74a585fee04b8e..923aa0636cdd2b09661cc8739780d9195e5655721e06a9b5ab2dae7bf4125cbe 100644 (file)
@@ -1,8 +1,9 @@
-MAP contains concatenation of string(key)-value pairs.
-Keys *must* be non-empty, unique and length-first bytewise ascending ordered.
+MAP contains concatenation of [encoding/String](key)⇔value pairs.
 
     MAP [STR(KEY0) || ITEM0 || STR(KEY1) || ITEM1 || ...] EOC
 
+Keys *must* be non-empty, unique and length-first bytewise ascending ordered.
+
 Hint: Encoding code for known format can be ordered itself to emit
 values in an already properly sorted way.
 
index 51c14d1a1b27d2a55d551ac592bd5573b2dd121fc533f7a3738b28636c155faf..75806c615c204d8ebeb66edfd8291e11f683829c1c6152c36864a931ed44d238 100644 (file)
@@ -1,9 +1,8 @@
-There are two kinds of strings: binary (STR) and
-UTF-8 (human-readable ones, STR).
+There are two kinds of strings:
+BIN (binary) and STR (human-readable, printable ones).
 
-Most significant tag's bit is set for them. Seventh bit tells is it
-UTF-8 string, binary otherwise. Next six bits contain the length of
-the string.
+Most significant tag's bit is set. Seventh bit tells is it UTF-8 string,
+binary otherwise. Next six bits contain the length of the string.
 
            len
          +------+
@@ -15,8 +14,8 @@ the string.
 If length value equals to:
 0-60 => Use as is.
 61   => 61 + next 8-bits value.
-62   => 62 + 255 + next big-endian 16-bits value.
-63   => 63 + 255 + 65535 + next big-endian 64-bits value.
+62   => 62 + 255 + next big-endian 16-bit value.
+63   => 63 + 255 + 65535 + next big-endian 64-bit value.
 
 String's length *must* be encoded in shortest possible form.
 
@@ -25,8 +24,9 @@ byte *is not* allowed. That should be normalized Unicode string.
 
 Example representations:
 
-0-byte binary string => 80
-4-byte binary string 0x01 0x02 0x03 0x04 => 84 01 02 03 04
-64-byte binary string with 0x41 => BD 03 41 41 ... 41
-UTF-8 string "привет мир" ("hello world" in russian) =>
-    D3 D0 BF D1 80 D0 B8 D0 B2 D0 B5 D1 82 20 D0 BC D0 B8 D1 80
+BIN ""                                | 80
+BIN [binary decode hex "01 02 03 04"] | 84 01 02 03 04
+BIN [string repeat "A" 64]            | BD 03 41 41 ... 41
+
+STR "hello world" | CB               68656C6C6F 20 776F726C64
+STR "привет мир"  | D3 D0BFD180D0B8D0B2D0B5D182 20 D0BCD0B8D180
similarity index 76%
rename from spec/encoding/TAI64
rename to spec/encoding/TAI
index 0a9754ccabee6b853ad6991b13a0c9a5d9832d9eeb40f1ddc4e601708deec5c6..d5168be03d1c577f3a6100eb3d659ada72d3999aaffea745b2a50b06de62dcca 100644 (file)
@@ -1,16 +1,16 @@
 Datetime is represented in, so called, external TAI64 format.
+=> http://cr.yp.to/libtai/tai64.html TAI64\r
 TAI stands for Temps Atomique International, the current international
 real time standard. Unlike UTC, it takes leap seconds into account,
 making it monotonous.
-
-=> http://cr.yp.to/libtai/tai64.html TAI64\r
 => http://cr.yp.to/proto/utctai.html TAI\r
 
-You can convert TAI to UTC by subtracting number of leap seconds.
+You can convert UTC to TAI by adding the number of leap seconds.
 
-TAI64N format adds 32-bit big-endian number of nanoseconds
-(up to 999999999) count.
-TAI64NA adds another 32-big big-endian part of attoseconds count.
+External TAI64 format is big-endian 64-bit number of TAI seconds passed
+since 1970-01-01, plus 1<<62. TAI64N format adds 32-bit big-endian
+number of nanoseconds (up to 999999999). TAI64NA adds another 32-big
+big-endian part of attoseconds.
 
 Shortest form *must* be used: if number of nanoseconds equals to zero,
 then use TAI64 format.
index dfa846ab967ebadfe5b62e5951f49d11a4bcde306ee4f0a2e47a24c26322867a..3f512ee952163a6a95dfe1adfd3f941ba9ba4656d66a813a046413ea7df4209a 100644 (file)
@@ -23,9 +23,9 @@ dec | hex | bin      | vlen |
 019 | 13  | 00010011 | 16   | [encoding/FLOAT] 128
 020 | 14  | 00010100 | 32   | [encoding/FLOAT] 256
 ... | ... | ...      | ...  | ...
-024 | 18  | 00011000 | 8    | [encoding/TAI64]
-025 | 19  | 00011001 | 12   | [encoding/TAI64] N
-026 | 1A  | 00011010 | 16   | [encoding/TAI64] NA
+024 | 18  | 00011000 | 8    | [encoding/TAI]64
+025 | 19  | 00011001 | 12   | [encoding/TAI]64N
+026 | 1A  | 00011010 | 16   | [encoding/TAI]64NA
 ... | ... | ...      | ...  | ...
 075 | 4B  | 01001011 | 15   | [encoding/MAGIC]
 ... | ... | ...      | ...  | ...
index 259bd419ff582d5772b2baa2efb02a0272a9e5da75c2460fb23b4bc90e99da62..47a936d431f88e4dc0e416e1556df5d8da09a3f5442779f7ed3506cb68d25097 100644 (file)
@@ -5,42 +5,41 @@ First element of the command's list is a command name. Possible
 following elements are command-specific.
 
 Here is full list of structure validation commands, that should be
-generated from higher level schema descriptions. Here comes human
-readable command name, its string byte-code and possible arguments.
+generated from higher level schema descriptions.
 
-TAKE | "." | args: k
+TAKE | [".", k]
     Take/choose the value of the "k" key in the map, if "k" is a string.
     If "k" is integer, then choose the k-th value in a list.
     If "k" equals to ".", then choose the element you are currently in.
     Command never fails, but key can be non-existent.
 
-EXISTS | "E"
+EXISTS | ["E"]
     Assure that chosen element exists.
 
-!EXISTS | "!E"
+!EXISTS | ["!E"]
     Assure that chosen element does not exist.
 
-EACH | "*"
+EACH | ["*"]
     Execute the next command against every element of the chosen
     (if it exists) list, or every value of the map.
 
-TYPE | "T" | args: T0 [T1 ...]
+TYPE | ["T", T0 [, T1, ...]]
     Check that chosen (if it exists) element's type is in (T0, T1 ...)
-    set. Possible types: BIN, BLOB, BOOL, HEXLET, INT, LIST, MAGIC, MAP,
-    NIL, STR, TAI.
+    set. Possible types: "BIN", "BLOB", "BOOL", "HEXLET", "INT", "LIST",
+    "MAGIC", "MAP", "NIL", "STR", "TAI".
 
-GT | ">" | args: n
+GT | [">", n]
     Check that chosen (if it exists) integer value is greater than "n".
     If chosen value is either list or map, then check their length.
     If the value is a string, then check its length.
 
-LT | "<" | args: n
+LT | ["<", n]
     Same as ">", but check that value is less than "n".
 
-SCHEMA | "S" | args: s
+SCHEMA | ["S", s]
     Check chosen (if it exists) element against schema named "s".
 
-TIMEPREC | "TP" | args: p
+TIMEPREC | ["TP", p]
     Check that chosen (if it exists) element, of time type, has value of
     maximal specified time precision. "p" is integer with following
     possible values:
@@ -52,11 +51,11 @@ TIMEPREC | "TP" | args: p
         15: only up to femtoseconds;
         18: up to attoseconds;
 
-UTC | "UTC"
-    Check that chosen (if it exists) element, of time type,
+UTC | ["UTC"]
+    Check that chosen (if it exists) element, of TAI type,
     can be converted to UTC.
 
-EQ | "=" | args: v
+EQ | ["=", v]
     Check that chosen (if it exists) element's value equals to binary
     string "v".
 
@@ -96,7 +95,7 @@ Corresponding schema can be:
         ["T", "STR"],
     ]}
 
-Here is example with multiple schemas:
+Here is an example with multiple schemas:
 
     latitude = -90..90
     longitude = -180..180
@@ -113,7 +112,7 @@ Here is example with multiple schemas:
             ["<", 3],
             [".", "."],
             ["*"],
-            [".", "INT"],
+            ["T", "INT"],
             [".", 0],
             [">", -91],
             [".", 0],
index 75e914f499ea3eaa5fcd58774c5dbaaecf53d64720b0c1727f8012877038eba1..610c99bc6ad726b66d0949f46f96204f61c4fa4c14d278420482f41d5b0fe5b9 100644 (file)
@@ -10,13 +10,14 @@ when you sanitise the structures.
 
 So suggestion is to specify those steps for some kind of very simple
 minimalistic validation machine, that interprets them, executing
-validation commands against the provided data structures. That "machine"
-should be simple enough to be able to implement it quickly and with sane
-amount of code. Validation steps should be easily decodable and
-conveniently parsed even in C-language.
+validation commands ([schema/cmds]) against the provided data
+structures. That "machine" should be simple enough to be able to
+implement it quickly and with sane amount of code. Validation steps
+should be easily decodable and conveniently parsed even in C-language.
 
 Let's use KEKS format itself for the serialised validation steps! And
-generate them from higher level language/code, convenient for humans.
+generate them from higher level language/code ([schema/tcl]), convenient
+for humans.
 
-    cmds = KEKS-Encode([schema/tcl] -> [schema/cmds])
-    validate(KEKS-Decode(cmds), KEKS-Decode(data))
+    [schema/tcl] -> [schema/cmds] -> keks-encode() => schema
+    validate(schema, keks-decode(data))
index f02d15f8d028da5905282ae00517d2ad0acf6686def94fcd0eff17ba38d08174..51f65eb5b1c04395f3f6b08cf5aa6d828cb1cbd62c88c966423e03c03e155190 100644 (file)
@@ -1,8 +1,8 @@
 Validation commands are pretty low-level and are inconvenient to write
 by hand, at least because of huge quantity of TAKEs.
 tcl/schema.tcl utility gives ability to convert much more nicer schemas
-written on Tcl language to the KEKS-encoded commands. We call that
-Tcl-written schemas KEKS/Schema.
+written on Tcl language to the KEKS-encoded commands. We call those
+Tcl-written schemas "KEKS/Schema".
 
 Example with "our" structure ([schema/cmds]) can be written as:
 
@@ -22,10 +22,10 @@ and [cm/pub/] as:
 <<    [schemas/pub-load.tcl]\r
 <<    [schemas/pub-sig-tbs.tcl]\r
 
-schema.tcl calls "schemas {s0 cmds0 s1 cmds1 ...}"
-commands to produce an encoded map with "cmds*" commands for
-"s*" schemas. There is "field" command that helps creation of
-commands related to the field.
+schema.tcl calls "schemas {s0 cmds0 s1 cmds1 ...}" commands to produce
+an encoded map with "cmds*" commands for "s*" schemas.
+
+"field" command helps creation of commands related to the field.
 
 Its first argument is either field's name in the map, or list's index or
 dot, meaning the self-structure itself.
@@ -48,8 +48,8 @@ empty. "len=n" checks the exact length. "=v" checks that given
 element has specified string/binary value (use "len=" for integers).
 
 "prec=p" issues TIMEPREC command, but instead of specifying the raw
-integer values, you choose one of: s, ms, us, ns, ps, fs, as. "utc"
-issues UTC command.
+integer values, you choose one of: s, ms, us, ns, ps, fs, as.
+"utc" issues UTC command.
 
 "of s" argument issues checking of EACH element of the list or map
 against the specified schema, or against specified type if "s" is a
index e81f2f9e1ad93fa09e1d60cd769fcb91df617aedee7493c0d2eeb070cda595b7..8748d86e38f04687a7e213fc36c139cf36581e12d29fc7963bc51a2c63abfe5d 100644 (file)
@@ -10,6 +10,7 @@ signed {
 load {
     {field . {map}}
     {field t {str} >0}
+    {# field v is optional, arbitrary type}
 }
 
 sig {