3 library(crypto): Cryptography and authentication library
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog SSL Interface
        • library(crypto): Cryptography and authentication library
          • Introduction
          • Design principle: Secure default algorithms
          • Representing binary data
          • Cryptographically secure random numbers
          • Hashes
          • Digital signatures
          • Asymmetric encryption and decryption
          • Symmetric encryption and decryption
          • Number theory
          • Elliptic curves
            • crypto_name_curve/2
            • crypto_curve_order/2
            • crypto_curve_generator/2
            • crypto_curve_scalar_mult/4
          • Example: Establishing a shared secret

3.10 Elliptic curves

This library provides functionality for reasoning over elliptic curves. Elliptic curves are represented as opaque objects. You acquire a handle for an elliptic curve via crypto_name_curve/2.

A point on a curve is represented by the Prolog term point(X, Y), where X and Y are integers that represent the point's affine coordinates.

The following predicates are provided for reasoning over elliptic curves:

[det]crypto_name_curve(+Name, -Curve)
Obtain a handle for a named elliptic curve. Name is an atom, and Curve is unified with an opaque object that represents the curve. Currently, only elliptic curves over prime fields are supported. Examples of such curves are prime256v1 and secp256k1.

If you have OpenSSL installed, you can get a list of supported curves via:

$ openssl ecparam -list_curves
[det]crypto_curve_order(+Curve, -Order)
Obtain the order of an elliptic curve. Order is an integer, denoting how many points on the curve can be reached by multiplying the curve's generator with a scalar.
[det]crypto_curve_generator(+Curve, -Point)
Point is the generator of the elliptic curve Curve.
[det]crypto_curve_scalar_mult(+Curve, +N, +Point, -R)
R is the result of N times Point on the elliptic curve Curve. N must be an integer, and Point must be a point on the curve.