Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rbnacl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ class BadAuthenticatorError < CryptoError; end
require "rbnacl/signatures/ed25519/signing_key"
require "rbnacl/signatures/ed25519/verify_key"

# Group Elements: Curve25519
# Group Elements: Curve25519, Ed25519
require "rbnacl/group_elements/curve25519"
require "rbnacl/group_elements/ed25519"

# One-time Authentication: Poly1305
require "rbnacl/one_time_auths/poly1305"
Expand Down
37 changes: 37 additions & 0 deletions lib/rbnacl/group_elements/ed25519.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# encoding: binary
# frozen_string_literal: true

module RbNaCl
module GroupElements
# Points on the Ed25519 elliptic curve
#
# This class provides low-level operations on Ed25519 curve points,
# including point validation.
class Ed25519
extend Sodium

sodium_type :core
sodium_primitive :ed25519

sodium_function_with_return_code :core_ed25519_is_valid_point,
:crypto_core_ed25519_is_valid_point,
%i[pointer]

# Number of bytes in an Ed25519 point
BYTES = 32

# Check if a point is valid on the Ed25519 curve
#
# @param point [String] The point to validate (32 bytes)
#
# @raise [LengthError] if the point is not 32 bytes
#
# @return [Boolean] true if the point is valid, false otherwise
def self.valid_point?(point)
point = point.to_str
Util.check_length(point, BYTES, "point")
core_ed25519_is_valid_point(point).zero?
end
end
end
end
Loading