Documentation
¶
Overview ¶
Package sqlitestore is the SQLCipher-backed implementation of anonauth.PseudonymStore. The pseudonym database lives in its own encrypted file with a key derived from the deployment's master seed via a dedicated HKDF info string, so the queue-storage seed and this file's seed never share derivation paths even when they share the same underlying secret.
Index ¶
- type Store
- func (s *Store) CheckAndIncrement(ctx context.Context, pub ed25519.PublicKey, epoch int64, limit uint32, ...) error
- func (s *Store) Close() error
- func (s *Store) DeleteExpired(ctx context.Context, before time.Time) (int, error)
- func (s *Store) Register(ctx context.Context, pub ed25519.PublicKey, created, expires time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the SQLCipher-backed pseudonym store.
func New ¶
New opens (or creates) the pseudonym database under dataDir. dataDir is created with 0700 permissions if it does not exist; the database file is encrypted with a key derived from seed via the package's dedicated HKDF info string.
func (*Store) CheckAndIncrement ¶
func (s *Store) CheckAndIncrement(ctx context.Context, pub ed25519.PublicKey, epoch int64, limit uint32, now time.Time) error
CheckAndIncrement runs the per-epoch counter logic atomically. The SELECT-then-UPDATE happens inside a transaction; the package mutex guards against the SQLITE_BUSY-free race between two writers reaching the same row at the same instant.
The sequence:
- SELECT the current row inside a transaction.
- If expires_at <= now, abort with ErrPseudonymExpired.
- If last_epoch != epoch, the row's counter is stale and we treat the current value as 0. Otherwise we use it as is.
- If the (possibly reset) counter is already at the limit, abort with ErrRateLimited.
- UPDATE the row to the new (epoch, counter+1) and commit.
func (*Store) DeleteExpired ¶
DeleteExpired removes records whose expiry is at or before before.