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 189)
182fn run_qsdc_example() -> Result<()> {
183 println!("\nQuantum Secure Direct Communication");
184 println!("---------------------------------");
185
186 // Create QSDC protocol with 1000 qubits
187 let num_qubits = 1000;
188 println!("Creating QSDC protocol with {num_qubits} qubits");
189 let qsdc = QSDC::new(num_qubits);
190
191 // Transmit message directly
192 let message = b"This message is sent directly using quantum channel";
193 println!(
194 "Message to transmit: '{}'",
195 std::str::from_utf8(message).unwrap()
196 );
197
198 let start = Instant::now();
199 let received = qsdc.transmit_message(message)?;
200 println!("Transmission completed in {:.2?}", start.elapsed());
201
202 println!(
203 "Received message: '{}'",
204 std::str::from_utf8(&received).unwrap()
205 );
206
207 // Check for errors
208 let errors = message
209 .iter()
210 .zip(received.iter())
211 .filter(|(&a, &b)| a != b)
212 .count();
213
214 println!(
215 "Bit error rate: {:.2}%",
216 (errors as f64) / (message.len() as f64) * 100.0
217 );
218
219 Ok(())
220}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 199)
182fn run_qsdc_example() -> Result<()> {
183 println!("\nQuantum Secure Direct Communication");
184 println!("---------------------------------");
185
186 // Create QSDC protocol with 1000 qubits
187 let num_qubits = 1000;
188 println!("Creating QSDC protocol with {num_qubits} qubits");
189 let qsdc = QSDC::new(num_qubits);
190
191 // Transmit message directly
192 let message = b"This message is sent directly using quantum channel";
193 println!(
194 "Message to transmit: '{}'",
195 std::str::from_utf8(message).unwrap()
196 );
197
198 let start = Instant::now();
199 let received = qsdc.transmit_message(message)?;
200 println!("Transmission completed in {:.2?}", start.elapsed());
201
202 println!(
203 "Received message: '{}'",
204 std::str::from_utf8(&received).unwrap()
205 );
206
207 // Check for errors
208 let errors = message
209 .iter()
210 .zip(received.iter())
211 .filter(|(&a, &b)| a != b)
212 .count();
213
214 println!(
215 "Bit error rate: {:.2}%",
216 (errors as f64) / (message.len() as f64) * 100.0
217 );
218
219 Ok(())
220}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.