### Initialize and Start Local Party for Re-Sharing Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Initializes a new local party for re-sharing operations using provided parameters and key data. The party's start method should be run in a goroutine to handle re-sharing processes asynchronously. ```go party := resharing.NewLocalParty(params, ourKeyData, outCh, endCh) go func() { err := party.Start() // handle err ... }() ``` -------------------------------- ### Get Message as Protobuf Wrapper Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Retrieves the message as a protobuf wrapper struct. This method is intended for exceptional scenarios, such as integration with mobile applications. ```go // Returns the protobuf wrapper message struct, used only in some exceptional scenarios (i.e. mobile apps) WireMsg() *tss.MessageWrapper ``` -------------------------------- ### Initialize Keygen Local Party Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Initializes a `LocalParty` for the key generation protocol. The `preParams` can be omitted to compute them during the first round. The `endCh` receives the saved data upon completion. ```go party := keygen.NewLocalParty(params, outCh, endCh, preParams) // Omit the last arg to compute the pre-params in round 1 go func() { err := party.Start() // handle err ... }() ``` -------------------------------- ### Initialize Signing Local Party Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Initializes a `LocalParty` for the signing protocol. Requires the message to sign, protocol parameters, and the key data from the keygen protocol. The signature is sent through `endCh`. ```go party := signing.NewLocalParty(message, params, ourKeyData, outCh, endCh) go func() { err := party.Start() // handle err ... }() ``` -------------------------------- ### Generate Keygen Pre-Parameters Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Generates pre-computation parameters for the keygen protocol. This can take time and is recommended to be done beforehand. The concurrency limit defaults to the number of available CPU cores. ```go // When using the keygen party it is recommended that you pre-compute the "safe primes" and Paillier secret beforehand because this can take some time. // This code will generate those parameters using a concurrency limit equal to the number of available CPU cores. preParams, _ := keygen.GeneratePreParams(1 * time.Minute) ``` -------------------------------- ### Create a Local Party ID Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Creates a `*PartyID` for the current peer. The `id` field must be unique, `moniker` is optional, and `uniqueKey` is a big.Int representing a unique identifier for this peer. ```go // Set up the parameters // Note: The `id` and `moniker` fields are for convenience to allow you to easily track participants. // The `id` should be a unique string representing this party in the network and `moniker` can be anything (even left blank). // The `uniqueKey` is a unique identifying key for this peer (such as its p2p public key) as a big.Int. thisParty := tss.NewPartyID(id, moniker, uniqueKey) ``` -------------------------------- ### Create TSS Parameters Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Initializes the parameters for a TSS protocol instance, including the curve, peer context, current party's ID, total number of parties, and the threshold. ```go params := tss.NewParameters(curve, ctx, thisParty, len(parties), threshold) ``` -------------------------------- ### Create and Sort Participant Party IDs Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Creates and sorts `PartyID` instances for each participating peer. Each `PartyID` requires a unique ID, an optional moniker, and a unique key represented as a big.Int. ```go // Create a `*PartyID` for each participating peer on the network (you should call `tss.NewPartyID` for each one) parties := tss.SortPartyIDs(getParticipantPartyIDs()) ``` -------------------------------- ### Create Party ID Map Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Creates a map to easily look up `*PartyID` instances by their string ID. This is useful for processing incoming messages. ```go // You should keep a local mapping of `id` strings to `*PartyID` instances so that an incoming message can have its origin party's `*PartyID` recovered for passing to `UpdateFromBytes` (see below) partyIDMap := make(map[string]*PartyID) for _, id := range parties { partyIDMap[id.Id] = id } ``` -------------------------------- ### Create Peer Context Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Creates a `PeerContext` from a sorted list of `PartyID`s. This context is used to manage peer information within the TSS protocol. ```go ctx := tss.NewPeerContext(parties) ``` -------------------------------- ### Update Party State from Wire Bytes Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md The main entry point for updating a party's state from raw bytes received over the network. This method is thread-safe and handles message routing. ```go // The main entry point when updating a party's state from the wire UpdateFromBytes(wireBytes []byte, from *tss.PartyID, isBroadcast bool) (ok bool, err *tss.Error) ``` -------------------------------- ### Update Party State from Parsed Message Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md An alternative entry point for updating a party's state using a pre-parsed message object. This is useful for local testing or scenarios where messages are already processed. ```go // You may use this entry point to update a party's state when running locally or in tests Update(msg tss.ParsedMessage) (ok bool, err *tss.Error) ``` -------------------------------- ### Select Elliptic Curve Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Selects the elliptic curve to be used for cryptographic operations. Supports both ECDSA (secp256k1) and EdDSA. ```go // Select an elliptic curve // use ECDSA curve := tss.S256() // or use EdDSA // curve := tss.Edwards() ``` -------------------------------- ### Convert Message to Wire Bytes Source: https://github.com/bnb-chain/tss-lib/blob/master/README.md Converts a tss.Message into bytes suitable for transmission over the network, including routing information. This is the typical method used by transport implementations. ```go // Returns the encoded message bytes to send over the wire along with routing information WireBytes() ([]byte, *tss.MessageRouting, error) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.