Class: Confium::TC::Session

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scheme:, threshold:, num_parties:, party_index:) ⇒ Session

Returns a new instance of Session.



24
25
26
27
28
29
30
31
32
# File 'lib/confium/tc/session.rb', line 24

def initialize(scheme:, threshold:, num_parties:, party_index:)
  @scheme = scheme
  @threshold = threshold
  @num_parties = num_parties
  @party_index = party_index
  @state = :pending
  @local_share = nil
  @result = nil
end

Instance Attribute Details

#num_partiesObject (readonly)

Returns the value of attribute num_parties.



22
23
24
# File 'lib/confium/tc/session.rb', line 22

def num_parties
  @num_parties
end

#party_indexObject (readonly)

Returns the value of attribute party_index.



22
23
24
# File 'lib/confium/tc/session.rb', line 22

def party_index
  @party_index
end

#schemeObject (readonly)

Returns the value of attribute scheme.



22
23
24
# File 'lib/confium/tc/session.rb', line 22

def scheme
  @scheme
end

#stateObject (readonly)

Returns the value of attribute state.



22
23
24
# File 'lib/confium/tc/session.rb', line 22

def state
  @state
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



22
23
24
# File 'lib/confium/tc/session.rb', line 22

def threshold
  @threshold
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/confium/tc/session.rb', line 39

def complete?
  @state == :completed
end

#resultObject



43
44
45
46
# File 'lib/confium/tc/session.rb', line 43

def result
  raise "Session not complete" unless complete?
  @result
end

#set_local_share(share_bytes) ⇒ Object

Raises:

  • (ArgumentError)


34
35
36
37
# File 'lib/confium/tc/session.rb', line 34

def set_local_share(share_bytes)
  raise ArgumentError, "share must be a String" unless share_bytes.is_a?(String)
  @local_share = share_bytes
end