Class: Sigma::HintsBag

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/sigma/transaction.rb

Overview

Collection of hints to be used by prover

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



180
181
182
# File 'lib/sigma/transaction.rb', line 180

def pointer
  @pointer
end

Class Method Details

.createHintsBag

Create an empty collection

Returns:



184
185
186
187
188
# File 'lib/sigma/transaction.rb', line 184

def self.create
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_hints_bag_empty(pointer)
  init(pointer)
end

.with_raw_pointer(pointer) ⇒ HintsBag

Note:

A user of sigma_rb generally does not need to call this function

Takes ownership of an existing HintsBag Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



194
195
196
# File 'lib/sigma/transaction.rb', line 194

def self.with_raw_pointer(pointer)
  init(pointer)
end

Instance Method Details

#add_commitment_hint(commitment_hint) ⇒ Object

Add to collection

Parameters:



200
201
202
# File 'lib/sigma/transaction.rb', line 200

def add_commitment_hint(commitment_hint)
  ergo_lib_hints_bag_add_commitment(self.pointer, commitment_hint.pointer)
end

#get_commitment_hint(index) ⇒ CommitmentHint?

Get item at specified index or return nil if no item exists

Parameters:

  • index (Integer)

Returns:



213
214
215
216
217
218
219
220
221
222
# File 'lib/sigma/transaction.rb', line 213

def get_commitment_hint(index)
  pointer = FFI::MemoryPointer.new(:pointer)
  res = ergo_lib_hints_bag_get(self.pointer, index, pointer)
  Util.check_error!(res[:error])
  if res[:is_some]
    Sigma::CommitmentHint.with_raw_pointer(pointer)
  else
    nil
  end
end

#lenInteger

Get length of collection

Returns:

  • (Integer)


206
207
208
# File 'lib/sigma/transaction.rb', line 206

def len
  ergo_lib_hints_bag_add_commitment_len(self.pointer)
end