mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-09-11 14:06:13 +03:00
commit
f5fa503b18
@ -202,13 +202,13 @@ ec_add p s t
|
|||||||
ec_sub :: PrimeModulus -> ProjectivePoint -> ProjectivePoint -> ProjectivePoint
|
ec_sub :: PrimeModulus -> ProjectivePoint -> ProjectivePoint -> ProjectivePoint
|
||||||
ec_sub p s t = ec_add p s u
|
ec_sub p s t = ec_add p s u
|
||||||
where u = case BN.bigNatSub (primeMod p) (py t) of
|
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))]
|
(# (# #) | #) -> panic "ec_sub" ["cooridnate not in reduced form!", show (BN.bigNatToInteger (py t))]
|
||||||
{-# INLINE ec_sub #-}
|
{-# INLINE ec_sub #-}
|
||||||
|
|
||||||
|
|
||||||
ec_negate :: PrimeModulus -> ProjectivePoint -> ProjectivePoint
|
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 #-}
|
{-# INLINE ec_negate #-}
|
||||||
|
|
||||||
-- | Compute the elliptic curve group addition operation
|
-- | Compute the elliptic curve group addition operation
|
||||||
@ -294,7 +294,7 @@ ec_mult p d s
|
|||||||
| BN.bigNatIsZero (pz s) = zro
|
| BN.bigNatIsZero (pz s) = zro
|
||||||
| otherwise =
|
| otherwise =
|
||||||
case m of
|
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
|
_ -> go m zro
|
||||||
|
|
||||||
where
|
where
|
||||||
|
4
tests/issues/issue1675/issue1675.icry
Normal file
4
tests/issues/issue1675/issue1675.icry
Normal 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
|
6
tests/issues/issue1675/issue1675.icry.stdout
Normal file
6
tests/issues/issue1675/issue1675.icry.stdout
Normal 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}
|
Loading…
Reference in New Issue
Block a user