{"id":32301385,"url":"https://github.com/bardiakz/oqs","last_synced_at":"2026-02-19T21:53:12.462Z","repository":{"id":305762883,"uuid":"1022668052","full_name":"bardiakz/oqs","owner":"bardiakz","description":"oqs - A Dart FFI wrapper for liboqs, delivering post-quantum cryptographic algorithms. Supports NIST-standardized KEMs (e.g., ML-KEM) and signatures (e.g., ML-DSA), optimized for Flutter and cross-platform applications (Android, iOS, Linux, macOS, Windows). MIT Licensed.","archived":false,"fork":false,"pushed_at":"2026-02-14T19:01:02.000Z","size":261,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-14T21:57:29.336Z","etag":null,"topics":["cryptography","dart","ffi","flutter","kem","kyber","liboqs","ml-dsa","ml-kem","oqs","pqc","quantom-cryptography"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bardiakz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-07-19T15:12:01.000Z","updated_at":"2026-02-14T19:01:05.000Z","dependencies_parsed_at":"2025-07-21T22:38:33.730Z","dependency_job_id":"0df23eb3-015c-46a1-879b-e0726751f99e","html_url":"https://github.com/bardiakz/oqs","commit_stats":null,"previous_names":["bardiakz/oqs"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bardiakz/oqs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bardiakz%2Foqs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bardiakz%2Foqs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bardiakz%2Foqs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bardiakz%2Foqs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bardiakz","download_url":"https://codeload.github.com/bardiakz/oqs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bardiakz%2Foqs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29634417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","dart","ffi","flutter","kem","kyber","liboqs","ml-dsa","ml-kem","oqs","pqc","quantom-cryptography"],"created_at":"2025-10-23T05:40:21.957Z","updated_at":"2026-02-19T21:53:12.458Z","avatar_url":"https://github.com/bardiakz.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OQS for Dart\n\n[![pub package](https://img.shields.io/pub/v/oqs.svg)](https://pub.dev/packages/oqs)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nDart FFI bindings for [liboqs](https://github.com/open-quantum-safe/liboqs), providing post-quantum KEM and signature primitives.\n\n## Version Compatibility\n\n| `oqs` package | `liboqs` |\n|---|---|\n| `3.x` | `0.15.x` |\n| `2.x` | `0.14.x` (legacy) |\n\n`3.0.0` is a breaking release aligned to `liboqs 0.15.0`.\n\n## Install\n\n```yaml\ndependencies:\n  oqs: ^3.1.0\n```\n\n## Native Library Setup\n\nYou need a native `liboqs` library for your platform.\n\n### Option 1: Prebuilt binaries (Recommended)\n\nDownload pre-built binaries from:\n- https://github.com/bardiakz/liboqs-binaries/releases\n\n**Supported platforms:**\n- Linux: x86_64, ARM64 (aarch64)\n- macOS: ARM64 (Apple Silicon)\n- Windows: x64\n- iOS: XCFramework (device + simulator)\n- Android: armeabi-v7a, arm64-v8a, x86, x86_64\n\n**Using the all-platforms archive:**\n\n```bash\n# Extract the combined archive\ntar -xzf liboqs-0.15.0-all-platforms.tar.gz\n\n# Use in your Dart code\nLibOQSLoader.loadLibrary(binaryRoot: '/path/to/liboqs-0.15.0');\n```\n\nThe all-platforms archive contains architecture-separated binaries:\n```\nliboqs-0.15.0/\n  lib/x86_64/liboqs.so      # Linux x86_64\n  lib/aarch64/liboqs.so     # Linux ARM64\n  lib/liboqs.dylib          # macOS ARM64\n  bin/oqs.dll               # Windows x64\n  android/arm64-v8a/        # Android binaries\n  liboqs.xcframework/       # iOS\n```\n\n### Option 2: Build from source\n\n```bash\ngit clone https://github.com/open-quantum-safe/liboqs.git\ncd liboqs\nmkdir build \u0026\u0026 cd build\ncmake -GNinja -DCMAKE_INSTALL_PREFIX=/usr/local ..\nninja\nninja install\n```\n\n### Optional explicit paths\n\n```dart\nimport 'package:oqs/oqs.dart';\n\nLibOQSLoader.customPaths = LibraryPaths(\n  windows: r'C:\\libs\\oqs.dll',\n  linuxX64: '/usr/local/lib/liboqs.so',\n  linuxArm64: '/usr/local/lib/liboqs.so',  // For ARM64 systems\n  macOS: '/opt/homebrew/lib/liboqs.dylib',\n);\n```\n\n## Library Loading Guide\n\n`LibOQSLoader.loadLibrary()` uses fallback strategies in this exact order:\n\n1. `explicitPath` argument\n2. `LibOQSLoader.customPaths` (`LibraryPaths`)\n3. Deprecated `LibOQSLoader.customPath`\n4. Environment variable (`LIBOQS_PATH`, or `envVarName`)\n5. `binaryRoot` extracted release layout\n6. Package-relative paths\n7. System loader/default name (`liboqs.so`, `oqs.dll`, `liboqs.dylib`)\n8. Legacy default paths (`bin/\u003cplatform\u003e/...`)\n\nIf all fail, `LibraryLoadException` includes all attempted strategies.\n\n### Auto Path Selection (Package-relative)\n\n`PackageRelativeStrategy` checks:\n\n- `./bin/\u003clibrary-file\u003e`\n- `./lib/\u003clibrary-file\u003e`\n- `./lib/native/\u003clibrary-file\u003e`\n- `./native/\u003clibrary-file\u003e`\n- `./blobs/\u003clibrary-file\u003e`\n- Android extras:\n  - `./lib/arm64-v8a/liboqs.so`\n  - `./lib/armeabi-v7a/liboqs.so`\n  - `./lib/x86_64/liboqs.so`\n  - `./lib/x86/liboqs.so`\n\n### Platform Notes\n\n- **Linux**: Automatically detects x86_64 vs ARM64 (aarch64) architecture\n- **iOS**: Uses `DynamicLibrary.process()` (XCFramework/static linking), not `DynamicLibrary.open(...)`\n- **Android**: ABI-specific selection supported through `LibraryPaths.currentPlatformPath`\n- **macOS/Windows**: System resolution works when library is installed in standard paths\n\n### Recommended Config Patterns\n\nUse explicit, deterministic config for production:\n\n```dart\nfinal lib = LibOQSLoader.loadLibrary(\n  explicitPath: '/opt/liboqs/lib/liboqs.so',\n);\n```\n\nOr per-platform config:\n\n```dart\nLibOQSLoader.customPaths = LibraryPaths(\n  windows: r'C:\\oqs\\oqs.dll',\n  linuxX64: '/usr/local/lib/liboqs.so',\n  linuxArm64: '/usr/local/lib/liboqs.so',\n  macOS: '/opt/homebrew/lib/liboqs.dylib',\n  androidArm64: '/data/local/tmp/liboqs.so',\n);\n```\n\nOr extracted release root:\n\n```dart\nfinal lib = LibOQSLoader.loadLibrary(binaryRoot: '/opt/liboqs-0.15.0');\n```\n\n### Cache Behavior\n\n- Loader caches resolved `DynamicLibrary` by default.\n- Update paths at runtime: set `LibOQSLoader.customPaths = ...` (this clears cache).\n- Manual reset: `LibOQSLoader.clearCache()`.\n\n### Debug Checklist\n\n1. Verify `LibOQS.getVersion()` returns non-empty string.\n2. Print `LibOQS.getSupportedKEMAlgorithms()` to confirm expected build features.\n3. If loading fails, inspect thrown `LibraryLoadException` strategy list and fix the earliest intended path.\n\n## Quick Start\n\n```dart\nimport 'dart:typed_data';\nimport 'package:oqs/oqs.dart';\n\nvoid main() {\n  LibOQS.init();\n\n  final kems = LibOQS.getSupportedKEMAlgorithms();\n  if (kems.isEmpty) {\n    throw StateError('No enabled KEM algorithms in loaded liboqs');\n  }\n\n  final kem = KEM.create(kems.first)!;\n  final kp = kem.generateKeyPair();\n  final enc = kem.encapsulate(kp.publicKey);\n  final dec = kem.decapsulate(enc.ciphertext, kp.secretKey);\n\n  print(dec.length == enc.sharedSecret.length); // true\n\n  kem.dispose();\n  LibOQS.cleanup();\n}\n```\n\n## API Notes\n\n- Prefer runtime algorithm discovery:\n  - `LibOQS.getSupportedKEMAlgorithms()`\n  - `LibOQS.getSupportedSignatureAlgorithms()`\n- Do not hard-code key/signature lengths. Use:\n  - `kem.publicKeyLength`, `kem.secretKeyLength`, `kem.ciphertextLength`\n  - `sig.publicKeyLength`, `sig.secretKeyLength`, `sig.maxSignatureLength`\n- Deterministic keypair generation is algorithm-dependent:\n  - `kem.supportsDeterministicGeneration`\n  - `kem.seedLength`\n\n## Signature Example\n\n```dart\nimport 'dart:convert';\nimport 'dart:typed_data';\nimport 'package:oqs/oqs.dart';\n\nvoid main() {\n  final sigAlgs = LibOQS.getSupportedSignatureAlgorithms();\n  if (sigAlgs.isEmpty) {\n    throw StateError('No enabled signature algorithms');\n  }\n\n  final sig = Signature.create(sigAlgs.first);\n  final kp = sig.generateKeyPair();\n\n  final msg = Uint8List.fromList(utf8.encode('hello pqc'));\n  final s = sig.sign(msg, kp.secretKey);\n  final ok = sig.verify(msg, s, kp.publicKey);\n\n  print(ok); // true\n  sig.dispose();\n}\n```\n\n## Migration to 3.x (`liboqs 0.15.0`)\n\n1. Upgrade dependency in `pubspec.yaml` to `^3.1.0`.\n2. Ensure native `liboqs` binary is `0.15.x`.\n3. Replace fixed algorithm assumptions (`Kyber*`, `Dilithium*`) with runtime discovery.\n4. Remove hard-coded size assertions and read lengths from each algorithm instance.\n5. Re-run tests against every target platform binary you ship.\n\n## Common Problems\n\n### Library not found\n\nSet `LibOQSLoader.customPaths` or install `liboqs` to standard system paths.\n\n### Algorithm not available\n\nEnabled algorithms depend on how your `liboqs` binary was built. Check:\n\n```dart\nprint(LibOQS.getSupportedKEMAlgorithms());\nprint(LibOQS.getSupportedSignatureAlgorithms());\n```\n\n## Security Notes\n\n- Use NIST-standardized algorithms (`ML-KEM-*`, `ML-DSA-*`) for production.\n- Dispose algorithm objects (`kem.dispose()`, `sig.dispose()`) when done.\n- Keep `liboqs` binaries updated and track security advisories.\n- Do not share mutable crypto object state across isolates/threads.\n\n## Examples\n\nSee the [`example/`](example/) directory for end-to-end usage samples.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbardiakz%2Foqs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbardiakz%2Foqs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbardiakz%2Foqs/lists"}