feat: add device_id to CustomerKeySeed

This commit is contained in:
jane400 2024-08-18 18:09:27 +02:00 committed by jane400
parent cc52b99144
commit cda0f946da

View file

@ -6,9 +6,10 @@ use ed25519_dalek::Signer;
pub struct CustomerKeySeed {
postnumber: String,
seed: Seed,
uuid: Uuid,
pub postnumber: String,
pub seed: Seed,
pub uuid: Uuid,
pub device_id: Option<String>,
}
pub struct Seed {
@ -44,17 +45,25 @@ impl CustomerKeySeed {
postnumber,
seed: Seed::random(),
uuid: uuid::Uuid::new_v4(),
device_id: None,
}
}
pub fn from(postnumber: &String, seed: Vec<u8>, uuid: &Uuid) -> Self {
pub fn from(postnumber: &String, seed: Vec<u8>, uuid: &Uuid, device_id: String) -> Self {
CustomerKeySeed {
postnumber: postnumber.clone(),
seed: Seed::from_bytes(seed),
uuid: uuid.clone()
uuid: uuid.clone(),
device_id: Some(device_id),
}
}
pub fn set_device_id(&mut self, device_id: String) {
assert!(self.device_id.is_none());
self.device_id = Some(device_id);
}
pub(crate) fn sign(&self, message: &[u8]) -> String {
let signing_key = SigningKey::from_bytes(self.seed.as_bytes());