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

User Addresses are hashes of Public Keys #475

Merged
merged 8 commits into from
Feb 18, 2022
Merged

User Addresses are hashes of Public Keys #475

merged 8 commits into from
Feb 18, 2022

Conversation

huitseeker
Copy link
Contributor

This advances #318.

Main changes:

  • cryptographic operations are moves from base_types to a separate crypto file.
  • the behavior of the Authorities' signatures does not change,
    • their signatures are a new type AuthoritySignature, which is just an alias of the former Signature type.
    • Signing, signature verification, do not change for Authorities.
    • We remove references to their address where relevant, i.e. in the separation of SuiAddress (hashes of user PublicKeys) and PublicKey, authorities only manipulate and concern themselves with the later.
  • the Signature type is introduced:
    • it consists of the bytes of an ed25519 signature, followed by the bytes of the public key this signature is valid for,
    • it's straightforward to tweak an implementation of a Signer producing a certain type of signature into one that appends the bytes of the public key after the signature, for all reasonable signers,
    • we demonstrate this by augmenting the existing impl signer::Signer<AuthoritySignature> for our KeyPair type with an impl signer::Signer<Signature>,
    • the verification (check) of this new user Signature type now takes a SuiAddress argument
    • on top of verifying the validity of the cryptographic signature for its embedded public key, check also checks the PublicKey indeed hashes to the expected SuiAddress passed as an argument.
  • the SuiAddress type is a 32-byte array
    • it's produced by hashing a PublicKey using SHA3-256 into a 32-byte array,

Possible Follow-ups

  • debate and decide on a faster hash function with a smaller output size (20 bytes comes to mind)
  • debate and decide on renaming Signature to UserSignature
  • split get_key_pair into random_user_keypair which returns (SuiAddress, KeyPair), and random_authority_keypair which returns (PublicKeyBytes, KeyPair),
  • ... and make sure those are only called in tests.

Ancillary changes

Copy link
Contributor

@lxfind lxfind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -4,7 +4,6 @@ on:
push:
branches: [ main, extensions ]
pull_request:
branches: [ main, extensions ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this change for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filtered the target branches that would trigger a CI run on a PR.

@lxfind lxfind force-pushed the decouple-suiaddress-publickey branch from 8ced661 to fc7a5b6 Compare February 18, 2022 03:09
Base automatically changed from decouple-suiaddress-publickey to main February 18, 2022 03:43
@huitseeker
Copy link
Contributor Author

Opened #481 for leftovers

@huitseeker huitseeker merged commit 1591f31 into main Feb 18, 2022
@huitseeker huitseeker deleted the address_to_hash branch February 18, 2022 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants