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

Always use full commitment #1818

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Always use full commitment #1818

wants to merge 5 commits into from

Conversation

Trivo25
Copy link
Member

@Trivo25 Trivo25 commented Sep 12, 2024

Why? This prevents transactions from being replayed. Deletable accounts will also benefit from this change in the future

closes #1798

@Trivo25 Trivo25 marked this pull request as ready for review September 12, 2024 13:10
@@ -897,8 +901,6 @@ class AccountUpdate implements Types.AccountUpdate {
*/
requireSignature() {
let { nonce, isSameAsFeePayer } = AccountUpdate.getSigningInfo(this);
// if this account is the same as the fee payer, we use the "full commitment" for replay protection
this.body.useFullCommitment = isSameAsFeePayer;
Copy link
Collaborator

@mitschabaude mitschabaude Sep 12, 2024

Choose a reason for hiding this comment

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

previously there were two different ways we ensured that it's not replayed:

  • if the account was the same as the fee payer, we used the full commitment
  • otherwise, we incremented the nonce and set a nonce precondition

I like the simplification of just always using the full commitment (my initial idea on why not to do that was flexibility of signing with one key without yet having the fee payer sign; but now I think the simplicity is more important)

What this also means is that we don't need to do the nonce increase in this function depending on isSameAsFeePayer.

Instead, I would do the following:

  • add a boolean optional parameter to this function noFullCommitment, if it's true do the nonce increment instead
  • remove the isSameAsFeePayer return value from getSigningInfo

Comment on lines +617 to +620

// useFullCommitment = true by default, prevents replay attacks and similar issues
// the developer can still modify this to false if needed later on
body.useFullCommitment = Bool(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this, how about setting this to true in requireSignature() instead of always? it's a bit weird to me that the default account update differs from the natural dummy AU with no apparent reason

Copy link
Collaborator

Choose a reason for hiding this comment

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

or in setLazySignature?

Copy link
Collaborator

Choose a reason for hiding this comment

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

well or maybe we should remove setLazySignature since it no longer holds a private key so no real purpose

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