diff options
Diffstat (limited to 'Shard.hs')
-rw-r--r-- | Shard.hs | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -53,15 +53,15 @@ shardIdents tunables (Name name) keyid = E.encodeUtf8 $ basename <> T.pack (show n) mksha :: B.ByteString -> Raaz.Base16 mksha = Raaz.encode . Raaz.sha256 - idents = map mk [1..totalObjects (head (shardParams tunables))] + idents = map mk [1..totalObjects (shardParams tunables)] bruteforcecalc = bruteForceLinearSearch creationcost hashtunables = nameGenerationHash $ nameGenerationTunable tunables genShards :: EncryptedSecretKey -> Tunables -> IO [Shard] genShards (EncryptedSecretKey esk _) tunables = do shares <- SS.encode - (neededObjects $ head $ shardParams tunables) - (totalObjects $ head $ shardParams tunables) + (neededObjects $ shardParams tunables) + (totalObjects $ shardParams tunables) (BL.fromStrict esk) return $ map (\(n, share) -> Shard n (StorableObject $ encodeShare share)) (zip [1..] shares) @@ -70,14 +70,14 @@ combineShards :: Tunables -> [Shard] -> Either String EncryptedSecretKey combineShards tunables shards | null shards = Left "No shards could be downloaded. Perhaps you entered the wrong name or password?" - | length shards < minimum (map neededObjects (shardParams tunables)) = + | length shards < neededObjects (shardParams tunables) = Left "Not enough are shards currently available to reconstruct your data." | otherwise = Right $ mk $ SS.decode $ map decodeshard shards where mk b = EncryptedSecretKey (BL.toStrict b) unknownCostCalc decodeshard (Shard sharenum so) = decodeShare sharenum sharesneeded $ fromStorableObject so - sharesneeded = neededObjects $ head $ shardParams tunables + sharesneeded = neededObjects $ shardParams tunables -- | This efficient encoding relies on the share using a finite field of -- size 256, so it maps directly to bytes. |