Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

SPV library API discussion #1

Open
AndrewGuarda opened this issue Dec 21, 2017 · 21 comments
Open

SPV library API discussion #1

AndrewGuarda opened this issue Dec 21, 2017 · 21 comments

Comments

@AndrewGuarda
Copy link

AndrewGuarda commented Dec 21, 2017

Dear Z-Cash foundation and community.Guarda is doing Z-Cash grant SPV library and Wallet Android project #ZcashFoundation/GrantProposals-2017Q4#16. We'd like to have the communications in a transparent and community-oriented way. It will be really great to have any valuable feedback regarding SPV function and methods that we are going to implement.
Please leave your comments below and we'll take it into the account.

@AndrewGuarda AndrewGuarda reopened this Dec 28, 2017
@AndrewGuarda AndrewGuarda changed the title SPV library API description SPV library API discussion Dec 28, 2017
@AndrewGuarda
Copy link
Author

Terms of reference
Z-Cash wallet functions:

  • Generate Private+public keys for t-addr
  • Generate Private (spending) + public keys for z-addr
  • Get balance for own t-addr
  • Get balance for own z-addr
  • Sign and sent transaction using t-addr private key. Change should send back to the sending address
  • Sign and sent transaction using z-addr spending key. Change should send back to the sending address
  • Support memo field for the transactions
  • Send ZEC between t-addr and z-addr and vice versa
  • History for own t-addr
  • History for own z-addr
  • Keys backup
  • Restore the wallet from backup for both t-addr and z-addr

OS requirements: from Android 4.4 and higher

The list of SPV library methods:

  • Generate private+public t-addr keys. Executes on the device, no network calls, instant result expecting.
public static String generateNewPrivateKey_taddr();
public static String publicKeyFromPrivateKey_taddr(String privKey);
  • Generate spending+public z-addr keys. Executes on the device, no network calls, instant result expecting.
public static String generateNewPrivateKey_zaddr();
public static String publicKeyFromPrivateKey_zaddr(String privKey);
  • Get t-addr balance, asynchronous network method, the result is callback function
public void getBalance_taddr(String pubKey, WalletCallback<String, Long> onComplete);
  • Get t-addr balance, asynchronous network method, the result is callback function
public void getBalance_zaddr(String pubKey, WalletCallback<String, Long> onComplete);
  • Send t-addr transaction, asynchronous network method, the result is callback. Separate method to generate transaction on the device.
public ZCashTransaction_taddr createTransaction_taddr(fromAddr, toAddr, amount, fee, memo, privateKey);
public void pushTransaction_taddr(ZCashTransaction_taddr tx, WalletCallback<String, Void> onComplete);
  • Send t-addr transaction, asynchronous network method, the result is the callback. Separate method to generate the transaction on the device.
public ZCashTransaction_zaddr createTransaction_zaddr(fromAddr, toAddr, amount, fee, memo, privateKey);
public void pushTransaction_zaddr(ZCashTransaction_zaddr tx, WalletCallback<String, Void> onComplete);
  • History for t-addr. Returns following details: Sum, time, date, hash, origin address, destination address, balance after/before, confirmations, block height
public void getTransactionHistory_taddr(String pubKey, int limit, int offset, WalletCallback<String, List<ZCashTransactionDetails_taddr>> onComplete);
  • History for z-addr. Returns following details: Sum, time, date, hash, origin address, destination address, balance after/before, confirmations, block height
public void getTransactionHistory_zaddr(String pubKey, int limit, int offset, WalletCallback<String, List<ZCashTransactionDetails_zaddr>> onComplete);
  • Restore t-addr using backup
public void importWallet_taddr(String privateKey, WalletCallback<String, Void> onComplete);
  • Restore z-addr using the backup. It will require blockchain scan.
public void importWallet_zaddr(String privateKey, WalletCallback<String, Void> onComplete);

@BlinkyStitt
Copy link

Why are you sending change back to the senders address? Address reuse should be avoided if possible. Generating change addresses with an HD wallet is pretty simple and there are already standards for it.

@garethtdavies
Copy link

@wysenynja there is a good post here https://forum.z.cash/t/i-dont-want-too-many-own-addresses-in-my-wallet/22497/2?u=garethtdavies discussing this issue.

@garethtdavies
Copy link

In the history for z-addr method should the destination be displayed? See this earlier discussion zcash/zcash#1438

@bitcartel
Copy link

@guardaco Is there a reason to support Android 4.4 instead of targeting the latest Android 8.0 and taking advantage of the latest frameworks and toolchain?

@chaserileyroberts
Copy link

How is the RNG of generateNewPrivateKey implemented or accessed? It might be a good idea to allow dependency injection in case we learn later that the RNG is compromised.

@AndrewGuarda
Copy link
Author

@wysenynja thank you for the feedback. For the mobile wallet, it's not so useful to have the list of HD addresses, the number of addresses will grow for each outgoing transaction. Finally, the addresses long list will almost useless in mobile interfaces. That's why we decide to use origin address for receiving unspent.

@AndrewGuarda
Copy link
Author

@bitcartel there is a number of restrictions for the wallet functionality on 4.4 and early, I'm afraid it will be impossible to have the full wallet functions in that case. For my own opinion the market share of such devices mapped for ZEC users will not so great. Do you have any ideas why we need to support 4.4 and early devices?

@Uche32
Copy link

Uche32 commented Feb 28, 2018

the amount of Android 8.0 and + are so limited that a former version is the best way, but 4.4 seems a bit to far back in the time. if someone uses still Android 4.4 then he probably should not be into cryptocurrency, just a thought.

@mineZcash
Copy link

Are you planning on restricting functionality for devices that have less RAM? Or having some sort of way for the app to detect the hardware?

Generation of a Z-transaction currently takes 1.7GB of RAM and 40seconds to complete.

Newer Android phones have 4GB of system RAM standard (and up to 8GB) but many older Android phones only have 2GB standard.

How do you plan on ensuring that you don't lock up or crash older devices?

@AndrewGuarda
Copy link
Author

@mineZcash you're right absolutely. As far as we are doing non-custodial solution, we are not able to use any external wallet services for operations with spending key. So there is no way to generate Z-transaction out of the device. It will be done by the SPV library on the device.

It will take some time, but nobody can avoid it in case of shielded transactions. We'll try to make the process transparent and clear for customers to avoid claims.

For the old devices, we'll do the performance tests and check the results. We can make the limitations or restrictions for z-transactions in case there is no chance to complete it. We'll consult with @lindanlee regarding the best user experience for that users.

I hope Sapling and z2-addr will help to reducу the resources consumption.

@bitcartel
Copy link

bitcartel commented Feb 28, 2018

Android 8 also targets low-end devices.
https://www.android.com/versions/oreo-8-0/go-edition/

Android 4.4 is only 12% of the market.
https://developer.android.com/about/dashboards/index.html

All those people with old phones running Android 4 will probably upgrade soon, especially as more mobile apps drop support in order to take advantage of latest OS features.

Whilst Google still provides security patches, consider that the last OS release was 4.4.4 (KTU84Q) on July 7, 2014 - almost 4 years ago.

I don't think you need to support Android 4. I do think you should target Android 8 and by the time you have launched the wallet later this year, Android 9 will be out.

@daira
Copy link

daira commented Mar 2, 2018

Doesn't it depend completely on which features are provided by each release since 4.4? There's no point in artificially depending on a release with features that you don't actually need.

@daira
Copy link

daira commented Mar 2, 2018

@AndrewGuarda wrote:

I hope Sapling and z2-addr will help to reducу the resources consumption.

Just a minor point: the prefix for Sapling addresses on mainnet will be "zs".

@BlinkyStitt
Copy link

I think Nathan's comment about change addresses is missing several important factors.

I've replied at the official forums: https://forum.z.cash/t/i-dont-want-too-many-own-addresses-in-my-wallet/22497/4?u=wysenynja

@AndrewGuarda
Copy link
Author

@wysenynja thank you so much for the addresses issue. We'll try to implement our best in terms of a mobile wallet

@AndrewGuarda
Copy link
Author

@bitcartel you're absolutely right. As far as we'll have z-addr we need to run the application at the high-end devices in terms to get suitable performance.

@AndrewGuarda
Copy link
Author

@Thenerdstation RNG is a good point. At the moment we're planning to use built-in RNG. I'm not sure that most users will be ready to use external RNG and can understand why they need it. Almost the same issue with using own blockchain node. It sounds like the expert-level features. Definitely, we need to think about such features in later releases. I appreciate your feedback.

@AndrewGuarda
Copy link
Author

Hello all,

we've released in beta our t-addr Zcash wallet. The beta is available at the Play Market https://play.google.com/store/apps/details?id=com.guarda.zec for Zcash community review. I'll appreciate any valuable feedback.

@mineZcash
Copy link

Nice work @AndrewGuarda

@AndrewGuarda
Copy link
Author

Dear all,
please find t-addr SPV-library repository https://github.com/guardaco/zcash-SPV

@mineZcash

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants