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

EIP1271 Support #617

Open
wants to merge 10 commits into
base: epic-v0.6.x
Choose a base branch
from

Conversation

derekpierre
Copy link
Member

@derekpierre derekpierre commented Jan 29, 2025

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

Co-authored by @theref

What this does:
Based over #616 .

  • Support for EIP1271 authentication
  • Allow AuthSignatures that can be used with :userAddress to be EIP4361, EIP4361 Single Sign On, EIP1271 (Smart contract wallet). Before we only allowed EIP4361 (non-single sign-on but this was too restrictive)

Issues fixed/closed:
Related to nucypher/nucypher#3576.

Follow-up issue: #620

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

@codecov-commenter
Copy link

codecov-commenter commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (epic-v0.6.x@4f713cf). Learn more about missing BASE report.

Additional details and impacted files
@@              Coverage Diff               @@
##             epic-v0.6.x     #617   +/-   ##
==============================================
  Coverage               ?   89.34%           
==============================================
  Files                  ?       76           
  Lines                  ?     6671           
  Branches               ?      367           
==============================================
  Hits                   ?     5960           
  Misses                 ?      675           
  Partials               ?       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@derekpierre derekpierre self-assigned this Feb 3, 2025
@derekpierre derekpierre changed the title [WIP] Musings for EIP1271 Support EIP1271 Support Feb 3, 2025
@derekpierre derekpierre marked this pull request as ready for review February 3, 2025 20:21
vzotova
vzotova previously approved these changes Feb 4, 2025
Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

Very complete tests, great! 🙌

I just left a small question.

public readonly signature: string,
) {}

public async getOrCreateAuthSignature(): Promise<EIP1271AuthSignature> {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm missing something, but the function name (getOrCREATEAuthSignature()) makes me think that the function is able to create a new EIP1271AuthProvider object, but this is not correct, right? This function will be called only for already created objects. Should we rename it?

Copy link
Member Author

Choose a reason for hiding this comment

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

makes me think that the function is able to create a new EIP1271AuthProvider object

It's the flip. AuthProviders implement the function getOrCreateAuthSignature(). The AuthProvider is specified as a parameter to the ConditionContext, which then uses it to generate an AuthSignature via the getOrCreateAuthSignature() function.

So for EIP1271 as an example the code looks like the following:

const authProvider = new EIP1271AuthProvider(...);
conditionContext.addAuthProvider(':userAddressEIP1271', authProvider)
...
const decryptedMessage = await decrypt(
      ...
      messageKit,
      conditionContext,
    );

This conditionContext can then provide the auth signature data needed for proving ownership using the auth provider - see https://github.com/derekpierre/taco-web/blob/eip1271-support/packages/taco/src/conditions/context/context.ts#L116.

This function will be called only for already created objects. Should we rename it?

The getOrCreateAuthSignature() was named (perhaps incorrectly so) as such because it may not actually create the object because the auth signature object could be cached. For example, EIP4361 caches the auth signature after first creating it for 2 hours and doesn't need to create it again within that 2 hours i.e. subsequet calls to getOrCreateAuthSignature simply uses the cached object if called again within that 2-hour window. That being said, perhaps the name is too tied to implementation. we can always rename it to getAuthSignature() or something else ... although let's do that in a different PR ...?

Copy link
Member

Choose a reason for hiding this comment

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

Got it!
|
Yes, something to consider, but in a different PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #621

@derekpierre
Copy link
Member Author

Found a separate issue. Moving to draft.

@derekpierre derekpierre marked this pull request as draft February 5, 2025 14:42
This was referenced Feb 5, 2025
Expand existing AuthSignature type and schema to accomodate new type.
Update LocalStorage to be type-specific via generics.
…better organized.

Add condition context tests for EIP1271 reserved context param.
Updates AuthProviderType to handle multiple provider types for USER_ADDRESS_PARAM_DEFAULT while
maintaining single type for external EIP4361. Updates related tests to properly map auth provider
keys.
theref and others added 4 commits February 11, 2025 11:55
Adds fakeBogusProvider export with proper ExternalProvider implementation to enable testing of authentication failure cases.
@derekpierre
Copy link
Member Author

Found a separate issue. Moving to draft.

Issue resolved.

@derekpierre derekpierre dismissed manumonti’s stale review February 11, 2025 16:31

Will be resolved in separate PR

@derekpierre derekpierre marked this pull request as ready for review February 11, 2025 16:48
@derekpierre derekpierre dismissed vzotova’s stale review February 11, 2025 19:25

Need to re-review updated changes

Copy link
Member

@manumonti manumonti left a comment

Choose a reason for hiding this comment

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

Great! LGTM 🙌

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.

5 participants