Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit fdb104a

Browse files
committed
more extended Generating multisignature address chapter
1 parent 1056793 commit fdb104a

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

docs/multisig.rst

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In order to use multisignature functionality, a special multisignature address m
2020

2121
Created digests should be shared with each multisignature participant, so each one of them could regenerate address and ensure it is OK.
2222

23-
Here is the examples where digest is created:
23+
Here is the example where digest is created:
2424

2525
.. code-block:: python
2626
@@ -113,13 +113,57 @@ First signer for multisignature wallet is defining address where tokens should b
113113
Sign the inputs
114114
---------------
115115

116+
When trytes are prepared, round of signing must be performed. Order of signing must be the same as in generate multisignature addresses procedure (as described above).
117+
118+
.. note::
119+
120+
In example below, all signing is done on one local machine. In real case, each participant sign bundle locally and then passes it to next participant in previously defined order
121+
122+
**index**, **count** and **security_lavel** parameters for each private key should be the same as used in **get_digests** function in previous steps.
123+
124+
.. code-block:: python
125+
126+
bundle = Bundle.from_tryte_strings(prepared_trytes)
127+
128+
gpk_result = api_1.get_private_keys(index=0, count=1, security_level=3)
129+
private_key_1 = gpk_result['keys'][0] # type: PrivateKey
130+
private_key_1.sign_input_transactions(bundle, 1)
131+
132+
gpk_result = api_2.get_private_keys(index=42, count=1, security_level=3)
133+
private_key_2 = gpk_result['keys'][0] # type: PrivateKey
134+
private_key_2.sign_input_transactions(bundle, 4)
135+
136+
gpk_result = api_3.get_private_keys(index=8, count=1, security_level=2)
137+
private_key_3 = gpk_result['keys'][0] # type: PrivateKey
138+
private_key_3.sign_input_transactions(bundle, 7)
139+
140+
signed_trytes = bundle.as_tryte_strings()
141+
116142
.. note::
117143

118-
Validate the signatures.
144+
After creation, bundle can be optionally validated:
145+
146+
.. code-block:: python
147+
148+
validator = BundleValidator(bundle)
149+
if not validator.is_valid():
150+
raise ValueError(
151+
'Bundle failed validation:\n{errors}'.format(
152+
errors = '\n'.join((' - ' + e) for e in validator.errors),
153+
),
154+
)
155+
156+
119157
120158
Broadcast the bundle
121159
--------------------
122160

161+
When bundle is created it can be broadcasted in standard way:
162+
163+
.. code-block:: python
164+
165+
api_1.send_trytes(trytes=signed_trytes, depth=3)
166+
123167
Remarks
124168
-------
125169

@@ -129,5 +173,22 @@ Full code `example`_.
129173

130174
How M-of-N works
131175

176+
One of the key differences between IOTA multi-signatures is that M-of-N (e.g. 3 of 5) works differently. What this means is that in order to successfully spend inputs, all of the co-signers have to sign the transaction. As such, in order to enable M-of-N we have to make use of a simple trick: sharing of private keys.
177+
178+
This concept is best explained with a concrete example:
179+
180+
Lets say that we have a multi-signature between 3 parties: Alice, Bob and Carol. Each has their own private key, and they generated a new multi-signature address in the aforementioned order. Currently, this is a 3 of 3 multisig. This means that all 3 participants (Alice, Bob and Carol) need to sign the inputs with their private keys in order to successfully spend them.
181+
182+
In order to enable a 2 of 3 multisig, the cosigners need to share their private keys with the other parties in such a way that no single party can sign inputs alone, but that still enables an M-of-N multsig. In our example, the sharing of the private keys would look as follows:
183+
184+
Alice -> Bob
185+
186+
Bob -> Carol
187+
188+
Carol -> Alice
189+
190+
Now, each participant holds two private keys that he/she can use to collude with another party to successfully sign the inputs and make a transaction. But no single party holds enough keys (3 of 3) to be able to independently make the transaction.
191+
192+
132193
.. _example: https://github.com/iotaledger/iota.lib.py/blob/develop/examples/multisig.py
133194
.. _wiki: https://github.com/iotaledger/wiki/blob/master/multisigs.md

0 commit comments

Comments
 (0)