Represent a scalar in the base field
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
- Packagecardano-crypto-1.3.0
- Exports16
- LanguageHaskell2010
- LicenceMIT
- SourceEdwards25519.hs
Basic types
3 declarationsRepresent a point on the Edwards 25519 curve
Instances5Eq, Ord, Show, NFData, Hashable
Eq PointCompressedDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519Ord PointCompressedDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519Show PointCompressedDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519NFData PointCompressedDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519Hashable PointCompressedDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519
Represent a signature
Constructors
Instances5Eq, Ord, Show, NFData, Hashable
Eq SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519Ord SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519Show SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519NFData SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519Hashable SignatureDefined in cardano-crypto-1.3.0 · Crypto.Math.Edwards25519
smart constructor & destructor
7 declarationsCreate 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 declarationsCreate a scalar from integer. mainly for debugging purpose.
Add 2 scalar in the base field together
Lift a scalar to the curve, and returning a compressed point
Add 2 points together
Signature & Verify
2 declarationsCreate 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 a signature