diff --git a/doc/musig-spec.mediawiki b/doc/musig-spec.mediawiki
index e2a3364a..b41f5c62 100644
--- a/doc/musig-spec.mediawiki
+++ b/doc/musig-spec.mediawiki
@@ -90,9 +90,10 @@ The algorithm '''''KeyAgg(pk1..u, tweak1..v, is_xonly_t1..u, tweak1..v, is_xonly_t1..v)''''' is defined as:
+* Let ''pk2 = GetSecondKey(pk1..u)''
* For ''i = 1 .. u'':
-** Let ''ai = KeyAggCoeff(pk1..u, pki)''.
** Let ''Pi = point(pki)''; fail if that fails.
+** Let ''ai = KeyAggCoeff'(pk1..u, pki, pk2)''.
* Let ''Q0 = a1⋅P1 + a2⋅P1 + ... + au⋅Pu''
* Fail if ''is_infinite(Q0)''.
* Let ''tacc0 = 0''
@@ -104,15 +105,19 @@ The algorithm '''''KeyAggInternal(pk1..u, tweak1..v, is_xo
The algorithm '''''HashKeys(pk1..u)''''' is defined as:
* Return ''hashKeyAgg list(pk1 || pk2 || ... || pku)''
-The algorithm '''''IsSecond(pk1..u, pk')''''' is defined as:
+The algorithm '''''GetSecondKey(pk1..u)''''' is defined as:
* For ''j = 1 .. u'':
** If ''pkj ≠ pk1'':
-*** Return ''true'' if ''pkj = pk' '', otherwise return ''false''.
-* Return ''false''
+*** Return ''pkj''
+* Return ''bytes(0)''
The algorithm '''''KeyAggCoeff(pk1..u, pk')''''' is defined as:
-* Let ''L = HashKeys(pk1..u)''.
-* If ''IsSecond(pk1..u, pk')'':
+* Let ''pk2 = GetSecondKey(pk1..u)'':
+* Return ''KeyAggCoeff'(pk1..u, pk', pk2)''
+
+The algorithm '''''KeyAggCoeff'(pk1..u, pk', pk2)''''' is defined as:
+* Let ''L = HashKeys(pk1..u)''
+* If ''pk' = pk2'':
** Return 1
* Return ''int(hashKeyAgg coefficient(L || pk')) mod n''