From ae288c2bdc6527cf5603e2e26688c8c5f987863f Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sat, 29 Aug 2026 22:32:36 +0200 Subject: [PATCH] Build EC public point from private scalar --- lib/cose/key/ec2.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/cose/key/ec2.rb b/lib/cose/key/ec2.rb index 03372b8..ec75050 100644 --- a/lib/cose/key/ec2.rb +++ b/lib/cose/key/ec2.rb @@ -70,8 +70,13 @@ def map def to_pkey if curve group = OpenSSL::PKey::EC::Group.new(curve.pkey_name) - public_key_bn = OpenSSL::BN.new("\x04" + pad_coordinate(group, x) + pad_coordinate(group, y), 2) - public_key_point = OpenSSL::PKey::EC::Point.new(group, public_key_bn) + public_key_point = if x && y + coordinates = pad_coordinate(group, x) + pad_coordinate(group, y) + public_key_bn = OpenSSL::BN.new("\x04" + coordinates, 2) + OpenSSL::PKey::EC::Point.new(group, public_key_bn) + else + group.generator.mul(OpenSSL::BN.new(d, 2)) + end # RFC5480 SubjectPublicKeyInfo asn1 = OpenSSL::ASN1::Sequence(