Class: Ccrypto::Java::ED25519KeyBundle

Inherits:
Object
  • Object
show all
Includes:
ED25519KeyBundle, DataConversion, X25519KeyBundle, TR::CondUtils, TeLogger::TeLogHelper
Defined in:
lib/ccrypto/java/engines/ed25519_engine.rb

Overview

ED25519PrivateKey

Instance Method Summary collapse

Methods included from DataConversion

#from_b64, #from_b64_mime, #from_hex, included, #logger, #to_b64, #to_b64_mime, #to_bin, #to_hex, #to_java_bytes, #to_str

Constructor Details

#initialize(kp) ⇒ ED25519KeyBundle

Returns a new instance of ED25519KeyBundle.



102
103
104
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 102

def initialize(kp)
  @nativeKeypair = kp
end

Instance Method Details

#derive_dh_shared_secret(pubKey, &block) ⇒ Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 117

def derive_dh_shared_secret(pubKey, &block)
  
  JCEProvider.instance.add_bc_provider

  ka = javax.crypto.KeyAgreement.getInstance("X25519",JCEProvider::BCProv.name)
  ka.init(@nativeKeypair.getPrivate)
  ka.doPhase(pubKey, true)
  ka.generateSecret()

end

#private_keyObject



113
114
115
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 113

def private_key
  ED25519PrivateKey.new(@nativeKeypair.getPrivate) 
end

#public_keyObject



106
107
108
109
110
111
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 106

def public_key
  if @pubKey.nil?
    @pubKey = ED25519PublicKey.new(@nativeKeypair.getPublic)
  end
  @pubKey
end