File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
hnix-store-core/src/System/Nix/Internal Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,13 @@ import qualified Data.Text as T
2929import Data.Word (Word8 )
3030import qualified GHC.TypeLits as Kind
3131 (Nat , KnownNat , natVal )
32- import Data.Coerce (coerce )
3332import System.Nix.Internal.Base
3433 ( BaseEncoding (Base16 ,NixBase32 ,Base64 )
3534 , encodeWith
3635 , decodeWith
3736 )
37+ import Data.Bool (bool )
38+ import Data.Coerce (coerce )
3839
3940-- | The universe of supported hash algorithms.
4041--
@@ -203,15 +204,18 @@ truncateDigest
203204truncateDigest (Digest c) =
204205 Digest $ BS. pack $ fmap truncOutputByte [0 .. n- 1 ]
205206 where
206- n = fromIntegral $ Kind. natVal ( Proxy @ n )
207+ n = fromIntegral $ Kind. natVal $ Proxy @ n
207208
208209 truncOutputByte :: Int -> Word8
209210 truncOutputByte i = foldl' (aux i) 0 [0 .. BS. length c - 1 ]
210211
211212 inputByte :: Int -> Word8
212- inputByte j = BS. index c ( fromIntegral j)
213+ inputByte j = BS. index c j
213214
214215 aux :: Int -> Word8 -> Int -> Word8
215- aux i x j = if j `mod` fromIntegral n == fromIntegral i
216- then xor x (inputByte $ fromIntegral j)
217- else x
216+ aux i x j =
217+ bool
218+ id
219+ (`xor` inputByte j)
220+ (j `mod` n == i)
221+ x
You can’t perform that action at this time.
0 commit comments