Class: Longfellow::ZkSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/longfellow/zk_spec.rb

Overview

Immutable view over a ‘ZkSpecStruct` entry owned by the native library.

A ZK specification identifies a circuit format/interpretation that a prover and verifier must agree on. Instances are obtained from zk_specs or find_zk_spec; they wrap a pointer into the library’s static ‘kZkSpecs` storage and are passed back into the prover, verifier and circuit generator.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(struct) ⇒ ZkSpec

Returns a new instance of ZkSpec.

Parameters:



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/longfellow/zk_spec.rb', line 16

def initialize(struct)
  @struct = struct
  system_ptr = struct[:system]
  @system = system_ptr.null? ? nil : system_ptr.read_string
  # circuit_hash is a NUL-terminated 64-char hex string in a [65]char field.
  @circuit_hash = struct[:circuit_hash].to_ptr.read_string
  @num_attributes = struct[:num_attributes]
  @version = struct[:version]
  @block_enc_hash = struct[:block_enc_hash]
  @block_enc_sig = struct[:block_enc_sig]
end

Instance Attribute Details

#block_enc_hashObject (readonly)

Returns the value of attribute block_enc_hash.



12
13
14
# File 'lib/longfellow/zk_spec.rb', line 12

def block_enc_hash
  @block_enc_hash
end

#block_enc_sigObject (readonly)

Returns the value of attribute block_enc_sig.



12
13
14
# File 'lib/longfellow/zk_spec.rb', line 12

def block_enc_sig
  @block_enc_sig
end

#circuit_hashObject (readonly)

Returns the value of attribute circuit_hash.



12
13
14
# File 'lib/longfellow/zk_spec.rb', line 12

def circuit_hash
  @circuit_hash
end

#num_attributesObject (readonly)

Returns the value of attribute num_attributes.



12
13
14
# File 'lib/longfellow/zk_spec.rb', line 12

def num_attributes
  @num_attributes
end

#systemObject (readonly)

Returns the value of attribute system.



12
13
14
# File 'lib/longfellow/zk_spec.rb', line 12

def system
  @system
end

#versionObject (readonly)

Returns the value of attribute version.



12
13
14
# File 'lib/longfellow/zk_spec.rb', line 12

def version
  @version
end

Instance Method Details

#to_ptrFFI::Pointer

Returns pointer to the underlying ZkSpecStruct, for passing into native calls.

Returns:

  • (FFI::Pointer)

    pointer to the underlying ZkSpecStruct, for passing into native calls.



30
31
32
# File 'lib/longfellow/zk_spec.rb', line 30

def to_ptr
  @struct.to_ptr
end

#to_sObject Also known as: inspect



34
35
36
37
# File 'lib/longfellow/zk_spec.rb', line 34

def to_s
  "#<Longfellow::ZkSpec #{@system} v#{@version} " \
    "attrs=#{@num_attributes} hash=#{@circuit_hash}>"
end