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

Passkey support #611

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open

Passkey support #611

wants to merge 21 commits into from

Conversation

ScreamingHawk
Copy link
Contributor

Major changes:

  • Add passkey package with passkey signer
  • Use /rpc/API/GetAuthToken2 with reference chain id for auth
  • Use /rpc/API/SaveSignerSignatures2 with reference chain id for recording witnesses
  • Optionally skip EIP-1271 validation when recovering config from signature
  • Optionally signer can return a "validation signature" to use for validation. (e.g. Using 6492)
  • Guard uses "validation signature" when available for checking validity. See v2 signature decoding validates EIP-6492 signatures go-sequence#177

Note: All changes are backwards compatible.

chainID: numberString(args.chainId),
signatures: filteredSignatures
})
if (filteredSignatures.length === 0 || typeof args.signatures[0] === 'string') {
Copy link
Member

Choose a reason for hiding this comment

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

Why not use saveSignerSignatures2 every time? This check seems a bit buggy, as it assumes that the whole list of signatures will use the same type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to keep saveWitnesses backwards compatible.
I'll update this to check that the entire list matches a format. To make this error happen they would have to ignore the type string[] | SignerSignature[] though. We generally accept that the types are as specified.

Copy link
Member

Choose a reason for hiding this comment

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

what does it mean backwards compatible? like being able to roll this sequence.js update before sessions is updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clients that use trackers in sequence.js would need to upgrade their implementation if they upgrade to this version. I wanted to avoid breaking changes where possible.

Copy link
Member

Choose a reason for hiding this comment

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

But couldn't you recover the address if string[] and then use saveSignerSignatures2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so? Correct me if I'm wrong but we'd need the wallet config version, which this function doesn't have access to. We could assume, but that seems even more error prone than using the current method as is.

@@ -6,6 +6,7 @@ export type PresignedConfig = {
nextConfig: commons.config.Config
signature: string
referenceChainId?: string
validateBehavior?: 'ignore' | 'throw'
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be an argument of savePresignedConfiguration instead? Does PresignedConfigLink makes any use of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems related to referenceChainId. Both are for validation purposes.

Copy link
Member

Choose a reason for hiding this comment

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

Not really. referenceChainId specifies the chain to use for signature validation (without it, validation wouldn’t be possible), as it gives meaning to the signature. validateBehavior is not directly tied to the signature itself but acts as a rule for the process involving the signature. This “rule” shouldn’t inadvertently cross into other contexts.

/**
* Build a validation signature for an undeployed contract signer.
*/
buildValidationSignature?(signatureBytes: ethers.BytesLike): Promise<ethers.BytesLike | undefined>;
Copy link
Member

Choose a reason for hiding this comment

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

Is this a 6492 signature or something else? if so, can we add 6492 to the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is for now but I guess it doesn't have to be. If we extend support to other validation encodings (zk or something?) we could reuse this method.
Happy to rename if you think we won't reuse later.

Copy link
Member

Choose a reason for hiding this comment

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

Let’s rename it for now. I’d prefer it to be obvious at a glance.

Copy link
Member

@Agusx1211 Agusx1211 left a comment

Choose a reason for hiding this comment

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

Left a few comments, nice work tho

@ScreamingHawk ScreamingHawk requested a review from a team as a code owner December 5, 2024 20:06
@ScreamingHawk ScreamingHawk force-pushed the passkeys branch 2 times, most recently from c5ee3fe to 260bacb Compare December 9, 2024 21:54
decoded,
payload,
this.provider,
'ignore'
Copy link
Member

Choose a reason for hiding this comment

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

Why are we passing "ignore" here if we do have a provider? aren't we risking contaminating the local database of signatures?

I guess the alternative would be to miss data, which may be worse.

@Agusx1211
Copy link
Member

Lets test this on fun before merging it to master. I published a tag release 0.0.0-20241216114019.

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