What is the expression for the confidence interval in a Kaplan-Meier curve? In R, the survival fit object gives the non-parametric MLE for the survival curve via the Kaplan-Meier estimator. The fit also provides a confidence interval. What is the expression for the confidence interval, or where is the reference, to reproduce the method?

leukemia.surv <- survfit(Surv(time, status) ~ 1, data = aml, subset=x=='Nonmaintained') 
plot(leukemia.surv) 


The default starts with the Nelson-Aalen cumulative hazard estimate $\hat\Lambda(t)$, taking the square root of its variance estimate to get a standard error. If $\Delta \bar N(t_i)$ is the number of events at time $t_i$ and $\bar Y(t_i)$ the number then at risk, the variance estimate is:
$$\text{var}\left[ \hat\Lambda(t) \right] = \sum_{i:t_i \le t} \frac{\Delta \bar N(t_i)}{\bar Y^2(t_i)}.$$
That's Equation 2.4 of Therneau and Grambsch, as recommended by Gavin Simpson; see the corresponding C code, at about line 200 in its current incarnation.
That standard error is then transformed to confidence intervals as specified by a conf.type argument, with "log" as the default. That default "calculates intervals based on the cumulative hazard or log(survival)," according to the manual page. Code in R implementing the conf.type options for a given standard error is visible in survival:::survfit_confint.
