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

Base64URL #4692

Closed
dcposch opened this issue Oct 19, 2023 · 1 comment · Fixed by #4822
Closed

Base64URL #4692

dcposch opened this issue Oct 19, 2023 · 1 comment · Fixed by #4822
Labels
Milestone

Comments

@dcposch
Copy link

dcposch commented Oct 19, 2023

🧐 Motivation

OZ has a great Base64 encoder. (And, as far as I can tell, the only audited one.)

There's a lot of interest in passkey-based wallets now, which offer an excellent self-custody UX. These rely on the WebAuthn standard, which uses Base64URL.

For that use case and for completeness, it would be great to have a canonical, audited onchain Base64URL encoder.

📝 Details

Encoding Input Output
Base64 hello world aGVsbG8gd29ybGQ=
Base64URL hello world aGVsbG8gd29ybGQ

I think this can be done with contract derived from Base64.sol with two straightforward modifications:

  • Change two characters in the lookup table
  • Remove the trailing = padding

If there's interest, I'm happy to send a PR.

@ernestognw ernestognw added this to the 5x milestone Nov 1, 2023
@Amxx Amxx added the idea label Jan 4, 2024
@Amxx Amxx modified the milestones: 5x, 5.x Jan 4, 2024
@Amxx Amxx mentioned this issue Jan 8, 2024
3 tasks
@ernestognw
Copy link
Member

Hey @dcposch, thanks for opening the issue. We agree this is an important use case and we're considering it for a future minor release.

For other readers, the two different characters for this version are -_ instead of +/ according to RFC4648.

This is being implemented through #4822 but we may want to also add a fuzz test suite for it after (and if) foundry-rs/foundry#6744 is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants