Safe Haskell | None |
---|---|
Language | Haskell2010 |
Scalar multiplication in a group.
This is crypto_scalarmult_*
from NaCl.
Note that this primitive is designed to only make the Computational Diffie–Hellman problem hard. It makes no promises about other assumptions, therefore it is the user’s responsibility to hash the output if required for the security of the specific application.
Synopsis
- newtype Point a = Point (SizedByteArray CRYPTO_SCALARMULT_BYTES a)
- toPoint :: ByteArrayAccess bytes => bytes -> Maybe (Point bytes)
- newtype Scalar a = Scalar (SizedByteArray CRYPTO_SCALARMULT_SCALARBYTES a)
- toScalar :: ByteArrayAccess bytes => bytes -> Maybe (Scalar bytes)
- mult :: forall outBytes pointBytes scalarBytes. (ByteArrayAccess pointBytes, ByteArrayAccess scalarBytes, ByteArray outBytes) => Point pointBytes -> Scalar scalarBytes -> Maybe (Point outBytes)
- multBase :: forall outBytes scalarBytes. (ByteArrayAccess scalarBytes, ByteArray outBytes) => Scalar scalarBytes -> Point outBytes
Documentation
Point in the group.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString
.
toPoint :: ByteArrayAccess bytes => bytes -> Maybe (Point bytes) Source #
Convert bytes to a group point.
Scalar that can be used for group multiplication.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString
.
Instances
ByteArray a => ByteArrayN CRYPTO_SCALARMULT_SCALARBYTES (Scalar a) Source # | |
Defined in NaCl.Scalarmult | |
Eq a => Eq (Scalar a) Source # | |
Ord a => Ord (Scalar a) Source # | |
Defined in NaCl.Scalarmult | |
Show a => Show (Scalar a) Source # | |
ByteArrayAccess a => ByteArrayAccess (Scalar a) Source # | |
toScalar :: ByteArrayAccess bytes => bytes -> Maybe (Scalar bytes) Source #
Convert bytes to a scalar.
:: forall outBytes pointBytes scalarBytes. (ByteArrayAccess pointBytes, ByteArrayAccess scalarBytes, ByteArray outBytes) | |
=> Point pointBytes | Group point. |
-> Scalar scalarBytes | Scalar. |
-> Maybe (Point outBytes) |
Multiply a group point by an integer.
Note that this function is slightly different from the corresponding function
in NaCl. Namely, unlike crypto_scalarmult
in NaCl, this one will return
Nothing
if:
- either the group point has a small order (1, 2, 4, or 8)
- or the result of the multiplication is the identity point.
This is how it is implemented in libsodium.