|
|
|
|
// Package inspectview renders the result of capsule.Inspect as the
|
|
|
|
|
// "datekeys inspect" command prints it. The command and the generator of the
|
|
|
|
|
// frozen inspect outputs (testdata/fixtures/*.inspect.json) share it, so that
|
|
|
|
|
// the frozen files are exactly what the command prints.
|
|
|
|
|
package inspectview
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
datekeys "g.activething.com/go/DateKeys"
|
|
|
|
|
"g.activething.com/go/DateKeys/capsule"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// View is the result of "datekeys inspect"; "-json" prints it as JSON.
|
|
|
|
|
type View struct {
|
Implement capsule format 2 of spec v0.9
The reference moves to the DateKeys Protocol Specification v0.9, approved
by its author on 29 September 2026. Encrypt writes capsule format 2 only;
Open and Inspect read formats 1 and 2, and a format 1 capsule keeps the
verdict v0.8.2 gave it.
Format 2 (spec §22, §29.1, §31, §39):
- VERSION in the PRELUDE is the capsule format, capsule.Format; any other
value is ERR_UNSUPPORTED_VERSION at step 2.
- CONTROL_CBOR has the schema version of its format. Version 2 adds key 6,
payload_length (8 bytes, big-endian, at most L_MAX = 2^53 - 2^46), and
key 7, padding (1 bloque256, 2 reforzado); it is 103 bytes without
extensions, whatever L.
- The payload is the content padded with zeros to P = rule(L). Step 17
checks the length and the zeros, and Open writes only the first L bytes.
- INNER_ACCESS_AGE holds exactly 16 X25519 stanzas: 1 to 16 credentials,
and a dummy in each slot left, in a uniformly random order.
Writer rules (spec §62.1): EncryptOptions.Length is required and the
source must deliver exactly that many bytes; recipients that are not
canonical or of low order are rejected (agewrap.CheckX25519Recipient);
self-checks of the header, the control, INNER_ACCESS_AGE and PAYLOAD_AGE.
The CLI measures its input, takes -padding and reports the format.
Test data: seven format 2 fixtures, padding vectors checked against
math/big, format 2 CBOR vectors, and the mutation corpus in both formats
with the 22 cases of the third list of spec §64, built without randomness
by sealing the fixtures again with their known keys and nonces. The
format 1 fixtures are kept byte for byte and never regenerated; the
differential corpus keeps its 1825 cases and adds a block per format 2
fixture. The spec copy loses its "to be implemented" markers, and the
READMEs, CHANGELOG, traceability and testdata/README.md follow v0.9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 week ago
|
|
|
File string `json:"file"`
|
|
|
|
|
// Format is the capsule format, once the prelude is valid (spec §70).
|
|
|
|
|
Format int `json:"format,omitempty"`
|
|
|
|
|
CapsuleID string `json:"capsule_id,omitempty"`
|
|
|
|
|
DateKey string `json:"datekey,omitempty"`
|
|
|
|
|
Profile string `json:"profile,omitempty"`
|
|
|
|
|
Round uint64 `json:"round,omitempty"`
|
|
|
|
|
UnlockAt string `json:"unlock_at,omitempty"`
|
|
|
|
|
AccessPolicy string `json:"access_policy,omitempty"`
|
|
|
|
|
// PublicNote is the public note, text of the creator that nobody has
|
|
|
|
|
// checked (spec v0.11, §24.1).
|
|
|
|
|
PublicNote string `json:"public_note,omitempty"`
|
|
|
|
|
Valid bool `json:"valid"`
|
|
|
|
|
Error string `json:"error,omitempty"`
|
|
|
|
|
Checks []capsule.CheckResult `json:"checks"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// New returns the view of the inspection of file: the result and the error
|
|
|
|
|
// of capsule.Inspect.
|
|
|
|
|
func New(file string, result *capsule.Inspection, err error) View {
|
Implement capsule format 2 of spec v0.9
The reference moves to the DateKeys Protocol Specification v0.9, approved
by its author on 29 September 2026. Encrypt writes capsule format 2 only;
Open and Inspect read formats 1 and 2, and a format 1 capsule keeps the
verdict v0.8.2 gave it.
Format 2 (spec §22, §29.1, §31, §39):
- VERSION in the PRELUDE is the capsule format, capsule.Format; any other
value is ERR_UNSUPPORTED_VERSION at step 2.
- CONTROL_CBOR has the schema version of its format. Version 2 adds key 6,
payload_length (8 bytes, big-endian, at most L_MAX = 2^53 - 2^46), and
key 7, padding (1 bloque256, 2 reforzado); it is 103 bytes without
extensions, whatever L.
- The payload is the content padded with zeros to P = rule(L). Step 17
checks the length and the zeros, and Open writes only the first L bytes.
- INNER_ACCESS_AGE holds exactly 16 X25519 stanzas: 1 to 16 credentials,
and a dummy in each slot left, in a uniformly random order.
Writer rules (spec §62.1): EncryptOptions.Length is required and the
source must deliver exactly that many bytes; recipients that are not
canonical or of low order are rejected (agewrap.CheckX25519Recipient);
self-checks of the header, the control, INNER_ACCESS_AGE and PAYLOAD_AGE.
The CLI measures its input, takes -padding and reports the format.
Test data: seven format 2 fixtures, padding vectors checked against
math/big, format 2 CBOR vectors, and the mutation corpus in both formats
with the 22 cases of the third list of spec §64, built without randomness
by sealing the fixtures again with their known keys and nonces. The
format 1 fixtures are kept byte for byte and never regenerated; the
differential corpus keeps its 1825 cases and adds a block per format 2
fixture. The spec copy loses its "to be implemented" markers, and the
READMEs, CHANGELOG, traceability and testdata/README.md follow v0.9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 week ago
|
|
|
v := View{File: file, Valid: err == nil, Error: datekeys.Code(err), Checks: result.Checks, Format: int(result.Prelude.Format)}
|
|
|
|
|
if h := result.Header; h != nil {
|
|
|
|
|
v.CapsuleID, v.DateKey, v.Profile, v.Round, v.AccessPolicy = h.CapsuleIDHex(), h.DateKey.Compact(), h.DateKey.ProfileID, h.DateKey.Round, h.Policy.String()
|
|
|
|
|
v.PublicNote, _ = h.PublicNote()
|
|
|
|
|
}
|
|
|
|
|
if !result.UnlockAt.IsZero() {
|
|
|
|
|
v.UnlockAt = result.UnlockAt.Format(time.RFC3339)
|
|
|
|
|
}
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WriteJSON writes v as indented JSON followed by a newline.
|
|
|
|
|
func (v View) WriteJSON(w io.Writer) error {
|
|
|
|
|
enc := json.NewEncoder(w)
|
|
|
|
|
enc.SetIndent("", " ")
|
|
|
|
|
return enc.Encode(v)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WriteText writes v as lines of text, one per check.
|
|
|
|
|
func (v View) WriteText(w io.Writer) {
|
|
|
|
|
fmt.Fprintf(w, "%s\n", v.File)
|
|
|
|
|
for _, c := range v.Checks {
|
|
|
|
|
mark := "ok "
|
|
|
|
|
if !c.OK {
|
|
|
|
|
mark = "FAIL"
|
|
|
|
|
}
|
|
|
|
|
fmt.Fprintf(w, " [%s] step %2d %-26s %s\n", mark, c.Step, c.Name, c.Detail)
|
|
|
|
|
}
|
|
|
|
|
if v.Valid {
|
Implement capsule format 2 of spec v0.9
The reference moves to the DateKeys Protocol Specification v0.9, approved
by its author on 29 September 2026. Encrypt writes capsule format 2 only;
Open and Inspect read formats 1 and 2, and a format 1 capsule keeps the
verdict v0.8.2 gave it.
Format 2 (spec §22, §29.1, §31, §39):
- VERSION in the PRELUDE is the capsule format, capsule.Format; any other
value is ERR_UNSUPPORTED_VERSION at step 2.
- CONTROL_CBOR has the schema version of its format. Version 2 adds key 6,
payload_length (8 bytes, big-endian, at most L_MAX = 2^53 - 2^46), and
key 7, padding (1 bloque256, 2 reforzado); it is 103 bytes without
extensions, whatever L.
- The payload is the content padded with zeros to P = rule(L). Step 17
checks the length and the zeros, and Open writes only the first L bytes.
- INNER_ACCESS_AGE holds exactly 16 X25519 stanzas: 1 to 16 credentials,
and a dummy in each slot left, in a uniformly random order.
Writer rules (spec §62.1): EncryptOptions.Length is required and the
source must deliver exactly that many bytes; recipients that are not
canonical or of low order are rejected (agewrap.CheckX25519Recipient);
self-checks of the header, the control, INNER_ACCESS_AGE and PAYLOAD_AGE.
The CLI measures its input, takes -padding and reports the format.
Test data: seven format 2 fixtures, padding vectors checked against
math/big, format 2 CBOR vectors, and the mutation corpus in both formats
with the 22 cases of the third list of spec §64, built without randomness
by sealing the fixtures again with their known keys and nonces. The
format 1 fixtures are kept byte for byte and never regenerated; the
differential corpus keeps its 1825 cases and adds a block per format 2
fixture. The spec copy loses its "to be implemented" markers, and the
READMEs, CHANGELOG, traceability and testdata/README.md follow v0.9.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 week ago
|
|
|
fmt.Fprintf(w, " valid before unlock; opens at %s (round %d, %s, format %d)\n", v.UnlockAt, v.Round, v.AccessPolicy, v.Format)
|
|
|
|
|
}
|
|
|
|
|
if v.PublicNote != "" {
|
|
|
|
|
fmt.Fprintf(w, " Nota pública del creador (sin comprobar): %s\n", v.PublicNote)
|
|
|
|
|
if v.Valid {
|
|
|
|
|
fmt.Fprintln(w, " Nadie puede comprobar antes de la fecha quién creó la cápsula ni si va firmada.")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|