Construct $O_{cho}$ with all attributes of $O_{own}$, subtracting $\gamma$ from volume and replacing the access key with a newly sampled $\alpha$. If $\gamma == O_{own}.s.v$, then use dummy values for $O_{cho}$.
Construct $O_{chn}$ with all attributes of $O_{n}$, subtracting $\gamma - \sum_{i=0}^{n-1} O_i.s.v$ from volume and replacing the access key with a newly sampled $\alpha$. If $\gamma == \sum_{i=0}^n O_i.s.v$, then use dummy values for $O_{chn}$.
Construct $\bar O_{cho} = (O_{cho}.t, H(O_{cho}.s))$ and $\bar O_{chn} = (O_{chn}.t, H(O_{chn}.s))$.
Add ${\bar O_{own}, {\bar O_i}{i=0}^n, b{own}, {b_i}{i=0}^n, O{n-1}.p, \bar O_{cho}, \bar O_{chn}}$ as public outputs.
Bid Case ($O_{\text{own}}.t.\phi=0$)
Ask Case ($O_{\text{own}}.t.\phi=1$)
Initial
Initial
$b_{\text{own}} = (0, (O_{\text{own}}.s.p) (O_{\text{own}}.s.v))$
$b_{\text{own}} = (\gamma, 0)$
$b_i = (\gamma_{i}, 0)$
$b_i = (0, (O_{\text{i}}.s.p)(O_{\text{i}}.s.v))$
Final
Final
$\gamma = \sum_{i=0}^{n-1} \gamma_i + k$
$\gamma = \sum_{i=0}^{n-1} O_{i}.s.v + k$
Orders 0 to $n-1$ fully filled,
Orders 0 to $n-1$ fully filled,
$n^{th}$ order at least partially filled.
$n^{th}$ order at least partially filled.
$k \leq \gamma_n$
$k \leq O_{n}.v$
$\nu=(O_{\text{own}}.s.p)(O_{\text{own}}.s.v)-\sum_{i=0}^{n-1} \gamma_i(O_i.s.p) - k (O_n.s.p)$
$\nu= \sum_{i=0}^{n-1} (O_i.s.v)(O_i.s.p) + k(O_n.s.p)$
$b_{\text{own}}=(\gamma, \nu)$
$b_{\text{own}}=(0,\nu)$
$b_i$ for $0\leq i < n= (0, (O_{\text{own}}.s.p) (O_{\text{own}}.s.v))$
$b_i$ for $0\leq i < n= (O_i.s.v,0)$
Here, $\gamma_i == O_i.s.v$
$b_n=(\gamma_n-k, k (O_n.s.p))$
$b_n=(k, (O_n.s.p)(O_n.s.v-k))$