From 927b68b13e9c4a7cc9397a65d47b4b6f64249201 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Mon, 25 Sep 2023 09:18:42 -0400
Subject: [PATCH] Simplify our use of BA.xor

`Digest' hash` (x) is already a ByteArrayAccess, we don't need to convert to a
ByteString to apply xor.
---
 test/Generators.hs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/Generators.hs b/test/Generators.hs
index b295b62..18125c6 100644
--- a/test/Generators.hs
+++ b/test/Generators.hs
@@ -29,7 +29,7 @@ import qualified Hedgehog.Range as Range
 import Tahoe.CHK.Capability (Reader, fingerprint, verifier)
 import Tahoe.CHK.Crypto (storageIndexLength)
 import Tahoe.CHK.Merkle (MerkleTree, leafHashes, makeTreePartial)
-import Tahoe.CHK.SHA256d (Digest' (..), SHA256d, toBytes, zero)
+import Tahoe.CHK.SHA256d (Digest' (..), SHA256d, zero)
 import Tahoe.CHK.Server (StorageServerAnnouncement (StorageServerAnnouncement))
 import Tahoe.CHK.Share (Crypttext, Share (..), blocks, crypttextHashTree, neededHashes)
 import Tahoe.CHK.Types (Parameters (..), Required, ShareNum, StorageIndex, Total)
@@ -229,7 +229,7 @@ applyShareBitFlips (ShareTreeLeafBitFlips shareFlips) = first (zipWith flipLeave
     flipLeaves leafFlips share = share{_neededHashes = zipWith flipBits (view neededHashes share) leafFlips}
 
     flipBits :: forall hash a. HashAlgorithm hash => (a, Digest' hash) -> BS.ByteString -> (a, Digest' hash)
-    flipBits (a, x) y = (a, digestFromByteStringPartial $ BA.xor @BS.ByteString @BS.ByteString @BS.ByteString (toBytes x) y)
+    flipBits (a, x) y = (a, digestFromByteStringPartial $ BA.xor x y)
 applyShareBitFlips (BlockBitFlips blockFlips) = first (zipWith flipBlocks blockFlips)
   where
     flipBlocks :: [BS.ByteString] -> Share -> Share
-- 
GitLab