-
Notifications
You must be signed in to change notification settings - Fork 231
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
Add StreamVerifier
#196
Add StreamVerifier
#196
Conversation
Note that there's a https://docs.rs/signature/latest/signature/trait.DigestVerifier.html I think it would probably make sense for those to map to Ed25519ph though (although context-handling presents a complication). |
Yeah I saw that trait but it doesn't seem to map well to ed25519 since it receives the signature after the message digest has been created and we need to add parts from the public key and signature as the initially digested parts. |
Ed25519ph is intended to be the IUF mode for Ed25519, and is already implemented by Personally I would find it confusing to encounter an IUF mode for Ed25519 that wasn't Ed25519ph. |
If ed25519 and ed25519ph verifications algorithms were compatible, I wouldn't have an issue. What do you think is the best course of action for the use case listed of more-memory-efficient Discord webhook verification given I cannot change Discord itself to sign its requests using the *ph variant? This is clearly possible to acomplish unless the approach of this PR has security downsides I'm not aware of. |
You could potentially give it a different name which is less likely to be confused with Ed25519ph, like "StreamingVerifier" |
Ahh. If this is just a naming issue then sure that seems very appropriate. |
Yeah, I think it might be nice for |
Heya! What's the status of this PR? It'd be nice to have for twilight-rs, so I'd like to help if there's anything I can do. |
So I did attempt redoing this PR on top of I got around that by making a impl StreamingVerifier {
// ...
pub fn finalize_and_verify(self) -> Result<(), SignatureError> {
hazmat::raw_verify::<dirty_workaround::DirtyWorkaround>(&self.public_key, self.hasher.finalize().as_slice(), &self.signature)
}
} This seems like an incredibly bad idea on my part, but it works, so I felt obligated to share it. |
@Monadic-Cat can you open a PR so we can discuss options? |
let minus_A: EdwardsPoint = -self.public_key.point; | ||
let k = Scalar::from_hash(self.hasher); | ||
let R = | ||
EdwardsPoint::vartime_double_scalar_mul_basepoint(&k, &(minus_A), &self.signature.s); |
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.
I wonder if VerifyingKey::recover_R
could be further decomposed into VerifyingKey::recover_R_from_k
or thereabouts which captures this functionality.
cc @rozbb
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.
I've made that change along with some tangential work in #304
migrated to dalek-cryptography/curve25519-dalek#542 |
Context
In web applications, it is desirable to avoid storing the request payload. It is currently impossible to verify a signature based on a request payload that is receieved in a chunk stream without allocating additional memory equal to the size of the payload.
Solution
A stateful type that holds the public key, candidate signature, and hash state that can be updated incrementally.
To Do
ed25519-dalek
verify_stream
method toKeypair
References