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

Implement cryptographic hashing via various algorithms #122

Closed
wants to merge 21 commits into from

Conversation

CompeyDev
Copy link
Contributor

@CompeyDev CompeyDev commented Oct 15, 2023

What's in this PR?

Closes #105.

Refer to the above issue for tracking/implementation discussions.

TODO

  • Implement a base structure/framework
    • Macros for less boilerplate
    • Trait implementations
      • LuaUserData
      • FromLua
      • From for convenience
      • CryptoAlgo enum
  • Implement specific algorithms
    • Md5
    • Sha(1, 256, 512, 3_256, 3_512)
    • Blake(2, 3)
    • Argon2id
    • PBKDF2
  • Tests & QA
    • Agree on where to have the API be available and in what form
    • Tests
    • Documentation

@CompeyDev
Copy link
Contributor Author

@RustCrypto doesn't have a Blake3 implementation for Rust, so it might be a bit tricky to interop with our current framework being used for this.

@filiptibell
Copy link
Collaborator

Thank you for the PR! However, I'm not really sure if this is what I'd like hashing/crypto algorithms to look like in Lune.

From a users perspective:

  • A user thinking "I want to hash something" and then needing to keep track of a hasher object and learn what a digest is etc seems out of place for Lune - we tend to restrict API surface somewhat over going for maximum flexibility, to try to not expose too much to the user and not add cognitive overhead
  • Generally, to represent enum-like options in our built-in libraries, we use string literal unions as arguments (serde.encode/decode, stdio.prompt, ...), and not standalone functions. Naming functions this way prioritizes what the function does instead of how it does it
  • We don't have this kind of library-inside-library (crypto inside serde) anywhere else

I think this still needs some additional thought and design before moving on. The implementation using macros, boxing, mutexes seems more complex than it needs to be. Luau now also has a native buffer type, which negates some of the performance concerns we previously had for an API more similar to serde.encode/decode. I'll be leaving a comment on the related issue as well and we can try to keep design discussion there

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.

serde library should have hash functions
2 participants