feat(assessment): assign the demonstration category and keep result history
This commit is contained in:
1 parent
b3c6dc870b
commit
8277133712
61 files changed
+4338
-268
No files matched your search
@@ -31,6 +31,7 @@ const (
|
||||
labelAnswerFingerprint = "lincodex/assessment/answer-fingerprint/v1"
|
||||
labelSignalSession = "lincodex/assessment/signal-session/v1"
|
||||
labelSignalNetwork = "lincodex/assessment/signal-network/v1"
|
||||
labelResultCursor = "lincodex/assessment/result-history-cursor/v1"
|
||||
)
|
||||
|
||||
// Keyring computes the keyed digests of the anonymous identity operations:
|
||||
@@ -49,6 +50,7 @@ type Keyring struct {
|
||||
answerKey []byte
|
||||
signalSessionKey []byte
|
||||
signalNetworkKey []byte
|
||||
resultCursorKey []byte
|
||||
}
|
||||
|
||||
// NewKeyring derives the purpose keys from secret.
|
||||
@@ -67,6 +69,7 @@ func NewKeyring(secret []byte) (*Keyring, error) {
|
||||
answerKey: derive(secret, labelAnswerFingerprint),
|
||||
signalSessionKey: derive(secret, labelSignalSession),
|
||||
signalNetworkKey: derive(secret, labelSignalNetwork),
|
||||
resultCursorKey: derive(secret, labelResultCursor),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -103,6 +106,17 @@ func (keyring *Keyring) IdempotencyScope(operation, key, normalizedEmail string)
|
||||
return [outbound.IdempotencyDigestSize]byte(mac.Sum(nil))
|
||||
}
|
||||
|
||||
// ResultHistoryCursorSignature signs the position of a result history page for
|
||||
// one candidate under a key of its own, so a cursor can never be replayed as an
|
||||
// idempotency scope or the other way round.
|
||||
func (keyring *Keyring) ResultHistoryCursorSignature(position, candidateID string) [outbound.IdempotencyDigestSize]byte {
|
||||
mac := hmac.New(sha256.New, keyring.resultCursorKey)
|
||||
mac.Write([]byte(position))
|
||||
mac.Write([]byte{0})
|
||||
mac.Write([]byte(candidateID))
|
||||
return [outbound.IdempotencyDigestSize]byte(mac.Sum(nil))
|
||||
}
|
||||
|
||||
// Fingerprint identifies a request by its canonical body.
|
||||
func (keyring *Keyring) Fingerprint(canonicalBody []byte) [outbound.IdempotencyDigestSize]byte {
|
||||
mac := hmac.New(sha256.New, keyring.fingerprintKey)
|
||||
|
||||
Reference in new issue
Block a user