Device

Struct Device 

Source
pub struct Device { /* private fields */ }
Expand description

Handle to an open QUAC 100 device.

This struct provides access to all device functionality including KEM, signatures, hashing, random number generation, and key storage.

The device is automatically closed when this struct is dropped.

§Thread Safety

Device is Send and Sync, allowing it to be shared across threads. The underlying hardware operations are serialized by the device.

§Example

use quantacore::{initialize, open_first_device};

initialize().unwrap();
let device = open_first_device().unwrap();

let info = device.get_info().unwrap();
println!("Connected to: {}", info.model);

// Access subsystems
let kem = device.kem();
let sign = device.sign();
let hash = device.hash();
let random = device.random();

Implementations§

Source§

impl Device

Source

pub fn index(&self) -> u32

Get device index.

Source

pub fn get_info(&self) -> Result<DeviceInfo>

Get device information.

§Example
let device = open_first_device().unwrap();
let info = device.get_info().unwrap();
println!("Model: {}", info.model);
println!("Serial: {}", info.serial_number);
println!("Firmware: {}", info.firmware_version);
Source

pub fn get_status(&self) -> Result<DeviceStatus>

Get device status.

§Example
let device = open_first_device().unwrap();
let status = device.get_status().unwrap();
println!("Temperature: {}°C", status.temperature);
println!("Entropy: {}%", status.entropy_level);
println!("Healthy: {}", status.is_healthy());
Source

pub fn self_test(&self) -> Result<()>

Run device self-test.

This performs a comprehensive self-test of the device hardware and cryptographic implementations.

§Example
let device = open_first_device().unwrap();
device.self_test().expect("Self-test failed");
println!("Device self-test passed");
Source

pub fn reset(&self) -> Result<()>

Reset the device.

This performs a soft reset of the device. All ongoing operations will be cancelled.

Source

pub fn kem(&self) -> Kem

Get the KEM (Key Encapsulation Mechanism) subsystem.

§Example
let device = open_first_device().unwrap();
let kem = device.kem();
let keypair = kem.generate_keypair(KemAlgorithm::MlKem768).unwrap();
Source

pub fn sign(&self) -> Sign

Get the signature subsystem.

§Example
let device = open_first_device().unwrap();
let sign = device.sign();
let keypair = sign.generate_keypair(SignAlgorithm::MlDsa65).unwrap();
Source

pub fn hash(&self) -> Hash

Get the hash subsystem.

§Example
let device = open_first_device().unwrap();
let hash = device.hash();
let digest = hash.sha256(b"Hello, World!").unwrap();
Source

pub fn random(&self) -> Random

Get the random number generator subsystem.

§Example
let device = open_first_device().unwrap();
let random = device.random();
let bytes = random.bytes(32).unwrap();
Source

pub fn keys(&self) -> Keys

Get the key storage (HSM) subsystem.

§Example
let device = open_first_device().unwrap();
let keys = device.keys();
let slots = keys.list().unwrap();
Source

pub fn close(self)

Close the device explicitly.

This is optional; the device will be closed automatically when dropped.

Trait Implementations§

Source§

impl Clone for Device

Source§

fn clone(&self) -> Device

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Device

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl Send for Device

§

impl Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.