| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.Crypto.ECDSA
Description
ECDSA (NIST P-256) key operations for libp2p peer identity, using crypton.
Wire formats follow the libp2p peer-ids spec (matching go-libp2p): - Public key: DER-encoded SubjectPublicKeyInfo (PKIX), uncompressed point. - Private key: DER-encoded RFC 5915 ECPrivateKey (SEC1), with the named curve parameters and the public key included, as emitted by Go's x509.MarshalECPrivateKey. - Signatures: ECDSA over SHA-256 with deterministic nonces (RFC 6979), DER-encoded (SEQUENCE { r, s }).
Operates on raw ByteString so this module has no dependency on
LibP2P.Crypto.Key.
Synopsis
- generate :: IO (ByteString, ByteString)
- sign :: ByteString -> ByteString -> Either String ByteString
- verify :: ByteString -> ByteString -> ByteString -> Bool
- derivePublicKey :: ByteString -> Either String ByteString
Documentation
generate :: IO (ByteString, ByteString) Source #
Generate a new P-256 key pair, returning (public SPKI DER, private SEC1 DER).
sign :: ByteString -> ByteString -> Either String ByteString Source #
Sign a message with a SEC1-DER private key (ECDSA/SHA-256, DER output). Nonces are deterministic per RFC 6979, so signing is pure: the same key and message always produce the same signature.
verify :: ByteString -> ByteString -> ByteString -> Bool Source #
Verify a DER signature against an SPKI-DER public key (ECDSA/SHA-256).
derivePublicKey :: ByteString -> Either String ByteString Source #
Derive the SPKI-DER public key from a SEC1-DER private key.