Page MenuHomePhabricator

[electrum] never suggest the same proof master key or delegation key twice
ClosedPublic

Authored by PiRK on Oct 5 2023, 10:14.

Details

Summary

Previously we would always suggest the auxiliary key with index 0 as the proof master key, and open a key generation widget which shows index 1 by default when generating a delegation.

Store a counter/index as wallet data and increment it whenever a new auxiliary key is shown, so that we always suggest a new key. Users can still find their old keys by opening the Auxiliary keys tool and decrementing the value, but we will never suggest using an old one.

Bump the range of the index widget to allow the full range of indices, as per bip 32.

Test Plan

Open a wallet, open the proof editor dialog, close it and reopen a new proof editor dialog, check that the master key is different.
Then open a delegation editor dialog, click "generate key" and check that it opens an auxiliary key dialog with index 2 (0 and 1 were used for the two proofs). Increment the indexto 3, close the delegation dialog.
Then open the "Auxiliary keys" dialog via the "Wallet" menu, check that the index is now 4.

Close the wallet, reopen it, check that the index is now 5.

Set the index to 2147483647 (MAX value), close the wallet, reopen it and check that opening the auxiliary keys tool does not cause an overflow error (and the index is now stuck at 2147483647)

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Oct 5 2023, 10:14
PiRK edited the test plan for this revision. (Show Details)

prevent overflows

Fabien added a subscriber: Fabien.

I'm glad you tested the case of someone generating > 2 billion proofs/delegations :)

This revision is now accepted and ready to land.Oct 5 2023, 11:28

I'm glad you tested the case of someone generating > 2 billion proofs/delegations :)

Or just playing with the spinbox and copy-pasting an absurd number :)