  We generalize the study of the sum and difference sets of a subset of
$\mathbb{N}$ drawn from a binomial model to the following setting. Given $A
\subseteq \{0, 1, \dots, N\}$, an integer $h \geq 2$, and a linear form $L:
\mathbb{Z}^h \to \mathbb{Z}$ given by $$L(x_1, \dots, x_h) = u_1x_1 + \cdots +
u_hx_h, \quad u_i \in \mathbb{Z}_{\neq 0} \text{ for all } i \in [h],$$ we
study the size of $$L(A) = \left\{u_1a_1 + \cdots + u_ha_h : a_i \in A
\right\}$$ and its complement $L(A)^c$ when each element of $\{0, 1, \dots,
N\}$ is independently included in $A$ with probability $p(N)$. We identify two
phase transition phenomena. The first ``global" phase transition concerns the
relative sizes of $L(A)$ and $L(A)^c$, with $p(N) = N^{-\frac{h-1}{h}}$ as the
threshold. Asymptotically almost surely, it holds below the threshold that
almost all sums generated in $L(A)$ are distinct and almost all possible sums
are in $L(A)^c$, and above the threshold that almost all possible sums are in
$L(A)$. Our asymptotic formulae substantially extend work of Hegarty and Miller
and completely settle, with appropriate corrections made to its statement,
their conjecture from 2009. The second ``local" phase transition concerns the
asymptotic behavior of the number of distinct realizations in $L(A)$ of a given
value, with $p(N) = N^{-\frac{h-2}{h-1}}$ as the threshold. Specifically, it
identifies (in a sharp sense) when the number of such realizations obeys a
Poisson limit. Our main tools are recent results concerning the asymptotic
enumeration of partitions and weak compositions, classical theorems on Poisson
approximation, and the martingale machinery of Kim and Vu.
