leviathan-crypto 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/CLAUDE.md +88 -281
  2. package/LICENSE +4 -0
  3. package/README.md +275 -87
  4. package/dist/aes/aes-cbc.d.ts +40 -0
  5. package/dist/aes/aes-cbc.js +158 -0
  6. package/dist/aes/aes-ctr.d.ts +50 -0
  7. package/dist/aes/aes-ctr.js +141 -0
  8. package/dist/aes/aes-gcm-siv.d.ts +67 -0
  9. package/dist/aes/aes-gcm-siv.js +217 -0
  10. package/dist/aes/aes-gcm.d.ts +61 -0
  11. package/dist/aes/aes-gcm.js +226 -0
  12. package/dist/aes/cipher-suite.d.ts +21 -0
  13. package/dist/aes/cipher-suite.js +179 -0
  14. package/dist/aes/embedded.d.ts +1 -0
  15. package/dist/aes/embedded.js +26 -0
  16. package/dist/aes/generator.d.ts +14 -0
  17. package/dist/aes/generator.js +103 -0
  18. package/dist/aes/index.d.ts +58 -0
  19. package/dist/aes/index.js +125 -0
  20. package/dist/aes/ops.d.ts +60 -0
  21. package/dist/aes/ops.js +164 -0
  22. package/dist/aes/pool-worker.d.ts +1 -0
  23. package/dist/aes/pool-worker.js +92 -0
  24. package/dist/aes/types.d.ts +1 -0
  25. package/dist/aes/types.js +23 -0
  26. package/dist/aes.wasm +0 -0
  27. package/dist/blake3/embedded.d.ts +1 -0
  28. package/dist/blake3/embedded.js +26 -0
  29. package/dist/blake3/index.d.ts +143 -0
  30. package/dist/blake3/index.js +620 -0
  31. package/dist/blake3/types.d.ts +102 -0
  32. package/dist/blake3/types.js +31 -0
  33. package/dist/blake3/validate.d.ts +29 -0
  34. package/dist/blake3/validate.js +80 -0
  35. package/dist/blake3.wasm +0 -0
  36. package/dist/chacha20/cipher-suite.d.ts +10 -0
  37. package/dist/chacha20/cipher-suite.js +98 -13
  38. package/dist/chacha20/generator.d.ts +12 -0
  39. package/dist/chacha20/generator.js +91 -0
  40. package/dist/chacha20/index.d.ts +100 -3
  41. package/dist/chacha20/index.js +169 -35
  42. package/dist/chacha20/ops.d.ts +57 -6
  43. package/dist/chacha20/ops.js +107 -27
  44. package/dist/chacha20/pool-worker.js +14 -0
  45. package/dist/chacha20/types.d.ts +1 -32
  46. package/dist/cte-wasm.d.ts +1 -0
  47. package/dist/cte-wasm.js +3 -0
  48. package/dist/cte.wasm +0 -0
  49. package/dist/curve25519.wasm +0 -0
  50. package/dist/ecdsa/der.d.ts +23 -0
  51. package/dist/ecdsa/der.js +192 -0
  52. package/dist/ecdsa/ecprivatekey-der.d.ts +32 -0
  53. package/dist/ecdsa/ecprivatekey-der.js +230 -0
  54. package/dist/ecdsa/embedded.d.ts +1 -0
  55. package/dist/ecdsa/embedded.js +25 -0
  56. package/dist/ecdsa/index.d.ts +124 -0
  57. package/dist/ecdsa/index.js +366 -0
  58. package/dist/ecdsa/types.d.ts +31 -0
  59. package/dist/ecdsa/types.js +28 -0
  60. package/dist/ecdsa/validate.d.ts +18 -0
  61. package/dist/ecdsa/validate.js +92 -0
  62. package/dist/ed25519/embedded.d.ts +1 -0
  63. package/dist/ed25519/embedded.js +31 -0
  64. package/dist/ed25519/index.d.ts +70 -0
  65. package/dist/ed25519/index.js +308 -0
  66. package/dist/ed25519/types.d.ts +27 -0
  67. package/dist/ed25519/types.js +27 -0
  68. package/dist/ed25519/validate.d.ts +7 -0
  69. package/dist/ed25519/validate.js +77 -0
  70. package/dist/embedded/aes-pool-worker.d.ts +1 -0
  71. package/dist/embedded/aes-pool-worker.js +5 -0
  72. package/dist/embedded/aes.d.ts +1 -0
  73. package/dist/embedded/aes.js +3 -0
  74. package/dist/embedded/blake3.d.ts +1 -0
  75. package/dist/embedded/blake3.js +3 -0
  76. package/dist/embedded/chacha20-pool-worker.d.ts +1 -0
  77. package/dist/embedded/chacha20-pool-worker.js +5 -0
  78. package/dist/embedded/chacha20.d.ts +1 -1
  79. package/dist/embedded/chacha20.js +2 -2
  80. package/dist/embedded/curve25519.d.ts +1 -0
  81. package/dist/embedded/curve25519.js +3 -0
  82. package/dist/embedded/mldsa.d.ts +1 -0
  83. package/dist/embedded/mldsa.js +3 -0
  84. package/dist/embedded/mlkem.d.ts +1 -0
  85. package/dist/embedded/mlkem.js +3 -0
  86. package/dist/embedded/p256.d.ts +1 -0
  87. package/dist/embedded/p256.js +3 -0
  88. package/dist/embedded/serpent-pool-worker.d.ts +1 -0
  89. package/dist/embedded/serpent-pool-worker.js +5 -0
  90. package/dist/embedded/serpent.d.ts +1 -1
  91. package/dist/embedded/serpent.js +2 -2
  92. package/dist/embedded/sha2.d.ts +1 -1
  93. package/dist/embedded/sha2.js +2 -2
  94. package/dist/embedded/sha3.d.ts +1 -1
  95. package/dist/embedded/sha3.js +2 -2
  96. package/dist/embedded/slhdsa.d.ts +1 -0
  97. package/dist/embedded/slhdsa.js +3 -0
  98. package/dist/errors.d.ts +92 -1
  99. package/dist/errors.js +111 -1
  100. package/dist/fortuna.d.ts +18 -12
  101. package/dist/fortuna.js +166 -99
  102. package/dist/index.d.ts +42 -11
  103. package/dist/index.js +65 -20
  104. package/dist/init.d.ts +1 -3
  105. package/dist/init.js +73 -7
  106. package/dist/keccak/embedded.js +1 -1
  107. package/dist/keccak/index.d.ts +2 -0
  108. package/dist/keccak/index.js +4 -2
  109. package/dist/loader.d.ts +1 -19
  110. package/dist/loader.js +26 -32
  111. package/dist/merkle/blake3-tree.d.ts +35 -0
  112. package/dist/merkle/blake3-tree.js +187 -0
  113. package/dist/merkle/checkpoint.d.ts +58 -0
  114. package/dist/merkle/checkpoint.js +217 -0
  115. package/dist/merkle/index.d.ts +19 -0
  116. package/dist/merkle/index.js +37 -0
  117. package/dist/merkle/merkle-log.d.ts +130 -0
  118. package/dist/merkle/merkle-log.js +207 -0
  119. package/dist/merkle/merkle-verifier.d.ts +126 -0
  120. package/dist/merkle/merkle-verifier.js +296 -0
  121. package/dist/merkle/proof.d.ts +70 -0
  122. package/dist/merkle/proof.js +300 -0
  123. package/dist/merkle/sha256-tree.d.ts +33 -0
  124. package/dist/merkle/sha256-tree.js +145 -0
  125. package/dist/merkle/signed-log.d.ts +156 -0
  126. package/dist/merkle/signed-log.js +356 -0
  127. package/dist/merkle/signed-note.d.ts +309 -0
  128. package/dist/merkle/signed-note.js +648 -0
  129. package/dist/merkle/sth.d.ts +31 -0
  130. package/dist/merkle/sth.js +31 -0
  131. package/dist/merkle/storage.d.ts +40 -0
  132. package/dist/merkle/storage.js +71 -0
  133. package/dist/merkle/tree.d.ts +68 -0
  134. package/dist/merkle/tree.js +94 -0
  135. package/dist/mldsa/embedded.d.ts +1 -0
  136. package/dist/{kyber → mldsa}/embedded.js +5 -5
  137. package/dist/mldsa/expand.d.ts +53 -0
  138. package/dist/mldsa/expand.js +188 -0
  139. package/dist/mldsa/format.d.ts +16 -0
  140. package/dist/mldsa/format.js +68 -0
  141. package/dist/mldsa/hashvariant.d.ts +32 -0
  142. package/dist/mldsa/hashvariant.js +248 -0
  143. package/dist/mldsa/index.d.ts +142 -0
  144. package/dist/mldsa/index.js +463 -0
  145. package/dist/mldsa/keygen.d.ts +16 -0
  146. package/dist/mldsa/keygen.js +232 -0
  147. package/dist/mldsa/params.d.ts +21 -0
  148. package/dist/mldsa/params.js +55 -0
  149. package/dist/mldsa/sha3-helpers.d.ts +30 -0
  150. package/dist/mldsa/sha3-helpers.js +124 -0
  151. package/dist/mldsa/sign.d.ts +36 -0
  152. package/dist/mldsa/sign.js +380 -0
  153. package/dist/mldsa/types.d.ts +91 -0
  154. package/dist/mldsa/types.js +25 -0
  155. package/dist/mldsa/validate.d.ts +55 -0
  156. package/dist/mldsa/validate.js +125 -0
  157. package/dist/mldsa/verify.d.ts +29 -0
  158. package/dist/mldsa/verify.js +269 -0
  159. package/dist/mldsa.wasm +0 -0
  160. package/dist/mlkem/embedded.d.ts +1 -0
  161. package/dist/mlkem/embedded.js +27 -0
  162. package/dist/mlkem/indcpa.d.ts +49 -0
  163. package/dist/{kyber → mlkem}/indcpa.js +48 -48
  164. package/dist/mlkem/index.d.ts +37 -0
  165. package/dist/{kyber → mlkem}/index.js +41 -31
  166. package/dist/mlkem/kem.d.ts +21 -0
  167. package/dist/{kyber → mlkem}/kem.js +48 -13
  168. package/dist/{kyber → mlkem}/params.d.ts +4 -4
  169. package/dist/{kyber → mlkem}/params.js +2 -2
  170. package/dist/mlkem/suite.d.ts +12 -0
  171. package/dist/{kyber → mlkem}/suite.js +17 -12
  172. package/dist/{kyber → mlkem}/types.d.ts +4 -3
  173. package/dist/{kyber → mlkem}/types.js +1 -1
  174. package/dist/mlkem/validate.d.ts +23 -0
  175. package/dist/{kyber → mlkem}/validate.js +24 -20
  176. package/dist/{kyber.wasm → mlkem.wasm} +0 -0
  177. package/dist/p256.wasm +0 -0
  178. package/dist/ratchet/index.d.ts +8 -0
  179. package/dist/ratchet/index.js +38 -0
  180. package/dist/ratchet/kdf-chain.d.ts +13 -0
  181. package/dist/ratchet/kdf-chain.js +85 -0
  182. package/dist/ratchet/ratchet-keypair.d.ts +9 -0
  183. package/dist/ratchet/ratchet-keypair.js +61 -0
  184. package/dist/ratchet/root-kdf.d.ts +4 -0
  185. package/dist/ratchet/root-kdf.js +124 -0
  186. package/dist/ratchet/skipped-key-store.d.ts +14 -0
  187. package/dist/ratchet/skipped-key-store.js +154 -0
  188. package/dist/ratchet/types.d.ts +36 -0
  189. package/dist/ratchet/types.js +26 -0
  190. package/dist/serpent/cipher-suite.d.ts +10 -0
  191. package/dist/serpent/cipher-suite.js +144 -56
  192. package/dist/serpent/generator.d.ts +12 -0
  193. package/dist/serpent/generator.js +97 -0
  194. package/dist/serpent/index.d.ts +62 -1
  195. package/dist/serpent/index.js +97 -21
  196. package/dist/serpent/pool-worker.js +28 -102
  197. package/dist/serpent/serpent-cbc.d.ts +16 -6
  198. package/dist/serpent/serpent-cbc.js +58 -37
  199. package/dist/serpent/shared-ops.d.ts +63 -0
  200. package/dist/serpent/shared-ops.js +178 -0
  201. package/dist/serpent/types.d.ts +1 -5
  202. package/dist/serpent.wasm +0 -0
  203. package/dist/sha2/hash.d.ts +2 -0
  204. package/dist/sha2/hash.js +53 -0
  205. package/dist/sha2/hkdf.js +5 -5
  206. package/dist/sha2/index.d.ts +22 -1
  207. package/dist/sha2/index.js +80 -11
  208. package/dist/sha2/types.d.ts +41 -2
  209. package/dist/sha2.wasm +0 -0
  210. package/dist/sha3/hash.d.ts +2 -0
  211. package/dist/sha3/hash.js +53 -0
  212. package/dist/sha3/index.d.ts +87 -3
  213. package/dist/sha3/index.js +317 -19
  214. package/dist/sha3/kmac.d.ts +121 -0
  215. package/dist/sha3/kmac.js +800 -0
  216. package/dist/sha3.wasm +0 -0
  217. package/dist/shared/pkcs7.d.ts +22 -0
  218. package/dist/shared/pkcs7.js +84 -0
  219. package/dist/sign/ctx.d.ts +41 -0
  220. package/dist/sign/ctx.js +102 -0
  221. package/dist/sign/envelope.d.ts +45 -0
  222. package/dist/sign/envelope.js +152 -0
  223. package/dist/sign/hasher.d.ts +9 -0
  224. package/dist/sign/hasher.js +132 -0
  225. package/dist/sign/index.d.ts +11 -0
  226. package/dist/sign/index.js +34 -0
  227. package/dist/sign/sign-stream.d.ts +25 -0
  228. package/dist/sign/sign-stream.js +112 -0
  229. package/dist/sign/suites/ecdsa-p256.d.ts +2 -0
  230. package/dist/sign/suites/ecdsa-p256.js +120 -0
  231. package/dist/sign/suites/ed25519.d.ts +3 -0
  232. package/dist/sign/suites/ed25519.js +165 -0
  233. package/dist/sign/suites/hybrid-classical.d.ts +23 -0
  234. package/dist/sign/suites/hybrid-classical.js +526 -0
  235. package/dist/sign/suites/hybrid-pq.d.ts +4 -0
  236. package/dist/sign/suites/hybrid-pq.js +234 -0
  237. package/dist/sign/suites/mldsa.d.ts +7 -0
  238. package/dist/sign/suites/mldsa.js +161 -0
  239. package/dist/sign/suites/slhdsa.d.ts +7 -0
  240. package/dist/sign/suites/slhdsa.js +176 -0
  241. package/dist/sign/types.d.ts +106 -0
  242. package/dist/sign/types.js +28 -0
  243. package/dist/sign/verify-stream.d.ts +30 -0
  244. package/dist/sign/verify-stream.js +227 -0
  245. package/dist/slhdsa/embedded.d.ts +1 -0
  246. package/dist/slhdsa/embedded.js +26 -0
  247. package/dist/slhdsa/index.d.ts +149 -0
  248. package/dist/slhdsa/index.js +493 -0
  249. package/dist/slhdsa/params.d.ts +26 -0
  250. package/dist/slhdsa/params.js +70 -0
  251. package/dist/slhdsa/prehash.d.ts +68 -0
  252. package/dist/slhdsa/prehash.js +307 -0
  253. package/dist/slhdsa/sign.d.ts +39 -0
  254. package/dist/slhdsa/sign.js +116 -0
  255. package/dist/slhdsa/types.d.ts +129 -0
  256. package/dist/slhdsa/types.js +27 -0
  257. package/dist/slhdsa/validate.d.ts +60 -0
  258. package/dist/slhdsa/validate.js +127 -0
  259. package/dist/slhdsa/verify.d.ts +32 -0
  260. package/dist/slhdsa/verify.js +107 -0
  261. package/dist/slhdsa.wasm +0 -0
  262. package/dist/stream/header.js +8 -8
  263. package/dist/stream/index.d.ts +1 -0
  264. package/dist/stream/index.js +1 -0
  265. package/dist/stream/open-stream.js +65 -22
  266. package/dist/stream/seal-stream-pool.d.ts +2 -0
  267. package/dist/stream/seal-stream-pool.js +100 -33
  268. package/dist/stream/seal-stream.d.ts +1 -1
  269. package/dist/stream/seal-stream.js +48 -19
  270. package/dist/stream/seal.js +6 -6
  271. package/dist/stream/types.d.ts +3 -1
  272. package/dist/stream/types.js +1 -1
  273. package/dist/types.d.ts +22 -1
  274. package/dist/types.js +1 -1
  275. package/dist/utils.d.ts +9 -10
  276. package/dist/utils.js +84 -59
  277. package/dist/wasm-source.d.ts +9 -8
  278. package/dist/wasm-source.js +1 -1
  279. package/dist/x25519/embedded.d.ts +1 -0
  280. package/dist/x25519/embedded.js +31 -0
  281. package/dist/x25519/index.d.ts +43 -0
  282. package/dist/x25519/index.js +159 -0
  283. package/dist/x25519/types.d.ts +25 -0
  284. package/dist/x25519/types.js +27 -0
  285. package/dist/x25519/validate.d.ts +2 -0
  286. package/dist/x25519/validate.js +39 -0
  287. package/package.json +123 -64
  288. package/SECURITY.md +0 -276
  289. package/dist/ct-wasm.d.ts +0 -1
  290. package/dist/ct-wasm.js +0 -3
  291. package/dist/ct.wasm +0 -0
  292. package/dist/docs/aead.md +0 -323
  293. package/dist/docs/architecture.md +0 -932
  294. package/dist/docs/argon2id.md +0 -302
  295. package/dist/docs/chacha20.md +0 -674
  296. package/dist/docs/exports.md +0 -241
  297. package/dist/docs/fortuna.md +0 -313
  298. package/dist/docs/init.md +0 -302
  299. package/dist/docs/loader.md +0 -161
  300. package/dist/docs/serpent.md +0 -519
  301. package/dist/docs/sha2.md +0 -613
  302. package/dist/docs/sha3.md +0 -546
  303. package/dist/docs/types.md +0 -276
  304. package/dist/docs/utils.md +0 -367
  305. package/dist/embedded/kyber.d.ts +0 -1
  306. package/dist/embedded/kyber.js +0 -3
  307. package/dist/kyber/embedded.d.ts +0 -1
  308. package/dist/kyber/indcpa.d.ts +0 -49
  309. package/dist/kyber/index.d.ts +0 -38
  310. package/dist/kyber/kem.d.ts +0 -21
  311. package/dist/kyber/suite.d.ts +0 -13
  312. package/dist/kyber/validate.d.ts +0 -19
package/package.json CHANGED
@@ -1,66 +1,125 @@
1
1
  {
2
- "name": "leviathan-crypto",
3
- "version": "2.0.1",
4
- "author": "xero (https://x-e.ro)",
5
- "license": "MIT",
6
- "description": "Zero-dependency WASM cryptography for TypeScript. Paranoid ciphers, post-quantum key encapsulation, and Fortuna CSPRNG behind a strictly typed API. All computation runs outside the JS JIT on vector-verified primitives.",
7
- "type": "module",
8
- "sideEffects": false,
9
- "exports": {
10
- ".": "./dist/index.js",
11
- "./stream": "./dist/stream/index.js",
12
- "./serpent": "./dist/serpent/index.js",
13
- "./serpent/embedded": "./dist/serpent/embedded.js",
14
- "./chacha20": "./dist/chacha20/index.js",
15
- "./chacha20/embedded": "./dist/chacha20/embedded.js",
16
- "./sha2": "./dist/sha2/index.js",
17
- "./sha2/embedded": "./dist/sha2/embedded.js",
18
- "./sha3": "./dist/sha3/index.js",
19
- "./sha3/embedded": "./dist/sha3/embedded.js",
20
- "./keccak": "./dist/keccak/index.js",
21
- "./keccak/embedded": "./dist/keccak/embedded.js",
22
- "./kyber": "./dist/kyber/index.js",
23
- "./kyber/embedded": "./dist/kyber/embedded.js"
24
- },
25
- "types": "./dist/index.d.ts",
26
- "files": [
27
- "dist",
28
- "SECURITY.md",
29
- "CLAUDE.md"
30
- ],
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/xero/leviathan-crypto.git"
34
- },
35
- "homepage": "https://leviathan.3xi.club",
36
- "bugs": {
37
- "url": "https://github.com/xero/leviathan-crypto/issues"
38
- },
39
- "keywords": [
40
- "cryptography",
41
- "encryption",
42
- "serpent",
43
- "serpent-256",
44
- "cipher",
45
- "crypto",
46
- "typescript",
47
- "wasm",
48
- "webassembly",
49
- "chacha20",
50
- "xchacha20",
51
- "poly1305",
52
- "xchacha20-poly1305",
53
- "aead",
54
- "sha",
55
- "sha-256",
56
- "sha-512",
57
- "sha-3",
58
- "keccak",
59
- "shake",
60
- "hmac",
61
- "hkdf",
62
- "fortuna",
63
- "csprng",
64
- "entropy"
65
- ]
2
+ "name": "leviathan-crypto",
3
+ "version": "3.0.0",
4
+ "license": "MIT",
5
+ "description": "Paranoid post-quantum WASM cryptography library with bitsliced ciphers (Serpent, XChaCha20, AES), ML-KEM, lattice and hash-based signatures (ML-DSA, SLH-DSA, hybrid composites), hashing (SHA-2, SHA-3, BLAKE3), forward-secret ratchet, and Fortuna CSPRNG. Zero dependencies, tree-shakeable, and side-effect-free.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/xero/leviathan-crypto.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/xero/leviathan-crypto/issues"
12
+ },
13
+ "homepage": "https://leviathan.3xi.club",
14
+ "author": "xero (https://x-e.ro)",
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "exports": {
18
+ ".": "./dist/index.js",
19
+ "./stream": "./dist/stream/index.js",
20
+ "./serpent": "./dist/serpent/index.js",
21
+ "./serpent/embedded": "./dist/serpent/embedded.js",
22
+ "./chacha20": "./dist/chacha20/index.js",
23
+ "./chacha20/embedded": "./dist/chacha20/embedded.js",
24
+ "./sha2": "./dist/sha2/index.js",
25
+ "./sha2/embedded": "./dist/sha2/embedded.js",
26
+ "./sha3": "./dist/sha3/index.js",
27
+ "./sha3/embedded": "./dist/sha3/embedded.js",
28
+ "./keccak": "./dist/keccak/index.js",
29
+ "./keccak/embedded": "./dist/keccak/embedded.js",
30
+ "./mlkem": "./dist/mlkem/index.js",
31
+ "./mlkem/embedded": "./dist/mlkem/embedded.js",
32
+ "./aes": "./dist/aes/index.js",
33
+ "./aes/embedded": "./dist/aes/embedded.js",
34
+ "./blake3": "./dist/blake3/index.js",
35
+ "./blake3/embedded": "./dist/blake3/embedded.js",
36
+ "./ecdsa": "./dist/ecdsa/index.js",
37
+ "./ecdsa/embedded": "./dist/ecdsa/embedded.js",
38
+ "./ed25519": "./dist/ed25519/index.js",
39
+ "./ed25519/embedded": "./dist/ed25519/embedded.js",
40
+ "./mldsa": "./dist/mldsa/index.js",
41
+ "./mldsa/embedded": "./dist/mldsa/embedded.js",
42
+ "./slhdsa": "./dist/slhdsa/index.js",
43
+ "./slhdsa/embedded": "./dist/slhdsa/embedded.js",
44
+ "./x25519": "./dist/x25519/index.js",
45
+ "./x25519/embedded": "./dist/x25519/embedded.js",
46
+ "./ratchet": "./dist/ratchet/index.js",
47
+ "./sign": "./dist/sign/index.js",
48
+ "./merkle": "./dist/merkle/index.js"
49
+ },
50
+ "types": "./dist/index.d.ts",
51
+ "files": [
52
+ "dist",
53
+ "CLAUDE.md"
54
+ ],
55
+ "keywords": [
56
+ "cryptography",
57
+ "encryption",
58
+ "crypto",
59
+ "typescript",
60
+ "wasm",
61
+ "webassembly",
62
+ "simd",
63
+ "isomorphic",
64
+ "zero-dependency",
65
+ "constant-time",
66
+ "bitsliced",
67
+ "side-channel",
68
+ "post-quantum",
69
+ "pqc",
70
+ "hybrid",
71
+ "aead",
72
+ "kem",
73
+ "key-encapsulation",
74
+ "signing",
75
+ "signature",
76
+ "hashing",
77
+ "cipher",
78
+ "serpent",
79
+ "serpent-256",
80
+ "chacha20",
81
+ "xchacha20",
82
+ "poly1305",
83
+ "xchacha20-poly1305",
84
+ "aes",
85
+ "aes-256",
86
+ "aes-gcm-siv",
87
+ "kyber",
88
+ "ml-kem",
89
+ "mlkem",
90
+ "ml-dsa",
91
+ "mldsa",
92
+ "slh-dsa",
93
+ "slhdsa",
94
+ "ed25519",
95
+ "x25519",
96
+ "ecdsa",
97
+ "ecdsa-p256",
98
+ "p256",
99
+ "prime256v1",
100
+ "secp256r1",
101
+ "sha",
102
+ "sha-256",
103
+ "sha-512",
104
+ "sha-3",
105
+ "keccak",
106
+ "shake",
107
+ "cshake",
108
+ "blake3",
109
+ "hmac",
110
+ "kmac",
111
+ "hkdf",
112
+ "argon2",
113
+ "argon2id",
114
+ "fortuna",
115
+ "csprng",
116
+ "entropy",
117
+ "double-ratchet",
118
+ "ratchet",
119
+ "forward-secrecy",
120
+ "spqr",
121
+ "merkle",
122
+ "merkle-tree",
123
+ "transparency-log"
124
+ ]
66
125
  }
package/SECURITY.md DELETED
@@ -1,276 +0,0 @@
1
- # Leviathan Crypto Library Security Policy
2
-
3
- <img src="https://github.com/xero/leviathan-crypto/raw/main/docs/logo.svg" alt="Leviathan logo" width="100" align="left">
4
-
5
- - **[Version Support](#supported-versions)**
6
- - **[Security Posture](#security-posture)**
7
- - **[Cryptanalytic Audits](#cryptanalytic-audits)**
8
- - **[Vulnerability Reporting](#reporting-a-vulnerability)**
9
-
10
- ---
11
-
12
- ## Supported Versions
13
-
14
- | Version | Supported |
15
- | ------- | --------- |
16
- | v2.0.x | ✓ |
17
- | v1.4.x | ✗ |
18
- | v1.3.x | ✗ |
19
- | v1.2.x | ✗ |
20
- | v1.1.x | ✗ |
21
- | v1.0.x | ✗ |
22
-
23
- > [!CAUTION]
24
- > **All v1.x releases are deprecated.** Upgrading to v2 is strongly
25
- > recommended. v1.x releases will not receive security patches.
26
-
27
- > [!WARNING]
28
- > **v1.x known issues** (addressed in v2):
29
- > - Partial WASM buffer wipe on AEAD and serpent auth failure.
30
- > - HMAC tag and HKDF operations do not zero intermediate key material.
31
- > - TransformStream error paths leak derived keys.
32
- > - Pool workers copy result buffers.
33
- > - Scalar JS `constantTimeEqual` was "best-effort only".
34
-
35
- > [!WARNING]
36
- > **v2.0.0 known issue** (addressed in v2.0.1):
37
- > - `SealStreamPool` with `SerpentCipher` and `chunkSize: 65536` silently
38
- > produces corrupt plaintext on decrypt for inputs >= 65536 bytes. No
39
- > authentication error is raised. Upgrade to v2.0.1 immediately.
40
-
41
- ## Security Posture
42
-
43
- [`leviathan-crypto`](https://leviathan.3xi.club) is a cryptography library.
44
- Security is not an afterthought, it is the primary design constraint at every
45
- layer of the stack.
46
-
47
- ### Algorithm Correctness
48
-
49
- Every primitive in this library was implemented by hand in AssemblyScript
50
- against the authoritative specification for that algorithm:
51
- [FIPS 180-4][fips180] (SHA-2), [FIPS 202][fips202] (SHA-3),
52
- [FIPS 203][fips203] (ML-KEM),
53
- [RFC 8439][rfc8439] (ChaCha20-Poly1305), [RFC 2104][rfc2104] (HMAC),
54
- [RFC 5869][rfc5869] (HKDF), and the original
55
- [Serpent-256 specification][serpent] and S-box reference. No algorithm was
56
- ported from an existing implementation. The specs are always the source of truth.
57
-
58
- All implementations are verified against published known-answer test vectors
59
- from NIST, RFC appendices, NESSIE, and the Argon2 reference suite. Vectors
60
- are immutable: if an implementation produces incorrect output, the
61
- implementation is fixed and vectors are never adjusted to match code.
62
-
63
- ### Side-Channel Resistance
64
-
65
- Serpent's S-boxes are implemented as Boolean gate circuits designed with no table
66
- lookups, no data-dependent memory access, and no data-dependent branches. Every
67
- bit is processed unconditionally on every block. This is the most
68
- timing-safe cipher implementation approach available in a WASM runtime,
69
- where JIT optimisation can otherwise introduce observable timing variation.
70
-
71
- All security-sensitive comparisons (e.g. MAC verification, padding validation)
72
- use [`constantTimeEqual`][utils], which is backed by a dedicated WASM SIMD module
73
- (v128 XOR accumulate + `any_true`) when WebAssembly SIMD is available. The WASM
74
- execution path eliminates JIT short-circuiting and speculative optimization as
75
- theoretical side-channel vectors. On runtimes without SIMD (sha2/sha3-only
76
- consumers), the function falls back to a JS XOR-accumulate loop. This is best-effort
77
- constant-time, not a hardware-level guarantee. WASM comparison memory is
78
- wiped after every call.
79
-
80
- ### WASM Execution Model
81
-
82
- All cryptographic computation runs in WebAssembly, isolated outside the
83
- JavaScript JIT. WASM execution is deterministic and not subject to JIT
84
- speculation or optimisation. Each primitive family compiles to its own
85
- isolated binary with its own linear memory. For example, key material in
86
- the Serpent module cannot interact with memory in the SHA-3 module,
87
- even in principle. A dedicated WASM module handles constant-time comparison
88
- with its own single-page memory that is wiped after every call.
89
-
90
- Serpent and ChaCha20 modules require WebAssembly SIMD (`v128` instructions).
91
- `init()` and `initModule()` perform a SIMD preflight check and throw a
92
- clear error on runtimes without support. SIMD has been a baseline feature
93
- of all major browsers and runtimes since 2021. SHA-2 and SHA-3 modules
94
- run on any WASM-capable runtime.
95
-
96
- The `kyber` module requires WebAssembly SIMD for NTT and polynomial
97
- arithmetic (`v128` instructions). The SIMD preflight check is applied on
98
- `init()` alongside serpent and chacha20. Its linear memory is independent
99
- from all other modules. The kyber module's constant-time path (FO transform
100
- decapsulation) uses dedicated `ct_verify` and `ct_cmov` functions implemented
101
- in the kyber WASM binary. The comparison never passes through JavaScript.
102
-
103
- ### Cryptanalytic Audits
104
-
105
- All primitives undergo periodic cryptographic implementation reviews. See the [audit index][audits] for a full summary.
106
-
107
- | Primitive | Audit Description |
108
- | ------------------------------ | -------------------------------------------------------------------------------------- |
109
- | [serpent_audit][serpent_audit] | Correctness verification, side-channel analysis, cryptanalytic attack paper review |
110
- | [chacha_audit][chacha_audit] | XChaCha20-Poly1305 correctness, Poly1305 field arithmetic, HChaCha20 nonce extension |
111
- | [sha2_audit][sha2_audit] | SHA-256/512/384 correctness, HMAC and HKDF composition, constant verification |
112
- | [sha3_audit][sha3_audit] | Keccak permutation correctness, θ/ρ/π/χ/ι step verification, round constant derivation |
113
- | [hmac_audit][hmac_audit] | HMAC-SHA256/512/384 construction, key processing, RFC 4231 vector coverage |
114
- | [hkdf_audit][hkdf_audit] | HKDF extract-then-expand, info field domain separation, stream key derivation |
115
- | [kyber_audit][kyber_audit] | ML-KEM FIPS 203 correctness, NTT/Montgomery/Barrett verification, FO transform CT analysis, ACVP validation |
116
- | [stream_audit][stream_audit] | Streaming AEAD composition, counter nonce binding, final-chunk detection, key wipe paths |
117
-
118
- #### Additional Serpent-256 research
119
-
120
- The security margin of Serpent-256 has been independently researched and
121
- documented. The best known attack on the full 32-round cipher, _"biclique
122
- cryptanalysis"_, achieves a complexity of 2²⁵⁵·¹⁹ with 2⁴ chosen
123
- ciphertexts. This provides less than one bit of advantage over exhaustive
124
- key search and has zero practical impact. Independent research conducted
125
- against this implementation improved on the published result by −0.20 bits
126
- through systematic parameter search, confirming no structural weakness
127
- beyond what the published literature describes.
128
-
129
- See: [`xero/BicliqueFinder/biclique_research.md`][biclique]
130
-
131
- ### Authenticated Encryption by Default
132
-
133
- Raw unauthenticated cipher modes (`SerpentCbc`, `SerpentCtr`, `ChaCha20`) and
134
- stateless caller-managed-nonce primitives (`ChaCha20Poly1305`,
135
- `XChaCha20Poly1305`) are exposed for power users but are not the recommended
136
- entry point. The primary API surfaces (`Seal`, `SealStream`, `OpenStream`,
137
- `SealStreamPool`, and `KyberSuite`) are authenticated by construction with
138
- internally managed nonces.
139
-
140
- **All streaming constructions satisfy the _Cryptographic Doom Principle_:**
141
-
142
- `SealStream` / `OpenStream` with `SerpentCipher` uses encrypt-then-MAC
143
- (SerpentCbc + HMAC-SHA256). MAC verification is the unconditional gate on
144
- the open path. Decryption is unreachable until that gate clears. HKDF key
145
- derivation with the stream nonce and counter-nonce domain separation
146
- extends this guarantee to full stream integrity.
147
-
148
- `SealStream` / `OpenStream` with `XChaCha20Cipher` uses XChaCha20-Poly1305
149
- AEAD per chunk. The Poly1305 tag is verified inside the WASM `aeadDecrypt`
150
- call before any plaintext is produced. On authentication failure, the full
151
- chunk output buffer is wiped and plaintext bytes are never returned.
152
- Counter nonces with TAG_DATA/TAG_FINAL final-flag domain separation ensure
153
- reorder, splice, truncation, and cross-stream substitution all fail AEAD
154
- verification before decryption.
155
-
156
- `SealStreamPool` delegates per-chunk AEAD to isolated Web Workers. Each
157
- worker holds its own derived subkey and WASM instance. Any authentication
158
- error kills all workers, wipes all key material, and marks the pool dead. No retry, no partial results.
159
-
160
- ### Dependency Management
161
-
162
- The library has **zero** runtime dependencies by design.
163
- `sideEffects: false` is enforced in `package.json`. Argon2id integration
164
- is documented as an _optional_ external dependency.
165
- See: [`leviathan-crypto/wiki/argon2id`][argon2id-wiki].
166
-
167
- Build toolchain dependencies are pinned with exact version locks in
168
- `bun.lock`. GitHub Actions workflows use [SHA-pinned action references][workflows]
169
- throughout with no floating tags. Supply chain integrity is treated as a
170
- first-class concern for a cryptography library.
171
-
172
- ### Explicit Initialisation
173
-
174
- No class silently auto-initialises. The [`init()`][init] gate is mandatory and
175
- explicit, giving consumers full control over when WASM modules are loaded
176
- and ensuring no hidden initialisation costs or race conditions. Classes
177
- throw immediately if used before initialisation rather than failing
178
- silently.
179
-
180
- ### Agentic Development Contracts
181
-
182
- All AI-assisted development on this repository operates under a strict
183
- agentic contract defined in [`AGENTS.md`][agents]. The contract enforces
184
- spec authority over planning documents, immutable test vectors, gate
185
- discipline before extending any test suite, independent algorithm
186
- derivation from published standards, and constant-time/wipe requirements
187
- for all security-sensitive code paths. Agents are explicitly prohibited
188
- from guessing cryptographic values or resolving spec ambiguities silently.
189
-
190
- The contract has been verified against Claude, GitHub Copilot (VS Code),
191
- OpenHands, Kilo Code, Cursor, Windsurf, and Aider. Configuration files for
192
- each are present in the repository and all route to [`AGENTS.md`][agents]
193
- as the single source of authority.
194
-
195
- ---
196
-
197
- ## Reporting a Vulnerability
198
-
199
- > [!IMPORTANT]
200
- > **_Please do not open a public issue for security vulnerabilities._**
201
-
202
- ### Private Advisory (preferred)
203
-
204
- Use GitHub's private vulnerability reporting form:
205
- [https://github.com/xero/leviathan-crypto/security/advisories/new][advisory]
206
-
207
- This opens a private channel between you and the maintainer, and you will
208
- receive a response promptly. If the vulnerability is confirmed,
209
- we will collaborate to fully understand the issue, including a review of
210
- proposed fixes, so you can track and validate firsthand. Before any public
211
- advisory is published, we will agree on a coordinated disclosure timeline.
212
- After disclosure, you are encouraged to publish your own write-up, blog post,
213
- or research notes, for full hacker scene credit.
214
-
215
- ### Direct Contact
216
-
217
- If you prefer to contact the maintainer directly:
218
-
219
- - **Email:** x﹫xero.style · PGP: [`0xAC1D0000`][pgp]
220
- - **Matrix:** x0﹫rx.haunted.computer
221
-
222
- > [!NOTE]
223
- > Encrypted communication is welcome and _preferred_ for sensitive reports.
224
-
225
- ### Scope
226
-
227
- **Reports are in scope for:**
228
-
229
- - Authentication bypass in AEAD constructions
230
- - Key material exposure or improper zeroing
231
- - Incorrect entropy or CSPRNG weaknesses in Fortuna
232
- - Side-channel vulnerabilities (timing, memory access patterns)
233
- - Correctness bugs in cryptographic implementations (wrong output against
234
- test vectors)
235
- - Platform-specific behavioral differences (WASM execution, binary output,
236
- or timing characteristics that differ across operating systems or CPU
237
- architectures)
238
- - Supply chain issues (dependency tampering, workflow compromise)
239
- - Improper scope of exported symbols
240
-
241
- **Out of scope:**
242
-
243
- - Vulnerabilities in third-party packages not maintained by this project.
244
- This includes optional peer dependencies such as argon2id.
245
- Please report those directly to their maintainers.
246
- - Issues requiring physical access to the user's device
247
- - Theoretical attacks with no practical exploit path (e.g. complexity
248
- improvements that remain computationally infeasible)
249
- - Issues in the demo applications that do not affect the core library.
250
- Please open an issue in the [`leviathan-demos`][demos] repository instead.
251
-
252
- [fips180]: https://csrc.nist.gov/publications/detail/fips/180/4/final
253
- [fips202]: https://csrc.nist.gov/publications/detail/fips/202/final
254
- [fips203]: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.pdf
255
- [rfc8439]: https://www.rfc-editor.org/rfc/rfc8439
256
- [rfc2104]: https://www.rfc-editor.org/rfc/rfc2104
257
- [rfc5869]: https://www.rfc-editor.org/rfc/rfc5869
258
- [serpent]: https://www.cl.cam.ac.uk/~rja14/Papers/serpent.pdf
259
- [utils]: https://github.com/xero/leviathan-crypto/wiki/utils#constanttimeequal
260
- [demos]: https://github.com/xero/leviathan-demos/
261
- [serpent_audit]: https://github.com/xero/leviathan-crypto/wiki/serpent_audit
262
- [chacha_audit]: https://github.com/xero/leviathan-crypto/wiki/chacha_audit
263
- [sha2_audit]: https://github.com/xero/leviathan-crypto/wiki/sha2_audit
264
- [sha3_audit]: https://github.com/xero/leviathan-crypto/wiki/sha3_audit
265
- [hmac_audit]: https://github.com/xero/leviathan-crypto/wiki/hmac_audit
266
- [hkdf_audit]: https://github.com/xero/leviathan-crypto/wiki/hkdf_audit
267
- [kyber_audit]: https://github.com/xero/leviathan-crypto/wiki/kyber_audit
268
- [stream_audit]: https://github.com/xero/leviathan-crypto/wiki/stream_audit
269
- [audits]: https://github.com/xero/leviathan-crypto/wiki/audits
270
- [biclique]: https://github.com/xero/BicliqueFinder/blob/main/biclique-research.md
271
- [argon2id-wiki]: https://github.com/xero/leviathan-crypto/wiki/argon2id
272
- [workflows]: https://github.com/xero/leviathan-crypto/blob/main/scripts/pin-actions.ts
273
- [init]: https://github.com/xero/leviathan-crypto/wiki/init
274
- [agents]: https://github.com/xero/leviathan-crypto/blob/main/AGENTS.md
275
- [advisory]: https://github.com/xero/leviathan-crypto/security/advisories/new
276
- [pgp]: https://0w.nz/pgp.pub
package/dist/ct-wasm.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const CT_WASM: Uint8Array<ArrayBuffer>;
package/dist/ct-wasm.js DELETED
@@ -1,3 +0,0 @@
1
- // auto-generated — do not edit
2
- // raw WASM bytes for constant-time comparison module
3
- export const CT_WASM = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 8, 1, 96, 3, 127, 127, 127, 1, 127, 2, 16, 1, 3, 101, 110, 118, 6, 109, 101, 109, 111, 114, 121, 2, 1, 1, 1, 3, 2, 1, 0, 7, 20, 2, 7, 99, 111, 109, 112, 97, 114, 101, 0, 0, 6, 109, 101, 109, 111, 114, 121, 2, 0, 10, 111, 1, 109, 2, 3, 127, 1, 123, 3, 64, 32, 3, 65, 16, 106, 34, 4, 32, 2, 76, 4, 64, 32, 6, 32, 0, 32, 3, 106, 253, 0, 4, 0, 32, 1, 32, 3, 106, 253, 0, 4, 0, 253, 81, 253, 80, 33, 6, 32, 4, 33, 3, 12, 1, 11, 11, 3, 64, 32, 2, 32, 3, 74, 4, 64, 32, 5, 32, 0, 32, 3, 106, 45, 0, 0, 32, 1, 32, 3, 106, 45, 0, 0, 115, 114, 33, 5, 32, 3, 65, 1, 106, 33, 3, 12, 1, 11, 11, 32, 6, 253, 83, 4, 64, 65, 0, 15, 11, 32, 5, 69, 11]);
package/dist/ct.wasm DELETED
Binary file