`OpenSSL::PKey::EC::Point` should be able to get and set affine coordinates
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 276
- Forks
- 200
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 7
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by reviewing the existing OpenSSL::PKey::EC::Point API and the compressed and uncompressed point examples in the issue. Resolve the proposed constructor and coordinate-access design with maintainers, then define tests showing affine-coordinate retrieval and point construction work as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, ruby
- Domain
- cryptography
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100