Android wallet update 2:
Hello everyone;
I'm progressing in the Java MintCoin library. I got the SPV wallet kit distributed with bitcoinj working (ForwardingService) , it can sync from genesis block to latest block (persists on disk). It can generate a MintCoin address, and receive coins sent to that MintCoin address and send a transaction back. It has some problems creating the forwarding transaction though, I haven't digged in that direction yet.
My biggest concern is security vs. being lightweight enough for Android devices. Normally, SPV wallets are used in android wallets, which only store last x block headers (say 5000), and delete the rest. They trust on their peers and the cumulative POW difficulty of the chain. They don't verify any transactions.
In contrast, for a POW+POS coin, header difficulty in POS blocks is not a secure measure at all. Difficulty of the header is relatively low, and easy to forge. The coinstake transaction of POS block provides block's security, and if you're not verifying transactions, you will have problems. So, if you know that your peer is not validating any transactions at all, including coinstake, you know that you can forge a series of POS blocks and send it to your peer. (In order to be able to verify coinstake transaction, you need to have stored the corresponding transaction that generated it from at least 20 days ago. Its time open ended actually, its position can go up to genesis block. In contrast SPV clients only store transactions that relate to their own addresses, and discard the rest)
Currently, I'm working on a lightly-verified SPV blockchain implementation. It stores up to 40 days of blocks and tracks spent/unspent transactions seen in these blocks (this would somewhat affect the resource usage, but not as much as a full verifying blockchain which is almost impossible to run on android devices). As transactions of last 40 days would be always available, client would be able to verify a high percent of generated POS blocks (If they are indeed generated from unspent transactions, and if coin's owner really matches). It won't be able to verify POS blocks that are generated from older transactions.
So this is a mixed approach, although it doesn't verify all POS blocks, it would assume that a few unverifable POS blocks followed by a large number of verifiable POS blocks means that the network accepted the questionable chain, and that chain can be trusted as long as the network does. Actually this is not a verifying implementation, but rather a invalidating one; detecting as much invalid POS blocks as possible before they are appended to any chain.
This implementation is somewhat different than current bitcoinj/mintcoind 's transaction input/output connecting (they keep track of transactions spent only in the main chain, and rely on cumulative Proof of Work on alternative chains. They do a transaction reordering every time an alternative chain becomes longest). They can do this because they can verify any chain at anytime, they keep the whole history, they don't have any risk at all. In contrast POS with SPV has to keep track of spent/unspent transactions outputs in every possible branch simultaneously, so it can reject invalid POS blocks even before they end up in an alternate chain. This difference proved itself to be highly challenging to implement, although I believe I managed a way out.
So, well, I'm continuing working on this hard, and I believe I resolved most of the problems. Although library is currently working and able to persist on disk and receive transactions, it is not secure until this light verification is done. Hopefully I would be able to fully implement this by the weekend.
I'm working on github, I decided not to publish my changes to public until I can get a wallet android app working, so I avoid pushing my changes there. I'm currently only working only on the java library, it will be very easy to port any wallet to use it once library is properly working. But I don't want any other PoW+PoS coin to grab the library (even unsecure versions of it) and release an android app before us.
I really need some comments / feedbacks on my solution to POS Coin + SPV wallet security issue -- so if you think you have an idea, don't hesitate to contact me, I'll be happy to find out potential security issues and change the design before it's late.
Android wallet update:
Hello everybody; I'm working on a Java MintCoin library and an Android wallet.
For best security and long term development, I forked from latest bitcoinj last week. Converted it to Scrypt. Made it able to communicate with my local Mintcoin wallet over network. I just updated it to understand and accept PoS/PoW hybrid blocks, and I can announce you that it can sync with the blockchain from genesis block up to #239870, which is generated just minutes ago
There are some missing features yet:
- It can validate PoW block difficulties (calculation is a little different in PoW/PoS hybrids than pure PoW coins, PoS blocks affect calculations, and modifying bitcoinj library for this task really had some challenges) ; but it doesn't try to validate PoS block difficulties yet (this is a security issue and will be fixed before releasing)
- It doesn't verify POW block rewards (due to the fact that I couldn't find a specific pseudorandom generator implementation that decides on randomized POW block rewards). I don't think this would be an issue as the main use case would be a Simple Payment Verification wallet, checkpoints will cover our security up to removal of PoW from MintCoin (though it will be nice to have the checks in place)
- Minting: It's now almost clear that minting would be possible even in SPV wallet mode. I will annonuce details later. I have to figure out validating PoS blocks first.
- UI: I'm just trying to get the pure library working properly now. Once the library is working, it'll be very easy to fork/make an Android App that uses it
- Bloom filters: Here is a request for the community: Current Mintcoin wallet doesn't support Bloom filters. Bloom filters allow SPV clients download only the transactions they're interested in (instead of all transactions in blocks), reducing mobile users' data usage dramatically. Please put a bounty on it so that someone can merge it from bitcoin client. Android wallet will work without Bloom Filter support in the main client, but its data usage would be much more.