entropyxyz / entropy-core

Protocol and cryptography development.
https://docs.entropy.xyz/
GNU Affero General Public License v3.0
11 stars 2 forks source link

User can participate in signing protocol #362

Closed ameba23 closed 11 months ago

ameba23 commented 1 year ago

User participates in signing protocol - Feature Design Notes

Currently the user sends all shares to the threshold servers. In this feature, the user could keep one share to store themselves, and participate in the signing protocol together with the threshold servers.

Things we need:

  1. entropy-core - A way for the threshold servers to know whether or not the user is a signing party.
  2. entropy-core - A way for the threshold servers to communicate with the user when undertaking the signing protocol.
  3. synedrion-wasm - needs bindings to the sessions API.
  4. entropy-js a way for the user to execute the signing protocol and communicate with threshold servers.

1. entropy-core - A way for threshold servers to know whether the user is a signing party

The simplest way to do this would be that that the user indicates that they are going to participate in signing in a boolean passed in the UserTransactionRequest whenever they sign a message.

But probably better is if the chain tracks that the user has a key-share. This could be done as follows:

pub struct SigningPartyInfo<AccountId> {
    pub account: AccountId,
    pub signing_party_type: SigningPartyType,
}

pub enum SigningPartyType {
    User,
    ThresholdServer {
        endpoint: TssServerUrl,
        x25519_public_key: X25519PublicKey,
    },
}

2. entropy-core - The threshold servers communicate with the user to carry out the signing protocol

3. synedrion-wasm needs bindings to the sessions API

Need to cover make_interactive_signing_session and its output type Session<InteractiveSigningState>.

4. entropy-js - the user executes the signing protocol and communicates with threshold servers

ameba23 commented 1 year ago

I am planning to move the signing (and DKG) protocol logic, as well has the handshaking and encryption logic, into a separate crate that can be used by both the SDK and server - so the same code can be called by validator nodes and users to execute the signing and DKG protocols.

The tricky part of this is the different websocket implementations. Already we are using axum::extract::ws for handling incoming connections, and tokio-tungstenite for outgoing connections. In wasm we would use the native JS websocket implementation, eg: from bindings provided by the gloo-net crate.

Since we have channels which relay messages between the encrypted websocket connections and the signing / DKG protocols, one option would be to move the handshaking and encryption logic to the other side of these channels.

The other option is using the Stream and Sink traits, or some other trait giving us a way of accessing an arbitrary websocket implementation.

I think for both these options, error handling is going to be the hardest part.

ameba23 commented 11 months ago

Completed