{"id":15690480,"url":"https://github.com/soatok/experimental-caead","last_synced_at":"2025-08-18T11:46:02.681Z","repository":{"id":41537219,"uuid":"294070872","full_name":"soatok/experimental-caead","owner":"soatok","description":"Experimental committing AEAD designed by Soatok.","archived":false,"fork":false,"pushed_at":"2020-09-10T07:36:32.000Z","size":27,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-16T03:23:25.578Z","etag":null,"topics":["cryptography"],"latest_commit_sha":null,"homepage":"https://soatok.blog/2020/09/09/designing-new-cryptography-for-non-standard-threat-models","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soatok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-09T09:49:28.000Z","updated_at":"2025-07-22T19:18:26.000Z","dependencies_parsed_at":"2022-08-29T17:41:24.009Z","dependency_job_id":null,"html_url":"https://github.com/soatok/experimental-caead","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soatok/experimental-caead","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soatok%2Fexperimental-caead","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soatok%2Fexperimental-caead/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soatok%2Fexperimental-caead/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soatok%2Fexperimental-caead/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soatok","download_url":"https://codeload.github.com/soatok/experimental-caead/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soatok%2Fexperimental-caead/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270988040,"owners_count":24680662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography"],"created_at":"2024-10-03T18:10:25.892Z","updated_at":"2025-08-18T11:46:02.651Z","avatar_url":"https://github.com/soatok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cAEAD - Committing AEAD\n\nCommitting AEAD with ChaCha20 and BLAKE3.\n\n\u003e **Warning:** This is an experiment created by Soatok for fun. **Don't use it.**\n\u003e\n\u003e ![Soatok disapproves of using this](https://soatok.files.wordpress.com/2020/09//soatoktelegrams2020-09.png)\n\n#### Make sure you [read the blog post that accompanies this repository](https://soatok.blog/2020/09/09/designing-new-cryptography-for-non-standard-threat-models/).\n\n## What does this do?\n\nThis implements an [RKR-secure](https://keymaterial.net/2020/09/07/invisible-salamanders-in-aes-gcm-siv/)\nalternative to XChaCha20-Poly1305, for use in protocols that require RKR security (i.e. OPAQUE).\nThe primitives used (ChaCha20, BLAKE3) are secure and constant-time in software.\n\nAlthough large nonces (32 bytes) are employed by this construction, it is not strictly speaking nonce misuse resistant.\nIf you reuse a `(nonce, key)` tuple with two different messages, attackers will learn the XOR of the two plaintexts.\n\n(We're using the IETF variant of ChaCha20 with 96-bit nonces and 32-bit counters.)\n\n## How to Test this Code\n\n```\ngit clone https://github.com/soatok/experimental-caead\ncd js\nnpm install\nnpm test\n```\n\n## Algorithm Definition\n\n## Notation\n\n| Symbol | Meaning |\n|--------|---------|\n| `:=` | Assignment (store right-side value in left-side variable) |\n| \u003ccode\u003e\u0026#124;\u0026#124;\u003c/code\u003e | Concatenation |\n| `var[x:y]` | Slice `var` from index `x` to `y` | \n\n### Constants\n\nAlgorithm prefix: `CRYPTO_CAEAD_CHACHA20BLAKE3_`\n\n```\nDOMAIN_ENCRYPT := \"Soatok01\"\nDOMAIN_AUTH    := \"Soatok}~\"\nNONCE_BYTES    := 32\nKEY_BYTES      := 32\nTAG_BYTES      := 32\n```\n\n### Encryption Algorithm\n\n1. Split the key into an encryption key and an authentication key.\n   \n   ```\n   encKey := BLAKE3.keyedHash(key, DOMAIN_ENCRYPT || nonce[0:19])\n   authKey := BLAKE3.keyedHash(key, DOMAIN_AUTH || nonce[0:19])\n   ```\n2. Encrypt the message:\n   \n   ```\n   C := ChaCha20.encrypt(plaintext, nonce[20:31], encKey, block_counter = 0)\n   ```\n3. Calculate the authentication tag:\n   \n   ```\n   T := BLAKE3.keyedHash(authKey, aad || C || STORE64LE(aad.length) || STORE64LE(C.length))\n   ```\n4. Return `T || C`\n\n### Decryption Algorithm\n\n1. Split the key into an encryption key and an authentication key.\n   \n   ```\n   encKey := BLAKE3.keyedHash(key, DOMAIN_ENCRYPT || nonce[0:19])\n   authKey := BLAKE3.keyedHash(key, DOMAIN_AUTH || nonce[0:19])\n   ```\n2. Realculate the authentication tag:\n   \n   ```\n   T' := BLAKE3.keyedHash(authKey, aad || C || STORE64LE(aad.length) || STORE64LE(C.length))\n   ```\n3. Compare T with T' in constant-time. If it fails, abort.\n4. Decrypt the message:\n   \n   ```\n   P := ChaCha20.decrypt(C, nonce[20:31], encKey, block_counter = 0)\n   ```\n5. Return the decrypted plaintext.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoatok%2Fexperimental-caead","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoatok%2Fexperimental-caead","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoatok%2Fexperimental-caead/lists"}