diff --git a/doc/musig-spec.mediawiki b/doc/musig-spec.mediawiki index ef7224d26..1a3df765f 100644 --- a/doc/musig-spec.mediawiki +++ b/doc/musig-spec.mediawiki @@ -165,7 +165,7 @@ The following conventions are used, with constants as defined for [https://www.s * Functions and operations: ** ''||'' refers to byte array concatenation. ** The function ''x[i:j]'', where ''x'' is a byte array and ''i, j ≥ 0'', returns a ''(j - i)''-byte array with a copy of the ''i''-th byte (inclusive) to the ''j''-th byte (exclusive) of ''x''. -** The function ''bytes(x)'', where ''x'' is an integer, returns the 32-byte encoding of ''x'', most significant byte first. +** The function ''bytes(n, x)'', where ''x'' is an integer, returns the n-byte encoding of ''x'', most significant byte first. ** The function ''bytes(P)'', where ''P'' is a point, returns ''bytes(x(P))''. ** The function ''len(x)'' where ''x'' is a byte array returns the length of the array. ** The function ''has_even_y(P)'', where ''P'' is a point for which ''not is_infinite(P)'', returns ''y(P) mod 2 = 0''. @@ -230,7 +230,7 @@ Input: * For ''j = 1 .. u'': ** If ''pkj ≠ pk1'': *** Return ''pkj'' -* Return ''bytes(0)'' +* Return ''bytes(32, 0)'' '''''KeyAggCoeff(pk1..u, pk')''''': * Let ''pk2 = GetSecondKey(pk1..u)'': @@ -259,18 +259,18 @@ Input: * The secret signing key ''sk'': a 32-byte array or 0-byte array (optional argument) * The aggregate public key ''aggpk'': a 32-byte array or 0-byte array (optional argument) * The message ''m'': a 32-byte array or 0-byte array (optional argument) -* The auxiliary input ''in'': a byte array of length ''≥ 0'' (optional argument) +* The auxiliary input ''in'': a byte array with ''0 ≤ len(in) ≤ 232-1'' (optional argument) '''''NonceGen(sk, aggpk, m, in)''''': * Let ''rand' '' be a 32-byte array freshly drawn uniformly at random * If ''len(sk) > 0'': ** Let ''rand'' be the byte-wise xor of ''sk'' and ''hashMuSig/aux(rand')''The random data is hashed (with a unique tag) as a precaution against situations where the randomness may be correlated with the secret signing key itself. It is xored with the secret key (rather than combined with it in a hash) to reduce the number of operations exposed to the actual secret key.. * Else: let ''rand = rand' '' -* Let ''ki = int(hashMuSig/nonce(rand || len(aggpk) || aggpk || i || len(m) || m || len(in) || in)) mod n'' for ''i = 1,2'' +* Let ''ki = int(hashMuSig/nonce(rand || bytes(1, len(aggpk)) || aggpk || bytes(1, i) || bytes(1, len(m)) || m || bytes(4, len(in)) || in)) mod n'' for ''i = 1,2'' * Fail if ''k1 = 0'' or ''k2 = 0'' * Let ''R*1 = k1⋅G, R*2 = k2⋅G'' * Let ''pubnonce = cbytes(R*1) || cbytes(R*2)'' -* Let ''secnonce = bytes(k1) || bytes(k2)'' +* Let ''secnonce = bytes(32, k1) || bytes(32, k2)'' * Return ''secnonce'' and ''pubnonce'' ==== Nonce Aggregation ==== @@ -335,7 +335,7 @@ Input: * Let ''gv = 1'' if ''has_even_y(Q)'', otherwise let ''gv = -1 mod n'' *
Let ''d = gv⋅gaccv⋅gp⋅d' mod n'' (See [[negation-of-the-secret-key-when-signing|Negation Of The Secret Key When Signing]]) * Let ''s = (k1 + b⋅k2 + e⋅a⋅d) mod n'' -* Let ''psig = bytes(s)'' +* Let ''psig = bytes(32, s)'' * Let ''pubnonce = cbytes(k'1⋅G) || cbytes(k'2⋅G)'' * If ''PartialSigVerifyInternal(psig, pubnonce, bytes(P), session_ctx)'' (see below) returns failure, abortVerifying the signature before leaving the signer prevents random or attacker provoked computation errors. This prevents publishing invalid signatures which may leak information about the secret key. It is recommended, but can be omitted if the computation cost is prohibitive.. * Return partial signature ''psig'' @@ -385,7 +385,7 @@ Input: ** Let ''si = int(psigi)''; fail if ''si ≥ n''. * Let ''gv = 1'' if ''has_even_y(Q)'', otherwise let ''gv = -1 mod n'' * Let ''s = s1 + ... + su + e⋅gv⋅taccv mod n'' -* Return ''sig = ''bytes(R) || bytes(s)'' +* Return ''sig = ''bytes(R) || bytes(32, s)'' === Test Vectors and Reference Code ===