Class: MlDsa::KeyPair

Inherits:
Object
  • Object
show all
Defined in:
lib/ml_dsa/key_pair.rb

Overview

Holds a matched public/secret key pair returned by keygen. Supports destructuring: pk, sk = MlDsa.keygen(...).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(public_key, secret_key) ⇒ KeyPair

Returns a new instance of KeyPair.



12
13
14
15
16
# File 'lib/ml_dsa/key_pair.rb', line 12

def initialize(public_key, secret_key)
  @public_key = public_key
  @secret_key = secret_key
  freeze
end

Instance Attribute Details

#public_key ⇒ PublicKey (readonly)

Returns:



8
9
10
# File 'lib/ml_dsa/key_pair.rb', line 8

def public_key
  @public_key
end

#secret_key ⇒ SecretKey (readonly)

Returns:



10
11
12
# File 'lib/ml_dsa/key_pair.rb', line 10

def secret_key
  @secret_key
end

Instance Method Details

#inspect ⇒ String Also known as: to_s

Returns:

  • (String)


33
34
35
# File 'lib/ml_dsa/key_pair.rb', line 33

def inspect
  "#<MlDsa::KeyPair #{param_set.name}>"
end

#param_set ⇒ ParameterSet

Returns:



28
29
30
# File 'lib/ml_dsa/key_pair.rb', line 28

def param_set
  public_key.param_set
end

#to_ary ⇒ Array(PublicKey, SecretKey) Also known as: to_a, deconstruct

Support destructuring: pk, sk = keygen(...).

Returns:



20
21
22
# File 'lib/ml_dsa/key_pair.rb', line 20

def to_ary
  [public_key, secret_key]
end