CREATE TABLE agent_did_keys (
  key_id            VARCHAR(40)  PRIMARY KEY,
  agent_id          VARCHAR(40)  NOT NULL UNIQUE REFERENCES agents(agent_id),
  organization_id   VARCHAR(40)  NOT NULL REFERENCES organizations(organization_id),
  public_key_jwk    JSONB        NOT NULL,
  vault_key_path    VARCHAR(255) NOT NULL,
  key_type          VARCHAR(20)  NOT NULL DEFAULT 'EC',
  curve             VARCHAR(10)  NOT NULL DEFAULT 'P-256',
  created_at        TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
  rotated_at        TIMESTAMPTZ,
  CONSTRAINT agent_did_keys_key_type_check CHECK (key_type IN ('EC', 'RSA'))
);
CREATE INDEX idx_agent_did_keys_agent_id ON agent_did_keys(agent_id);
CREATE INDEX idx_agent_did_keys_org_id ON agent_did_keys(organization_id);
