HORIZON HASKELLDocslts/ghc-10.0.xaa25b892026-10-10Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · aa25b89 · 2026-10-10

Modulecrypton-2.1.7Haskell2010

Crypto.PubKey.ECC.DH

Elliptic curve Diffie Hellman

  • 4 types
  • 4 values
  • Packagecrypton-2.1.7
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause AND MIT AND ISC
  • SourceDH.hs
datadata Curve
#

Define either a binary curve or a prime curve.

Instances4Eq, Data, Read, Show
  • Eq CurveDefined in crypton-2.1.7 · Crypto.PubKey.ECC.Types
  • Data CurveDefined in crypton-2.1.7 · Crypto.PubKey.ECC.Types
  • Read CurveDefined in crypton-2.1.7 · Crypto.PubKey.ECC.Types
  • Show CurveDefined in crypton-2.1.7 · Crypto.PubKey.ECC.Types

Generating a shared key using our private number and the other party public point, reporting a rejected point instead of raising.

The public point comes from the other party, so it is checked before it is multiplied. A point that does not satisfy the curve equation is reported as CryptoError_PointCoordinatesInvalid.

Satisfying the equation is not by itself membership of the subgroup the base point generates; the two coincide only when the cofactor is 1. On a curve whose cofactor is above 1 the other party can offer a point of small order, and the value that comes back then depends on our private number only through its residue modulo that order, which hands them those bits. So the point is also required to be in the subgroup, by isPointInSubgroup, and is reported as CryptoError_PointSubgroupInvalid when it is not. That check costs one further scalar multiplication, and is skipped where the cofactor is 1 and it cannot fail.

An exchange that yields the point at infinity, and so has no x coordinate to derive the key from, is reported as CryptoError_ScalarMultiplicationInvalid.