Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/ed25519-dalek/src/verifying/stream.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / ed25519-dalek / src / verifying / stream.rs` 45 lines ยท 1332 bytes Raw Blame History 1 use curve25519_dalek::edwards::CompressedEdwardsY; 2 use sha2::Sha512; 3 4 use crate::verifying::RCompute; 5 use crate::{signature::InternalSignature, InternalError, SignatureError, VerifyingKey}; 6 7 /// An IUF verifier for `ed25519`. 8 /// 9 /// Created with [`VerifyingKey::verify_stream()`] or [`SigningKey::verify_stream()`]. 10 /// 11 /// [`SigningKey::verify_stream()`]: super::SigningKey::verify_stream() 12 #[allow(non_snake_case)] 13 pub struct StreamVerifier { 14 cr: RCompute, 15 sig_R: CompressedEdwardsY, 16 } 17 18 impl StreamVerifier { 19 /// Constructs new stream verifier. 20 /// 21 /// Seeds hash state with public key and signature components. 22 pub(crate) fn new(public_key: VerifyingKey, signature: InternalSignature) -> Self { 23 Self { 24 cr: RCompute::new(&public_key, signature, None), 25 sig_R: signature.R, 26 } 27 } 28 29 /// Digest message chunk. 30 pub fn update(&mut self, chunk: impl AsRef<[u8]>) { 31 self.cr.update(chunk.as_ref()); 32 } 33 34 /// Finalize verifier and check against candidate signature. 35 #[allow(non_snake_case)] 36 pub fn finalize_and_verify(self) -> Result<(), SignatureError> { 37 let expected_R = self.cr.finish(); 38 39 if expected_R == self.sig_R { 40 Ok(()) 41 } else { 42 Err(InternalError::Verify.into()) 43 } 44 } 45 }