Class: Longfellow::ZkSpec
- Inherits:
-
Object
- Object
- Longfellow::ZkSpec
- 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
-
#block_enc_hash ⇒ Object
readonly
Returns the value of attribute block_enc_hash.
-
#block_enc_sig ⇒ Object
readonly
Returns the value of attribute block_enc_sig.
-
#circuit_hash ⇒ Object
readonly
Returns the value of attribute circuit_hash.
-
#num_attributes ⇒ Object
readonly
Returns the value of attribute num_attributes.
-
#system ⇒ Object
readonly
Returns the value of attribute system.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(struct) ⇒ ZkSpec
constructor
A new instance of ZkSpec.
-
#to_ptr ⇒ FFI::Pointer
Pointer to the underlying ZkSpecStruct, for passing into native calls.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(struct) ⇒ ZkSpec
Returns a new instance of ZkSpec.
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_hash ⇒ Object (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_sig ⇒ Object (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_hash ⇒ Object (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_attributes ⇒ Object (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 |
#system ⇒ Object (readonly)
Returns the value of attribute system.
12 13 14 |
# File 'lib/longfellow/zk_spec.rb', line 12 def system @system end |
#version ⇒ Object (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_ptr ⇒ FFI::Pointer
Returns 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_s ⇒ Object 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 |