class PedicelPay::TokenHeader
Constants
- Error
Attributes
data_hash[RW]
ephemeral_pubkey[RW]
pubkey_hash[RW]
transaction_id[RW]
Public Class Methods
new(data_hash: nil, ephemeral_pubkey: nil, pubkey_hash: nil, transaction_id: nil)
click to toggle source
# File lib/pedicel-pay/token_header.rb, line 11 def initialize(data_hash: nil, ephemeral_pubkey: nil, pubkey_hash: nil, transaction_id: nil) @data_hash, @ephemeral_pubkey, @pubkey_hash, @transaction_id = \ data_hash, ephemeral_pubkey, pubkey_hash, transaction_id end
Public Instance Methods
sample()
click to toggle source
# File lib/pedicel-pay/token_header.rb, line 29 def sample self.transaction_id ||= PedicelPay.config[:random].bytes(32) self end
to_hash()
click to toggle source
# File lib/pedicel-pay/token_header.rb, line 16 def to_hash raise Error, 'missing ephemeral_pubkey' unless ephemeral_pubkey result = { ephemeralPublicKey: Base64.strict_encode64(Helper.ec_key_to_pkey_public_key(ephemeral_pubkey).to_der), publicKeyHash: pubkey_hash, transactionId: Helper.bytestring_to_hex(transaction_id), } result.merge!(applicationData: data_hash) if data_hash result end