Class: MlDsa::ParameterSet

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/ml_dsa/parameter_set.rb

Overview

Encapsulates a concrete ML-DSA parameter set (44, 65, or 87).

Obtain instances via the ML_DSA_44, ML_DSA_65, ML_DSA_87 constants; do not call new directly. Supports Comparable ordering by security level: ML_DSA_44 < ML_DSA_65 < ML_DSA_87.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, code, security_level, pk, sk, sig) ⇒ ParameterSet

Returns a new instance of ParameterSet.



25
26
27
28
29
30
31
32
33
# File 'lib/ml_dsa/parameter_set.rb', line 25

def initialize(name, code, security_level, pk, sk, sig)
  @name = name.freeze
  @code = code
  @security_level = security_level
  @public_key_bytes = pk
  @secret_key_bytes = sk
  @signature_bytes = sig
  freeze
end

Instance Attribute Details

#codeInteger (readonly)

Returns numeric code (44, 65, or 87).

Returns:

  • (Integer)

    numeric code (44, 65, or 87)



15
16
17
# File 'lib/ml_dsa/parameter_set.rb', line 15

def code
  @code
end

#nameString (readonly)

Returns human-readable name, e.g. "ML-DSA-44".

Returns:

  • (String)

    human-readable name, e.g. "ML-DSA-44"



13
14
15
# File 'lib/ml_dsa/parameter_set.rb', line 13

def name
  @name
end

#public_key_bytesInteger (readonly)

Returns public key size in bytes.

Returns:

  • (Integer)

    public key size in bytes



19
20
21
# File 'lib/ml_dsa/parameter_set.rb', line 19

def public_key_bytes
  @public_key_bytes
end

#secret_key_bytesInteger (readonly)

Returns secret key size in bytes.

Returns:

  • (Integer)

    secret key size in bytes



21
22
23
# File 'lib/ml_dsa/parameter_set.rb', line 21

def secret_key_bytes
  @secret_key_bytes
end

#security_levelInteger (readonly)

Returns NIST security level (2, 3, or 5).

Returns:

  • (Integer)

    NIST security level (2, 3, or 5)



17
18
19
# File 'lib/ml_dsa/parameter_set.rb', line 17

def security_level
  @security_level
end

#signature_bytesInteger (readonly)

Returns signature size in bytes.

Returns:

  • (Integer)

    signature size in bytes



23
24
25
# File 'lib/ml_dsa/parameter_set.rb', line 23

def signature_bytes
  @signature_bytes
end

Instance Method Details

#<=>(other) ⇒ Object



35
36
37
38
# File 'lib/ml_dsa/parameter_set.rb', line 35

def <=>(other)
  return nil unless other.is_a?(ParameterSet)
  @security_level <=> other.security_level
end

#inspectObject



44
45
46
# File 'lib/ml_dsa/parameter_set.rb', line 44

def inspect
  "#<MlDsa::ParameterSet #{@name}>"
end

#to_sObject



40
41
42
# File 'lib/ml_dsa/parameter_set.rb', line 40

def to_s
  @name
end