Skip to content

Commit 1156fc2

Browse files
committed
wip
1 parent a758520 commit 1156fc2

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

pub/hs-bitcoin-keys/bitcoin-keys/lib/Bitcoin/Keys.hs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,24 @@
33
-- | This module exports tools for working with Bitcoin keys.
44
module Bitcoin.Keys
55
( -- * Private
6-
I.Prv
7-
, I.parsePrv
8-
, I.prvRaw
9-
, I.prvToPub
6+
I.Prv,
7+
I.parsePrv,
8+
I.prvRaw,
9+
I.prvToPub,
1010

11-
-- * Public
12-
, I.Pub
13-
, parsePub
14-
, I.pubCompressed
15-
, I.pubUncompressed
11+
-- * Public
12+
I.Pub,
13+
parsePub,
14+
I.pubCompressed,
15+
I.pubUncompressed,
1616

17-
-- * Tweak
18-
, I.Tweak
19-
, I.parseTweak
20-
, I.pubAddTweak
21-
, I.prvAddTweak
22-
) where
17+
-- * Tweak
18+
I.Tweak,
19+
I.parseTweak,
20+
I.pubAddTweak,
21+
I.prvAddTweak,
22+
)
23+
where
2324

2425
import Control.Applicative
2526
import Control.Monad
@@ -61,5 +62,3 @@ parsePubUncompressed b = do
6162
guard (B.length b == 65 && B.index b 0 == 0x04)
6263
let w0 = 0x02 + (B.index b 64 .&. 0x01)
6364
I.parsePubCompressed (B.cons w0 (B.take 32 (B.drop 1 b)))
64-
65-

pub/hs-bitcoin-keys/bitcoin-keys/lib/Bitcoin/Keys/GHC.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module Bitcoin.Keys.GHC
1616
pubAddTweak,
1717
Tweak,
1818
parseTweak,
19+
Sig (..),
20+
mkSigDer,
21+
unSigDer,
1922
)
2023
where
2124

@@ -188,6 +191,19 @@ parseTweak x = do
188191
guard (B.length x == 32)
189192
Tweak <$> K.tweak x
190193

194+
newtype Sig = Sig
195+
{ unSig :: K.Sig
196+
}
197+
deriving stock (Eq, Show)
198+
199+
mkSigDer :: B.ByteString -> Maybe Sig
200+
mkSigDer =
201+
fmap Sig . withCtx K.importSig
202+
203+
unSigDer :: Sig -> B.ByteString
204+
unSigDer =
205+
withCtx K.exportSig . unSig
206+
191207
#if MIN_VERSION_secp256k1_haskell(1,0,0)
192208
withCtx :: (K.Ctx -> a) -> a
193209
withCtx f = Unsafe.unsafePerformIO $ K.withContext (pure . f)

0 commit comments

Comments
 (0)