Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions backup-shard/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: © 2025 Foundation Devices, Inc. <hello@foundation.xyz>
// SPDX-License-Identifier: GPL-3.0-or-later

use std::fmt;

use dcbor::{CBOR, CBOREncodable, Map};

#[derive(Debug, Default, Clone, PartialEq, zeroize::ZeroizeOnDrop)]
Expand Down Expand Up @@ -324,7 +326,7 @@ impl TryFrom<CBOR> for ShardVersion {
}
}

#[derive(Debug, Default, Clone, PartialEq, zeroize::ZeroizeOnDrop)]
#[derive(Default, Clone, PartialEq, zeroize::ZeroizeOnDrop)]
#[cfg_attr(
feature = "keyos",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
Expand All @@ -337,6 +339,18 @@ pub struct ShardV0 {
pub part_of_magic_backup: bool,
}

impl fmt::Debug for ShardV0 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ShardV0")
.field("device_id", &self.device_id)
.field("seed_fingerprint", &self.seed_fingerprint)
.field("seed_shamir_share", &"<redacted>")
.field("seed_shamir_share_index", &self.seed_shamir_share_index)
.field("part_of_magic_backup", &self.part_of_magic_backup)
.finish()
}
}

impl ShardV0 {
pub const VERSION: u8 = 0;
}
Expand Down Expand Up @@ -425,7 +439,7 @@ impl TryFrom<CBOR> for ShardV0 {
}
}

#[derive(Debug, Clone, PartialEq, zeroize::ZeroizeOnDrop)]
#[derive(Clone, PartialEq, zeroize::ZeroizeOnDrop)]
#[cfg_attr(
feature = "keyos",
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
Expand All @@ -441,6 +455,21 @@ pub struct ShardV1 {
pub scheme_share_count: usize,
}

impl fmt::Debug for ShardV1 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ShardV1")
.field("device_id", &self.device_id)
.field("seed_fingerprint", &self.seed_fingerprint)
.field("seed_shamir_share", &"<redacted>")
.field("seed_shamir_share_index", &self.seed_shamir_share_index)
.field("part_of_magic_backup", &self.part_of_magic_backup)
.field("timestamp", &self.timestamp)
.field("scheme_threshold", &self.scheme_threshold)
.field("scheme_share_count", &self.scheme_share_count)
.finish()
}
}

impl ShardV1 {
pub const VERSION: u8 = 1;
}
Expand Down
Loading