Skip to main content

Crate derec_library

Crate derec_library 

Source
Expand description

§DeRec Library

This crate provides an implementation of the DeRec protocol, a decentralized secret recovery mechanism that protects sensitive data by distributing shares of the secret among a set of Helpers.

Instead of relying on a single backup location, DeRec uses threshold secret sharing so that a secret can be reconstructed only when a sufficient number of Helpers collaborate.

§Protocol flows

The library implements the core protocol flows defined by DeRec:

These flows correspond to the lifecycle of a protected secret:

Pairing → Sharing → Verification (periodic) → Recovery (if needed)

§Design

The library provides a high-level API for implementing DeRec-compatible applications. Each flow is implemented as a separate module exposing the functions required to produce and process protocol messages.

Protocol messages themselves are defined using protobuf and are exposed through the derec_proto crate. Most applications should interact with the higher-level APIs instead of manipulating protobuf messages directly.

§Error handling

All public APIs return Result<T>, which wraps the crate-wide Error type. This type aggregates errors originating from the individual protocol flows while preserving their specific error semantics.

§Target environments

The library is designed to work in both:

  • native Rust environments
  • WebAssembly environments (via bindings exposed by individual modules)

WebAssembly bindings are primarily intended for integration with TypeScript applications.

Modules§

derec_message
Outer-envelope (DeRecMessage) parsing, building, and trace-id plumbing.
primitives
protocol
Higher-level protocol orchestrator for the DeRec protocol.
protocol_version
transport
Library-level transport endpoint type + validation.
types
Cross-layer shared types

Enums§

Error

Functions§

generate_replica_id
Generate a fresh replica identity using the OS CSPRNG.

Type Aliases§

Result