-
Notifications
You must be signed in to change notification settings - Fork 53
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
Sign and verify hashed data #213
Conversation
@finestructure @csjones I would appreciate if one of you could take the time to review this little change so more people can benefit from it. Thanks! 😃 |
I'm not a maintainer 🙂 |
Hey @davids11 👋 First off, thank you for contribution and suggesting these changes. Your pull request touches on a previous topic which mentioned that supporting other hash algorithms is already supported by this package via the Digest protocol. Given that the ECDSA APIs wouldn't need modification to support your use case, what are your thoughts on instead introducing a more generic Let me know if your willing to make these changes for this PR 🙂 |
Hi @csjones 👋 Thank you for the answer and the feedback! Happy to discuss this further :) |
Sorry for the confusion, my request was to implement In terms of "simply passing in an Evolving this codebase to make bytes explicitly typed will also catch errors at build time where the existing APIs using Would you mind telling me more about how / what you're using this change for? |
No problem! :) Let's see if we have a shared understanding: So instead of If that's what you mean, where do I find the If you mean instead to add another struct called
We use SHA3-256 to hash our data and key derivation. |
This is closest to what I mean but I'm confused by your reasoning of needing to implement A better detailed breakdown of the requested changes are:
struct 32BytesDigest: Digest {
...
public static func create(from bytes: [UInt8]) -> 32BytesDigest {
let first = output[0..<8].withUnsafeBytes { $0.load(as: UInt64.self) }
let second = output[8..<16].withUnsafeBytes { $0.load(as: UInt64.self) }
let third = output[16..<24].withUnsafeBytes { $0.load(as: UInt64.self) }
let forth = output[24..<32].withUnsafeBytes { $0.load(as: UInt64.self) }
return 32BytesDigest(bytes: (first, second, third, forth))
}
...
} Hope that helps the shared understanding 🙂 |
Thanks for the detailed answer, that definitely helped! 😃 Changes are implemented and ready to review. Instead of
My question is: Why does |
Glad it helped and thank you for the changes! Pretty good to go, only minor comments. Up to you if you want to address the comment with small changes.
Ahh I see what you mean now, good question. I do agree that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo for the struct name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [ ]
Enables the usage of other hash algorithms that aren't supported by the library like SHA3 for example.