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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Modulecrypton-2.1.7Haskell2010

Crypto.PubKey.ECC.P256

P256 support

  • 2 types
  • 30 values
  • Packagecrypton-2.1.7
  • Exports32
  • LanguageHaskell2010
  • LicenceBSD-3-Clause AND MIT AND ISC
  • SourceP256.hs
newtypenewtype Scalar
#

A P256 scalar

Instances4Eq, Show, NFData, ByteArrayAccess
  • Eq ScalarDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256
  • Show ScalarDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256
  • NFData ScalarDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256
  • ByteArrayAccess ScalarDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256
newtypenewtype Point
#

A P256 point

Instances3Eq, Show, NFData
  • Eq PointDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256
  • Show PointDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256
  • NFData PointDefined in crypton-2.1.7 · Crypto.PubKey.ECC.P256

Point arithmetic

15 declarations
valuepointDh :: ByteArray binary => Scalar -> Point -> binary
#

Similar to pointMul, serializing the x coordinate as binary. When scalar is multiple of point order the result is all zero.

valuetoPoint :: Scalar -> Point
#

Lift to curve a scalar

Using the curve generator as base point compute:

scalar * G

Scalar arithmetic

15 declarations
valuescalarReduce :: Scalar -> Scalar
#

Bring a scalar below the order of the curve

scalarFromInteger and scalarFromBinary take any 256 bits, so a scalar can arrive above the order; the arithmetic below wants it brought down first. Twice the order is more than 256 bits hold, so this is a single subtraction, taken or not through a mask rather than a branch.