Class: Sigma::ProverResult

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

Overview

Proof of correctness for transaction spending

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



134
135
136
# File 'lib/sigma/input.rb', line 134

def pointer
  @pointer
end

Class Method Details

.with_raw_pointer(pointer) ⇒ ProverResult

Note:

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

Takes ownership of an existing ProverResult Pointer.

Parameters:

  • pointer (FFI::MemoryPointer)

Returns:



169
170
171
# File 'lib/sigma/input.rb', line 169

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

Instance Method Details

#get_context_extensionContextExtension

Get context extension

Returns:



147
148
149
150
151
# File 'lib/sigma/input.rb', line 147

def get_context_extension
  pointer = FFI::MemoryPointer.new(:pointer)
  ergo_lib_prover_result_context_extension(self.pointer, pointer)
  Sigma::ContextExtension.with_raw_pointer(pointer)
end

#to_bytesArray<uint8>

Get proof bytes

Returns:

  • (Array<uint8>)

    Array of 8-bit integers [0-255]



138
139
140
141
142
143
# File 'lib/sigma/input.rb', line 138

def to_bytes
  proof_len = ergo_lib_prover_result_proof_len(self.pointer)
  b_ptr = FFI::MemoryPointer.new(:uint8, proof_len)
  ergo_lib_prover_result_proof(self.pointer, b_ptr)
  b_ptr.get_array_of_uint8(0, proof_len) 
end

#to_jsonString

JSON representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)

Returns:

  • (String)


155
156
157
158
159
160
161
162
163
# File 'lib/sigma/input.rb', line 155

def to_json
  s_ptr = FFI::MemoryPointer.new(:pointer, 1)
  error = ergo_lib_prover_result_to_json(self.pointer, s_ptr)
  Util.check_error!(error)
  s_ptr = s_ptr.read_pointer()
  str = s_ptr.read_string().force_encoding('UTF-8')
  Util.ergo_lib_delete_string(s_ptr)
  str
end