# Class RoomKeyStore | EchoHub Documentation
Holds room content keys for end-to-end encrypted channels: in-memory for the active session, persisted per-server in the client config (like saved sessions) so users don't retype the passphrase every launch. Keys never leave this machine and are encrypted at rest by . Also tracks which channels are known to be end-to-end encrypted, so senders can refuse to emit plaintext into a room whose key isn't cached yet.

# Class RoomKeyStore

Namespace
  EchoHub.Client.Services

Assembly
  EchoHub.Client.dll

Holds room content keys for end-to-end encrypted channels: in-memory for the active session, persisted per-server in the client config (like saved sessions) so users don't retype the passphrase every launch. Keys never leave this machine and are encrypted at rest by RoomKeyProtector. Also tracks which channels are known to be end-to-end encrypted, so senders can refuse to emit plaintext into a room whose key isn't cached yet.

    public sealed class RoomKeyStore

Inheritance
  object
  RoomKeyStore

Inherited Members
  object.GetType()
  object.ToString()
  object.Equals(object)
  object.Equals(object, object)
  object.ReferenceEquals(object, object)
  object.GetHashCode()

## Constructors

### RoomKeyStore()

    public RoomKeyStore()

### RoomKeyStore(RoomKeyProtector)

    public RoomKeyStore(RoomKeyProtector protector)

#### Parameters

`protector` RoomKeyProtector

## Methods

### Clear()

    public void Clear()

### HasKey(string)

    public bool HasKey(string channelName)

#### Parameters

`channelName` string

#### Returns

bool

### IsChannelEncrypted(string)

    public bool IsChannelEncrypted(string channelName)

#### Parameters

`channelName` string

#### Returns

bool

### LoadForServer(string)

Binds the store to a server and loads that server's cached keys from config.

    public void LoadForServer(string serverUrl)

#### Parameters

`serverUrl` string

### MarkChannelEncrypted(string, bool)

Records whether a channel is end-to-end encrypted (from channel listings, crypto metadata, or join outcomes). Senders consult this to block plaintext into rooms whose key isn't cached.

    public void MarkChannelEncrypted(string channelName, bool isEncrypted)

#### Parameters

`channelName` string
`isEncrypted` bool

### RemoveKey(string)

    public void RemoveKey(string channelName)

#### Parameters

`channelName` string

### StoreKey(string, byte[])

Stores a key for the session and persists it to the server's config entry.

    public void StoreKey(string channelName, byte[] key)

#### Parameters

`channelName` string
`key` byte[]

### TryGetKey(string, out byte[])

    public bool TryGetKey(string channelName, out byte[] key)

#### Parameters

`channelName` string
`key` byte[]

#### Returns

bool

### TryStoreFromEnvelope(string, string, byte[])

Unwraps a fresh key envelope and caches the key, overwriting any stale cached key (e.g. the channel was deleted and recreated under the same name, so the old key would encrypt messages nobody else can read). Returns false when the KEK doesn't open the envelope — the cache is left untouched.

    public bool TryStoreFromEnvelope(string channelName, string wrappedRoomKey, byte[] kek)

#### Parameters

`channelName` string
`wrappedRoomKey` string
`kek` byte[]

#### Returns

bool