Close Issue #1675
This commit is contained in:
mccleeary-galois 2024-07-10 15:06:10 -06:00 committed by GitHub
commit f5fa503b18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 3 deletions

View File

@ -202,13 +202,13 @@ ec_add p s t
ec_sub :: PrimeModulus -> ProjectivePoint -> ProjectivePoint -> ProjectivePoint
ec_sub p s t = ec_add p s u
where u = case BN.bigNatSub (primeMod p) (py t) of
(# | y' #) -> t{ py = y' }
(# | y' #) -> t{ py = y' `BN.bigNatRem` (primeMod p) }
(# (# #) | #) -> panic "ec_sub" ["cooridnate not in reduced form!", show (BN.bigNatToInteger (py t))]
{-# INLINE ec_sub #-}
ec_negate :: PrimeModulus -> ProjectivePoint -> ProjectivePoint
ec_negate p s = s{ py = BN.bigNatSubUnsafe (primeMod p) (py s) }
ec_negate p s = s{ py = (BN.bigNatSubUnsafe (primeMod p) (py s)) `BN.bigNatRem` (primeMod p) }
{-# INLINE ec_negate #-}
-- | Compute the elliptic curve group addition operation
@ -294,7 +294,7 @@ ec_mult p d s
| BN.bigNatIsZero (pz s) = zro
| otherwise =
case m of
0# -> panic "ec_mult" ["modulus too large", show (BN.bigNatToInteger (primeMod p))]
0# -> panic "ec_mult" ["integer with 0 width", show h]
_ -> go m zro
where

View File

@ -0,0 +1,4 @@
:m PrimeEC
ec_mult`{13} 3 {x = 0, y = 0, z = 1}
:t ec_mult`{13}
ec_mult`{13} 3 {x = 0, y = 0, z = 1} : ProjectivePoint 13

View File

@ -0,0 +1,6 @@
Loading module Cryptol
Loading module Cryptol
Loading module PrimeEC
{x = 0, y = 0, z = 1}
ec_mult`{13} : Z 13 -> ProjectivePoint 13 -> ProjectivePoint 13
{x = 0, y = 0, z = 1}