pub struct ProjectedContext { /* private fields */ }Expand description
A broadcast context whose messages are projected (decrypted and served) by this node’s HTTP endpoints.
Maps epoch numbers to their corresponding BroadcastKeys so the
projection handlers can decrypt messages from any epoch the node has
observed. Multiple epochs are retained for the blob TTL window so
messages encrypted under previous keys can still be decrypted.
Stores the context’s BroadcastAdmission mode and optional
ProjectionPolicy so projection handlers can enforce authentication
requirements (SCP-GG-007, SCP-GG-008).
See spec section 18.11.5.
Implementations§
Source§impl ProjectedContext
impl ProjectedContext
Sourcepub fn new(
context_id: &str,
broadcast_key: BroadcastKey,
admission: BroadcastAdmission,
projection_policy: Option<ProjectionPolicy>,
) -> Self
pub fn new( context_id: &str, broadcast_key: BroadcastKey, admission: BroadcastAdmission, projection_policy: Option<ProjectionPolicy>, ) -> Self
Creates a new ProjectedContext from a context ID, initial broadcast key,
admission mode, and optional projection policy.
The routing ID is computed as SHA-256(context_id) per spec section 5.14.6.
The key is inserted at its own epoch number. The admission mode and
projection policy are stored for use by projection handlers when deciding
whether to require authentication (spec section 18.11.2.1).
Sourcepub const fn routing_id(&self) -> &[u8; 32]
pub const fn routing_id(&self) -> &[u8; 32]
Returns the routing ID for this projected context.
Sourcepub fn context_id(&self) -> &str
pub fn context_id(&self) -> &str
Returns the context ID (hex-encoded string).
Sourcepub const fn keys(&self) -> &HashMap<u64, BroadcastKey>
pub const fn keys(&self) -> &HashMap<u64, BroadcastKey>
Returns a reference to the keys map (epoch -> broadcast key).
Sourcepub const fn admission(&self) -> BroadcastAdmission
pub const fn admission(&self) -> BroadcastAdmission
Returns the admission mode for this broadcast context.
Sourcepub const fn projection_policy(&self) -> Option<&ProjectionPolicy>
pub const fn projection_policy(&self) -> Option<&ProjectionPolicy>
Returns the projection policy, if any.
Sourcepub fn insert_key(&mut self, broadcast_key: BroadcastKey)
pub fn insert_key(&mut self, broadcast_key: BroadcastKey)
Inserts a broadcast key for the given epoch.
Keys are retained indefinitely rather than pruned after the blob TTL window (spec §18.11.5). This is acceptable because:
- Key rotations only occur on subscriber blocks (uncommon)
- Each key is ~40 bytes (32-byte secret + epoch + author DID ref)
- Even hundreds of epochs per context is negligible memory
If pruning becomes necessary, add a prune_before(epoch) method
keyed to the relay’s max_blob_ttl.
Important: After a governance ban (RevokeReadAccess /
governance_ban_subscriber), all author keys are rotated in the
ContextManager. The caller MUST propagate the new-epoch keys to
the projection registry via this method; otherwise the projection
endpoint cannot decrypt content encrypted under the new keys.
Sourcepub fn retain_only_epochs(&mut self, epochs: &HashSet<u64>)
pub fn retain_only_epochs(&mut self, epochs: &HashSet<u64>)
Removes all keys whose epoch is NOT in the given set.
Used after a Full-scope governance ban to ensure historical content
encrypted under pre-ban keys is no longer decryptable by the
projection endpoint. Messages referencing purged epochs will return
410 Gone rather than serving content that a banned subscriber may
have previously accessed.
Takes a set of epochs to retain (typically the new post-rotation epochs). This correctly handles epoch-divergent multi-author contexts where authors may be at different epochs.
Sourcepub fn key_for_epoch(&self, epoch: u64) -> Option<&BroadcastKey>
pub fn key_for_epoch(&self, epoch: u64) -> Option<&BroadcastKey>
Returns the broadcast key for the given epoch, if present.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProjectedContext
impl RefUnwindSafe for ProjectedContext
impl Send for ProjectedContext
impl Sync for ProjectedContext
impl Unpin for ProjectedContext
impl UnsafeUnpin for ProjectedContext
impl UnwindSafe for ProjectedContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more