diff options
author | joe <joe@jerkface.net> | 2014-04-15 14:28:57 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-15 14:28:57 -0400 |
commit | 86111acab0bbc4c1b2d523be1c50297f4ec8d388 (patch) | |
tree | 185ba13b4386dedf94800623c327ff7dc3fa61fc /kiki.hs | |
parent | 4d96c66f6ece8383c04543c875556d1fae9422f6 (diff) |
finished writeWalletKeys
Diffstat (limited to 'kiki.hs')
-rw-r--r-- | kiki.hs | 23 |
1 files changed, 0 insertions, 23 deletions
@@ -1109,29 +1109,6 @@ secp256k1_G = ECPa secp256k1_curve | |||
1109 | -} | 1109 | -} |
1110 | -} | 1110 | -} |
1111 | 1111 | ||
1112 | walletImportFormat 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 | |||
1122 | base58_encode :: S.ByteString -> String | ||
1123 | base58_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 | ||
1136 | cannonical_eckey x y = 0x4:pad32(numToBytes x) ++ pad32(numToBytes y) :: [Word8] | 1113 | cannonical_eckey x y = 0x4:pad32(numToBytes x) ++ pad32(numToBytes y) :: [Word8] |
1137 | where | 1114 | where |