HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecardano-crypto-1.3.0Haskell2010

Crypto.Math.Edwards25519

Simple module to play with the arithmetics of the twisted edwards curve Ed25519 using Extended Twisted Edwards Coordinates. Compared to the normal implementation this allow to use standard DH property:

for all valid s1 and s2 scalar:

scalarToPoint (s1 + s2) = pointAdd (scalarToPoint s1) (scalarToPoint s2)

For further useful references about Ed25519:

  • 3 types
  • 13 values

Basic types

3 declarations
newtypenewtype Scalar
#

Represent a scalar in the base field

newtypenewtype PointCompressed
#

Represent a point on the Edwards 25519 curve

Instances5Eq, Ord, Show, NFData, Hashable
newtypenewtype Signature
#

Represent a signature

Instances5Eq, Ord, Show, NFData, Hashable
  • Eq SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519
  • Ord SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519
  • Show SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519
  • NFData SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519
  • Hashable SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519

smart constructor & destructor

7 declarations
valuescalar :: ByteString -> Scalar
#

Create a Ed25519 scalar

Only check that the length is of expected size (32 bytes), no effort is made for the scalar to be in the right base field range on purpose.

Check if a scalar is valid and all the bits properly set/cleared scalarValid :: Scalar -> Bool scalarValid _s = True -- TODO

Smart constructor to create a compress point binary

Check if the length is of expected size

Arithmetic

4 declarations

Signature & Verify

2 declarations
valuesign :: ByteArrayAccess msg => Scalar -> ByteString -> msg -> Signature
#

Create a signature using a variant of ED25519 signature

we don't hash the secret key to derive a key + prefix, but instead we take an explicit salt and compute a prefix using the secret key + salt.