Closed rmurray2 closed 5 months ago
Hi @rmurray2,
tl:dr: this is not the right library for that.
The shares that this library provides are tied up to the underlying MPC protocol. So, they would only work/be secure in an environment that has the required preprocessing material. Which type of shares do you want? Usually, those are additive shares or shamir shares of the key.
The pub_key
and priv_key
you mention from the paillier function are NOT the keys for ecdsa (aka Ethereum signature scheme). They are part of the protocol that is described here. So, they are supposed to be big and the size of the keys matter: with small keys the scheme will not work due to overflow inside the homomorphic ecnryption scheme.
Note: tinysig
implementation is an emulation of the protocol proposed here. As such, it is supposed to be used as a whole. The shares are given by the protocol distributed_key_generation_protocol
and saved within the emulated network. You can print the network at any point in debug mode and I believe you can read the shares from there. Anyway, these shares are very specific to this protocol (you can check their shape in Fig 2 (pag 8)). You can also explore all this through the notebook we put together.
FYI: tinysig implementation is a prototype implementation of the proposed protocol and is only meant for educational purposes. The library is not audited and should be used with cautious.
How can this library be used to generate shares for an ethereum private key?
I tried chaning line 34 of tecdsa.py to:
pub_key, priv_key = paillier.generate_paillier_keypair(n_length=512)
then the
ecnil
object'she_private_key.q
andhe_private_key.p
values are the correct size to create an ethereum wallet. I changed this value because with the default key size of 3072, the private keyint
s are too big to create an ethereum wallet. (As a side question, which attribute ofhe_private_key
is actually storing the private key?p
orq
? ) When I don_length=512
, however, I get anOverflowError: Overflow detected in decrypted number
when callingts_online_protocol
Ultimately I'd like to use tinysig to a) generate a valid ethereum private key and b) split that key into shares which can be used in combination to sign transactions.
So my questions are:
1) Which attribute of the
ecnil
object stores the private key?p
orq
? 2) How can tinysig be used to generate shares of an ethereum private key? 3) How can the shares from question (2) be combined to sign a transaction?I posted this question on the ethereum stack exchange as well