Class: Confium::TC::SignerClient

Inherits:
Object
  • Object
show all
Defined in:
lib/confium/tc/network_coordinator.rb

Overview

Client side for NetworkCoordinator. One instance per signer process; each call opens its own connection, so signers never share state.

Defined Under Namespace

Classes: RemoteError

Instance Method Summary collapse

Constructor Details

#initialize(port:, host: '127.0.0.1') ⇒ SignerClient

Returns a new instance of SignerClient.



156
157
158
159
# File 'lib/confium/tc/network_coordinator.rb', line 156

def initialize(port:, host: '127.0.0.1')
  @host = host
  @port = port
end

Instance Method Details

#aggregate(session_id) ⇒ Object



189
190
191
192
# File 'lib/confium/tc/network_coordinator.rb', line 189

def aggregate(session_id)
  response = call('op' => 'aggregate', 'session_id' => session_id)
  [response.fetch('signature_hex')].pack('H*')
end

#create_session(message:, threshold:, scheme: 'CMP20-ECDSA-P256') ⇒ Object



161
162
163
164
165
166
167
168
169
# File 'lib/confium/tc/network_coordinator.rb', line 161

def create_session(message:, threshold:, scheme: 'CMP20-ECDSA-P256')
  response = call(
    'op' => 'create',
    'message_hex' => message.to_s.unpack1('H*'),
    'threshold' => threshold,
    'scheme' => scheme
  )
  response.fetch('session_id')
end

#submit_commitment(session_id, signer_id, commitment_bytes) ⇒ Object



171
172
173
174
175
176
177
178
# File 'lib/confium/tc/network_coordinator.rb', line 171

def submit_commitment(session_id, signer_id, commitment_bytes)
  call(
    'op' => 'commitment',
    'session_id' => session_id,
    'signer_id' => signer_id,
    'bytes_hex' => commitment_bytes.unpack1('H*')
  ).fetch('ok')
end

#submit_share(session_id, signer_id, share_bytes) ⇒ Object



180
181
182
183
184
185
186
187
# File 'lib/confium/tc/network_coordinator.rb', line 180

def submit_share(session_id, signer_id, share_bytes)
  call(
    'op' => 'share',
    'session_id' => session_id,
    'signer_id' => signer_id,
    'bytes_hex' => share_bytes.unpack1('H*')
  ).fetch('ok')
end