swt3-ai 0.1.1 → 0.4.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: e6b5ce85f7938c51d5738f838a78c3c5990c7ccc6ad8af7b79c9ea339231804e
4
- data.tar.gz: c1e2e302c8d52759233e8fc46a22b411634144390e642b0b30d4ad161187b490
3
+ metadata.gz: 3c33738eca6af0da5f3b341aca0c44f10d97f646a0aed85bd57901081c2bc6f9
4
+ data.tar.gz: 26e63c59eb176fc1d7cdfda26eed9841c1fa8e242a97915885a3396f26c43099
5
5
  SHA512:
6
- metadata.gz: 067bf588f7aefe172df7a74c712f0ae08d4182946bf2e074268d37d1f8af14c7c7b77c9ea198329dbd30df37e5669dcf5cfa9973319b22c5749095072504f8a4
7
- data.tar.gz: bd21ed1a6572663fb04c49a92bedc86953bd2ec9bdc88354b99ab282483ad6b5555a3b7851f1c2928bc135ab95239d9a812619a2f0299d84a0ffaac70d6b5a6b
6
+ metadata.gz: c8472c6b851815fd18a8a0f8f1b896b4fd8e727b4a9d4fcc12629beca30294aba4f5b7c95b912d6c5274da0123777bab811fa6723b066b041d228caeae7b292c
7
+ data.tar.gz: f7eda3a4fbeea3e9c58f36cb298f65da87c37bc4798add45af5ac28a81f68776383ee97597a0efb2ed3880aa379976184c0e857dbdb30ccc468cff5897dd6b97
@@ -0,0 +1,43 @@
1
+ require "openssl"
2
+
3
+ module Swt3Ai
4
+ module Fingerprint
5
+ # Mint an SWT3 fingerprint from the canonical formula.
6
+ #
7
+ # Returns the first 12 hex characters of:
8
+ # SHA-256("WITNESS:{tenant}:{proc}:{fa}:{fb}:{fc}:{ts_ms}")
9
+ #
10
+ # This formula is locked and must produce identical output across
11
+ # all SWT3 SDK implementations (Python, TypeScript, Rust, C#, Ruby).
12
+ def self.mint_fingerprint(tenant_id, procedure_id, factor_a, factor_b, factor_c, timestamp_ms)
13
+ input = "WITNESS:#{tenant_id}:#{procedure_id}:#{num_str(factor_a)}:#{num_str(factor_b)}:#{num_str(factor_c)}:#{timestamp_ms}"
14
+ sha256_hex(input, 12)
15
+ end
16
+
17
+ # Compute a truncated SHA-256 hash. Default length is 16 hex characters.
18
+ def self.sha256_truncated(data, length = 16)
19
+ sha256_hex(data, length)
20
+ end
21
+
22
+ # Compute SHA-256 and return the first N hex characters.
23
+ def self.sha256_hex(data, length = 64)
24
+ digest = OpenSSL::Digest::SHA256.hexdigest(data.to_s)
25
+ digest[0, [length, 64].min]
26
+ end
27
+
28
+ # Get the current timestamp in milliseconds and epoch seconds.
29
+ def self.timestamp_ms
30
+ ms = (Time.now.to_f * 1000).to_i
31
+ epoch = ms / 1000
32
+ [ms, epoch]
33
+ end
34
+
35
+ # Format a numeric factor as a string matching the canonical formula.
36
+ # Integer-valued floats are formatted without decimals: 1.0 -> "1"
37
+ def self.num_str(v)
38
+ v == v.to_i ? v.to_i.to_s : v.to_s
39
+ end
40
+
41
+ private_class_method :num_str
42
+ end
43
+ end
@@ -0,0 +1,15 @@
1
+ require "openssl"
2
+
3
+ module Swt3Ai
4
+ module Signing
5
+ # Sign a payload with HMAC-SHA256 for non-repudiation.
6
+ #
7
+ # If agent_id is provided, the message is "{fingerprint}:{agent_id}".
8
+ # Otherwise, the message is just the fingerprint.
9
+ # Returns a 64-character lowercase hex string.
10
+ def self.sign_payload(signing_key, anchor_fingerprint, agent_id = nil)
11
+ message = agent_id ? "#{anchor_fingerprint}:#{agent_id}" : anchor_fingerprint
12
+ OpenSSL::HMAC.hexdigest("SHA256", signing_key, message)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module Swt3Ai
2
+ # A witness payload ready for transmission to the witness endpoint.
3
+ WitnessPayload = Struct.new(
4
+ :procedure_id, :factor_a, :factor_b, :factor_c,
5
+ :clearing_level, :anchor_fingerprint, :anchor_epoch,
6
+ :fingerprint_timestamp_ms, :ai_model_id, :ai_prompt_hash,
7
+ :ai_response_hash, :ai_latency_ms, :ai_input_tokens,
8
+ :ai_output_tokens, :agent_id, :cycle_id,
9
+ :payload_signature, :policy_version_hash,
10
+ keyword_init: true
11
+ )
12
+
13
+ # A receipt returned by the witness endpoint after successful anchoring.
14
+ WitnessReceipt = Struct.new(
15
+ :procedure_id, :verdict, :swt3_anchor, :clearing_level,
16
+ :witnessed_at, :verification_url, :ok, :error,
17
+ keyword_init: true
18
+ )
19
+
20
+ # Configuration for a Witness client.
21
+ WitnessConfig = Struct.new(
22
+ :endpoint, :api_key, :tenant_id, :clearing_level,
23
+ :buffer_size, :flush_interval, :timeout, :max_retries,
24
+ :agent_id, :signing_key, :cycle_id, :policy_version,
25
+ keyword_init: true
26
+ )
27
+ end
data/lib/swt3_ai.rb CHANGED
@@ -1,7 +1,11 @@
1
- # SWT3 Witness Anchors for AI systems.
2
- # Cryptographic accountability protocol for AI inference, training, and deployment.
1
+ # SWT3 AI Witness SDK for Ruby.
2
+ # Cryptographic attestation for AI inference.
3
3
  # See https://tenova.io for documentation.
4
4
 
5
+ require_relative "swt3_ai/fingerprint"
6
+ require_relative "swt3_ai/signing"
7
+ require_relative "swt3_ai/types"
8
+
5
9
  module Swt3Ai
6
- VERSION = "0.1.1"
10
+ VERSION = "0.3.6"
7
11
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swt3-ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TeNova Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-22 00:00:00.000000000 Z
11
+ date: 2026-04-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Cryptographic accountability protocol for AI inference, training, and
14
- deployment.
13
+ description: Mint, verify, and sign SWT3 witness anchors for AI compliance. Cross-language
14
+ parity with Python and TypeScript SDKs. Zero external dependencies.
15
15
  email:
16
16
  - engineering@tenovaai.com
17
17
  executables: []
@@ -20,6 +20,9 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - README.md
22
22
  - lib/swt3_ai.rb
23
+ - lib/swt3_ai/fingerprint.rb
24
+ - lib/swt3_ai/signing.rb
25
+ - lib/swt3_ai/types.rb
23
26
  homepage: https://tenova.io
24
27
  licenses:
25
28
  - Apache-2.0
@@ -44,5 +47,5 @@ requirements: []
44
47
  rubygems_version: 3.4.20
45
48
  signing_key:
46
49
  specification_version: 4
47
- summary: SWT3 Witness Anchors for AI systems
50
+ summary: 'SWT3 AI Witness SDK: cryptographic attestation for AI inference'
48
51
  test_files: []