libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

LibP2P.Crypto.RSA

Description

RSA key operations for libp2p peer identity, using crypton.

Wire formats follow the libp2p peer-ids spec: - Public key: DER-encoded SubjectPublicKeyInfo (PKIX). - Private key: DER-encoded PKCS#1 RSAPrivateKey. - Signatures: RSASSA-PKCS1-v1_5 over SHA-256.

All functions operate on raw ByteString so this module does not depend on LibP2P.Crypto.Key (avoids an import cycle with the dispatcher).

Synopsis

Documentation

generate :: IO (ByteString, ByteString) Source #

Generate a new RSA key pair, returning (public SPKI DER, private PKCS#1 DER).

sign :: ByteString -> ByteString -> Either String ByteString Source #

Sign a message with a PKCS#1-DER private key (RSASSA-PKCS1-v1_5, SHA-256). Deterministic (no blinder), so it is pure.

verify :: ByteString -> ByteString -> ByteString -> Bool Source #

Verify a signature against an SPKI-DER public key (RSASSA-PKCS1-v1_5, SHA-256).

derivePublicKey :: ByteString -> Either String ByteString Source #

Derive the SPKI-DER public key from a PKCS#1-DER private key.