summaryrefslogtreecommitdiffhomepage
path: root/Types/Cost.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Types/Cost.hs')
-rw-r--r--Types/Cost.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/Types/Cost.hs b/Types/Cost.hs
index 2f181a2..2aa6ee7 100644
--- a/Types/Cost.hs
+++ b/Types/Cost.hs
@@ -34,11 +34,24 @@ instance Monoid (Cost t) where
mapCost :: (Integer -> Integer) -> Cost op -> Cost op
mapCost f (CPUCost (Seconds n)) = CPUCost (Seconds (f n))
+showCostMinutes :: Cost op -> String
+showCostMinutes (CPUCost (Seconds n))
+ | n < 61 = "1 minute"
+ | otherwise = show (n `div` 60) ++ " minutes"
+
-- | Operations whose cost can be measured.
data DecryptionOp
data CreationOp
data BruteForceOp
+-- | Things that track their creation cost.
+class HasCreationCost t where
+ getCreationCost :: t -> Cost CreationOp
+
+-- | Things that track their decryption cost.
+class HasDecryptionCost t where
+ getDecryptionCost :: t -> Cost DecryptionOp
+
-- | Calculation of a cost that depends on some amount of entropy.
type CostCalc op t = Entropy t -> Cost op