Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Proof building tool #229

Merged
merged 29 commits into from
Aug 24, 2022
Merged

Improve Proof building tool #229

merged 29 commits into from
Aug 24, 2022

Commits on Aug 24, 2022

  1. remove unnecessary StakeSigner

    In the previous Proof format, the stake key used to sign the proofid, which depended on the whole list of stakes. So we needed to keep a list of stake signers, and sign the stake only when they were all added.
    
    The new proof format is now designed to allow adding new stakes to an existing proof without requiring all the stake signatures to be updated. The stake key no longer signs all the other stakes. We can now sign the stakes as soon as they are added.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    0feff0b View commit details
    Browse the repository at this point in the history
  2. rename Proof.stakes to Proof.signed_stakes, to remove any ambiguity

    There is a Stake and a SignedStake object. This makes it clear that the list contains the latter.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    f094998 View commit details
    Browse the repository at this point in the history
  3. implement ProofBuilder.from_proof

    This allows to create a proofbuilder with exact same parameters and same existing stakes, and than add more stakes.
    
    The master private key must be provided again, as only the corresponding public key is available in the proof.
    
    Add a test (test result generated using the node buildavalancheproof RPC).
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    0cbf200 View commit details
    Browse the repository at this point in the history
  4. add methods to verify signatures in SignedStake and Proof

    Add also a stake_commitment attribute to the `Proof` class, so it is easy to verify the stakes in that proof.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    65d7249 View commit details
    Browse the repository at this point in the history
  5. add a test for the address to/from payout_script conversion

    This adds sanity checks to ensure the current code and tests are good, before changing the ProofBuilder to take an address rather than a script in the next commit.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    59b1329 View commit details
    Browse the repository at this point in the history
  6. make the proof builder take an Address instead of an output script

    This is in line with the buildavalancheproof RPC. If we ever need to support arbitrary scripts or pubkeys in the future, it is already possible using a ScriptOutput or a PublicKey object, even though the "payout_address" name does not really reflect this (fixme).
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    6c01889 View commit details
    Browse the repository at this point in the history
  7. [Proof editor] move code to add utxo to separate method

    Instead of passing utxos to the widget's __init__, add utxos using a dedicated method.
    This will enable adding additional coins once the widget is already built.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    70bdc2f View commit details
    Browse the repository at this point in the history
  8. [Proof editor] refactor dialog to pass utxos with a dedicated method

    This allows to remove the weird overloading of exec_ and the special do_execute flag, as we no longer need to test the utxos in __init__.
    Also rename AvalancheProofWidget to AvalancheProofEditor
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    b7d48cf View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    ce2f0d8 View commit details
    Browse the repository at this point in the history
  10. [Proof editor] add a checkbox to disable proof expiration

    Disabling the expiration time will cause it to be 0 in the proof. The calendar and timestamp combobox will be disabled.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    a412882 View commit details
    Browse the repository at this point in the history
  11. [Proof editor] add an "Add coins" button

    This loads coins from a json file.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    c53eec7 View commit details
    Browse the repository at this point in the history
  12. [proof builder] add a method to add a stake when there is a signature…

    … available
    
    This is useful for adding stakes extracted from an existing proof, without need to find the private key again and redo the signature. This will be especially useful when building proofs collaboratively, with different wallets adding their stakes to a proof templates, and later merging the proof in a master wallet that does not have the utxo keys.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    5c37d1e View commit details
    Browse the repository at this point in the history
  13. [Proof editor] implement load proof in proof editor

    This implements loading an existing proof.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    f12491a View commit details
    Browse the repository at this point in the history
  14. [proof builder] add a sign_and_add_stake method

    It makes more sense than the add_utxo method which has basically weak typing for parameters.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    019e2cc View commit details
    Browse the repository at this point in the history
  15. [proof editor] Don't fail on proofs with no stakes

    We want to be able to build  proofs with no stake to be used as proof templates for other wallets to load and stakes.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    f92e3ba View commit details
    Browse the repository at this point in the history
  16. [proof editor] don't load coins with no block height at all

    Previously we loaded them to show them in red in the utxo table, and later ignored them when building the proof.
    Excluding them early is easier, and will allow storing Stake objects directly instead of vaguely defined dictionaries.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    8377fdc View commit details
    Browse the repository at this point in the history
  17. [proof editor] store SignedStake or Stake + Key internally

    This removes boilerplate code attempting to analyze the dict objects used previously. Now, the dict object will only be used initially when loading coins from a file or building from coins in this wallet, and it will be converted internally into a Stake + Key (we need to wait for the rest of the proof data to be final before signing the stake).
    
    Remove also the coin freezing feature on proof building. The coins will likely not belong to the wallet building the proof.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    16356b2 View commit details
    Browse the repository at this point in the history
  18. [Proof editor] change "build proof from coins file" action into "Aval…

    …anche proof editor"
    
    The new workflow is not to open the proof editor, then click the "load coins" button.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    b4b20be View commit details
    Browse the repository at this point in the history
  19. [proof editor] add a save proof button

    This saves a proof to file, in hexadecimal text format.
    Also change the buttons layout to be horizontal below the proof display.
    Also use a regular button for the "generate delegation" button. The link looks weird.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    0feb66e View commit details
    Browse the repository at this point in the history
  20. [Proof builder] enable building proof without master private key (wit…

    …h invalid sig)
    
    This changes the proof builder to make it accept a master pub instead of a master private key.
    The resulting signature will be invalid.
    
    This is to allow people to add signed stakes to a proof without knowledge of the master key. Such an invalid proof can be used to gather stakes from multiple users, and merge all the proofs in the master wallet (who can then produce a correct signature).
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    9cfb368 View commit details
    Browse the repository at this point in the history
  21. [Proof editor] allow building of proof when private key is not available

    In such a case, if the public key is available, a proof can be produced with an invalid signature. This is useful for gathering signed stakes in invalid proofs (from other wallets) and later merging the resulting proofs  in the master wallet.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    4cac6cd View commit details
    Browse the repository at this point in the history
  22. [Proof editor] add a merge stakes buttons

    This should enable merging proofs with identical stake commitment data (master key and expiration time) but different stakes.
    The use case is:
     - a master wallet creates a proof template with no stakes (but all other data otherwise correct) and save it to a .proof file
     - multiple other wallets load this proof and add signed stakes to it from coin files, and save the result to a .proof file.
     - the master wallet loads one of the proof files (possibly the initial template), and then merge the stakes from all other files.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    51c117f View commit details
    Browse the repository at this point in the history
  23. [Proof editor] replace "ok" and "dismiss" buttons by single "Close" b…

    …utton
    
    There is no need for a "reject" status for these dialogs for now, they are pretty independant from the main window.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    00a0f0c View commit details
    Browse the repository at this point in the history
  24. [Proof editor] improve warnings when generating a proof without a pri…

    …vate master key
    
    Creating an unsigned proof is a standard procedure when signing the stakes with a different wallet, for the proof to be signed again later in the master wallet.
    So make the warnings less alarming, mention that it is OK to just sign stakes.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    c58bfaa View commit details
    Browse the repository at this point in the history
  25. [Proof editor] add information about signatures status

    Print good signatures in green, bad signatures in red. Add labels indicating the status of signatures below the proof display.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    d897cf2 View commit details
    Browse the repository at this point in the history
  26. [Proof editor] add option to load a proof from string

    In the proof editor, the "load proof" button now load a dialog accepting a copy-pasted string or loading from a .proof file.
    
    In the delegation tool, there is now a button "Load from file" to open a .proof file.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    fce829b View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    03fd29f View commit details
    Browse the repository at this point in the history
  28. [Proof editor] fix rich text proof

    In the serialization, I forgot to encode the number of stakes and the pubkey length. Fix this and add an assertion to avoid regressions.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    991ae5f View commit details
    Browse the repository at this point in the history
  29. [Proof editor] add "-unsigned" to the default proof filename when app…

    …licable
    
    When signing stakes in a different wallet than the wallet controlling the master key, the proof signature will be all 0s. Reflect this in the file name when saving the proof, to help with managing the files during the multi-step signing procedure.
    PiRK committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    9e48764 View commit details
    Browse the repository at this point in the history