diff --git a/README.md b/README.md index dcac23d..fc4f329 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ This database must be global and it **must never be changed or modified** as an The database must already exist, to prevent misconfigurations. Create it with ``` -sqlite3 checkpoints.db "CREATE TABLE checkpoints (logID BLOB PRIMARY KEY, body TEXT)" +sqlite3 checkpoints.db "CREATE TABLE checkpoints (logID BLOB PRIMARY KEY, body BLOB NOT NULL) STRICT" ``` Sunlight can alternatively use DynamoDB or S3-compatible object storage with `ETag` and `If-Match` support (such as Tigris) as global lock backends. diff --git a/cmd/sunlight-keygen/keygen.go b/cmd/sunlight-keygen/keygen.go index 7d4b333..7bc1fd2 100644 --- a/cmd/sunlight-keygen/keygen.go +++ b/cmd/sunlight-keygen/keygen.go @@ -17,6 +17,7 @@ import ( "filippo.io/keygen" "filippo.io/sunlight/internal/immutable" + "filippo.io/torchwood" "golang.org/x/crypto/hkdf" "golang.org/x/mod/sumdb/note" ) @@ -25,6 +26,7 @@ func main() { fs := flag.NewFlagSet("keygen", flag.ExitOnError) fileFlag := fs.String("f", "", "path to the seed file") prefixFlag := fs.String("prefix", "", "submission prefix for the log, to output a witness verifier key") + witnessFlag := fs.String("witness", "", "witness name, for generating a witness secret instead") fs.Parse(os.Args[1:]) if fs.NArg() != 0 || *fileFlag == "" { fmt.Fprintln(os.Stderr, "usage: sunlight-keygen -f ") @@ -57,6 +59,21 @@ func main() { log.Fatal("seed file must be exactly 32 bytes") } + if *witnessFlag != "" { + ed25519Secret := make([]byte, ed25519.SeedSize) + if _, err := io.ReadFull(hkdf.New(sha256.New, seed, []byte("sunlight Ed25519 witness key"), + []byte(*witnessFlag)), ed25519Secret); err != nil { + log.Fatal("failed to derive Ed25519 key:", err) + } + wk := ed25519.NewKeyFromSeed(ed25519Secret) + s, err := torchwood.NewCosignatureSigner(*witnessFlag, wk) + if err != nil { + log.Fatal("failed to create witness signer:", err) + } + fmt.Printf("Witness vkey: %s\n", s.Verifier()) + return + } + ecdsaSecret := make([]byte, 32) if _, err := io.ReadFull(hkdf.New(sha256.New, seed, []byte("sunlight"), []byte("ECDSA P-256 log key")), ecdsaSecret); err != nil { log.Fatal("failed to derive ECDSA secret:", err) diff --git a/cmd/sunlight/home.html b/cmd/sunlight/home.html index 3b9fa4e..43e7f38 100644 --- a/cmd/sunlight/home.html +++ b/cmd/sunlight/home.html @@ -52,26 +52,6 @@

Metrics are available. - - {{ if .Witness.Name }} -


- -

- The following witness is active. - -

{{ .Witness.Name }}

- -

- Submission prefix: {{ .Witness.SubmissionPrefix }}
- Known logs: -

- -
{{ .Witness.VerifierKey }}
- {{ end }}
@@ -103,6 +83,39 @@

Submit a certificate chain (PEM or JSON)

{{ end }} + {{ if .Witness.Name }} +
+ +

+ The following witness is active. + +

{{ .Witness.Name }}

+ +

+ Submission prefix: {{ .Witness.SubmissionPrefix }} + +

+ Verifier key: + +

{{ .Witness.VerifierKey }}
+ +

+ Log list sources: +

+ +

+ Known logs: +

+ {{ end }} +