Class: Sigma::NipopowProof

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pointerObject

Returns the value of attribute pointer.



15
16
17
# File 'lib/sigma/nipopow.rb', line 15

def pointer
  @pointer
end

Class Method Details

.with_json(json) ⇒ NipopowProof

Parse NiPoPow from json

Parameters:

  • json (String)

Returns:



20
21
22
23
24
25
# File 'lib/sigma/nipopow.rb', line 20

def self.with_json(json)
  pointer = FFI::MemoryPointer.new(:pointer)
  error = ergo_lib_nipopow_proof_from_json(json, pointer)
  Util.check_error!(error)
  init(pointer)
end

Instance Method Details

#is_better_than(other_proof) ⇒ bool

Implementation of the ≥ algorithm from [‘KMZ17`], see Algorithm 4

Returns:

  • (bool)

See Also:



30
31
32
33
34
35
# File 'lib/sigma/nipopow.rb', line 30

def is_better_than(other_proof)
  pointer = FFI::MemoryPointer.new(:pointer)
  res = ergo_lib_nipopow_proof_is_better_than(self.pointer, other_proof.pointer)
  Util.check_error!(res[:error])
  res[:value]
end

#to_jsonString

JSON representation

Returns:

  • (String)


39
40
41
42
43
44
45
46
47
# File 'lib/sigma/nipopow.rb', line 39

def to_json
  s_ptr = FFI::MemoryPointer.new(:pointer, 1)
  error = ergo_lib_nipopow_proof_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