Class: Ccrypto::Java::CrystalKyberPrivateKey

Inherits:
PrivateKey
  • Object
show all
Defined in:
lib/ccrypto/java/engines/crystal_kyber_engine.rb

Overview

class CrystalKyberPublicKey

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kp, param) ⇒ CrystalKyberPrivateKey

Returns a new instance of CrystalKyberPrivateKey.



87
88
89
90
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 87

def initialize(kp, param)
  super(kp) 
  @keyParam = param
end

Class Method Details

.to_key(params = {}) ⇒ Object



101
102
103
104
105
106
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 101

def self.to_key(params = {})
  param = params[:param]
  bcParam = CrystalKyberEngine.find_config(param)
  bcPrivKey = org.bouncycastle.pqc.crypto.crystals.kyber::KyberPrivateKeyParameters.new(bcParam.provider_config[:params], params[:s].to_java_bytes, params[:hpk].to_java_bytes, params[:nonce].to_java_bytes, params[:t].to_java_bytes, params[:rho].to_java_bytes)
  CrystalKyberPrivateKey.new(bcPrivKey, param)
end

Instance Method Details

#equals?(privKey) ⇒ Boolean Also known as: key_equals?

Returns:

  • (Boolean)


108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 108

def equals?(privKey)
  if not @native_privKey.nil?
    case privKey
    when CrystalKyberPrivateKey
      @native_privKey.encoded == privKey.to_bin
    else
      logger.warn "Unmatched private key : (native) #{@native_privKey} vs. (subject) #{privKey}"
      false
    end
  else
    logger.warn "CrystalKyberPrivateKey equals? returned false because native_privKey is nil"
    false
  end
end

#key_paramObject Also known as: param



92
93
94
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 92

def key_param
  @keyParam
end

#to_binObject



97
98
99
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 97

def to_bin
  @native_privKey.encoded
end