Method: ECIES::Crypt.public_key_from_hex
- Defined in:
- lib/ecies/crypt.rb
.public_key_from_hex(hex_string, ec_group = 'secp256k1') ⇒ OpenSSL::PKey::EC
Converts a hex-encoded public key to an OpenSSL::PKey::EC
.
161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/ecies/crypt.rb', line 161 def self.public_key_from_hex(hex_string, ec_group = 'secp256k1') ec_group = OpenSSL::PKey::EC::Group.new(ec_group) if ec_group.is_a?(String) sequence = OpenSSL::ASN1.Sequence([ OpenSSL::ASN1.Sequence([ OpenSSL::ASN1.ObjectId("id-ecPublicKey"), OpenSSL::ASN1::ObjectId(ec_group.curve_name), ]), OpenSSL::ASN1.BitString([hex_string].pack('H*')), ]) OpenSSL::PKey::EC.new(sequence.to_der) end |