syntax = "proto3";
package cald.lookup.v1;
import "Core.proto";
// If false, all generated code goes in a single java file
option java_multiple_files = true;
option java_package = "nexus.cald.api.lookup";
// Calling this service: each rpc in LookupService, at the end of this file, is an HTTP POST to
// //. is the name between "cald." and ".v1" in this file's package
// (cald.lookup.v1, so "lookup"), and is the rpc's name in kebab-case: a Lookup Service at
// https://example.com/cald takes matchCheck at https://example.com/cald/lookup/match-check. The
// body is the request message in protobuf's standard JSON encoding (Content-Type:
// application/json), and a 200 answer's body is the response message, encoded the same way. Every
// outcome the service decides, refusals included, is a 200 whose status field says which; any other
// HTTP status means the call didn't go through. A server that doesn't offer an rpc has no route for
// it.
// The Lookup Service's wire contract: six request/response families, each under its own banner
// below -- ingestion, resolution, match check, disavowal, registration deletion and the
// intermediate list.
// ---------------------------------------------------------------------------
// Shared types
// ---------------------------------------------------------------------------
// How much of the issuing chain a read response carries. The chain is assembled on demand from
// the shared de-duplicated store.
enum ChainDetail {
// The leaf pair alone.
LEAF_ONLY = 0;
// The leaf pair plus every intermediate needed to validate it, in `CertificateBundle`'s order
// (nearest issuer first).
WITH_INTERMEDIATES = 1;
// WITH_INTERMEDIATES plus the trusted root.
FULL_CHAIN = 2;
}
// Compact identifier for a held CaLD Certificate Pair: two
// role-named hashes, each over that leaf's full DER (`X509Certificate.getEncoded()`), never a
// concatenated blob -- no ordering convention to get wrong, and consistent with the
// `signing*` / `encryption*` field pairs already in Core.proto / Ca.proto. Full cert,
// not SPKI, so a re-issue that kept the same keys but changed the validity window or relay
// address reads as a different pair. Each hash names its own algorithm (SHA-256 today); one naming
// no algorithm, or one the service doesn't compute, names no pair: a match check answers
// NOT_CURRENT with the current pair, and a registration deletion naming it answers NOT_CURRENT.
message CertificatePairFingerprint {
cald.core.v1.Hash signingLeaf = 1;
cald.core.v1.Hash encryptionLeaf = 2;
}
// Per-read authentication, shared by resolution and match check.
// Carries the exact bytes that were signed -- a serialized SignedLookupRead (below), transmitted
// verbatim -- rather than the queried number / chain detail / requester number / timestamp as
// separately parsed fields the service would otherwise have to reconstruct into a matching
// serialization. The service verifies `signature` against `signedLookupRead` directly, then decodes
// it to recover those values. No certificate or chain is carried; the service verifies against
// the signing certificate it already holds for the requester number decoded from signedLookupRead.
message RequesterAuthentication {
bytes signedLookupRead = 1;
// Field 2 is deliberately left free for a future anti-replay element (a server salt or a
// per-requester counter) so it can be added inline with the other auth fields rather than
// tacked on at the end.
// By the requester's current signing key, over `signedLookupRead`, under signing context
// `cald/lookup/read/v1` (Core.proto).
bytes signature = 3;
}
// The exact parameter set a Lookup read signature covers. The requester
// builds this message, serializes it once, and transmits the result verbatim as
// RequesterAuthentication.signedLookupRead alongside a signature over it -- there is no
// reconstruction step on the verifying side. A dedicated message rather than the request itself,
// so the signed set is explicit and stays stable as the request messages grow -- and so any
// protobuf implementation, in any language, can reproduce the exact signed bytes without
// re-implementing a bespoke encoding. It has no map or floating-point fields, so a signer needs no
// special canonicalization beyond the default encoding.
//
// There is no in-band tag saying what a signed message is. A holder's signing key signs several
// message types (this one, registration deletions, the Relay's session requests, abuse reports,
// wake-up registrations and CaldMessages, the CA's reservation requests and redemption proofs, and
// sign-in answers), and several of their
// serializations decode as one another, since each puts a PhoneNumber in field 1 and a decoder keeps
// fields of the wrong wire type as unknown fields. What keeps one type from being accepted as
// another is the signing context each is signed under (Core.proto), not the encoding.
message SignedLookupRead {
cald.core.v1.PhoneNumber queriedNumber = 1;
ChainDetail chainDetail = 2;
cald.core.v1.PhoneNumber requesterNumber = 3;
int64 timestampEpochMillis = 4;
}
// The read responses (resolution, match-check refresh) carry the current pair + chain as a
// shared Core.proto CertificateBundle -- the same shape the CA returns from a successful
// registration. Both leaves are always populated; the intermediates/root are
// populated per the request's ChainDetail.
// Why the read gate refused a resolution or a match check: one enum
// both reads' responses carry, set only beside their REFUSED status, so the two can't drift.
enum ReadRefusal {
// Never sent: a REFUSED answer without a reason is a failure a reader can't act on beyond
// trying again later.
READ_REFUSAL_UNSPECIFIED = 0;
// The requester's own number is not enrolled on this instance; the client should enrol (publish
// its own pair through ingestion) before retrying. Distinct from NO_CURRENT_CERTIFICATE.
REQUESTER_NOT_ENROLLED = 1;
// The signature did not verify, the requester's signing certificate is outside its validity
// window, or the timestamp is outside the accepted skew.
REQUESTER_AUTHENTICATION_FAILED = 2;
// The per-requester rate limit was exceeded.
RATE_LIMITED = 3;
}
// ---------------------------------------------------------------------------
// Ingestion
// ---------------------------------------------------------------------------
// A submission carrying both leaf certificates plus the intermediates needed to chain them to a
// root the service already trusts, nearest issuer first (see `CertificateBundle`). The same
// `CertificateBundle` the CA hands back from a successful registration and Lookup returns as
// `currentBundle`, so a holder can forward what it received; the bundle's
// `rootCACertificate` is ignored on ingestion (the service chains against its own configured
// trust anchors), and both leaves are required. Both leaves must name `phoneNumber`, and the
// intermediates must leave the root out, or the submission is rejected.
message CertificateIngestionRequest {
cald.core.v1.PhoneNumber phoneNumber = 1;
cald.core.v1.CertificateBundle submittedBundle = 2;
}
message CertificateIngestionResponse {
// What became of the submission, for the submitter to branch on.
Status status = 1;
// Human-readable detail for logs: the rejection cause, or why the pair is not the current one.
// Empty on ACCEPTED and ALREADY_CURRENT. Never something to branch on: `status` is.
string reason = 2;
enum Status {
// Never sent. What a response with no status reads as; a submitter treats it as REFUSED.
STATUS_UNSPECIFIED = 0;
// The submitted pair is now the number's current pair (it was strictly newer than the one
// held, or the number had none).
ACCEPTED = 1;
// The submitted pair already was the number's current pair: the same two leaves. Nothing
// changed, and nothing needs to.
ALREADY_CURRENT = 2;
// A valid pair, but a different pair whose notBefore is equal or later is current
// The number has moved on: the submitter reports this rather than retrying.
SUPERSEDED = 3;
// The submission failed validation and changed nothing: a missing or undecodable leaf, a
// pair not issued to this number, a leaf outside its validity window, a chain that does not
// reach a trusted root, includes the root among its intermediates or runs through a
// disavowed intermediate, or a notBefore not after the number's disavowal floor or deletion
// floor. `reason` says which.
REFUSED = 4;
// Only from the public publish route (POST /lookup/ingest): this source, or this number, has
// made too many submissions lately. Checked before anything else, so it says
// nothing about the pair, and nothing changed. The submitter may try again later.
RATE_LIMITED = 5;
}
}
// ---------------------------------------------------------------------------
// Resolution
// ---------------------------------------------------------------------------
// The queried number and chain detail live only inside requesterAuthentication's
// signed content (SignedLookupRead) -- not duplicated here as separately-parsed fields the
// service would have to cross-check against the signed values. The service reads them only after
// the signature verifies.
message CurrentCertificateRequest {
RequesterAuthentication requesterAuthentication = 1;
}
message CurrentCertificateResponse {
Status status = 1;
// Set only when `status` is CURRENT_CERTIFICATE_FOUND. Chain material populated per the
// request's ChainDetail.
cald.core.v1.CertificateBundle currentBundle = 2;
// Set only when `status` is REFUSED: why the read gate refused the requester.
ReadRefusal refusal = 3;
// Nested so the read outcomes and the match-check outcomes (MatchCheckResponse.Status) do not
// collide in the file-level enum namespace.
enum Status {
// Never sent: a reader treats it as a failure. It is what a response with no
// status reads as -- an empty body, or one carrying only fields the reader doesn't know --
// so a missing answer can never read as a found pair.
STATUS_UNSPECIFIED = 0;
CURRENT_CERTIFICATE_FOUND = 1;
// The queried number has no current pair. Does not distinguish "never registered" from
// "expired then pruned".
NO_CURRENT_CERTIFICATE = 2;
// The read gate refused the requester; `refusal` says why.
REFUSED = 3;
}
}
// ---------------------------------------------------------------------------
// Match check / fast verify
// ---------------------------------------------------------------------------
// The queried number and chain detail live only inside requesterAuthentication's
// signed content, as in CurrentCertificateRequest. heldFingerprint is not signed -- it names which
// fingerprint to compare against, and doesn't affect who is authorized to read.
message MatchCheckRequest {
CertificatePairFingerprint heldFingerprint = 1;
RequesterAuthentication requesterAuthentication = 2;
}
message MatchCheckResponse {
Status status = 1;
// Set when `status` is NOT_CURRENT: the current pair at the request's
// ChainDetail, so a stale caller refreshes in one round trip. Absent for CURRENT and for
// NO_CURRENT_CERTIFICATE.
cald.core.v1.CertificateBundle currentBundle = 2;
// Set only when `status` is REFUSED: why the read gate refused the requester, the same values a
// resolution's refusal carries.
ReadRefusal refusal = 3;
enum Status {
// Never sent: a reader treats it as a failure. It is what a response with no
// status reads as -- an empty body, or one carrying only fields the reader doesn't know --
// so a missing answer can never read as a match.
STATUS_UNSPECIFIED = 0;
// The held fingerprint matches the current pair.
CURRENT = 1;
// A current pair exists but the held fingerprint does not match it; `currentBundle` is set.
NOT_CURRENT = 2;
// The queried number has no current pair, so the held certificate is not current. The same
// explicit "none" as resolution's NO_CURRENT_CERTIFICATE.
NO_CURRENT_CERTIFICATE = 3;
// The read gate refused the requester; `refusal` says why.
REFUSED = 4;
}
}
// ---------------------------------------------------------------------------
// Disavowal. Only an intermediate is ever disavowed; a client's leaf pair is retracted only
// through its intermediate's sweep.
// ---------------------------------------------------------------------------
// The request carries the exact bytes that were signed, not a separately-parsed target: the
// service verifies `authorization.signature` against `signedDisavowal` directly, then decodes
// `signedDisavowal` to learn what is being disavowed. It
// never independently reconstructs a SignedDisavowal from the parsed target and compares that
// re-serialization against what was signed -- two protobuf implementations are not guaranteed to
// produce byte-identical output for the same logical values (e.g. varint encoding is not
// canonical), so a reconstruction step could reject a legitimately-signed request. This is the
// same reason an X.509 certificate carries its TBSCertificate as raw bytes rather than the CA
// re-deriving them from parsed fields.
message DisavowalRequest {
// A serialized SignedDisavowal (below), transmitted verbatim.
bytes signedDisavowal = 1;
DisavowalAuthorization authorization = 2;
}
// The disavowing authority (the intermediate's parent CA) is derived from the
// certificates at verification time -- the signer's relationship to the target -- not declared by
// the client. There is deliberately no `authority` field here: a declared role the service then
// trusts invites a weaker check than the relationship it stands for.
message DisavowalAuthorization {
// Over DisavowalRequest.signedDisavowal -- the serialized SignedDisavowal (below), which binds
// the target certificate -- under signing context `cald/lookup/intermediate-disavowal/v1`
// (Core.proto). No nonce.
bytes signature = 1;
// The signer's certificate followed by any intermediates needed to chain it to a trusted
// root (signer first, then its issuers toward the root, DER), the root itself left out unless
// it is the signer: for a root-issued intermediate this is the root alone.
repeated bytes signerChain = 2;
}
// The signed content of a disavowal: the target (the full certificate) only, so the binding is
// to the exact certificate. A serialized instance of this
// message, verbatim, IS DisavowalRequest.signedDisavowal -- there is no separate "logical" form
// the wire content merely represents; the bytes on the wire are the bytes that were signed and the bytes that get parsed
// back. No map or floating-point fields, so a signer needs no special canonicalization beyond the
// default encoding. Field 1 is reserved and never populated, so this message's only populated
// field is 3, distinct from SignedLookupRead's field 1 (see that message's comment).
message SignedDisavowal {
reserved 1;
oneof target {
bytes intermediateCertificate = 3;
}
}
message DisavowalResponse {
Status status = 1;
// Set on ACCEPTED for an intermediate disavowal: how many number mappings the
// sweep removed.
int32 affectedNumberCount = 2;
enum Status {
// Never sent. What a response with no status reads as -- an empty body, or one carrying only
// a status this reader doesn't know -- so a missing answer never reads as ACCEPTED; a
// submitter treats it as not disavowed.
STATUS_UNSPECIFIED = 0;
ACCEPTED = 1;
// The signature did not verify, or the signer is not permitted to disavow this target.
UNAUTHORIZED = 2;
// The request names no intermediate, or its certificate could not be decoded. Nothing
// changed.
TARGET_NOT_CURRENT = 3;
// The target names a configured trust-anchor root.
ROOT_NOT_DISAVOWABLE = 4;
// The submitting source has made too many disavowal submissions lately.
// Checked before anything else, so it says nothing about the request, and nothing changed.
// The submitter may try again later.
RATE_LIMITED = 5;
}
}
// ---------------------------------------------------------------------------
// Registration deletion
// ---------------------------------------------------------------------------
// A holder withdrawing its own number's mapping from one Lookup Service, signed with the number's
// current signing key. Carries the exact bytes that were signed, as RequesterAuthentication does:
// the service verifies `signature` over `signedRegistrationDeletion` against the number's current
// signing certificate, then acts on the decoded content.
message RegistrationDeletionRequest {
// A serialized SignedRegistrationDeletion (below), transmitted verbatim.
bytes signedRegistrationDeletion = 1;
// By the number's current signing key, over `signedRegistrationDeletion` exactly as sent, under
// signing context `cald/lookup/registration-deletion/v1` (Core.proto).
bytes signature = 2;
}
// The exact content a registration deletion's signature covers.
message SignedRegistrationDeletion {
// The number whose registration is withdrawn: its current pair signs, and only its own mapping goes.
cald.core.v1.PhoneNumber phoneNumber = 1;
// The fingerprint of the pair the holder means to delete.
// Nothing is deleted unless it is the current pair's, so a captured request can never delete a
// later registration.
CertificatePairFingerprint heldFingerprint = 2;
// The canonical URL of the one endpoint this request is posted to, e.g.
// `https://alpha.cald.nexus/lookup/delete-registration` for Lookup or
// `https://alpha.cald.nexus/relay/forget-number` for a relay: scheme and host lower-case, the
// scheme's default port dropped, no query, fragment or trailing `/`. A
// service refuses a request naming any other, so the same bytes can't be replayed at another
// Lookup holding the pair, nor at the other service on the same host.
string audience = 3;
// When it was signed. Refused outside the read's freshness window.
int64 timestampEpochMillis = 4;
}
message RegistrationDeletionResponse {
Status status = 1;
// Human-readable detail for logs. Never something to branch on: `status` is.
string reason = 2;
enum Status {
// Never sent. What a response with no status reads as; a holder treats it as not deleted.
STATUS_UNSPECIFIED = 0;
// The number's mapping is gone, and no pair as old as the deleted one can be published for it
// again (the deletion floor).
DELETED = 1;
// The number has no current pair here, so there is nothing to delete.
NOT_ENROLLED = 2;
// The signature verified, but heldFingerprint isn't the current pair's: nothing was deleted.
NOT_CURRENT = 3;
// The content didn't decode, the signature didn't verify against the current signing
// certificate, the audience isn't this service, or the timestamp isn't fresh. Nothing changed.
AUTHENTICATION_FAILED = 4;
// Too many deletion requests lately, from this source or for this number. Nothing changed.
RATE_LIMITED = 5;
}
}
// ---------------------------------------------------------------------------
// The intermediate list
// ---------------------------------------------------------------------------
// Every intermediate this instance publishes, for clients to fetch about daily and keep, so a
// message need not carry its sender's intermediate. Public: no requester
// authentication, since every entry proves itself -- a listed intermediate against the root a
// client pins, a disavowal by its parent CA's signature.
message ListIntermediatesRequest {
// The listVersion of the list the client already holds, or empty for none. When it is still
// the current version the response is NOT_MODIFIED and carries no certificates, so a daily
// fetch that finds nothing new is cheap.
string knownListVersion = 1;
}
message ListIntermediatesResponse {
Status status = 1;
// Identifies this exact list: equal versions mean equal lists. Opaque to clients, which only
// ever echo it back as knownListVersion. Set on both statuses.
string listVersion = 2;
// DER of every intermediate published here that is unexpired and not disavowed.
// Empty on NOT_MODIFIED.
repeated bytes intermediateCertificates = 3;
// Every unexpired intermediate disavowed here, as the exact DisavowalRequest this
// instance accepted -- the parent CA's signature over the SignedDisavowal naming the
// certificate, with the signer's chain -- so a client verifies the removal itself instead of
// trusting a server that could simply have left an entry out. Empty on NOT_MODIFIED.
repeated DisavowalRequest disavowals = 4;
enum Status {
// Never sent. What a response with no status reads as -- an empty body, or one carrying only a
// status this reader doesn't know -- so a missing answer never reads as a list holding nothing;
// a client changes nothing it holds and tries again later.
STATUS_UNSPECIFIED = 0;
// The full list follows.
LIST = 1;
// knownListVersion is the current version; nothing has changed.
NOT_MODIFIED = 2;
}
}
// ---------------------------------------------------------------------------
// Service
// ---------------------------------------------------------------------------
// The Lookup Service's operations, each request message with the response that answers it, one per
// family above. Carried as HTTP POST with protobuf-JSON bodies; this block documents the exchanges
// and generates no gRPC code.
service LookupService {
// A number's current pair, at the requested chain detail. Only a requester enrolled here may
// read, signing each request, within a per-requester rate limit.
rpc resolve(CurrentCertificateRequest) returns (CurrentCertificateResponse);
// "Is the pair I hold still current?" -- a mismatch returns the current pair in the same round
// trip. The same read authentication as resolve.
rpc matchCheck(MatchCheckRequest) returns (MatchCheckResponse);
// Anyone holding a pair: submit it as a number's current pair. Submitter-agnostic: the pair is
// validated on its own merits, and the newest valid pair wins.
// The CA reaches it in-process after issuing; holders and others reach it through the public
// publish route, which is rate limited per source and per number.
rpc ingest(CertificateIngestionRequest) returns (CertificateIngestionResponse);
// An intermediate's parent CA: retract a compromised intermediate, and with it every pair
// chaining through it. Anyone may submit the parent's signed request, since its signature is
// the authorization. Rate limited per source.
rpc disavow(DisavowalRequest) returns (DisavowalResponse);
// A number's holder, signing with its current key: delete the number's registration here, and
// refuse that pair, or any not newer, while a copy could still be valid. Rate limited per
// source and per signed number.
rpc deleteRegistration(RegistrationDeletionRequest) returns (RegistrationDeletionResponse);
// Anyone: every unexpired, undisavowed intermediate published here that still chains to a trusted
// root, and every unexpired intermediate disavowal with its proof; or NOT_MODIFIED when the
// caller's copy is current. Public, since every entry proves itself.
rpc listIntermediates(ListIntermediatesRequest) returns (ListIntermediatesResponse);
}