Class: Secp256k1::BaseKey

Inherits:
Object
  • Object
show all
Defined in:
lib/secp256k1/key.rb

Direct Known Subclasses

PrivateKey, PublicKey

Instance Method Summary collapse

Constructor Details

#initialize(ctx, flags) ⇒ BaseKey

Returns a new instance of BaseKey.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/secp256k1/key.rb', line 8

def initialize(ctx, flags)
  @destroy = false

  unless ctx
    raise ArgumentError, "invalid flags" unless [NO_FLAGS, FLAG_SIGN, FLAG_VERIFY, ALL_FLAGS].include?(flags)
    ctx = FFI::AutoPointer.new C.secp256k1_context_create(flags), C.method(:secp256k1_context_destroy)
    @destroy = true
  end

  @flags = flags
  @ctx = ctx
end