Module

Crypt.NaCl

Package
purescript-tweetnacl
Repository
AlexaDeWit/purescript-tweetnacl

Re-exports from Crypt.NaCl.Box

#getBoxSecretKey Source

getBoxSecretKey :: BoxKeyPair -> BoxSecretKey

Get a BoxSecretKey from the given BoxKeyPair

#getBoxPublicKey Source

getBoxPublicKey :: BoxKeyPair -> BoxPublicKey

Get a BoxPublicKey from the given BoxKeyPair

#getBoxKeyPair Source

getBoxKeyPair :: BoxSecretKey -> BoxKeyPair

Get a BoxKeyPair from the given BoxSecretKey

#generateBoxKeyPair Source

generateBoxKeyPair :: Effect BoxKeyPair

Generate a BoxKeyPair for NaCl Box operations

#boxOpenAfter Source

boxOpenAfter :: Box -> Nonce -> BoxSharedKey -> Maybe Message

Similar to boxOpen, but opens a box with a BoxSharedKey that has been generated with boxBefore instead of a BoxPublicKey and BoxSecretKey

#boxOpen Source

boxOpen :: Box -> Nonce -> BoxPublicKey -> BoxSecretKey -> Maybe Message

Opening a box decrypts and authenticates the message. This will return the Message plaintext if decryption and SignatureB64 validation succeeds, and Nothing if authentication or decryption fails.

#boxBefore Source

boxBefore :: BoxPublicKey -> BoxSecretKey -> BoxSharedKey

Create a BoxSharedKey from one user's BoxPublicKey and a separate user's BoxSecretKey

#boxAfter Source

boxAfter :: Message -> Nonce -> BoxSharedKey -> Box

Create a Box with a BoxSharedKey

#box Source

box :: Message -> Nonce -> BoxPublicKey -> BoxSecretKey -> Box

Create a Box, which is an encrypted, authenticated message

Re-exports from Crypt.NaCl.Class

#Uint8ArrayAble Source

class Uint8ArrayAble a  where

Denotes a class of NaCl types which are convertable to Uint8Arrays. Instances of this typeclass will unsafeCoerce their values to Uint8Array because we know that everything in/out of the underlying library are, in fact, Uint8Arrays.

Members

Instances

#Uint8ArrayReadable Source

class Uint8ArrayReadable a  where

Denotes a class of NaCl types which are convertable from Uint8Arrays. Instances of this typeclass will unsafeCoerce their values from Uint8Array because we know that everything in/out of the underlying library are, in fact, Uint8Arrays.

Members

Instances

#Utf8Decodable Source

class Utf8Decodable a  where

This type class denotes types that can be decoded to a UTF8 String.

The toString function returns Either Error String to handle errors during the decode. We will generally unsafeCoerce because we know the underlying type is already of Uint8Array from the wrapped library.

Members

Instances

#Utf8Encodable Source

class Utf8Encodable a  where

This type class denotes types that can be encoded to a UTF8 String. The fromString function returns the type of the type class instance. We will generally unsafeCoerce from the Uint8Array type to the NaCl type we want because all underlying types are Uint8Array

Members

Instances

Re-exports from Crypt.NaCl.Hash

#hash Source

hash :: Uint8Array -> HashSha512

Compute the SHA-512 hash of any Uint8Array

Re-exports from Crypt.NaCl.Random

#setPRNG Source

setPRNG :: (Uint8Array -> Int -> Effect Unit) -> Effect Unit

Assigns a new PRNG for all random data generation

#generateNonce Source

generateNonce :: Effect Nonce

Generate a cryptographically secure, random Nonce for NaCl operations

Re-exports from Crypt.NaCl.SecretBox

#secretBoxOpen Source

secretBoxOpen :: SecretBox -> Nonce -> SecretBoxKey -> Maybe Message

Open a SecretBox, returning Maybe Message If decryption and authentication succeed, Just Message will be returned. If decryption or authentication fail, Nothing will be returned

#secretBox Source

secretBox :: Message -> Nonce -> SecretBoxKey -> SecretBox

Create a SecretBox, which is an encrypted and authenticated message

#generateSecretBoxKey Source

generateSecretBoxKey :: Effect SecretBoxKey

Generate a key for use with a SecretBox

Re-exports from Crypt.NaCl.Sign

#verifyDetached Source

verifyDetached :: Message -> Signature -> Boolean

Verifies a Signature, given the Message

#signOpen Source

signOpen :: SignedMessage -> SignPublicKey -> Maybe Message

Varifies the signature contained in a SignedMessage against a given SignPublicKey. Returns Just Message if the signature verifies, or Nothing otherwise.

#signDetached Source

signDetached :: Message -> SignSecretKey -> Signature

Like sign, but only returns the Signature, not the message contents

#sign Source

sign :: Message -> SignSecretKey -> SignedMessage

Sign a Message using the given SignSecretKey. Returns the contents of the message, signed, as a SignedMessage

#getSignSecretKey Source

getSignSecretKey :: SignKeyPair -> SignSecretKey

Get the SignSecretKey for a given SignKeyPair

#getSignPublicKey Source

getSignPublicKey :: SignKeyPair -> SignPublicKey

Get the SignPublicKey for a given SignKeyPair

#getSignKeyPairFromSeed Source

getSignKeyPairFromSeed :: SignSeed -> SignKeyPair

Get the signing keypair for a given SignSeed

#getSignKeyPair Source

getSignKeyPair :: SignSecretKey -> SignKeyPair

Get the signing keypair for a given SignSecretKey

#generateSignKeyPair Source

generateSignKeyPair :: Effect SignKeyPair

Generate a random key pair for signing messages

Re-exports from Crypt.NaCl.Types

#SignedMessage Source

data SignedMessage :: Type

A NaCl SignedMessage, which is represented as a Uint8Array in JS

Instances

#Signature Source

data Signature :: Type

A NaCl Signature

#SignSeed Source

data SignSeed :: Type

A NaCl SignSeed (a 32 byte seed can be used to generate a 64 byte SignSecretKey)

#SignSecretKey Source

data SignSecretKey :: Type

A NaCl SignSecretKey

Instances

#SignPublicKey Source

data SignPublicKey :: Type

A NaCl SignPublicKey

Instances

#SignKeyPair Source

newtype SignKeyPair

A NaCl SignKeyPair containing a SignPublicKey and a SignSecretKey

Constructors

Instances

#SecretBoxKey Source

data SecretBoxKey :: Type

a NaCL SecretBoxKey

Instances

#SecretBox Source

data SecretBox :: Type

a NaCL SecretBox

Instances

#Nonce Source

data Nonce :: Type

A NaCl Nonce

Instances

#Message Source

data Message :: Type

A NaCl Message, which is represented as a Uint8Array in JS

Instances

#HashSha512 Source

data HashSha512 :: Type

A NaCl SHA-512 Hash

Instances

#BoxSharedKey Source

data BoxSharedKey :: Type

A NaCl BoxSharedKey

Instances

#BoxSecretKey Source

data BoxSecretKey :: Type

A NaCl BoxSecretKey

Instances

#BoxPublicKey Source

data BoxPublicKey :: Type

A NaCl BoxPublicKey

Instances

#BoxKeyPair Source

newtype BoxKeyPair

A NaCl BoxKeyPair containing a BoxPublicKey and a BoxSecretKey

Constructors

Instances

#Box Source

data Box :: Type

A NaCl Box, which is an encrypted, authenticated message

Instances