What's new

How to use deterministic zerocoin generation.

Jeffrey

Administrator
Staff member
What is deterministic zPIV Generation?
Zerocoins, or zPIV, are now deterministically generated using a unique 256 bit seed. Each wallet will generate a new seed on its first run. The deterministic seed is used to generate a string of zPIV that can be recalculated at any time using the seed. Deterministic zPIV allows for users to backup all of their future zPIV by simply recording their seed and keeping it in a safe place (similar to backing up a private key for PIV). The zPIV seed needs to remain in the wallet in order to spend the zPIV after it is generated, if the seed is changed then the coins will not be spendable because the wallet will not have the ability to regenerate all of the private zPIV data from the seed. It is important that users record their seed after their first run of the wallet. If the wallet is locked during the first run, then the seed will be generated the first time the wallet is unlocked.
Is deterministic generation safer?
The PIVX Developers do consider dzPIV to be safer to use than raw zerocoins. Raw zerocoins are databased with absolutely no encryption. If someone were to write some code to sweep your computer for zerocoins, even if your wallet is encrypted, they would likely be able to steal those coins.
When using dzPIV and an encrypted wallet, the zPIV seed is encrypted and only unlocked with your password. The rest of the zerocoin information associated with your dzPIV is never databased and is simply recalculated on the fly when it is needed.
dzPIV is less secure in the sense that if someone is able to steal your seed, they are going to be able to steal your entire chain of zPIV (the same concept as someone stealing your private key).mnemonic
What information is needed to generate my zPIV?
Each zPIV can be created using your zPIV Seed and a count. The count represents the position in the position in your string of zPIV that was created. For example if you create 10 different zPIV, and your zPIV seed is 0x9e...f12 you will have the following:
Coin 1Coin 2...Coin 10
Seed0x9e...f120x9e...f120x9e...f12
Count1210
How to locate and backup your zPIV seed:
  • If your wallet is encrypted, unlock the wallet with Settings-> Unlock Wallet. Make sure that you uncheck for staking an anonymization only
  • Go Tools -> Debug Console -> Console
  • Type getzpivseed
Your zPIV seed will be output to the console. The seed is a 64 character hexadecimal string (256bit). It is not a mnemonic phrase. Backup this seed in a safe location, preferably offline.
How do I restore my zPIV using my seed?
Using the zPIV Seed to restore the information about your zPIV is computational expensive, it can take several hours to restore all of the coins. Although it requires a lot of computation, it does provide a good fail safe in the case of wallet corruptions, machine failure, or other situations.
Importing a seed
Important Warning: It is extremely important that if you are importing a seed, you should be aware that you are setting whatever the wallet's current seed to as inactive. Right now the wallet is only coded to handle one seed at a time. If the wallet you import to has zPIV generated by a different seed, then these zPIV will not be spendable until you switch the seed back.
Using the RPC command setzpivseed to replace the wallets existing seed with the seed you are importing. Please read the warning above before doing this!
As seen above, a dzPIV is comprised of your master zPIV seed and the count the coin is in the sequence. If you know that you have only generated a few zPIV, the wallet will likely automatically detect those for you because it will pregenerate the public value of the zPIV (called PublicCoin within the codebase) and will search the blockchain for any knowledge of that zPIV.
Extended Search
If the automatic import does not work, there are likely gaps in your generation sequence. For example when staking zPIV, you may have had 20 orphans in a row, thus bumping the count up by 20 without any of those Public Coins making it onto the blockchain. In this situation, you are able to tell your wallet to search a certain count range on the blockchain.
In this example, I think my wallet generated up to count 100. I import my zPIV Seed to a fresh wallet.dat using RPC command setzpivseed 9e...f12. The wallet automatically generates mints 1-20 and checks the chain for those values. If it finds that count 15 was used and on the blockchain, it will then generate up to 35 (keeping a buffer of 20) and check if any of those were added to the chain. The wallet loops through that process until no coins are found in the buffer of 20.
After the wallet stops syncing dzPIV, I type in command dzpivstate which will return something like this:
{
"dzpiv_count": 15,
"mintpool_count": 35
}

My wallet stopped generating at 35, but I suspect my mints could be all the way up to count 100. I tell the wallet to generate up to count 100. I want the wallet to start at count 35 because I have already generated up to count 35. I want my wallet to generate an additional 65 zPIV so that it will check up to count 100. Searching for zPIV takes computation, so I am going to run it on two threads. I type the following command searchdzpiv 35 65 2.

When the process is finished it will return the message done. I can now use dzpivstate to see what the current count is (the last found zPIV added to the blockchain + 1). I can also go to the Privacy Dialog and check that my zPIV have been added.
 
Top