nexusq 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc02cce3fd358aad750b503011f71a74be3788f74eae505f0f5ffa2295f8466c
4
- data.tar.gz: 7a8f14601b0b7036eca9e83279b54abbfee9f0d1806b1689d37e2eec6c09ac85
3
+ metadata.gz: 0d0cbd6ccb5958fd4306054feb0b4bf35a7af7e30eb7715976bf143b155a7780
4
+ data.tar.gz: 2a60ad05e3c5876ef9baba273da02514a87911edc6933f226190a22621117cbf
5
5
  SHA512:
6
- metadata.gz: 4507def0f5dd466ef8becd4bc1395436b33d7adfd0d5bdff73d2e493deac679eebafb031a64d189782b3ced2061655fa51a1af5fbc79f64a6cb7864aac7bcd58
7
- data.tar.gz: 5f3bfde921eb8734001f5fefdb54db60540766c634980ffe9fa5e178fa7cb5559285b4c31440b7a967b10fdd02c5eec69a4b319ce063226f6ab3564d2788f09d
6
+ metadata.gz: 3c5bebf374836d3917df4cec3d9cc45751d51395469ab3c3b17849364c81426dffa88eb7354c455a47aecc14036b1dad48756c1a57a6c1cde709456888cf23a6
7
+ data.tar.gz: 94f5b08433de43c04f93b7403318f5944a10bd2cae04965db9a68f1b885b2f97d3e4a01ec8fd866cd3da39d4d6abbf6a2ef8d26ed23f0ce09093e3cad1816be2
data/README.md CHANGED
@@ -8,9 +8,11 @@ through `libnexusq`.
8
8
 
9
9
  - Ruby 3.0 or newer.
10
10
  - The `ffi` gem (`gem install ffi`).
11
- - The C SDK built (`cargo build -p nexusq-c`).
12
- - `libnexusq.so` available at runtime through `LD_LIBRARY_PATH` or
13
- `NEXUSQ_LIBRARY`.
11
+ - Published releases automatically download the version-matched runtime and
12
+ verify its SHA-256 checksum on Linux x64/ARM64 glibc, macOS ARM64, and Windows
13
+ x64. Rust is not required by SDK consumers; the library is cached under
14
+ `~/.cache/nexusq/<version>/<runtime-asset>`.
15
+ - `NEXUSQ_LIBRARY` remains an advanced override for a local/custom library.
14
16
 
15
17
  ## Usage
16
18
 
@@ -25,17 +27,13 @@ puts "vault created at #{vault.path}"
25
27
  puts "format version: #{vault.format_version}"
26
28
  ```
27
29
 
28
- Run with:
30
+ Run normally after installing the published SDK:
29
31
 
30
32
  ```bash
31
- NEXUSQ_LIBRARY=/path/to/nexusq/target/debug/libnexusq.so ruby your_program.rb
33
+ ruby your_program.rb
32
34
  ```
33
35
 
34
- If the library directory is already on the dynamic loader path:
35
-
36
- ```bash
37
- LD_LIBRARY_PATH=/path/to/nexusq/target/debug ruby your_program.rb
38
- ```
36
+ For source-checkout smoke tests or a custom build, set `NEXUSQ_LIBRARY` to the library path.
39
37
 
40
38
  ## What is available
41
39
 
@@ -10,6 +10,9 @@ require "tmpdir"
10
10
  require_relative "../../lib/nexusq"
11
11
 
12
12
  puts "nexusq version: #{Nexusq.version}"
13
+ provider = Nexusq.backend_info
14
+ abort "invalid backend metadata" unless provider[:name] && provider[:native_available] == (provider[:name] == "native-experimental") && provider[:experimental] == provider[:native_available]
15
+ puts "PQC backend: #{provider[:name]}"
13
16
 
14
17
  path = File.join(Dir.tmpdir, "nexusq_ruby_smoke_#{$$}.nqv")
15
18
  File.delete(path) if File.exist?(path)
data/lib/nexusq.rb CHANGED
@@ -6,13 +6,71 @@
6
6
  # cryptography or business logic; every operation delegates to libnexusq.
7
7
 
8
8
  require "ffi"
9
+ require "digest"
10
+ require "fileutils"
11
+ require "open-uri"
12
+ require "rbconfig"
9
13
 
10
14
  module Nexusq
11
15
  extend FFI::Library
12
16
 
13
- ffi_lib ENV.fetch("NEXUSQ_LIBRARY", "nexusq")
17
+ RUNTIME_VERSION = "4.1.1"
18
+
19
+ def self.resolve_library
20
+ override = ENV["NEXUSQ_LIBRARY"]
21
+ return override unless override.nil? || override.empty?
22
+
23
+ os = RbConfig::CONFIG.fetch("host_os", "").downcase
24
+ arch = RbConfig::CONFIG.fetch("host_cpu", "").downcase
25
+ if os.include?("linux") && ["/lib/ld-musl-x86_64.so.1", "/lib/ld-musl-aarch64.so.1", "/lib/ld-musl-armhf.so.1"].any? { |path| File.exist?(path) }
26
+ raise LoadError, "Prebuilt NEXUS-Q Linux runtimes require glibc, not musl/Alpine; set NEXUSQ_LIBRARY to a compatible build."
27
+ end
28
+ asset, local_name = if os.include?("linux") && %w[x86_64 amd64].include?(arch)
29
+ ["nexusq-sdk-runtime-linux-x64.so", "libnexusq.so"]
30
+ elsif os.include?("linux") && %w[aarch64 arm64].include?(arch)
31
+ ["nexusq-sdk-runtime-linux-arm64.so", "libnexusq.so"]
32
+ elsif os.include?("darwin") && %w[arm64 aarch64].include?(arch)
33
+ ["nexusq-sdk-runtime-macos-arm64.dylib", "libnexusq.dylib"]
34
+ elsif os.match?(/mingw|mswin/) && %w[x86_64 amd64].include?(arch)
35
+ ["nexusq-sdk-runtime-windows-x64.dll", "nexusq.dll"]
36
+ else
37
+ raise LoadError, "No prebuilt NEXUS-Q runtime for #{os}/#{arch}; set NEXUSQ_LIBRARY to a compatible library path."
38
+ end
39
+
40
+ cache = File.join(Dir.home, ".cache", "nexusq", RUNTIME_VERSION, asset)
41
+ library = File.join(cache, local_name)
42
+ digest_file = "#{library}.sha256"
43
+ FileUtils.mkdir_p(cache)
44
+ if File.file?(library) && File.file?(digest_file) &&
45
+ Digest::SHA256.file(library).hexdigest == File.read(digest_file).strip
46
+ return library
47
+ end
48
+
49
+ base = "https://github.com/lecodev-26/nexus-q/releases/download/v#{RUNTIME_VERSION}/"
50
+ checksums = URI.open("#{base}NATIVE-RUNTIME-SHA256SUMS", "User-Agent" => "NEXUS-Q Ruby SDK", open_timeout: 10, read_timeout: 30, &:read)
51
+ expected = checksums.lines.find { |line| line.strip.end_with?(" #{asset}") }&.split&.first
52
+ raise LoadError, "No published checksum for #{asset}" unless expected
53
+
54
+ bytes = URI.open("#{base}#{asset}", "User-Agent" => "NEXUS-Q Ruby SDK", open_timeout: 10, read_timeout: 60, &:read)
55
+ actual = Digest::SHA256.hexdigest(bytes)
56
+ raise LoadError, "SHA-256 mismatch for #{asset}; refusing to load an unverified runtime" unless actual == expected.downcase
57
+
58
+ temporary = "#{library}.download"
59
+ File.binwrite(temporary, bytes)
60
+ File.rename(temporary, library)
61
+ File.write(digest_file, "#{actual}\n")
62
+ library
63
+ rescue LoadError
64
+ raise
65
+ rescue StandardError => e
66
+ raise LoadError, "Unable to obtain verified NEXUS-Q #{RUNTIME_VERSION} runtime: #{e.message}. Set NEXUSQ_LIBRARY to a compatible library path."
67
+ end
68
+
69
+ ffi_lib resolve_library
14
70
 
15
71
  attach_function :nexusq_version, [], :string
72
+ attach_function :nexusq_backend_name, [], :string
73
+ attach_function :nexusq_backend_is_experimental, [], :uint8
16
74
  attach_function :nexusq_last_error_message, [], :string
17
75
  attach_function :nexusq_vault_create, [:string, :string, :string], :int32
18
76
  attach_function :nexusq_vault_format_version, [:string], :int32
@@ -21,6 +79,12 @@ module Nexusq
21
79
  nexusq_version
22
80
  end
23
81
 
82
+ # Reports the provider compiled into the loaded library; it does not switch providers.
83
+ def self.backend_info
84
+ name = nexusq_backend_name
85
+ { name: name, experimental: nexusq_backend_is_experimental != 0, native_available: name == "native-experimental" }
86
+ end
87
+
24
88
  def self.last_error
25
89
  nexusq_last_error_message
26
90
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexusq
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - lecodev-26
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-10-22 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: ffi
@@ -25,6 +26,7 @@ dependencies:
25
26
  version: '1.15'
26
27
  description: Thin FFI wrapper over the NEXUS-Q C SDK (libnexusq). No cryptography
27
28
  or business logic lives here.
29
+ email:
28
30
  executables: []
29
31
  extensions: []
30
32
  extra_rdoc_files: []
@@ -34,8 +36,10 @@ files:
34
36
  - lib/nexusq.rb
35
37
  homepage: https://github.com/lecodev-26/nexus-q
36
38
  licenses:
37
- - MIT OR Apache-2.0
39
+ - MIT
40
+ - Apache-2.0
38
41
  metadata: {}
42
+ post_install_message:
39
43
  rdoc_options: []
40
44
  require_paths:
41
45
  - lib
@@ -50,7 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
54
  - !ruby/object:Gem::Version
51
55
  version: '0'
52
56
  requirements: []
53
- rubygems_version: 3.6.9
57
+ rubygems_version: 3.4.20
58
+ signing_key:
54
59
  specification_version: 4
55
60
  summary: Ruby bindings for NEXUS-Q
56
61
  test_files: []