Module: Solace::Utils::Curve25519Dalek
- Extended by:
- FFI::Library
- Defined in:
- lib/solace/utils/curve25519_dalek.rb
Overview
Module for interacting with the Curve25519 Dalek library
This module provides a wrapper around the Curve25519 Dalek library, which is a pure-Rust implementation of the Curve25519 elliptic curve. It uses FFI to interface with the native rust library when checking if a point is on the curve.
Constant Summary collapse
- LIB_PATH =
!@attribute LIB_PATH
File.(libfile, __dir__)
Class Method Summary collapse
-
.on_curve?(bytes) ⇒ Boolean
Checks if a point is on the curve.
Class Method Details
.on_curve?(bytes) ⇒ Boolean
Checks if a point is on the curve
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/solace/utils/curve25519_dalek.rb', line 48 def self.on_curve?(bytes) raise ArgumentError, 'Must be 32 bytes' unless bytes.bytesize == 32 FFI::MemoryPointer.new(:uchar, 32) do |ptr| ptr.put_bytes(0, bytes) result = Curve25519Dalek.is_on_curve(ptr) case result when 1 then return true when 0 then return false else raise "Unexpected return code from native is_on_curve: #{result}" end end end |