{"id":15833737,"url":"https://github.com/itzmeanjan/sparkle","last_synced_at":"2025-07-03T14:40:13.782Z","repository":{"id":37978549,"uuid":"488087911","full_name":"itzmeanjan/sparkle","owner":"itzmeanjan","description":"Accelerated Sparkle - Lightweight Authenticated Encryption \u0026 Hashing","archived":false,"fork":false,"pushed_at":"2023-01-20T08:49:23.000Z","size":233,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-06T13:41:49.876Z","etag":null,"topics":["aead","authenticated-encryption","hashing","lightweight-cryptography","nist-lwc","sparkle","verified-decryption"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itzmeanjan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-03T05:27:56.000Z","updated_at":"2024-03-07T00:12:25.000Z","dependencies_parsed_at":"2023-02-12T01:00:32.685Z","dependency_job_id":null,"html_url":"https://github.com/itzmeanjan/sparkle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fsparkle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fsparkle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fsparkle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzmeanjan%2Fsparkle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzmeanjan","download_url":"https://codeload.github.com/itzmeanjan/sparkle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246637898,"owners_count":20809699,"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","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":["aead","authenticated-encryption","hashing","lightweight-cryptography","nist-lwc","sparkle","verified-decryption"],"created_at":"2024-10-05T13:41:53.499Z","updated_at":"2025-04-01T12:26:41.847Z","avatar_url":"https://github.com/itzmeanjan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sparkle\nAccelerated Sparkle - Lightweight Authenticated Encryption \u0026amp; Hashing\n\n## Overview\n\nAfter implementing `ascon`, `tinyjambu` \u0026 `xoodyak`, I've picked up `sparkle` --- another NIST Light Weight Cryptography ( LWC ) final round candidate, which offers following functions\n\nFunctionality | What does it offer ?\n:-- | --:\nEsch{256, 384} | Lightweight, cryptographic secure Hash function, producing 256/ 384 -bit output digest, when provided with N -bytes input s.t. N \u003e= 0\nSchwaemm256-{128, 256}/ Schwaemm128-128/ Schwaemm192-192 | Authenticated encryption with associated data ( AEAD ) scheme, which takes 128/ 192/ 256 -bit secret key, 128/ 192/ 256 -bit public message nonce, N -bytes associated data, M -bytes plain text s.t. N, M \u003e= 0 and computes M -bytes encrypted data along with 128/ 192/ 256 -bit authentication tag. During verified decryption step, one needs to provide secret key, public message nonce, authentication tag, associated data \u0026 encrypted bytes to decrypt routine, which produces equal many decrypted data bytes \u0026 boolean verification flag. **If tag verification fails during decryption, no unverified plain text is released**.\n\n\u003e **Warning** Sparkle AEAD schemes provide confidentiality only for plain text, though it provides integrity \u0026 authenticity for both plain text \u0026 associated data. Read Sparkle [specification](https://csrc.nist.gov/CSRC/media/Projects/lightweight-cryptography/documents/finalist-round/updated-spec-doc/sparkle-spec-final.pdf) for better understanding.\n\nIn this repository, I'm maintaining one zero-dependency, header-only, easy-to-use C++ library, implementing Sparkle Hash \u0026 AEAD specification, while using C++20 features ( note this when you're compiling your project ). Using it is as easy as including proper header files ( generally [esch.hpp](./include/esch.hpp) or [schwaemm.hpp](./include/schwaemm.hpp) ) in your C++ project and letting compiler know where it can find these headers. I've also kept C-ABI compliant wrapper functions, which can be interfaced from other languages such as Python, Rust ( using FFI; [more](https://en.wikipedia.org/wiki/Foreign_function_interface) ).\n\n\u003e **Note** Learn more about AEAD [here](https://en.wikipedia.org/wiki/Authenticated_encryption)\n\n\u003e **Note** If interested in my work on other NIST LWC finalists such as\n\n- Ascon, [see](https://github.com/itzmeanjan/ascon)\n- TinyJambu, [see](https://github.com/itzmeanjan/tinyjambu)\n- Xoodyak, [see](https://github.com/itzmeanjan/xoodyak)\n\nWhile writing this implementation of Sparkle, I followed [this](https://csrc.nist.gov/CSRC/media/Projects/lightweight-cryptography/documents/finalist-round/updated-spec-doc/sparkle-spec-final.pdf) specification, which was submitted to NIST LWC, see [here](https://csrc.nist.gov/projects/lightweight-cryptography/finalists).\n\n## Prerequisites\n\n- C++ compiler like `g++`/ `clang++`, with C++20 standard library support\n\n```bash\n$ g++ --version\ng++ (Homebrew GCC 12.2.0) 12.2.0\n\n$ clang++ --version\nApple clang version 14.0.0 (clang-1400.0.29.202)\n```\n\n- System development utilities such as `make`, `cmake`, `git`, `unzip`, `wget` and `python3`\n\n```bash\n$ make --version\nGNU Make 3.81\n\n$ cmake --version\ncmake version 3.25.1\n\n$ git --version\ngit version 2.39.1\n\n$ unzip -v\nUnZip 6.00 of 20 April 2009, by Info-ZIP\n\n$ wget --version\nGNU Wget 1.21.3 built on darwin22.1.0\n\n$ python3 --version\nPython 3.10.9\n```\n\n- For installing `python3` dependencies, issue\n\n```bash\n# ensure you've pip\npython3 -m pip install -r wrapper/python/requirements.txt --user\n\n# On Ubuntu you may, if pip is not available\nsudo apt-get install python3-pip\n```\n\n- For benchmarking Sparkle Hash \u0026 AEAD implementations on CPU, you'll need `google-benchmark` library globally installed; follow [this](https://github.com/google/benchmark/tree/60b16f1#installation) document.\n\n## Testing\n\nFor ensuring functional correctness \u0026 compatibility with Sparkle specification, I excute Sparkle Hash \u0026 AEAD functions on test vectors ( KATs ) provided with NIST LWC submission package of Sparkle \u0026 check computed results against provided ones.\n\nIssue following command to test\n\n```bash\nmake\n```\n\n## Benchmarking\n\nFor benchmarking Sparkle Hash \u0026 AEAD functions on CPU, I'm using `google-benchmark` library; issue\n\n```bash\nmake benchmark\n```\n\n\u003e **Warning** If you've CPU scaling enabled, you may want to disable that; see [this](https://github.com/google/benchmark/blob/60b16f11a30146ac825b7d99be0b9887c24b254a/docs/user_guide.md#disabling-cpu-frequency-scaling) guide\n\n### On Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz ( compiled using Clang )\n\n```bash\n2023-01-20T12:29:38+04:00\nRunning ./bench/a.out\nRun on (8 X 2400 MHz CPU s)\nCPU Caches:\n  L1 Data 32 KiB\n  L1 Instruction 32 KiB\n  L2 Unified 256 KiB (x4)\n  L3 Unified 6144 KiB\nLoad Average: 1.33, 1.42, 1.53\n------------------------------------------------------------------------------------------\nBenchmark                                Time             CPU   Iterations UserCounters...\n------------------------------------------------------------------------------------------\nbench_sparkle::sparkle\u003c4, 7\u003e          56.8 ns         56.8 ns     12045083 bytes_per_second=537.669M/s\nbench_sparkle::sparkle\u003c4, 10\u003e         80.4 ns         80.4 ns      8572653 bytes_per_second=379.803M/s\nbench_sparkle::sparkle\u003c6, 7\u003e           120 ns          120 ns      5667236 bytes_per_second=381.158M/s\nbench_sparkle::sparkle\u003c6, 11\u003e          188 ns          188 ns      3683590 bytes_per_second=243.318M/s\nbench_sparkle::sparkle\u003c8, 8\u003e           181 ns          181 ns      3833642 bytes_per_second=336.992M/s\nbench_sparkle::sparkle\u003c8, 12\u003e          274 ns          274 ns      2555575 bytes_per_second=223.071M/s\nesch256_hash/64                        693 ns          692 ns       979007 bytes_per_second=88.1581M/s\nesch256_hash/128                      1183 ns         1182 ns       584434 bytes_per_second=103.314M/s\nesch256_hash/256                      2207 ns         2205 ns       313259 bytes_per_second=110.719M/s\nesch256_hash/512                      4208 ns         4190 ns       167479 bytes_per_second=116.529M/s\nesch256_hash/1024                     8106 ns         8098 ns        82031 bytes_per_second=120.6M/s\nesch256_hash/2048                    16029 ns        16006 ns        43802 bytes_per_second=122.024M/s\nesch256_hash/4096                    31538 ns        31506 ns        22182 bytes_per_second=123.986M/s\nesch384_hash/64                       1195 ns         1194 ns       565360 bytes_per_second=51.119M/s\nesch384_hash/128                      1951 ns         1948 ns       360229 bytes_per_second=62.6669M/s\nesch384_hash/256                      3443 ns         3440 ns       205665 bytes_per_second=70.9704M/s\nesch384_hash/512                      6339 ns         6332 ns       108202 bytes_per_second=77.1115M/s\nesch384_hash/1024                    12206 ns        12192 ns        56750 bytes_per_second=80.0994M/s\nesch384_hash/2048                    23965 ns        23929 ns        28942 bytes_per_second=81.6202M/s\nesch384_hash/4096                    47392 ns        47339 ns        14746 bytes_per_second=82.5159M/s\nschwaemm256_128_encrypt/64/32          739 ns          736 ns       944058 bytes_per_second=124.41M/s\nschwaemm256_128_decrypt/64/32          745 ns          744 ns       924996 bytes_per_second=123.063M/s\nschwaemm256_128_encrypt/128/32        1012 ns         1011 ns       699196 bytes_per_second=150.913M/s\nschwaemm256_128_decrypt/128/32        1077 ns         1077 ns       636856 bytes_per_second=141.721M/s\nschwaemm256_128_encrypt/256/32        1492 ns         1491 ns       464878 bytes_per_second=184.197M/s\nschwaemm256_128_decrypt/256/32        1517 ns         1516 ns       457681 bytes_per_second=181.167M/s\nschwaemm256_128_encrypt/512/32        2535 ns         2533 ns       275825 bytes_per_second=204.788M/s\nschwaemm256_128_decrypt/512/32        2535 ns         2532 ns       272598 bytes_per_second=204.86M/s\nschwaemm256_128_encrypt/1024/32       4532 ns         4528 ns       154314 bytes_per_second=222.4M/s\nschwaemm256_128_decrypt/1024/32       4601 ns         4596 ns       151337 bytes_per_second=219.126M/s\nschwaemm256_128_encrypt/2048/32       8555 ns         8550 ns        79427 bytes_per_second=232.006M/s\nschwaemm256_128_decrypt/2048/32       8734 ns         8726 ns        78770 bytes_per_second=227.338M/s\nschwaemm256_128_encrypt/4096/32      16657 ns        16644 ns        41507 bytes_per_second=236.527M/s\nschwaemm256_128_decrypt/4096/32      16910 ns        16898 ns        40713 bytes_per_second=232.967M/s\nschwaemm192_192_encrypt/64/32          988 ns          988 ns       703397 bytes_per_second=92.7009M/s\nschwaemm192_192_decrypt/64/32          994 ns          993 ns       696254 bytes_per_second=92.1954M/s\nschwaemm192_192_encrypt/128/32        1378 ns         1377 ns       502556 bytes_per_second=110.802M/s\nschwaemm192_192_decrypt/128/32        1389 ns         1388 ns       491680 bytes_per_second=109.905M/s\nschwaemm192_192_encrypt/256/32        2021 ns         2019 ns       340792 bytes_per_second=136.015M/s\nschwaemm192_192_decrypt/256/32        2031 ns         2029 ns       341537 bytes_per_second=135.365M/s\nschwaemm192_192_encrypt/512/32        3461 ns         3458 ns       198437 bytes_per_second=150.026M/s\nschwaemm192_192_decrypt/512/32        3452 ns         3448 ns       203055 bytes_per_second=150.464M/s\nschwaemm192_192_encrypt/1024/32       6170 ns         6165 ns       111187 bytes_per_second=163.365M/s\nschwaemm192_192_decrypt/1024/32       6179 ns         6171 ns       113269 bytes_per_second=163.192M/s\nschwaemm192_192_encrypt/2048/32      11742 ns        11734 ns        59098 bytes_per_second=169.051M/s\nschwaemm192_192_decrypt/2048/32      11638 ns        11632 ns        58482 bytes_per_second=170.535M/s\nschwaemm192_192_encrypt/4096/32      22709 ns        22689 ns        30435 bytes_per_second=173.511M/s\nschwaemm192_192_decrypt/4096/32      22625 ns        22608 ns        30917 bytes_per_second=174.134M/s\nschwaemm128_128_encrypt/64/32          612 ns          612 ns      1108595 bytes_per_second=149.604M/s\nschwaemm128_128_decrypt/64/32          595 ns          594 ns      1146507 bytes_per_second=154.076M/s\nschwaemm128_128_encrypt/128/32         857 ns          856 ns       782936 bytes_per_second=178.211M/s\nschwaemm128_128_decrypt/128/32         828 ns          827 ns       833552 bytes_per_second=184.454M/s\nschwaemm128_128_encrypt/256/32        1353 ns         1352 ns       512138 bytes_per_second=203.193M/s\nschwaemm128_128_decrypt/256/32        1323 ns         1322 ns       528605 bytes_per_second=207.786M/s\nschwaemm128_128_encrypt/512/32        2344 ns         2341 ns       298139 bytes_per_second=221.633M/s\nschwaemm128_128_decrypt/512/32        2266 ns         2264 ns       303380 bytes_per_second=229.112M/s\nschwaemm128_128_encrypt/1024/32       4330 ns         4308 ns       159806 bytes_per_second=233.751M/s\nschwaemm128_128_decrypt/1024/32       4175 ns         4170 ns       166537 bytes_per_second=241.493M/s\nschwaemm128_128_encrypt/2048/32       8211 ns         8201 ns        82849 bytes_per_second=241.881M/s\nschwaemm128_128_decrypt/2048/32       8022 ns         8013 ns        85426 bytes_per_second=247.55M/s\nschwaemm128_128_encrypt/4096/32      16029 ns        16010 ns        42385 bytes_per_second=245.897M/s\nschwaemm128_128_decrypt/4096/32      15724 ns        15701 ns        44363 bytes_per_second=250.728M/s\nschwaemm256_256_encrypt/64/32         1035 ns         1034 ns       670440 bytes_per_second=88.5618M/s\nschwaemm256_256_decrypt/64/32         1055 ns         1054 ns       643276 bytes_per_second=86.8737M/s\nschwaemm256_256_encrypt/128/32        1409 ns         1407 ns       496817 bytes_per_second=108.443M/s\nschwaemm256_256_decrypt/128/32        1443 ns         1436 ns       480443 bytes_per_second=106.286M/s\nschwaemm256_256_encrypt/256/32        2162 ns         2160 ns       322889 bytes_per_second=127.144M/s\nschwaemm256_256_decrypt/256/32        2175 ns         2174 ns       319302 bytes_per_second=126.359M/s\nschwaemm256_256_encrypt/512/32        3656 ns         3651 ns       192493 bytes_per_second=142.105M/s\nschwaemm256_256_decrypt/512/32        3662 ns         3658 ns       191939 bytes_per_second=141.821M/s\nschwaemm256_256_encrypt/1024/32       6618 ns         6612 ns       102796 bytes_per_second=152.31M/s\nschwaemm256_256_decrypt/1024/32       6717 ns         6705 ns       103986 bytes_per_second=150.196M/s\nschwaemm256_256_encrypt/2048/32      12644 ns        12630 ns        54997 bytes_per_second=157.054M/s\nschwaemm256_256_decrypt/2048/32      12607 ns        12593 ns        53943 bytes_per_second=157.521M/s\nschwaemm256_256_encrypt/4096/32      24526 ns        24492 ns        28538 bytes_per_second=160.74M/s\nschwaemm256_256_decrypt/4096/32      24752 ns        24706 ns        28401 bytes_per_second=159.342M/s\n```\n\n## Usage\n\nUsing Sparkle C++ API is as easy as including proper header files \u0026 letting compiler know where it can find these header files, which is `./include` directory.\n\nIf you're interested in\n\n- Esch256 Hash, import `./include/esch256.hpp`\n- Esch384 Hash, import `./include/esch384.hpp`\n\n\u003e Or just include `./include/esch.hpp` for Esch hashing\n\n- Schwaemm128-128 AEAD, import `./include/schwaemm128_128.hpp`\n- Schwaemm192-192 AEAD, import `./include/schwaemm192_192.hpp`\n- Schwaemm256-128 AEAD, import `./include/schwaemm256_128.hpp`\n- Schwaemm256-256 AEAD, import `./include/schwaemm256_256.hpp`\n\n\u003e Or just include `./include/schwaemm.hpp` for Schwaemm AEAD\n\nI strongly advise you to go through following examples, where I demonstrate usage of Sparkle C++ API.\n\n- For Esch{256, 384} Hash, see [here](./example/hash.cpp)\n- For Schwaemm{128, 192, 256}-{128, 192, 256} AEAD, see [here](./example/aead.cpp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Fsparkle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzmeanjan%2Fsparkle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzmeanjan%2Fsparkle/lists"}