Class: Sigma::ProverResult
- Inherits:
-
Object
- Object
- Sigma::ProverResult
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/input.rb
Overview
Proof of correctness for transaction spending
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.with_raw_pointer(pointer) ⇒ ProverResult
Takes ownership of an existing ProverResult Pointer.
Instance Method Summary collapse
-
#get_context_extension ⇒ ContextExtension
Get context extension.
-
#to_bytes ⇒ Array<uint8>
Get proof bytes.
-
#to_json ⇒ String
JSON representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers).
Instance Attribute Details
#pointer ⇒ Object
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.
169 170 171 |
# File 'lib/sigma/input.rb', line 169 def self.with_raw_pointer(pointer) init(pointer) end |
Instance Method Details
#get_context_extension ⇒ ContextExtension
Get context extension
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_bytes ⇒ Array<uint8>
Get proof bytes
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_json ⇒ String
JSON representation as text (compatible with Ergo Node/Explorer API, numbers are encoded as numbers)
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 |