File tree Expand file tree Collapse file tree 2 files changed +32
-17
lines changed
pub/hs-bitcoin-keys/bitcoin-keys/lib/Bitcoin Expand file tree Collapse file tree 2 files changed +32
-17
lines changed Original file line number Diff line number Diff line change 3
3
-- | This module exports tools for working with Bitcoin keys.
4
4
module Bitcoin.Keys
5
5
( -- * 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,
10
10
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,
16
16
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
23
24
24
25
import Control.Applicative
25
26
import Control.Monad
@@ -61,5 +62,3 @@ parsePubUncompressed b = do
61
62
guard (B. length b == 65 && B. index b 0 == 0x04 )
62
63
let w0 = 0x02 + (B. index b 64 .&. 0x01 )
63
64
I. parsePubCompressed (B. cons w0 (B. take 32 (B. drop 1 b)))
64
-
65
-
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ module Bitcoin.Keys.GHC
16
16
pubAddTweak ,
17
17
Tweak ,
18
18
parseTweak ,
19
+ Sig (.. ),
20
+ mkSigDer ,
21
+ unSigDer ,
19
22
)
20
23
where
21
24
@@ -188,6 +191,19 @@ parseTweak x = do
188
191
guard (B. length x == 32 )
189
192
Tweak <$> K. tweak x
190
193
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
+
191
207
#if MIN_VERSION_secp256k1_haskell(1,0,0)
192
208
withCtx :: (K. Ctx -> a ) -> a
193
209
withCtx f = Unsafe. unsafePerformIO $ K. withContext (pure . f)
You can’t perform that action at this time.
0 commit comments