I’m trying to use the secret-extended-key-main from zecwallet to generate additional diversified addresses from that same root address. Is there a good way to validate that my new addresses are valid? I put them in the ‘address validate’ window and it says “ismine”:false but I’m not sure if this is just saying that particular string doesn’t match an exact string in my wallet.
Best to ask the developer of ZecWallet: @adityapk00
Are you doing it programmatically? There’s some example code here: zecpaperwallet/paper.rs at master · adityapk00/zecpaperwallet · GitHub
From the UI, there’s no way to test an address, and I think that’s by design. Remember that diversified addresses are indistinguishable from regular addresses, so there’s no obvious way to associate 2 diversified addresses.
I mean a “regular” zaddr is just a diversified address at index 0 (or the lowest index that produces a valid address, using AES-FPE to generate the diversifier) per my understanding of the spec, right?
The case I’m mentioning is where I control the private keys of the address. I know it isn’t possible to associate 2 diversified addresses given just the 2 addresses, but what if the addresses belong to me and I know what the private keys behind them are?
Oh, OK. If you have the private key, then it is quite straightforward.
You need to check if the PaymentAddress<Bls12>.pk_d
extracted from the Address String matches the PaymentAddress<Bls12>.pk_d
calculated from the private key.
To extract it from the address, see: librustzcash/encoding.rs at main · zcash/librustzcash · GitHub
To calculate it from the private key, you do:
ExtendedFullViewingKey::from(&extspk).fvk.default_address().unwrap().1
where extspk
is the ExtendedSpendingKey
Another way is to get the Diversifier
from the Address, and use that diversifier with the private key to calculate the address, and see if the address string matches.
See here for an example from the Zec Paper Wallet: zecpaperwallet/paper.rs at master · adityapk00/zecpaperwallet · GitHub
I was actually trying to write my own implementation of this (a script that calculates a diversified address given an ivk, dk, and index), I guess I just wanted to make sure my implementation actually works correctly and I’ll really be able to receive the zec sent to the addresses my script generate.
I’m not super familiar with rust but will check out the example, thanks
If all you want to do is do a test, then there’s a simpler way
What you do is:
- Import the private key into zcashd
- Send a small amount of ZEC to the diversified address (corresponding to the private key)
- See if zcashd recognizes the incoming payment
zcashd has the code to detect incoming payments for all diversified addresses for it’s private keys. When it sees an incoming payment, it also adds the diversified address automatically to the wallet and processes the incoming payment…
You can do this on testnet so there’s no actual ZEC wasted
hi, could you please share me the full code to generate diversifies address?
thank you so much!