Maintainer | vincent@typed.io |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
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
- data Scalar
- data PointCompressed
- newtype Signature = Signature { }
- scalar :: ByteString -> Scalar
- scalarP :: Bytes 32 -> Scalar
- unScalar :: Scalar -> ByteString
- pointCompressed :: HasCallStack => ByteString -> PointCompressed
- pointCompressedP :: Bytes 32 -> PointCompressed
- unPointCompressed :: PointCompressed -> ByteString
- unPointCompressedP :: PointCompressed -> Bytes 32
- scalarFromInteger :: Integer -> Scalar
- scalarAdd :: Scalar -> Scalar -> Scalar
- scalarToPoint :: Scalar -> PointCompressed
- pointAdd :: PointCompressed -> PointCompressed -> PointCompressed
- sign :: ByteArrayAccess msg => Scalar -> ByteString -> msg -> Signature
- verify :: ByteArrayAccess msg => PointCompressed -> msg -> Signature -> Bool
Basic types
data PointCompressed Source #
Represent a point on the Edwards 25519 curve
Instances
Represent a signature
Instances
Eq Signature Source # | |
Ord Signature Source # | |
Defined in Crypto.Math.Edwards25519 |
|
Show Signature Source # | |
NFData Signature Source # | |
Defined in Crypto.Math.Edwards25519 |
|
Hashable Signature Source # | |
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.
unScalar :: Scalar -> ByteString Source #
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
pointCompressedP :: Bytes 32 -> PointCompressed Source #
unPointCompressedP :: PointCompressed -> Bytes 32 Source #
Arithmetic
scalarFromInteger :: Integer -> Scalar Source #
Create a scalar from integer. mainly for debugging purpose.
scalarToPoint :: Scalar -> PointCompressed Source #
Lift a scalar to the curve, and returning a compressed point
pointAdd :: PointCompressed -> PointCompressed -> PointCompressed Source #
Add 2 points together
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.
verify :: ByteArrayAccess msg => PointCompressed -> msg -> Signature -> Bool Source #
Verify a signature