SequenceNumberStore
Persists Sender Sequence Numbers across restarts (RFC 8613 Appendix B.1.1), so a restarted endpoint never reuses an AEAD nonce under the same Sender Key.
The application supplies the store, because only it knows where durable storage is on its platform; kcoap-oscore/README.md has recipes. EphemeralSequenceNumberStore keeps numbers in memory and is only correct for keys that are new in this process run.
A SecurityContext does not write every number: it reserves a block of numbers ahead, persists the end of the block, and writes again only when the block is used up. Every number it hands out is below a limit that store has already returned for, so after a restart it continues from the persisted value, skipping at most one block. SecurityContext.derive records a context it sees for the first time with the limit 0, so deriving it again counts as a restore (FreshnessPolicy.AUTO).
Implementations shared by several contexts must be safe for concurrent calls. Keep the values out of backups that can be restored onto a device: an older value brought back is exactly a nonce reuse.
At most one live context may use a store under one context name. Discard the previous context before deriving it again from the same store: the store keeps one limit per name and cannot tell two contexts apart, so both would hand out the same numbers (SecurityContext.derive explains how).