Class: Ccrypto::Ruby::X25519KeyBundle
- Inherits:
-
Object
- Object
- Ccrypto::Ruby::X25519KeyBundle
- Includes:
- X25519KeyBundle, TR::CondUtils, TeLogger::TeLogHelper
- Defined in:
- lib/ccrypto/ruby/engines/x25519_engine.rb
Instance Method Summary collapse
- #derive_dh_shared_secret(pubKey) ⇒ Object
-
#initialize(kp) ⇒ X25519KeyBundle
constructor
A new instance of X25519KeyBundle.
- #private_key ⇒ Object
- #public_key ⇒ Object
Constructor Details
#initialize(kp) ⇒ X25519KeyBundle
Returns a new instance of X25519KeyBundle.
19 20 21 |
# File 'lib/ccrypto/ruby/engines/x25519_engine.rb', line 19 def initialize(kp) @nativeKeypair = kp end |
Instance Method Details
#derive_dh_shared_secret(pubKey) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ccrypto/ruby/engines/x25519_engine.rb', line 34 def derive_dh_shared_secret(pubKey) case pubKey when Ccrypto::X25519PublicKey uPubKey = pubKey.native_pubKey else raise KeypairEngineException, "Unknown X25519 public key type '#{pubKey.class}'" end @nativeKeypair.diffie_hellman(uPubKey).to_bytes end |
#private_key ⇒ Object
30 31 32 |
# File 'lib/ccrypto/ruby/engines/x25519_engine.rb', line 30 def private_key X25519PrivateKey.new(@nativeKeypair) end |
#public_key ⇒ Object
23 24 25 26 27 28 |
# File 'lib/ccrypto/ruby/engines/x25519_engine.rb', line 23 def public_key if @pubKey.nil? @pubKey = X25519PublicKey.new(@nativeKeypair.public_key) end @pubKey end |