Open
Description
It is possible using a little magic to create a point with a raw x and y:
def self.from_compressed_point(group, x, is_even)
x_value = x.to_s(2).rjust(32, "\x00")
prefix = is_even ? "\x02" : "\x03"
encoded = OpenSSL::BN.new [ prefix, x_value ].join, 2
OpenSSL::PKey::EC::Point.new(group, encoded)
end
One can similarly use some magic to get uncompressed points and turn them into two OpenSSL::BN instances
It would be better if we supported this without using compressed point form magic, like so (RBS signature with hypothetical overload):
class OpenSSL::PKey::EC::Point
# Since the OpenSSL operation returns both
def affine_coordinates -> [ OpenSSL::BN, OpenSSL::BN ]
# Convenance methods for above
attr_reader :x, :y -> OpenSSL::BN
# Choice 1 - Using Bool for Y
def initialize : (group: OpenSSL::PKey::EC::Group, x: OpenSSL::BN, even: Boolean) -> OpenSSL::PKey::EC::Point
# Choice 2 - Using a symbol for Y
def initialize : (group: OpenSSL::PKey::EC::Group, x: OpenSSL::BN, y:[ :even, :odd ]) -> OpenSSL::PKey::EC::Point
# Using X and Y directly
def initialize : (group: OpenSSL::PKey::EC::Group, x: OpenSSL::BN, y: OpenSSL::BN) -> OpenSSL::PKey::EC::Point
end
I've intentionally omitted mutating the X and Y of a point after creation. Because all of these have a different aridity they will not conflict. Similarly adding Jacobian would create an aridity == 4.
The big question is for choice 1 or 2 when creating an X and which Y value.
Metadata
Metadata
Assignees
Labels
No labels