zingolib icon indicating copy to clipboard operation
zingolib copied to clipboard

Internal address space should be use for creating change outputs

Open krnak opened this issue 2 years ago • 2 comments

Avoiding usage of internal address space could lead to incomplete funds discovery when migrating from foreign wallet to Zingo wallet by passing a seed phrase (opposite direction should be fine).

Current state

Every change output is sent to the first external address

orchard: m/32h/133h/0h
sapling: m/32h/133h/0h
transparent: m/44h/133h/0h/0/0

According to the specification

Every change output should be sent to an internal address

orchard: m/32h/133h/0h/0
sapling: m/32h/133h/0h/0
transparent: m/44h/133h/0h/1/x

where x is a fresh index for every new change output.

It is recommended to use multiple transparent addresses to decrease linkability of user's public transaction records. Linkability is not an issue for shielded addresses thus one shielded internal address (at diversifying index 0) is sufficient.

Internal shielded address can be get by

let change_address = fvk.address_at(0, Scope::Internal);

Sources

BIP-44: Multi-Account Hierarchy for Deterministic Wallets ZIP-32: Shielded Hierarchical Deterministic Wallets

krnak avatar Feb 16 '23 09:02 krnak