crypto-pubkey 0.2.4 → 0.2.5
raw patch · 2 files changed
+38/−5 lines, 2 files
Files
- Crypto/PubKey/ECC/DH.hs +36/−0
- crypto-pubkey.cabal +2/−5
+ Crypto/PubKey/ECC/DH.hs view
@@ -0,0 +1,36 @@+module Crypto.PubKey.ECC.DH (+ Curve+ , PublicPoint+ , PrivateNumber+ , SharedKey(..)+ , generatePrivate+ , calculatePublic+ , getShared+ ) where++import Crypto.Number.Generate (generateMax)+import Crypto.PubKey.ECC.Prim (pointMul)+import Crypto.Random (CPRG)+import Crypto.Types.PubKey.DH (SharedKey(..))+import Crypto.Types.PubKey.ECC (PublicPoint, PrivateNumber, Curve, Point(..))+import Crypto.Types.PubKey.ECC (ecc_n, ecc_g, common_curve)++-- | Generating a private number d.+generatePrivate :: CPRG g => g -> Curve -> (PrivateNumber, g)+generatePrivate rng curve = generateMax rng n+ where+ n = ecc_n $ common_curve curve++-- | Generating a public point Q.+calculatePublic :: Curve -> PrivateNumber -> PublicPoint+calculatePublic curve d = q+ where+ g = ecc_g $ common_curve curve+ q = pointMul curve d g++-- | Generating a shared key using our private number and+-- the other party public point.+getShared :: Curve -> PrivateNumber -> PublicPoint -> SharedKey+getShared curve db qa = SharedKey x+ where+ Point x _ = pointMul curve db qa
crypto-pubkey.cabal view
@@ -1,5 +1,5 @@ Name: crypto-pubkey-Version: 0.2.4+Version: 0.2.5 Description: Public Key cryptography .@@ -20,10 +20,6 @@ Tests/KAT/*.hs Benchs/PregenKeys.hs -Flag benchmark- Description: Build benchmarks- Default: False- Library Build-Depends: base >= 4 && < 5 , bytestring@@ -43,6 +39,7 @@ Crypto.PubKey.MaskGenFunction Crypto.PubKey.ECC.Generate Crypto.PubKey.ECC.Prim+ Crypto.PubKey.ECC.DH Crypto.PubKey.ECC.ECDSA other-modules: Crypto.PubKey.ElGamal Crypto.PubKey.RSA.Types