summaryrefslogtreecommitdiffhomepage
path: root/Tunables.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Tunables.hs')
-rw-r--r--Tunables.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/Tunables.hs b/Tunables.hs
index d7e5ac7..1d087bf 100644
--- a/Tunables.hs
+++ b/Tunables.hs
@@ -9,6 +9,7 @@ module Tunables where
import Cost
import qualified Crypto.Argon2 as Argon2
+import Data.Word
-- | To determine the tunables used for a key name the expensive hash of the
-- name is calculated, using a particular configuration, and if the
@@ -139,3 +140,19 @@ knownObjectSizes :: [Int]
knownObjectSizes = map (calc . snd) knownTunings
where
calc t = objectSize t * shareOverhead t
+
+-- Hash for client-server Proof Of Work. This is tuned to take around
+-- 4 seconds to calculate the hash on a 4 core machine, with 0 added
+-- iterations. Adding more iterations will increase that somewhat.
+--
+-- This is not included in Tunables because it doesn't affect object
+-- encryption and storage.
+proofOfWorkHashTunable :: Word32 -> ExpensiveHashTunable
+proofOfWorkHashTunable addits =
+ UseArgon2 (CPUCost (Seconds (4 + (4 * fromIntegral addits `div` 20))) (Divisibility 4)) $
+ Argon2.HashOptions
+ { Argon2.hashIterations = 20 + addits
+ , Argon2.hashMemory = 131072 -- 128 mebibtyes per thread
+ , Argon2.hashParallelism = 4
+ , Argon2.hashVariant = Argon2.Argon2i
+ }