Skip to main content

Crate scp_platform

Crate scp_platform 

Source
Expand description

Platform abstraction layer for SCP.

This crate defines the four platform abstraction traits that every SCP component depends on for device-specific capabilities:

  • KeyCustody — Cryptographic key management (generation, signing, ECDH, pseudonym derivation). Production: Secure Enclave (iOS), Android Keystore.
  • DeviceAttestation — Device attestation tokens (App Attest, Play Integrity).
  • Push — Push notification registration and handling (APNs, FCM).
  • Storage — Persistent key-value byte storage (Keychain, encrypted SQLite).

All traits are Send + Sync with async methods, designed for injection through initializers. Production implementations use hardware security; testing implementations (in-memory, see ADR-006) provide identical API surfaces with no external dependencies.

§Architecture

See ADR-006 (“In-Memory Platform Adapter”) in .docs/adrs/phase-1.md for the full design rationale. The trait definitions in this crate are the authoritative source for all platform adapter contracts.

§Usage

Components accept platform traits as generic parameters or trait objects:

async fn create_identity<K: scp_platform::KeyCustody>(custody: &K) {
    let handle = custody.generate_keypair(scp_platform::KeyType::Ed25519).await?;
    // ...
}

Re-exports§

pub use encrypted::EncryptedStorage;
pub use error::PlatformError;
pub use traits::CustodyType;
pub use traits::DeviceAttestation;
pub use traits::DeviceAttestationToken;
pub use traits::KeyCustody;
pub use traits::KeyHandle;
pub use traits::KeyType;
pub use traits::PseudonymKeypair;
pub use traits::PublicKey;
pub use traits::Push;
pub use traits::PushToken;
pub use traits::SharedSecret;
pub use traits::Signature;
pub use traits::Storage;
pub use traits::WakeSignal;

Modules§

encrypted
Sealed marker trait for storage backends that encrypt data at rest.
error
Platform error types for SCP platform abstraction traits.
traits
Platform abstraction traits for SCP.