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

PPRF trait methods should be fallible #14

Open
rillian opened this issue Mar 9, 2022 · 0 comments
Open

PPRF trait methods should be fallible #14

rillian opened this issue Mar 9, 2022 · 0 comments

Comments

@rillian
Copy link
Contributor

rillian commented Mar 9, 2022

The ppoprf crate defines a PPRF trait with a generic interface over a puncturable pseudo-random function. These methods take &[u8] binary data for input and output.

However, those arguments must in fact conform to constraints imposed by the underlying implementation: 32-byte CompressedRistretto points or a valid metadata tag byte sequence in the case of the ggm implementation. Since the arguments are untyped, the caller has no safe way to ensure the methods won't panic, and must rely on ad hoc, redundant validation of anything passed to the trait implementation.

Generally it's better for libraries to return a Result type whenever error is possible, so the caller can decided how to handle such cases. To implement this the PPFR trait should define an error type, which probably looks like a union of GGMError with argument length and format mismatches, and have the fallible methods return that as part of the result.

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

No branches or pull requests

1 participant