HORIZON HASKELLDocslts/ghc-9.14.x99ffbb82026-10-19Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 99ffbb8 · 2026-10-19

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:

Contents
  1. Basic types
  2. smart constructor & destructor
  3. Arithmetic
  4. Signature & Verify
Synopsis

Basic types

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

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

Signature & Verify

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.