Module: Solace::Utils::Curve25519Dalek
- Extended by:
- FFI::Library
- Defined in:
- lib/solace/utils/curve25519_dalek.rb
Constant Summary collapse
- LIB_PATH =
The path to the native library
File.(libfile, __dir__)
Class Method Summary collapse
-
.on_curve?(bytes) ⇒ Boolean
Checks if a point is on the curve.
Instance Method Summary collapse
-
#is_on_curve ⇒ FFI::Function
Attach the native function.
Class Method Details
.on_curve?(bytes) ⇒ Boolean
Checks if a point is on the curve
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/solace/utils/curve25519_dalek.rb', line 43 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 |
Instance Method Details
#is_on_curve ⇒ FFI::Function
Attach the native function
36 |
# File 'lib/solace/utils/curve25519_dalek.rb', line 36 attach_function :is_on_curve, [:pointer], :int |