HORIZON HASKELLDocslts/ghc-10.0.xaa25b892026-10-10Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · aa25b89 · 2026-10-10

Modulecrypton-2.1.7Haskell2010

Crypto.PubKey.Rabin.RW

Rabin-Williams cryptosystem for public-key encryption and digital signature. See pages 323 - 324 in "Computational Number Theory and Modern Cryptography" by Song Y. Yan. Also inspired by https://github.com/vanilala/vncrypt/blob/master/vncrypt/vnrw_gmp.c. The Jacobi symbols here are taken modulo the public modulus, not the private primes, so what Crypto.PubKey.Rabin.Basic says about that does not apply; the note there about Integer arithmetic does.

  • 2 types
  • 6 values
  • Packagecrypton-2.1.7
  • Exports8
  • LanguageHaskell2010
  • LicenceBSD-3-Clause AND MIT AND ISC
  • SourceRW.hs
datadata PrivateKey
#

Represent a Rabin-Williams private key.

Constructors

Instances5Eq, Data, Read, Show, DebugShow
valuedecrypt
  1. :: HashAlgorithm hash
  2. => OAEPParams hash ByteString ByteString

    OAEP padding parameters

  3. -> PrivateKey

    private key

  4. -> ByteString

    ciphertext

  5. -> Maybe ByteString
#

Decrypt ciphertext using private key.

The ciphertext has to be what encrypt produces: the big-endian encoding, with no leading zero octet, of a value below the modulus. The primitives work modulo n, so without that condition c and c + n -- and c with a zero octet in front of it -- would all decrypt to the same message, and a ciphertext would not be unique to its plaintext.