package walletprovidergosdk
import walletprovidergosdk "github.com/silence-laboratories/wallet-provider-go-sdk"
Package walletprovidergosdk provides a client SDK for interacting with the Silence Laboratories Wallet Provider Network.
This SDK simplifies the process of integrating distributed key generation (DKG) and signing capabilities into your Go applications. It handles the complex networking and cryptographic protocols required to communicate with the Wallet Provider nodes.
Overview
The SDK is designed to be easy to use while providing robust security and performance. The main entry point is the NetworkClient, which manages connections and executes protocols.
Features
- Distributed Key Generation (DKG): Securely generate keys distributed across multiple parties.
- Distributed Signing: Sign transactions or messages without ever reconstructing the full private key.
- Quorum Change: Handle changes dynamically the set of participants by adding or removing nodes.
Getting Started
To use the SDK, first create a NetworkClientConfig with your API key and the list of network nodes. Then, instantiate a NetworkClient using NewNetworkClient.
// 1. Setup client
config := &walletprovidergosdk.NetworkClientConfig{
APIKey: "your-api-key",
NetworkNodes: []networkclient.NetworkNode{
{
Endpoint: url.URL{
Scheme: "wss",
Host: "node1.example.com",
},
Attestation: types.NoneAttest,
},
{
Endpoint: url.URL{
Scheme: "wss",
Host: "node2.example.com",
},
Attestation: types.NoneAttest,
},
},
}
client, err := walletprovidergosdk.NewNetworkClient(config)
// 2. Prepare Keygen Options
opts := []wp_requests.KeygenOpts{
{
T: 2,
N: 2,
SignAlg: types.ED25519,
},
}
// 3. Create Request Config
reqCfg := &walletprovidergosdk.RequestConfig{
// Set necessary config fields
}
// 4. Execute Keygen
result, err := client.Keygen(reqCfg, opts)
Configuration
- NetworkClientConfig: Configuration for the network client, including API key and network nodes.
- RequestConfig: Configuration for individual requests, including timeouts and protocol versions.
- github.com/silence-laboratories/wallet-provider-go-sdk/networkclient/wp_requests.KeygenOpts: Parameters for distributed key generation, including threshold, number of shares, metadata, and signature algorithm.
For more detailed examples, see the examples directory or the example tests in this package.
Index
- type ChallengeResponseExchanger
-
type NetworkClient
- func NewNetworkClient(config *NetworkClientConfig) (*NetworkClient, error)
- func (nc *NetworkClient) Keygen(cfg *RequestConfig, keygenOpts []wp_requests.KeygenOpts) ([]wp_responses.KeyshareIdentifier, error)
- func (nc *NetworkClient) QuorumChange(cfg *RequestConfig, quorumChangeRequest *wp_requests.QuorumChangeRequest) (*wp_responses.KeyshareIdentifier, error)
- func (nc *NetworkClient) Signgen(cfg *RequestConfig, signOpts *wp_requests.SignOpts) ([]wp_responses.SigngenResponse, error)
- type NetworkClientConfig
-
type NetworkClientWithChalResp
- func NewNetworkClientWithChalResp(config *NetworkClientConfig) (*NetworkClientWithChalResp, error)
- func (nc *NetworkClientWithChalResp) AddEphKey(cfg *RequestConfig, addEphKeyReq *wp_requests.AddEphKeyRequest, ...) ([]wp_responses.AddEphKeyResponse, error)
- func (nc *NetworkClientWithChalResp) Keygen(cfg *RequestConfig, keygenOpts []wp_requests.KeygenOpts, ...) ([]wp_responses.KeyshareIdentifier, error)
- func (nc *NetworkClientWithChalResp) RevokeEphKey(cfg *RequestConfig, revokeEphKeyReq *wp_requests.RevokeEphKeyRequest, ...) (string, error)
- func (nc *NetworkClientWithChalResp) Signgen(cfg *RequestConfig, signOpts *wp_requests.SignOpts, ...) ([]wp_responses.SigngenResponse, error)
- type NetworkConn
- type NodeEndpoint
- type RRLoadBalancer
- type RequestConfig
- type SignRequestBuilder
- type SignRequestType
- type Slug
- type Transaction
Types
type ChallengeResponseExchanger
type ChallengeResponseExchanger interface { Next() (string, error) // Returns (message, error) Send(msg string) error RequestUserSignatures(finalChallenge string) (string, error) // Returns user signatures }
ChallengeResponseExchanger is required for types.ApiV1. It abstracts a bidirectional message transport used to exchange challenges from the network with the user during challenge-response flows. Implementations are responsible for sending challenges to the user and collecting their signatures over the challenge.
type NetworkClient
type NetworkClient struct { // contains filtered or unexported fields }
NetworkClient is responsible for connecting to the network nodes and exchanging messages with them. It exposes methods to run network functions such as keygen, signgen, etc.
func NewNetworkClient
func NewNetworkClient(config *NetworkClientConfig) (*NetworkClient, error)
NewNetworkClient creates a new NetworkClient instance.
- `config`: configuration options for the network client.
func (*NetworkClient) Keygen
func (nc *NetworkClient) Keygen( cfg *RequestConfig, keygenOpts []wp_requests.KeygenOpts, ) ([]wp_responses.KeyshareIdentifier, error)
Keygen executes distributed key generation based on the provided options.
- `cfg`: configuration options of API routes: version, request_id... - `keygenOpts`: options for keygen operation.
Returns:
- `[]wp_responses.KeyshareIdentifier`: the result of keygen operation
func (*NetworkClient) QuorumChange
func (nc *NetworkClient) QuorumChange( cfg *RequestConfig, quorumChangeRequest *wp_requests.QuorumChangeRequest, ) (*wp_responses.KeyshareIdentifier, error)
QuorumChange executes quorum change protocol based on the provided options.
- `cfg`: configuration options of API routes: version, request_id... - `quorumChangeRequest`: options for quorum change operation.
Returns:
- `*wp_responses.KeyshareIdentifier`: the result of quorum change operation
func (*NetworkClient) Signgen
func (nc *NetworkClient) Signgen( cfg *RequestConfig, signOpts *wp_requests.SignOpts, ) ([]wp_responses.SigngenResponse, error)
Signgen executes signing based on the provided options.
- `cfg`: configuration options of API routes: version, request_id... - `signOpts`: options for sign operation.
Returns:
- `[]wp_responses.SigngenResponse`: the result of signgen operation
type NetworkClientConfig
type NetworkClientConfig struct { // APIKey is the API key used for authentication with the network nodes. APIKey string // NetworkNodes is the list of network nodes to connect to. NetworkNodes []networkclient.NetworkNode // SetupSK is the setup signing key used for authentication with the network nodes. SetupSK *setup_sk.WpSigningKey }
NetworkClientConfig holds the required configuration for the NetworkClient construction.
type NetworkClientWithChalResp
type NetworkClientWithChalResp struct { // contains filtered or unexported fields }
NetworkClientWithChalResp is responsible for connecting to the network nodes and exchanging messages with them using the challenge-response protocol types.ApiV1. It exposes methods to run network functions such as keygen, signgen, adding ephemeral keys, and revoking ephemeral keys.
func NewNetworkClientWithChalResp
func NewNetworkClientWithChalResp(config *NetworkClientConfig) (*NetworkClientWithChalResp, error)
NewNetworkClientWithChalResp creates a new NetworkClientWithChalResp instance.
- `config`: configuration options for the network client.
func (*NetworkClientWithChalResp) AddEphKey
func (nc *NetworkClientWithChalResp) AddEphKey( cfg *RequestConfig, addEphKeyReq *wp_requests.AddEphKeyRequest, chalRespExchanger ChallengeResponseExchanger, ) ([]wp_responses.AddEphKeyResponse, error)
AddEphKey handles adding an ephemeral key using the types.ApiV1
- `cfg`: configuration options of API routes: version, request_id... - `addEphKeyReq`: request payload for adding an ephemeral key. - `chalRespExchanger`: transport to exchange messages with the user for collecting signatures.
Returns:
- `[]wp_responses.AddEphKeyResponse`: the result of the add ephemeral key operation returned by the network.
func (*NetworkClientWithChalResp) Keygen
func (nc *NetworkClientWithChalResp) Keygen( cfg *RequestConfig, keygenOpts []wp_requests.KeygenOpts, chalRespExchanger ChallengeResponseExchanger, ) ([]wp_responses.KeyshareIdentifier, error)
Keygen executes distributed key generation based on the provided options using types.ApiV1.
- `cfg`: configuration options of API routes: version, request_id... - `keygenOpts`: options for keygen operation. - `chalRespExchanger`: transport to exchange messages with the user for collecting signatures.
Returns:
- `[]wp_responses.KeyshareIdentifier`: the result of keygen operation
func (*NetworkClientWithChalResp) RevokeEphKey
func (nc *NetworkClientWithChalResp) RevokeEphKey( cfg *RequestConfig, revokeEphKeyReq *wp_requests.RevokeEphKeyRequest, chalRespExchanger ChallengeResponseExchanger, ) (string, error)
RevokeEphKey handles revoking an ephemeral key using the types.ApiV1
- `cfg`: configuration options of API routes: version, request_id... - `revokeEphKeyReq`: request payload for revoking an ephemeral key. - `chalRespExchanger`: transport to exchange messages with the user for collecting signatures.
Returns:
- `string`: the result of the revoke ephemeral key operation returned by the network ("success" or error messages).
func (*NetworkClientWithChalResp) Signgen
func (nc *NetworkClientWithChalResp) Signgen( cfg *RequestConfig, signOpts *wp_requests.SignOpts, chalRespExchanger ChallengeResponseExchanger, ) ([]wp_responses.SigngenResponse, error)
Signgen executes signing based on the provided options using the types.ApiV1
- `cfg`: configuration options of API routes: version, request_id... - `signOpts`: options for sign operation. - `chalRespExchanger`: transport to exchange messages with the user for collecting signatures.
Returns:
- `[]wp_responses.SigngenResponse`: the result of signgen operation
type NetworkConn
type NetworkConn struct { // contains filtered or unexported fields }
NetworkConn encapsulates a WebSocket connection to the Initiator node along with the API key used for authentication. It provides primitives to send requests and receive responses from/to the Initiator node.
type NodeEndpoint
type NodeEndpoint struct { Endpoint url.URL // contains filtered or unexported fields }
type RRLoadBalancer
type RRLoadBalancer struct { // contains filtered or unexported fields }
type RequestConfig
type RequestConfig struct { // Version is the API version (current supported: "v1", "v2"). Version types.ApiVersion // RequestID is a unique identifier for the request. RequestID string }
RequestConfig holds the configuration for a request to the wallet provider API.
func NewRequestConfig
func NewRequestConfig(version types.ApiVersion, requestID string) *RequestConfig
type SignRequestBuilder
type SignRequestBuilder struct { // contains filtered or unexported fields }
SignRequestBuilder constructs the canonicalized JSON request payload for DSG. The value returned by Build() should be assigned to SignOpts.Message.
func NewSignRequestBuilder
func NewSignRequestBuilder() *SignRequestBuilder
NewSignRequestBuilder creates a new SignRequestBuilder.
func (*SignRequestBuilder) Build
func (b *SignRequestBuilder) Build() (string, error)
Build builds and returns the Map<string, Transaction> as canonicalized JSON. Returns the canonicalized JSON of Map<string, Transaction>.
func (*SignRequestBuilder) SetRequest
func (b *SignRequestBuilder) SetRequest(transactionID string, message string, requestType SignRequestType) *SignRequestBuilder
SetRequest sets the transaction ID, message, and request type for the sign request. Ensures that each transaction ID is only set once.
- transactionID: The transaction ID.
- message: The message to be signed.
- requestType: The type of the sign request. See SignRequestType.
Returns the builder instance to allow chaining.
type SignRequestType
type SignRequestType string
SignRequestType represents the type of signing transaction.
const ( // SignRequestTypeEIP1559 specifies an EVM based (EIP-1559) transaction. SignRequestTypeEIP1559 SignRequestType = "EIP1559" // SignRequestTypeEIP712 specifies an EIP-712 transaction. SignRequestTypeEIP712 SignRequestType = "EIP712" // SignRequestTypeEIP191 specifies an EIP-191 transaction. SignRequestTypeEIP191 SignRequestType = "EIP191" // SignRequestTypeRawBytes specifies a raw bytes transaction. SignRequestTypeRawBytes SignRequestType = "rawBytes" // SignRequestTypeSolanaTx specifies a Solana transaction. SignRequestTypeSolanaTx SignRequestType = "solanaTransaction" )
func ParseSignRequestType
func ParseSignRequestType(s string) (SignRequestType, error)
ParseSignRequestType converts a string into a SignRequestType, returning an error if the value is not a recognized request type.
func (SignRequestType) String
func (srt SignRequestType) String() string
type Slug
type Slug string
Slug represents the last segment of the API route.
const ( SlugKeygen Slug = "keygen" SlugSigngen Slug = "signgen" SlugAddEphKey Slug = "addEphemeralKey" SlugRevokeEphKey Slug = "revokeEphemeralKey" SlugQuorumChange Slug = "quorumChange" )
func (Slug) String
func (s Slug) String() string
String implements the fmt.Stringer interface for Slug.
type Transaction
type Transaction struct { SigningMessage string `json:"signingMessage"` RequestType SignRequestType `json:"requestType"` }
Transaction represents a single signing transaction descriptor.
Directories
| docs-server/cmd/docpost | |
| docs-server/cmd/docserver | Package main provides a static file server for versioned Go documentation. |
| networkclient | |
| setup_sk |