Represent a Rabin-Williams public key.
Constructors
PublicKeypublic_size :: Intsize of key in bytes
public_n :: Integerpublic p*q
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Modulecryptonite-0.30Haskell2010
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.
Represent a Rabin-Williams public key.
PublicKeypublic_size :: Intsize of key in bytes
public_n :: Integerpublic p*q
Represent a Rabin-Williams private key.
Eq PrivateKeyDefined in cryptonite-0.30 · Crypto.PubKey.Rabin.RWData PrivateKeyDefined in cryptonite-0.30 · Crypto.PubKey.Rabin.RWRead PrivateKeyDefined in cryptonite-0.30 · Crypto.PubKey.Rabin.RWShow PrivateKeyDefined in cryptonite-0.30 · Crypto.PubKey.Rabin.RWGenerate a pair of (private, public) key of size in bytes. Prime p is congruent 3 mod 8 and prime q is congruent 7 mod 8.
encrypt :: (HashAlgorithm hash, MonadRandom m)=> OAEPParams hash ByteString ByteStringOAEP padding parameters
-> PublicKeypublic key
-> ByteStringplaintext
-> m (Either Error ByteString)Encrypt plaintext using public key.
encryptWithSeed :: HashAlgorithm hash=> ByteStringSeed
-> OAEPParams hash ByteString ByteStringOAEP padding
-> PublicKeypublic key
-> ByteStringplaintext
-> Either Error ByteStringEncrypt plaintext using public key an a predefined OAEP seed.
See algorithm 8.11 in "Handbook of Applied Cryptography" by Alfred J. Menezes et al.
decrypt :: HashAlgorithm hash=> OAEPParams hash ByteString ByteStringOAEP padding parameters
-> PrivateKeyprivate key
-> ByteStringciphertext
-> Maybe ByteStringDecrypt ciphertext using private key.
sign :: HashAlgorithm hash=> PrivateKeyprivate key
-> hashhash function
-> ByteStringmessage to sign
-> Either Error IntegerSign message using hash algorithm and private key.
verify :: HashAlgorithm hash=> PublicKeypublic key
-> hashhash function
-> ByteStringmessage
-> Integersignature
-> BoolVerify signature using hash algorithm and public key.