{"id":19632130,"url":"https://github.com/chrisliaw/roqs","last_synced_at":"2025-10-14T23:54:31.658Z","repository":{"id":208836672,"uuid":"719592539","full_name":"chrisliaw/roqs","owner":"chrisliaw","description":"Ruby wrapper to the liboqs library","archived":false,"fork":false,"pushed_at":"2025-06-24T09:59:08.000Z","size":17358,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-24T10:48:42.203Z","etag":null,"topics":["liboqs"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/chrisliaw.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-16T13:51:28.000Z","updated_at":"2025-06-24T09:59:11.000Z","dependencies_parsed_at":"2025-01-10T09:47:03.911Z","dependency_job_id":null,"html_url":"https://github.com/chrisliaw/roqs","commit_stats":null,"previous_names":["chrisliaw/roqs"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/chrisliaw/roqs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisliaw%2Froqs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisliaw%2Froqs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisliaw%2Froqs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisliaw%2Froqs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrisliaw","download_url":"https://codeload.github.com/chrisliaw/roqs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrisliaw%2Froqs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264314840,"owners_count":23589663,"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":["liboqs"],"created_at":"2024-11-11T12:12:59.381Z","updated_at":"2025-10-14T23:54:26.611Z","avatar_url":"https://github.com/chrisliaw.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Roqs\n\nRoqs is the Ruby wrapper to the [Open Quantum Safe library](https://openquantumsafe.org). The native library was tested against the liboqs at [liboqs](https://github.com/open-quantum-safe/liboqs)\n\nDue to the direct invocation of the shared library via the libffi toolkit, unless there are major API changes at the liboqs side, this library will keep working as the library is just a bridge between liboqs and Ruby runtime via the API called. Any new supported algorithms internal to the liboqs can be just immediately utilized by the Ruby runtime.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'roqs'\n```\n\nAnd then execute:\n\n    bundle install\n\nOr install it yourself as:\n\n    gem install roqs\n\n## Usage\n\nOQS mainly only has two group of functions: Key Encapsulation Mechanism (KEM) and Signature (SIG).\n\nTherefore the Ruby wrapper abstraction is following the liboqs C version as baseline.\n\n### Key Encapsulation Mechanism (KEM)\n\nFor KEM, the API is simple:\n\n1. List all supported KEM PQ algorithms - PQ algorithms can be enable or disabled at compile time so it all depends on the liboqs native library. This API listed down the algorithms which are *supported* as reported by the native library. If you're using your own version of the library, you might have different output.\n\n```ruby\nrequire 'roqs'\n\nsupported_algo = Roqs::KEM.supported_kem_algo\nsupported_algo.each do |al|\n  # al is the algorithm name (string) which is required by subsequent API\n  ...\nend\n```\n\n2. Generate keypair\n\n```ruby\nrequire 'roqs'\n\nkyber = Roqs::KEM.new('Kyber768')\npubKey, secretKey = kyber.genkeypair\n# note pubKey and secretKey (or private key) is Fiddle::Pointer type and \n# is required to be used by the C API in the subsequent phase.\n# Note that pubKey and secretKey are required to be free manually\n# Refer spec file for usage\n```\n\n3. Key encapsulation - KEM is meant for key encapsulation which similar with Diffie-Hellman kind of key exchange\n\n```ruby\nrequire 'roqs'\n\nsessionKey, cipher = kyber.derive_encapsulation_key(pubKey)\n# cipher is required to be sent to recipient end to re-generate the sessionKey at recipient end.\n# Returned sessionKey is meant to convert into the final AES (or any other symmetric key) \n# for the actual data encryption\n```\n\n4. Key decapsulation - Re-generate the session key from the private key\n\n```ruby\nrequire 'roqs'\n\nsessionKey = kyber.derive_decapsulation_key(cipher, secretKey)\n# cipher is given by sender and privKey is the recipient own private key\n```\n\n*sessionKey* returned from derive\\_encapsulation\\_key() shall be same as the *sessionKey* from derive\\_decapsulation\\_key(). That session key shall be the AES key (any other symmetric key) for the data encryption.\n\n### Signature mechanism\n\nSignature mechanism is similar with KEM.\n\n1. List all supported Signature PQ algorithms - It is same as KEM as algorithm can be turned on or off during compile time\n\n```ruby\nrequire 'roqs'\n\nsupported_algo = Roqs::SIG.supported_signature_algo\nsupported_algo.each do |al|\n  # al is the algorithm name (string) which is required by subsequent API\n  ...\nend\n```\n\n2. Generate keypair\n\n```ruby\nrequire 'roqs'\n\ndili = Roqs::SIG.new('Dilithium5')\npubKey, secretKey = dili.genkeypair\n# note pubKey and secretKey (or private key) is Fiddle::Pointer type and \n# is required to be used by the C API in the subsequent phase.\n# Note that pubKey and secretKey are required to be free manually\n# Refer spec file for usage\n```\n\n3. Generate data signature\n\n```rubyion\nrequire 'roqs'\n\n# sign data using sender secretKey/private key\nsignature = dili.sign(\"this is message\", secretKey)\n```\n\n4. Verify data signature\n\n```ruby\nrequire 'roqs'\n\n# verify signature with given data using sender public key\nres = dili.verify(\"this is message\", signature, pubKey)\n# res is boolean to indicate the signature verification is passed or failed\n```\n\nspec folder has the necessary API example usage.\n\n## Test Results\n\nRefer to [test result](https://github.com/chrisliaw/liboqs-ruby/blob/master/TEST-RESULT.md) for details.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisliaw%2Froqs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrisliaw%2Froqs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrisliaw%2Froqs/lists"}