Module: Sygna::PrivateInfo
- Defined in:
- lib/sygna/private_info.rb
Class Method Summary collapse
Class Method Details
.decode(data) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/sygna/private_info.rb', line 13 def self.decode(data) config = Sygna::Config.instance private_key = OpenSSL::PKey::EC.new(config.private_key) crypt.decrypt(private_key, [data].pack("H*")) end |
.encode(data, public_key_hex) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/sygna/private_info.rb', line 3 def self.encode(data, public_key_hex) group = OpenSSL::PKey::EC::Group.new('secp256k1') key = OpenSSL::PKey::EC.new(group) public_key_bn = OpenSSL::BN.new(public_key_hex, 16) public_key = OpenSSL::PKey::EC::Point.new(group, public_key_bn) key.public_key = public_key crypt.encrypt(key, data.to_json).unpack('H*').first end |