`OpenSSL::PKey::EC::Point` should be able to get and set affine coordinates

Đang mở
#433 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@rickmark đang làm issue này rồi.

Từ ngày 4/4/2021.

  • #435 của @rickmark — đang mở

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
c, ruby
Lĩnh vực
cryptography

Hướng nghiên cứu

Không có tệp hoặc bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng việc xem xét API OpenSSL::PKey::EC::Point hiện có và các ví dụ về điểm nén và không nén trong issue. Thống nhất với các maintainer về thiết kế constructor và cách truy cập tọa độ được đề xuất, sau đó định nghĩa các bài kiểm thử cho thấy việc lấy tọa độ affine và xây dựng điểm hoạt động như dự kiến.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C
Star
276
Fork
208
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/openssl

Tất cả issue của ruby/openssl

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.