Schnorr signature and multi-sig overview & guideline #1434
AndrejMitrovic
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
In the BOA blockchain we want to be able to support several types of signatures:
1 of 1
,2 of 2
,3 of 3
, and so on. This is called ann-of-n
scheme, because then
is the same on both sides. This means if 3 people want to collaborate on signing a message, they must combine their public keys into a single public key, and all 3 of their signatures must be combined.k-of-n
scheme, because the number of signers can be smaller than the number of total participants. For example,1 of 2
,2 of 3
,2 of 4
,3 of 4
,4 of 4
, or any combination wherek <= n
.Curve and signature
We use Curve25519 and not Secp256k1. There is an open issue about changing our curve to Secp256k1, but as of this time it has not been scheduled for development: #207
Our signature signing consists of the following steps:
"SCT4KKJNYLTQO4TVDPVJQZEONTVVW66YLRWAINWI3FZDY7U4JS4JJEI4"
.x
.X
.r
.R
.Challenge
. TheChallenge
is defined asChallenge = H(X ~ R ~ Transaction)
. This is described below:Challenge
use libsodium to hash theX
(this is the Point of the Scalar of the Secret of the Seed used in signing), and hash theR
(the Point of the Scalar of the random nonce), and hash theTransaction
itself.Challenge
. An example of using libsodium for hashing is here.Scalar signature = r + (Challenge * x)
. Where as mentioned beforer
is the Scalar of the random nonce, andx
is the Scalar of the private key.Note: Please be aware that the random nonce is changed for every new signing, therefore the signature will appear different when signing the same transaction multiple times. This will not change the transaction's hash however.
Schnorr single-party signature
The support code has been implemented in the ECC.D and Schnorr.d modules.
As of today (2020-12-18), the
v0.x.x
branch does not use Schnorr for validating Transaction signatures yet!The
v0.x.x
branch currently usesEdDSA
for validating the signatures, as seen in the Key.d module.The
flash-layer
branch does use Schnorr. It replacedEdDSA
Transaction signature validation withSchnorr
signature validation, as can be seen in the Engine.d module.Schnorr multi-signatures
This is the
n-of-n
signature scheme where the number of participants is always the same as the number of signers.For example,
1 of 1
,2 of 2
,3 of 3
,4 of 4
, and so on.Validating these signatures is the same as validating single-party signatures.
That means the execution engine already supports these signatures.
However, creating these signatures is complex and has security and safety implications.
Please read the
Creating Schnorr multi-signatures
section below for more information.Note: A
2 of 4
signature is not a multi-signature, it is a threshold multi-signature described in the next section.Threshold multi-signatures
This is the
k-of-n
signature scheme. In this case the number of signers can be less than the number of total participants.For example, if
Alice
,Bob
, andCharlie
want to create a2 of 3
spending condition, it will require the signatures of:Alice and Bob
orBob and Charlie
orAlice and Charlie
.There are two ways of supporting threshold signatures:
CHECK_MULTI_SIG
. It is implemented in Bitcoin. It is also implemented in Agora PR #1429. This is a non-interactive scheme. It is highly secure, but a little bit innefficient.CHECK_MULTI_SIG for simple threshold signatures
In Agora PR #1429, we've implemented the
CHECK_MULTI_SIG
opcode. This allows highly-secure but slightly inneficient threshold signatures. This adds support fork of n
signatures.The way they work is simple. The lock script of an
Output
contains the list of public keys and the requiredcount
of signatures.For example:
Here
3
is the total number of participants, followed by the list of public keys on the left.To the left of that is
2
which is the required number of signatures.Assume that each user has their own signature, for example:
Then, the Input unlock script in the Transaction can be any of these:
This scheme is non-interactive, which means that the users do not have to interactively pick a single
nonce
for their signatures.Instead, each user can use their own nonce. Nonces are important because they must be random in order to be secure.
Benefit:
Drawback:
Dedicated threshold signature creating scheme
A more efficient way of adding support for threshold signatures is to use a dedicated scheme which produces a single Schnorr signature.
However, most implementations which currently exist are experimental and may not be proven secure yet.
This is why we've decided to implement
CHECK_MULTI_SIG
.MuSig
MuSig is a scheme of interactively creating a multi-signature, and creating a single resulting Schnorr signature
which can be validated in the same way as a normal single-party schnorr signature.
Therefore Agora already supports validating such signatures.
This scheme supports
n-of-n
signatures, and notk-of-n
.What is MuSig for? Why do we need it? Can't we just use
CHECK_MULTI_SIG
?MuSig is a way of creating an
n-of-n
multi-sig which generates a single schnorr signature.Since this is a single signature, it's very efficient to store on the blockchain.
And it's also very efficient to validate.
Briefly, the scheme works as follows:
commitment
. They do not revealR
. They revealhash(R)
.message
. In our example this is aTransaction
.Transaction
then they proceed to share their actualR
nonces. TheR
is the preimage ofhash(R)
. This is whyhash(R)
is called acommitment
, andR
is called the preimage.R
, and shares their partial signature to each other.Why do they not reveal their R, but instead they initially reveal only the hash of it?
Because, if an attacker knows all of the R's in advance they could generate a transaction with a very specific hash,
which can end up revealing the private key of a user if they use that R during signing.
See the
Pre-sharing nonce commitments
section in this article for more information.Benefits:
CHECK_MULTI_SIG
. The signature is small, it only contains the combined public key (32 bytes) and the combined signature (64 bytes).Drawbacks:
commitment
and then later theirR
nonces.Conclusion
n-of-n
validation is also supported, because it is the sameas validating a single-signer schnorr signature.
k-of-n
schnorr validation is supported by theCHECK_MULTI_SIG
opcode.If we want efficient multi-sig N-of-N which produces a single signature we would require the wallet to use
MuSig
.For threshold
k-of-n
signatures the wallet would either have to useCHECK_MULTI_SIG
,OR they would need to find an alternative scheme which supports
k-of-n
.Beta Was this translation helpful? Give feedback.
All reactions