Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/ct_worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Run the following for each of the `dev2025h1a` and `dev2025h2a` log shards to co
openssl genpkey -algorithm ed25519 | npx wrangler -e=${ENV} secret put WITNESS_KEY_${LOG_NAME}
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 | npx wrangler -e=${ENV} secret put SIGNING_KEY_${LOG_NAME}

(Note: For mtc_worker we use ed25519 for both the witness key and the signing key.)
(Note: For mtc_worker we use ed25519 for the signing key. There is no witness.)

1. Deploy the worker. The worker will be available at `https://static-ct-${ENV}.<your-team>.workers.dev/logs/${LOG_NAME}`.

Expand Down
11 changes: 1 addition & 10 deletions crates/mtc_worker/src/frontend_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
//! Entrypoint for the static CT submission APIs.

use crate::{
load_checkpoint_signers, load_origin, load_roots, load_signing_key, load_witness_key,
SequenceMetadata, CONFIG,
load_checkpoint_signers, load_origin, load_roots, load_signing_key, SequenceMetadata, CONFIG,
};
use der::{
asn1::{SetOfVec, UtcTime, Utf8StringRef},
Expand Down Expand Up @@ -50,8 +49,6 @@ struct MetadataResponse<'a> {
description: &'a Option<String>,
#[serde_as(as = "Base64")]
key: &'a [u8],
#[serde_as(as = "Base64")]
witness_key: &'a [u8],
submission_url: &'a str,
monitoring_url: &'a str,
}
Expand Down Expand Up @@ -229,15 +226,9 @@ async fn main(req: Request, env: Env, _ctx: Context) -> Result<Response> {
let key = verifying_key
.to_public_key_der()
.map_err(|e| e.to_string())?;
let witness_key = load_witness_key(&ctx.env, name)?;
let witness_key = witness_key
.verifying_key()
.to_public_key_der()
.map_err(|e| e.to_string())?;
Response::from_json(&MetadataResponse {
description: &params.description,
key: key.as_bytes(),
witness_key: witness_key.as_bytes(),
submission_url: &params.submission_url,
monitoring_url: if params.monitoring_url.is_empty() {
&params.submission_url
Expand Down
11 changes: 2 additions & 9 deletions crates/mtc_worker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use signed_note::KeyName;
use std::collections::HashMap;
use std::str::FromStr;
use std::sync::{LazyLock, OnceLock};
use tlog_tiles::{CheckpointSigner, CosignatureV1CheckpointSigner, SequenceMetadata};
use tlog_tiles::{CheckpointSigner, SequenceMetadata};
use tokio::sync::OnceCell;
#[allow(clippy::wildcard_imports)]
use worker::*;
Expand All @@ -31,17 +31,12 @@ static CONFIG: LazyLock<AppConfig> = LazyLock::new(|| {
});

static SIGNING_KEY_MAP: OnceLock<HashMap<String, OnceLock<Ed25519SigningKey>>> = OnceLock::new();
static WITNESS_KEY_MAP: OnceLock<HashMap<String, OnceLock<Ed25519SigningKey>>> = OnceLock::new();
static ROOTS: OnceCell<CertPool> = OnceCell::const_new();

pub(crate) fn load_signing_key(env: &Env, name: &str) -> Result<&'static Ed25519SigningKey> {
load_ed25519_key(env, name, &SIGNING_KEY_MAP, &format!("SIGNING_KEY_{name}"))
}

pub(crate) fn load_witness_key(env: &Env, name: &str) -> Result<&'static Ed25519SigningKey> {
load_ed25519_key(env, name, &WITNESS_KEY_MAP, &format!("WITNESS_KEY_{name}"))
}

pub(crate) fn load_ed25519_key(
env: &Env,
name: &str,
Expand Down Expand Up @@ -76,13 +71,11 @@ pub(crate) fn load_checkpoint_signers(env: &Env, name: &str) -> Vec<Box<dyn Chec
// TODO should the CA cosigner have a different ID than the log itself?
let cosigner_id = log_id.clone();
let signing_key = load_signing_key(env, name).unwrap().clone();
let witness_key = load_witness_key(env, name).unwrap().clone();

// Make the checkpoint signers from the secret keys and put them in a vec
let signer = MTCSubtreeCosigner::new(cosigner_id, log_id, origin.clone(), signing_key);
let witness = CosignatureV1CheckpointSigner::new(origin, witness_key);

vec![Box::new(signer), Box::new(witness)]
vec![Box::new(signer)]
}

pub(crate) fn load_origin(name: &str) -> KeyName {
Expand Down