
Security News
Oxlint Introduces Type-Aware Linting Preview
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Roqs is the Ruby wrapper to the Open Quantum Safe library. The native library was tested against the liboqs at liboqs
Due 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.
Add this line to your application's Gemfile:
gem 'roqs'
And then execute:
bundle install
Or install it yourself as:
gem install roqs
OQS mainly only has two group of functions: Key Encapsulation Mechanism (KEM) and Signature (SIG).
Therefore the Ruby wrapper abstraction is following the liboqs C version as baseline.
For KEM, the API is simple:
require 'roqs'
supported_algo = Roqs::KEM.supported_kem_algo
supported_algo.each do |al|
# al is the algorithm name (string) which is required by subsequent API
...
end
require 'roqs'
kyber = Roqs::KEM.new('Kyber768')
pubKey, secretKey = kyber.genkeypair
# note pubKey and secretKey (or private key) is Fiddle::Pointer type and
# is required to be used by the C API in the subsequent phase.
# Note that pubKey and secretKey are required to be free manually
# Refer spec file for usage
require 'roqs'
sessionKey, cipher = kyber.derive_encapsulation_key(pubKey)
# cipher is required to be sent to recipient end to re-generate the sessionKey at recipient end.
# Returned sessionKey is meant to convert into the final AES (or any other symmetric key)
# for the actual data encryption
require 'roqs'
sessionKey = kyber.derive_decapsulation_key(cipher, secretKey)
# cipher is given by sender and privKey is the recipient own private key
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.
Signature mechanism is similar with KEM.
require 'roqs'
supported_algo = Roqs::SIG.supported_signature_algo
supported_algo.each do |al|
# al is the algorithm name (string) which is required by subsequent API
...
end
require 'roqs'
dili = Roqs::SIG.new('Dilithium5')
pubKey, secretKey = dili.genkeypair
# note pubKey and secretKey (or private key) is Fiddle::Pointer type and
# is required to be used by the C API in the subsequent phase.
# Note that pubKey and secretKey are required to be free manually
# Refer spec file for usage
require 'roqs'
# sign data using sender secretKey/private key
signature = dili.sign("this is message", secretKey)
require 'roqs'
# verify signature with given data using sender public key
res = dili.verify("this is message", signature, pubKey)
# res is boolean to indicate the signature verification is passed or failed
spec folder has the necessary API example usage.
Refer to test result for details.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that roqs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.