feat: Add secret length validation#639
Closed
thesimplekid wants to merge 10 commits into
Closed
Conversation
feat: Add secret length validation with 512-byte limit feat: Add MAX_SECRET_LENGTH constant for secret length validation
5 tasks
ok300
reviewed
Mar 10, 2025
| { | ||
| Self(secret.into()) | ||
| let secret_str = secret.into(); | ||
| if secret_str.chars().count() > crate::nuts::nut00::MAX_SECRET_LENGTH { |
Contributor
There was a problem hiding this comment.
Looks like the same validation logic should apply as in the new custom Secret deserializer.
Maybe extract the logic in validate_secret (even though it's only length check now) and call it both in the deserializer and here? Extracting it in a method would make validation easier to manage or extend in the future.
| pub async fn verify_proof(&self, proof: &Proof) -> Result<(), Error> { | ||
| // Check that the secret length is not greater than MAX_SECRET_LENGTH characters | ||
| ensure_cdk!( | ||
| proof.secret.to_string().chars().count() <= cdk_common::nuts::nut00::MAX_SECRET_LENGTH, |
Contributor
There was a problem hiding this comment.
This would also be a good place to call the validate_secret mentioned above.
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Co-authored-by: ok300 <106775972+ok300@users.noreply.github.com>
Collaborator
Author
|
Think i closed this by accident |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: Add secret length validation with 512-byte limit
feat: Add MAX_SECRET_LENGTH constant for secret length validation
Description
cashubtc/nuts#234
Notes to the reviewers
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just final-checkbefore committing