confium 0.5.0 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +47 -0
- data/Cargo.lock +432 -12
- data/ext/confium_native/Cargo.toml +16 -0
- data/ext/confium_native/extconf.rb +5 -0
- data/ext/confium_native/src/lib.rs +4 -0
- data/ext/confium_native/src/openpgp_verify.rs +189 -0
- data/lib/confium/audit/otlp_sink.rb +23 -6
- data/lib/confium/native_windows.rb +31 -0
- data/lib/confium/tc/coordinator.rb +24 -36
- data/lib/confium/tc/signing_session.rb +93 -0
- data/lib/confium/tc.rb +4 -6
- data/lib/confium/version.rb +1 -1
- data/lib/confium.rb +5 -16
- metadata +5 -9
- data/lib/confium/cfm.rb +0 -23
- data/lib/confium/crypto.rb +0 -51
- data/lib/confium/digest.rb +0 -62
- data/lib/confium/ffi.rb +0 -23
- data/lib/confium/lib.rb +0 -33
- data/lib/confium/tc/session.rb +0 -51
- data/lib/confium/tc/session_stub.rb +0 -43
data/lib/confium/crypto.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# {Confium::Crypto} is the registry namespace for Confium's cryptographic
|
|
4
|
-
# interfaces.
|
|
5
|
-
#
|
|
6
|
-
# Mirroring the Rust plugin-interface registry (TODO #02), each Ruby
|
|
7
|
-
# interface module (Digest, and future Cipher, AEAD, KDF, RNG, Signature,
|
|
8
|
-
# KEM, ...) registers itself here on load rather than being enumerated in
|
|
9
|
-
# a central case statement. This keeps the registry open for extension
|
|
10
|
-
# (OCP) and makes the set of available interfaces a single source of
|
|
11
|
-
# truth.
|
|
12
|
-
#
|
|
13
|
-
# Example:
|
|
14
|
-
#
|
|
15
|
-
# module Confium
|
|
16
|
-
# module Digest
|
|
17
|
-
# Confium::Crypto.register(:hash, self)
|
|
18
|
-
# end
|
|
19
|
-
# end
|
|
20
|
-
#
|
|
21
|
-
# Confium::Crypto.lookup(:hash) # => Confium::Digest
|
|
22
|
-
module Confium
|
|
23
|
-
module Crypto
|
|
24
|
-
# @type ivar @interfaces: Hash[Symbol, untyped]
|
|
25
|
-
@interfaces = {}
|
|
26
|
-
|
|
27
|
-
class << self
|
|
28
|
-
# Register an interface +klass+ under the symbolic +name+. Adding a
|
|
29
|
-
# new interface is a one-line registration; no central switch needs
|
|
30
|
-
# editing.
|
|
31
|
-
def register(name, klass)
|
|
32
|
-
@interfaces[name] = klass
|
|
33
|
-
klass
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Resolve a registered interface by +name+. Raises ArgumentError if
|
|
37
|
-
# nothing has been registered under that name.
|
|
38
|
-
def lookup(name)
|
|
39
|
-
@interfaces.fetch(name) do
|
|
40
|
-
raise ArgumentError, "unknown interface #{name.inspect}"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
# Enumerate the names of every registered interface. Primarily for
|
|
45
|
-
# introspection and tooling.
|
|
46
|
-
def interfaces
|
|
47
|
-
@interfaces.keys.dup
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
data/lib/confium/digest.rb
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ffi'
|
|
4
|
-
require 'digest'
|
|
5
|
-
|
|
6
|
-
module Confium
|
|
7
|
-
class Digest < ::Digest::Class
|
|
8
|
-
attr_reader :name, :ptr
|
|
9
|
-
|
|
10
|
-
def initialize(cfm, name)
|
|
11
|
-
@name = name
|
|
12
|
-
pptr = ::FFI::MemoryPointer.new(:pointer)
|
|
13
|
-
Confium.call_ffi(:cfm_hash_create, cfm.ptr, pptr, name, nil, nil, nil)
|
|
14
|
-
ptr = pptr.read_pointer
|
|
15
|
-
raise if ptr.null?
|
|
16
|
-
|
|
17
|
-
@ptr = ::FFI::AutoPointer.new(ptr, self.class.method(:destroy))
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def initialize_copy(source)
|
|
21
|
-
@name = source.name
|
|
22
|
-
pptr = ::FFI::MemoryPointer.new(:pointer)
|
|
23
|
-
Confium.call_ffi(:cfm_hash_clone, source.ptr, pptr)
|
|
24
|
-
ptr = pptr.read_pointer
|
|
25
|
-
@ptr = ::FFI::AutoPointer.new(ptr, self.class.method(:destroy))
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def self.destroy(ptr)
|
|
29
|
-
Confium::Lib.cfm_hash_destroy(ptr)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def block_length
|
|
33
|
-
plength = ::FFI::MemoryPointer.new(:uint32)
|
|
34
|
-
Confium.call_ffi(:cfm_hash_block_size, @ptr, plength)
|
|
35
|
-
plength.read(:uint32)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def digest_length
|
|
39
|
-
plength = ::FFI::MemoryPointer.new(:uint32)
|
|
40
|
-
Confium.call_ffi(:cfm_hash_output_size, @ptr, plength)
|
|
41
|
-
plength.read(:uint32)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def update(data)
|
|
45
|
-
Confium.call_ffi(:cfm_hash_update, @ptr, data, data.bytesize)
|
|
46
|
-
self
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def reset
|
|
50
|
-
Confium.call_ffi(:cfm_hash_reset, @ptr)
|
|
51
|
-
self
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def finish
|
|
55
|
-
buf = ::FFI::MemoryPointer.new(:uint8, digest_length)
|
|
56
|
-
Confium.call_ffi(:cfm_hash_finalize, @ptr, buf, buf.size)
|
|
57
|
-
buf.read_bytes(buf.size)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
alias << update
|
|
61
|
-
end
|
|
62
|
-
end
|
data/lib/confium/ffi.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ffi'
|
|
4
|
-
|
|
5
|
-
# {Confium::FFI} is the namespace for everything that touches the native
|
|
6
|
-
# Confium shared library through Ruby-FFI.
|
|
7
|
-
#
|
|
8
|
-
# This file registers autoload entries for the planned FFI helper modules
|
|
9
|
-
# (Library, Error, Options). They are listed in the TODO #14 architecture
|
|
10
|
-
# (see `TODO.finalize/14-ruby-bindings-architecture.md`) and will be added
|
|
11
|
-
# as the bindings grow; until then the autoloads are inert — they only
|
|
12
|
-
# trigger a load when the corresponding constant is first referenced.
|
|
13
|
-
#
|
|
14
|
-
# Note: the legacy FFI library wrapper still lives at `Confium::Lib`
|
|
15
|
-
# (file `confium/lib.rb`) and is autoloaded from `confium.rb`. It will be
|
|
16
|
-
# migrated into `Confium::FFI::Library` in a follow-up.
|
|
17
|
-
module Confium
|
|
18
|
-
module FFI
|
|
19
|
-
autoload :Library, 'confium/ffi/library'
|
|
20
|
-
autoload :Error, 'confium/ffi/error'
|
|
21
|
-
autoload :Options, 'confium/ffi/options'
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/confium/lib.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'ffi'
|
|
4
|
-
|
|
5
|
-
module Confium
|
|
6
|
-
module Lib
|
|
7
|
-
extend ::FFI::Library
|
|
8
|
-
|
|
9
|
-
FFI_LAYOUT = {
|
|
10
|
-
cfm_create: [%i[pointer], :uint32],
|
|
11
|
-
cfm_destroy: [%i[pointer], :uint32],
|
|
12
|
-
cfm_plugin_load: [%i[pointer string string pointer pointer], :uint32],
|
|
13
|
-
cfm_hash_create: [%i[pointer pointer pointer pointer pointer pointer], :uint32],
|
|
14
|
-
cfm_hash_output_size: [%i[pointer pointer], :uint32],
|
|
15
|
-
cfm_hash_block_size: [%i[pointer pointer], :uint32],
|
|
16
|
-
cfm_hash_update: [%i[pointer pointer uint32], :uint32],
|
|
17
|
-
cfm_hash_reset: [%i[pointer], :uint32],
|
|
18
|
-
cfm_hash_clone: [%i[pointer pointer], :uint32],
|
|
19
|
-
cfm_hash_finalize: [%i[pointer pointer uint32], :uint32],
|
|
20
|
-
cfm_hash_destroy: [%i[pointer], :void]
|
|
21
|
-
}.freeze
|
|
22
|
-
|
|
23
|
-
ffi_lib([ENV.fetch('CONFIUM_LIB', nil), 'confium', 'libconfium'].compact)
|
|
24
|
-
|
|
25
|
-
FFI_LAYOUT.each do |func, ary|
|
|
26
|
-
class_eval do
|
|
27
|
-
attach_function(func, ary.first, ary.last)
|
|
28
|
-
end
|
|
29
|
-
rescue ::FFI::NotFoundError
|
|
30
|
-
# that's okay
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/confium/tc/session.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'confium/lib'
|
|
4
|
-
|
|
5
|
-
# Confium::TC::Session wraps a threshold cryptography session.
|
|
6
|
-
#
|
|
7
|
-
# A session represents one signing or decryption operation involving
|
|
8
|
-
# T-of-N parties. The session goes through states: pending →
|
|
9
|
-
# commitments_collected → shares_collected → completed.
|
|
10
|
-
#
|
|
11
|
-
# Usage:
|
|
12
|
-
# session = Confium::TC::Session.new(scheme: "FROST-ed25519",
|
|
13
|
-
# threshold: 3,
|
|
14
|
-
# num_parties: 5,
|
|
15
|
-
# party_index: 0)
|
|
16
|
-
# session.set_local_share(share_bytes)
|
|
17
|
-
# session.round(incoming_messages) # returns outgoing messages
|
|
18
|
-
# result = session.result if session.complete?
|
|
19
|
-
module Confium
|
|
20
|
-
module TC
|
|
21
|
-
class Session
|
|
22
|
-
attr_reader :scheme, :threshold, :num_parties, :party_index, :state
|
|
23
|
-
|
|
24
|
-
def initialize(scheme:, threshold:, num_parties:, party_index:)
|
|
25
|
-
@scheme = scheme
|
|
26
|
-
@threshold = threshold
|
|
27
|
-
@num_parties = num_parties
|
|
28
|
-
@party_index = party_index
|
|
29
|
-
@state = :pending
|
|
30
|
-
@local_share = nil
|
|
31
|
-
@result = nil
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def set_local_share(share_bytes)
|
|
35
|
-
raise ArgumentError, 'share must be a String' unless share_bytes.is_a?(String)
|
|
36
|
-
|
|
37
|
-
@local_share = share_bytes
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def complete?
|
|
41
|
-
@state == :completed
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def result
|
|
45
|
-
raise 'Session not complete' unless complete?
|
|
46
|
-
|
|
47
|
-
@result
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Confium::TC::SessionStub — placeholder for the multi-party TC session
|
|
4
|
-
# interface. The full Session implementation wraps
|
|
5
|
-
# confium_tc::session::Session which drives 3-round FROST/CMP20/GG18
|
|
6
|
-
# signing ceremonies.
|
|
7
|
-
#
|
|
8
|
-
# This stub provides the interface shape so consumers can write code
|
|
9
|
-
# against it. The actual session orchestration will be wired through
|
|
10
|
-
# magnus in a future PR (TODO.completion/009-multi-party-tc-sessions.md).
|
|
11
|
-
|
|
12
|
-
module Confium
|
|
13
|
-
module TC
|
|
14
|
-
class SessionStub
|
|
15
|
-
attr_reader :scheme, :threshold, :party_count, :this_party_idx, :round
|
|
16
|
-
|
|
17
|
-
def initialize(scheme:, threshold:, party_count:, this_party_idx:)
|
|
18
|
-
@scheme = scheme
|
|
19
|
-
@threshold = threshold
|
|
20
|
-
@party_count = party_count
|
|
21
|
-
@this_party_idx = this_party_idx
|
|
22
|
-
@round = 0
|
|
23
|
-
@complete = false
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def complete?
|
|
27
|
-
@complete
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Stub: returns an empty RoundResult. Real implementation will
|
|
31
|
-
# call confium_tc::session::Session::round_step.
|
|
32
|
-
def round_step(_incoming_messages)
|
|
33
|
-
@round += 1
|
|
34
|
-
@complete = @round >= 3 # FROST is 3 rounds
|
|
35
|
-
{ outgoing: [], complete: @complete }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def result
|
|
39
|
-
nil # Real implementation returns the signature/secret bytes.
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|