1

It is possible to sign a transaction by doing:

from eth_account import Account
import web3 as Web3

web3 = Web3()
my_private_key = Account.from_key('0x...')
signed = web3.eth.account.sign_transaction(some_transaction, my_private_key.privateKey)

where the entire private key is required to be loaded into a variable.

But is it possible to sign a transaction in n steps where the private key is divided into n shares? i.e. where the full key is never loaded into memory? For example, let's say a private key is split between Person A and Person B

  1. Person A uses their half of the private key to partially sign the transaction, producing output_A

  2. Person B takes output_A and their half of the private key to produce the final signed transaction

Is this how an MPC wallet works? If so, how does it work under the hood?

With Shamir Secret Sharing, a private key could be split into shares to be reconstituted later, but it wouldn't get around the problem of ultimately having to load the full private key to sign a transaction.

Forgive me if this is a naive question; I don't have a background in cryptography. Just wondering if something like this is possible

2 Answers 2

1

Yes, you are referring to MPC. specifically Ethereum uses ECDSA, so you want an ECDSA MPC.

here is ZenGo's repo used by ZenGo Wallet: https://github.com/ZenGo-X/multi-party-ecdsa

MPC stands for Multi-Party Computation, meaning the entire key isn't known to any party. of course this requires all parties to perform the computation to sign the transaction.

alternatively as suggested you might want to consider a simpler approach such as multisig wallet.

if your intention is avoiding loading the key controlled by a single party into memory then consider a hardware wallet such as Ledger or Trezor, or use a TEE - Trusted Execution Environment.

0

As per my knowledge, your question is related "Multi-signature wallet". However, construct that in Python is a pain I assume, because it related to EVM opcode and security wallet.

Normally, when people want to sign transaction by multi-signature wallet. They usually use 3rd party such as Gnosis Safe (https://safe.global/), I also use this service several times.

Another solution for you is to save the "private_key" in an environment secret, and only A and B can decode that .env file. Then, the code will load the .env variable.

Hope it helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.