Class: GooglePayRuby::EcV2DecryptionStrategy
- Inherits:
-
Object
- Object
- GooglePayRuby::EcV2DecryptionStrategy
- Defined in:
- lib/google_pay_ruby/ec_v2_decryption_strategy.rb
Instance Method Summary collapse
- #decrypt(signed_message) ⇒ Object
-
#initialize(private_key_pem) ⇒ EcV2DecryptionStrategy
constructor
A new instance of EcV2DecryptionStrategy.
Constructor Details
#initialize(private_key_pem) ⇒ EcV2DecryptionStrategy
Returns a new instance of EcV2DecryptionStrategy.
9 10 11 |
# File 'lib/google_pay_ruby/ec_v2_decryption_strategy.rb', line 9 def initialize(private_key_pem) @private_key = OpenSSL::PKey::EC.new(private_key_pem) end |
Instance Method Details
#decrypt(signed_message) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/google_pay_ruby/ec_v2_decryption_strategy.rb', line 13 def decrypt() = JSON.parse() ephemeral_public_key = ['ephemeralPublicKey'] = ['encryptedMessage'] tag = ['tag'] shared_key = get_shared_key(ephemeral_public_key) derived_key = get_derived_key(ephemeral_public_key, shared_key) symmetric_encryption_key = derived_key[0...64] mac_key = derived_key[64..-1] (mac_key, tag, ) = (, symmetric_encryption_key) JSON.parse() end |