Skip to content

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hnix-store-core/src/System/Nix/Internal/Signature.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Description : Nix-relevant interfaces to NaCl signatures.
33
-}
44
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE CPP #-}
56

67
module System.Nix.Internal.Signature where
78

@@ -11,16 +12,25 @@ import qualified Data.ByteString as Bytes
1112
import Data.Coerce ( coerce )
1213
import Crypto.Saltine.Core.Sign ( PublicKey )
1314
import Crypto.Saltine.Class ( IsEncoding(..) )
14-
import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes
1515

16+
-- 2021-05-30: NOTE: Please, clean-up these overloads in ~2022
17+
#if MIN_VERSION_saltine(0,2,0)
18+
import qualified Crypto.Saltine.Internal.Sign as NaClSizes
19+
#else
20+
import qualified Crypto.Saltine.Internal.ByteSizes as NaClSizes
21+
#endif
1622

1723
-- | A NaCl signature.
1824
newtype Signature = Signature ByteString
1925
deriving (Eq, Ord)
2026

2127
instance IsEncoding Signature where
2228
decode s
29+
#if MIN_VERSION_saltine(0,2,0)
30+
| Bytes.length s == NaClSizes.sign_bytes = Just $ Signature s
31+
#else
2332
| Bytes.length s == NaClSizes.sign = Just $ Signature s
33+
#endif
2434
| otherwise = Nothing
2535
encode = coerce
2636

0 commit comments

Comments
 (0)