pub struct QSDC {
pub num_qubits: usize,
pub error_rate: f64,
}Expand description
Quantum Secure Direct Communication protocol
Fields§
§num_qubits: usizeNumber of qubits to use
error_rate: f64Error rate for the quantum channel
Implementations§
Source§impl QSDC
impl QSDC
Sourcepub fn new(num_qubits: usize) -> Self
pub fn new(num_qubits: usize) -> Self
Creates a new QSDC protocol instance
Examples found in repository?
examples/quantum_crypto.rs (line 181)
174fn run_qsdc_example() -> Result<()> {
175 println!("\nQuantum Secure Direct Communication");
176 println!("---------------------------------");
177
178 // Create QSDC protocol with 1000 qubits
179 let num_qubits = 1000;
180 println!("Creating QSDC protocol with {num_qubits} qubits");
181 let qsdc = QSDC::new(num_qubits);
182
183 // Transmit message directly
184 let message = b"This message is sent directly using quantum channel";
185 println!(
186 "Message to transmit: '{}'",
187 std::str::from_utf8(message).unwrap()
188 );
189
190 let start = Instant::now();
191 let received = qsdc.transmit_message(message)?;
192 println!("Transmission completed in {:.2?}", start.elapsed());
193
194 println!(
195 "Received message: '{}'",
196 std::str::from_utf8(&received).unwrap()
197 );
198
199 // Check for errors
200 let errors = message
201 .iter()
202 .zip(received.iter())
203 .filter(|(&a, &b)| a != b)
204 .count();
205
206 println!(
207 "Bit error rate: {:.2}%",
208 (errors as f64) / (message.len() as f64) * 100.0
209 );
210
211 Ok(())
212}Sourcepub fn with_error_rate(self, error_rate: f64) -> Self
pub fn with_error_rate(self, error_rate: f64) -> Self
Sets the error rate for the quantum channel
Sourcepub fn transmit_message(&self, message: &[u8]) -> Result<Vec<u8>>
pub fn transmit_message(&self, message: &[u8]) -> Result<Vec<u8>>
Transmits a message directly using the quantum channel
Examples found in repository?
examples/quantum_crypto.rs (line 191)
174fn run_qsdc_example() -> Result<()> {
175 println!("\nQuantum Secure Direct Communication");
176 println!("---------------------------------");
177
178 // Create QSDC protocol with 1000 qubits
179 let num_qubits = 1000;
180 println!("Creating QSDC protocol with {num_qubits} qubits");
181 let qsdc = QSDC::new(num_qubits);
182
183 // Transmit message directly
184 let message = b"This message is sent directly using quantum channel";
185 println!(
186 "Message to transmit: '{}'",
187 std::str::from_utf8(message).unwrap()
188 );
189
190 let start = Instant::now();
191 let received = qsdc.transmit_message(message)?;
192 println!("Transmission completed in {:.2?}", start.elapsed());
193
194 println!(
195 "Received message: '{}'",
196 std::str::from_utf8(&received).unwrap()
197 );
198
199 // Check for errors
200 let errors = message
201 .iter()
202 .zip(received.iter())
203 .filter(|(&a, &b)| a != b)
204 .count();
205
206 println!(
207 "Bit error rate: {:.2}%",
208 (errors as f64) / (message.len() as f64) * 100.0
209 );
210
211 Ok(())
212}Trait Implementations§
Auto Trait Implementations§
impl Freeze for QSDC
impl RefUnwindSafe for QSDC
impl Send for QSDC
impl Sync for QSDC
impl Unpin for QSDC
impl UnwindSafe for QSDC
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.