summaryrefslogtreecommitdiff
path: root/kiki.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2014-04-15 14:28:57 -0400
committerjoe <joe@jerkface.net>2014-04-15 14:28:57 -0400
commit86111acab0bbc4c1b2d523be1c50297f4ec8d388 (patch)
tree185ba13b4386dedf94800623c327ff7dc3fa61fc /kiki.hs
parent4d96c66f6ece8383c04543c875556d1fae9422f6 (diff)
finished writeWalletKeys
Diffstat (limited to 'kiki.hs')
-rw-r--r--kiki.hs23
1 files changed, 0 insertions, 23 deletions
diff --git a/kiki.hs b/kiki.hs
index 9c748e5..4daff67 100644
--- a/kiki.hs
+++ b/kiki.hs
@@ -1109,29 +1109,6 @@ secp256k1_G = ECPa secp256k1_curve
1109 -} 1109 -}
1110-} 1110-}
1111 1111
1112walletImportFormat idbyte k = secret_base58_foo
1113 where
1114 -- isSecret (SecretKeyPacket {}) = True
1115 -- isSecret _ = False
1116 secret_base58_foo = base58_encode seckey
1117 Just d = lookup 'd' (key k)
1118 (_,bigendian) = S.splitAt 2 (S.concat $ L.toChunks $ encode d)
1119 seckey = S.cons idbyte bigendian
1120
1121
1122base58_encode :: S.ByteString -> String
1123base58_encode hash = replicate zcount '1' ++ map (base58chars !!) (reverse rdigits)
1124 where
1125 zcount = S.length . S.takeWhile (==0) $ hash
1126 cksum = S.take 4 . SHA256.hash . SHA256.hash $ hash
1127 n = foldl' (\a b->a*256+b) 0 . map asInteger $ concatMap S.unpack [hash, cksum]
1128 asInteger x = fromIntegral x :: Integer
1129 rdigits = unfoldr getdigit n
1130 where
1131 getdigit d = do
1132 guard (d/=0)
1133 let (q,b) = d `divMod` 58
1134 return (fromIntegral b,q)
1135 1112
1136cannonical_eckey x y = 0x4:pad32(numToBytes x) ++ pad32(numToBytes y) :: [Word8] 1113cannonical_eckey x y = 0x4:pad32(numToBytes x) ++ pad32(numToBytes y) :: [Word8]
1137 where 1114 where