feat(assessment): find the attempt behind a leaked task text

This commit is contained in:
shira committed 2026-10-11 13:19:38 +03:00
1 parent bb917bf62e
commit 5a731c25b7
26 files changed
+2500

No files matched your search

@@ -36,6 +36,7 @@ const (
labelWatermark = "lincodex/assessment/watermark/v1"
labelSignalAgent = "lincodex/assessment/signal-agent/v1"
labelWorkClient = "lincodex/assessment/work-client/v1"
labelLeakText = "lincodex/assessment/leak-text/v1"
)
// Keyring computes the keyed digests of the anonymous identity operations:
@@ -59,6 +60,7 @@ type Keyring struct {
watermarkKey []byte
signalAgentKey []byte
workClientKey []byte
leakTextKey []byte
}
// NewKeyring derives the purpose keys from secret.
@@ -82,6 +84,7 @@ func NewKeyring(secret []byte) (*Keyring, error) {
watermarkKey: derive(secret, labelWatermark),
signalAgentKey: derive(secret, labelSignalAgent),
workClientKey: derive(secret, labelWorkClient),
leakTextKey: derive(secret, labelLeakText),
}, nil
}
@@ -268,3 +271,13 @@ func (keyring *Keyring) AssessmentWorkClientDigest(attemptID uuid.UUID, clientID
mac.Write([]byte(clientID))
return domain.AssessmentDigest(mac.Sum(nil))
}
// AssessmentLeakTextDigest stands for the text of one operator search in the
// audit. It is keyed, so the audit can show that a text was searched twice
// without keeping it, and nobody can confirm a guess about a text from the
// audit alone.
func (keyring *Keyring) AssessmentLeakTextDigest(text []byte) domain.AssessmentDigest {
mac := hmac.New(sha256.New, keyring.leakTextKey)
mac.Write(text)
return domain.AssessmentDigest(mac.Sum(nil))
}