cardano-crypto-1.1.1: Cryptography primitives for cardano
Maintainer vincent@typed.io
Safe Haskell None
Language Haskell2010

Crypto.Math.Edwards25519

Description

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:

Synopsis

Basic types

data Scalar Source #

Represent a scalar in the base field

smart constructor & destructor

scalar :: ByteString -> Scalar Source #

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.

pointCompressed :: HasCallStack => ByteString -> PointCompressed Source #

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

scalarFromInteger :: Integer -> Scalar Source #

Create a scalar from integer. mainly for debugging purpose.

scalarAdd :: Scalar -> Scalar -> Scalar Source #

Add 2 scalar in the base field together

scalarToPoint :: Scalar -> PointCompressed Source #

Lift a scalar to the curve, and returning a compressed point

Signature & Verify

sign :: ByteArrayAccess msg => Scalar -> ByteString -> msg -> Signature Source #

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.