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

Update challenge transaction helpers sep 10 #497

Conversation

marcelosalloum
Copy link
Contributor

Summary

This PR updates the challenge transaction verifiers to accept multiple signatures, according to the issue #483

What

Add new challenge transactions helpers to utils to support verifying a challenge transaction that has multiple signatures. Three new functions were added and an existent function was deprecated:

  • readChallengeTx: reads the challenge details to parse the transaction and the client account ID out of the transaction.
  • verifyChallengeTxSigners: verify that the signers of the transaction are a subset of a list of public keys passes as arguments.
  • verifyChallengeTxThreshold: verify that the signers of the transaction are a subset of a list of signers that meet a required threshold.
  • Deprecate verifyChallengeTx.

Why

The SEP-10 change that was merged in stellar/stellar-protocol#489 clarifies how an implementer should verify that signers of the transaction are signers on the account and that accounts may have multiple signers.

An implementer needs to read out of the transaction the client account before verifying the transaction and then its threshold. For that reason we need three steps:

  1. Read out details we need before verification (readChallengeTx)
  2. Verify the signatures (verifyChallengeTxSigners)
  3. Verify if the signatures meet the given threshold (verifyChallengeTxThreshold)

The read call also validates the server signature because no challenge transaction would ever be valid to read if it wasn't signed by the server.

For further info, please refer to the SEP-10 protocol.

… replaced most of the 'verifyChallengeTx' implementation with a call to 'readChallengeTx'
…transaction-helpers-sep-10

* upstream/master:
  Fix broken link to Stellar logo+wordmark (stellar#496)
  Junk the _link omition for AccountResponse class (stellar#495)
  v4.0.0 - Horizon 1.0 support (stellar#488)
  Add is_authorized to BalanceLineAsset. (stellar#491)
  Update yarn.lock. (stellar#490)
  Typescript fixes (stellar#489)
Copy link
Contributor

@abuiles abuiles left a comment

Choose a reason for hiding this comment

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

@marcelosalloum looking good! I left some comments

src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
test/unit/utils_test.js Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Thanks making this change @marcelosalloum! There are a couple small things I think we need to tweak, and I have a couple questions that I suspect might be me misunderstanding something about Typescript. They are noted in line below. Otherwise this looks great. Great job on the tests too!

src/utils.ts Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Show resolved Hide resolved
src/utils.ts Outdated Show resolved Hide resolved
src/utils.ts Show resolved Hide resolved
test/unit/utils_test.js Show resolved Hide resolved
test/unit/utils_test.js Show resolved Hide resolved
test/unit/utils_test.js Outdated Show resolved Hide resolved
test/unit/utils_test.js Show resolved Hide resolved
test/unit/utils_test.js Show resolved Hide resolved
Copy link
Contributor

@abuiles abuiles left a comment

Choose a reason for hiding this comment

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

LGTM! @leighmcculloch can you have a final view before we merged it.

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👍 🎉 🚀 :shipit:

src/utils.ts Outdated Show resolved Hide resolved
…ansaction-helpers-sep-10

* origin/master:
  Extend offer call builder to return a single offer. (stellar#499)
@marcelosalloum marcelosalloum merged commit 474b3b1 into stellar:master Feb 18, 2020
@marcelosalloum marcelosalloum deleted the update-challenge-transaction-helpers-sep-10 branch February 18, 2020 20:22
@marcelosalloum marcelosalloum restored the update-challenge-transaction-helpers-sep-10 branch February 18, 2020 20:53
@abuiles abuiles mentioned this pull request Feb 18, 2020
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.

Update challenge transaction helpers for SEP-10 v1.3.0
3 participants