add the binding to get the size by bytes

This commit is contained in:
Vincent Hanquez 2016-12-02 14:59:46 +00:00
parent 422c5fdb09
commit 11e42a256d

View File

@ -18,6 +18,7 @@ module Crypto.ECC.Simple.Types
, CurveBinaryParam(..)
, CurvePrimeParam(..)
, curveSizeBits
, curveSizeBytes
, CurveParameters(..)
-- * specific curves definition
, SEC_p112r1(..)
@ -70,6 +71,10 @@ curveSizeBits proxy =
CurvePrime (CurvePrimeParam p) -> numBits p
CurveBinary (CurveBinaryParam c) -> numBits c - 1
-- | get the size of the curve in bytes
curveSizeBytes :: Curve curve => proxy curve -> Int
curveSizeBytes proxy = (curveSizeBits proxy + 7) `div` 8
-- | Define common parameters in a curve definition
-- of the form: y^2 = x^3 + ax + b.
data CurveParameters curve = CurveParameters