Module: PQCrypto::HybridKEM

Defined in:
lib/pq_crypto/hybrid_kem.rb

Defined Under Namespace

Classes: EncapsulationResult, Keypair, PublicKey, SecretKey

Constant Summary collapse

CANONICAL_ALGORITHM =
:ml_kem_768_x25519_xwing
DETAILS =
AlgorithmRegistry.details_for_family(:ml_kem_hybrid).freeze

Class Method Summary collapse

Class Method Details

.details(algorithm) ⇒ Object



44
45
46
# File 'lib/pq_crypto/hybrid_kem.rb', line 44

def details(algorithm)
  DETAILS.fetch(resolve_algorithm!(algorithm)).dup
end

.generate(algorithm = CANONICAL_ALGORITHM) ⇒ Object



10
11
12
13
14
# File 'lib/pq_crypto/hybrid_kem.rb', line 10

def generate(algorithm = CANONICAL_ALGORITHM)
  algorithm = resolve_algorithm!(algorithm)
  public_key, secret_key = PQCrypto.__send__(:native_hybrid_kem_keypair)
  Keypair.new(PublicKey.new(algorithm, public_key), SecretKey.new(algorithm, secret_key))
end

.public_key_from_bytes(algorithm, bytes) ⇒ Object



16
17
18
# File 'lib/pq_crypto/hybrid_kem.rb', line 16

def public_key_from_bytes(algorithm, bytes)
  PublicKey.new(resolve_algorithm!(algorithm), bytes)
end

.public_key_from_pqc_container_der(der, algorithm = nil) ⇒ Object



24
25
26
27
# File 'lib/pq_crypto/hybrid_kem.rb', line 24

def public_key_from_pqc_container_der(der, algorithm = nil)
  resolved_algorithm, bytes = Serialization.public_key_from_pqc_container_der(algorithm, der)
  PublicKey.new(resolve_algorithm!(resolved_algorithm), bytes)
end

.public_key_from_pqc_container_pem(pem, algorithm = nil) ⇒ Object



29
30
31
32
# File 'lib/pq_crypto/hybrid_kem.rb', line 29

def public_key_from_pqc_container_pem(pem, algorithm = nil)
  resolved_algorithm, bytes = Serialization.public_key_from_pqc_container_pem(algorithm, pem)
  PublicKey.new(resolve_algorithm!(resolved_algorithm), bytes)
end

.secret_key_from_bytes(algorithm, bytes) ⇒ Object



20
21
22
# File 'lib/pq_crypto/hybrid_kem.rb', line 20

def secret_key_from_bytes(algorithm, bytes)
  SecretKey.new(resolve_algorithm!(algorithm), bytes)
end

.secret_key_from_pqc_container_der(der, algorithm = nil) ⇒ Object



34
35
36
37
# File 'lib/pq_crypto/hybrid_kem.rb', line 34

def secret_key_from_pqc_container_der(der, algorithm = nil)
  resolved_algorithm, bytes = Serialization.secret_key_from_pqc_container_der(algorithm, der)
  SecretKey.new(resolve_algorithm!(resolved_algorithm), bytes)
end

.secret_key_from_pqc_container_pem(pem, algorithm = nil) ⇒ Object



39
40
41
42
# File 'lib/pq_crypto/hybrid_kem.rb', line 39

def secret_key_from_pqc_container_pem(pem, algorithm = nil)
  resolved_algorithm, bytes = Serialization.secret_key_from_pqc_container_pem(algorithm, pem)
  SecretKey.new(resolve_algorithm!(resolved_algorithm), bytes)
end

.supportedObject



48
49
50
# File 'lib/pq_crypto/hybrid_kem.rb', line 48

def supported
  DETAILS.keys.dup
end