| 1 | package change |
| 2 | |
| 3 | import ( |
| 4 | "crypto/sha256" |
| 5 | "encoding/hex" |
| 6 | "sort" |
| 7 | ) |
| 8 | |
| 9 | // AttestationRefs is the namespace the integrator keeps evidence under. |
| 10 | const AttestationRefs = "refs/the-valley/attestations/" |
| 11 | |
| 12 | // EvidenceFingerprint is the evidence state the integrator writes into an |
| 13 | // outcome record (integrator/refs.go): the first 16 hex digits of the |
| 14 | // SHA-256 over every attestation ref on origin, one "<ref> <oid>" line |
| 15 | // each, every line ending in a newline, in byte order. An outcome record |
| 16 | // with a different fingerprint was written about other evidence. |
| 17 | // |
| 18 | // The integrator, valley status and the restacker each compute it from |
| 19 | // what they read, so it is defined once, here. |
| 20 | func EvidenceFingerprint(attestations []string) string { |
| 21 | sorted := append([]string(nil), attestations...) |
| 22 | sort.Strings(sorted) |
| 23 | h := sha256.New() |
| 24 | for _, line := range sorted { |
| 25 | h.Write([]byte(line + "\n")) |
| 26 | } |
| 27 | return hex.EncodeToString(h.Sum(nil))[:16] |
| 28 | } |