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