Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transparent private keys fail to import into zcash (encoding error) #1414

Closed
Ban44n opened this issue Sep 17, 2016 · 8 comments
Closed

Transparent private keys fail to import into zcash (encoding error) #1414

Ban44n opened this issue Sep 17, 2016 · 8 comments
Labels

Comments

@Ban44n
Copy link

Ban44n commented Sep 17, 2016

According to the specs (section 5.6.2 and 5.6.1) it should be theoretically possible to import a private key from the bitcoin wallet to the zcash wallet, since the spec states that the private and public keys of Zcash have exactly the same encoding as Bitcoin. This spec would also mean that users should be able to use existing 3rd party utilities to generate transparent wallets for Zcash. However it turns out that this is not the case: we get an "invalid private key encoding" error.

Please correct me if I am wrong here, but according to the specs I think this should be possible:

ampy@euih42-ee:~/zcash/src$ bitcoin-cli getaddressesbyaccount ""
[
  "1MzGN3zeLLko9PCyxfZsvBexHGRN9a9XR", 
  "1BvgsfsZQVtkLS69NvGF8rw6NZW2ShJQHr"
]
ampy@euih42-ee:~/zcash/src$ bitcoin-cli dumpprivkey 1MzGN3zeLLko9PCyxfZsvBexHGRN9a9XR
L2D7Ba7ZeaxSowxMwHGHTq55j5yqoao68ryBFzEs7HqaW7W4XaTv
ampy@euih42-ee:~/zcash/src$ ./zcash-cli importprivkey L2D7Ba7ZeaxSowxMwHGHTq55j5yqoao68ryBFzEs7HqaW7W4XaTv
error: {"code":-5,"message":"Invalid private key encoding"}
ampy@euih42-ee:~/zcash/src$ 

Or the other way around

ampy@euih42-ee:~/zcash/src$ ./zcash-cli getaddressesbyaccount ""
[
    "n1EbdDCXWRsFtJ5ecAo1BLAHY5xrHkMcan"
]
ampy@euih42-ee:~/zcash/src$ ./zcash-cli dumpprivkey n1EbdDCXWRsFtJ5ecAo1BLAHY5xrHkMcan
cNZiv9r95aSmJPkKVn3FjzBvN5wBP6fbZPKL6hcY1UuHfAgDj1Qj
ampy@euih42-ee:~/zcash/src$ bitcoin-cli importprivkey cNZiv9r95aSmJPkKVn3FjzBvN5wBP6fbZPKL6hcY1UuHfAgDj1Qj
error code: -5
error message:
Invalid private key encoding
ampy@euih42-ee:~/zcash/src$ 

Don't worry, these private keys will never be used for any wallet! I put them here to proof my point.

This bug is very unfortunate, because it means that 3rd party utils cannot be used to generate transparent wallets for zcash.

@bitcartel
Copy link
Contributor

bitcartel commented Sep 18, 2016

It looks like the Bitcoin node is running on Mainnet, whereas Zcash is running on Testnet. Try putting Bitcoin into Testnet mode and repeating the above.

Note that third party tools will probably need to be updated as transparent addresses on Zcash mainnet will have a different prefix from that used by Bitcoin mainnet.

@Ban44n
Copy link
Author

Ban44n commented Sep 18, 2016

@bitcartel Thanks. It seems to work when both daemons are running in the same mode. Could you tell me which prefix is enforced on zcash transparent addresses on mainnet?

ampy@euih42-ee:~/zcash/src$ bitcoin-cli getaddressesbyaccount ""
[
  "myrEh5pmhK3wanYRJhwX7TALpy22Qg97zd"
]
ampy@euih42-ee:~/zcash/src$ bitcoin-cli dumpprivkey myrEh5pmhK3wanYRJhwX7TALpy22Qg97zd
cTQyR1JqwdmFnUTHvP5ddujtVHZjaqMUE5mHg8njj51HXXU6Uhiw
ampy@euih42-ee:~/zcash/src$ ./zcash-cli importprivkey cTQyR1JqwdmFnUTHvP5ddujtVHZjaqMUE5mHg8njj51HXXU6Uhiw
ampy@euih42-ee:~/zcash/src$

@daira
Copy link
Contributor

daira commented Sep 18, 2016

I don't think we've decided on that prefix yet. That's why the spec hasn't been updated.

@Ban44n
Copy link
Author

Ban44n commented Sep 19, 2016

Not to be pushing or anything, but do you have a date for this? 👍

@daira
Copy link
Contributor

daira commented Sep 19, 2016

Probably beta 2. (That is, if we make a change it'll essentially have to be in beta 2.)

@daira
Copy link
Contributor

daira commented Sep 19, 2016

See #812.

@daira daira added A-wallet Area: Wallet usability labels Sep 19, 2016
@daira
Copy link
Contributor

daira commented Sep 19, 2016

And no problem with pushing :-)

@daira
Copy link
Contributor

daira commented Oct 18, 2016

#812 was merged for beta 2, and the spec updated to include the new prefixes.

@daira daira closed this as completed Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants