Class: Ccrypto::Java::CrystalKyberPublicKey
- Inherits:
-
CrystalKyberPublicKey
- Object
- CrystalKyberPublicKey
- Ccrypto::Java::CrystalKyberPublicKey
- Includes:
- DataConversion, TR::CondUtils
- Defined in:
- lib/ccrypto/java/engines/crystal_kyber_engine.rb
Class Method Summary collapse
-
.to_key(params, bin) ⇒ Object
Public API.
Instance Method Summary collapse
-
#encoded ⇒ Object
Public API.
-
#initialize(kp, param) ⇒ CrystalKyberPublicKey
constructor
A new instance of CrystalKyberPublicKey.
- #key_equals?(pubKey) ⇒ Boolean (also: #equals?)
-
#key_param ⇒ Object
(also: #param)
Public API.
-
#to_bin ⇒ Object
Public API.
- #to_s ⇒ Object
Methods included from DataConversion
#from_b64, #from_b64_mime, #from_hex, included, #logger, #to_b64, #to_b64_mime, #to_hex, #to_java_bytes, #to_str
Constructor Details
#initialize(kp, param) ⇒ CrystalKyberPublicKey
Returns a new instance of CrystalKyberPublicKey.
19 20 21 22 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 19 def initialize(kp, param) super(kp) @keyParam = param end |
Class Method Details
.to_key(params, bin) ⇒ Object
Public API
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 45 def self.to_key(params, bin) bin = to_java_bytes(bin) if not bin.is_a?(::Java::byte[]) case params when Ccrypto::CrystalKyberConfig pa = params.provider_config[:params] when Symbol pa = CrystalKyberEngine.supported_configs[params] if not_empty?(pa) pa = pa.provider_config[:params] end else raise CrystalKyberEngineError, "Unsupported params type '#{params.class}'" end raise CrystalKyberEngineError, "Unknown param '#{param}'" if is_empty?(pa) pubKey = KyberPublicKeyParameters.new(pa, bin) CrystalKyberPublicKey.new(pubKey, params) end |
Instance Method Details
#encoded ⇒ Object
Public API
36 37 38 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 36 def encoded to_bin end |
#key_equals?(pubKey) ⇒ Boolean Also known as: equals?
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 66 def key_equals?(pubKey) if not @native_pubKey.nil? case pubKey when CrystalKyberPublicKey @native_pubKey.encoded == pubKey.to_bin else logger.warn "Unmatched public key : (native) #{@native_pubKey} vs. (subject) #{pubKey}" false end else logger.warn "CrystalKyberPublicKey equals? returned false because native_pubKey is nil" false end end |
#key_param ⇒ Object Also known as: param
Public API
25 26 27 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 25 def key_param @keyParam end |
#to_bin ⇒ Object
Public API
31 32 33 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 31 def to_bin @native_pubKey.encoded end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/ccrypto/java/engines/crystal_kyber_engine.rb', line 40 def to_s "Crystal Kyber - #{@keyParam} : #{native.inspect}" end |