Skip to content

Commit

Permalink
stub WIF functions and base conversion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsuo committed Nov 25, 2014
1 parent b944c20 commit bca1ee2
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ A (self-educational, incomplete, and likely incorrect) library for working with
# To Do
First, we're going to implement a thin-client wallet.

- Should consider creating object types (e.g., addresses with metadata; wallets; etc)

## Public key distribution
- Base58 encoding / decoding [ref](https://github.com/bitcoin/bitcoin/blob/master/src/base58.cpp)
- RIPEMD-160 [ref](https://github.com/bitcoin/bitcoin/blob/master/src/crypto/ripemd160.cpp)
Expand Down
2 changes: 2 additions & 0 deletions src/Coin.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ module Coin
##############################################################################

include(joinpath("Crypto", "Crypto.jl"))
include(joinpath("Wallet", "Wallet.jl"))
include(joinpath("Util", "Util.jl"))

end # module Coin
9 changes: 9 additions & 0 deletions src/Util/Base.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Base

##############################################################################
##
## Dependencies
##
##############################################################################

end # module Base
11 changes: 11 additions & 0 deletions src/Util/Util.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Util

##############################################################################
##
## Load files
##
##############################################################################

include("Base.jl")

end # module Util
48 changes: 48 additions & 0 deletions src/Wallet/WIF.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module WIF

##############################################################################
##
## Dependencies
##
##############################################################################

using Coin

##############################################################################
##
## Exported methods and types
##
##############################################################################

export private2wif, wif2private, wif_checksum

##############################################################################
##
## Wallet interchange format function definitions
##
##############################################################################

# NOTE: As described in the document https://en.bitcoin.it/wiki/WIF

# Convert private key to WIF.
# TODO: turn keys into objects to hold metadata
# - which_net: which network to use; 0x80 for mainnet, 0xef for testnet
# - compression: 01 if private key corresponds to compressed public key
function private2wif(pk::ASCIIString; which_net="80", compression="")
pk = string(which_net, pk, compression)

hashed = Coin.Crypto.SHA2.sha256(pk)
hashed = Coin.Crypto.SHA2.sha256(hashed)

checksum = hashed[1:8]

pk = string(pk, checksum)
end

function wif2private(wif::ASCIIString)
end

function wif_checksum(wif::ASCIIString)
end

end # module WIF
11 changes: 11 additions & 0 deletions src/Wallet/Wallet.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Wallet

##############################################################################
##
## Load files
##
##############################################################################

include("WIF.jl")

end # module Wallet

0 comments on commit bca1ee2

Please sign in to comment.