HAN-ASD-DT / rsa / RSA

The RSA crypto-system in Elm.

Constructors

generate : Basics.Int -> Basics.Int -> Result GenerationError ( PublicKey, PrivateKey )

Generates a key-pair for the RSA crypto-system.

The arguments should be two primes. Note that the primes should remain private.


type PrivateKey

The private keys of the RSA crypto-system.

Uses to decrypt a message.


type alias PublicKey =
{ n : Basics.Int, e : Basics.Int }

The public keys of the RSA crypto-system.

Used to encrypt a message.

Usage

encrypt : PublicKey -> Basics.Int -> Basics.Int

Encrypts a message.

decrypt : PrivateKey -> Basics.Int -> Basics.Int

Decrypts a message.

Error Handling


type GenerationError

The reason why a key-pair generation can go wrong.

errorString : GenerationError -> String

Returns a String detailing why the key-pair generation failed.

Usage

let
    ( public, private ) =
        generate 37 79
in
encrypt public value