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
- Constants
- type ChallengeResponseExchanger
- type DsgRequestType
-
type NetworkClient
- func NewNetworkClient(config *NetworkClientConfig) (*NetworkClient, error)
- func (nc *NetworkClient) AddEphKey(cfg *RequestConfig, req *wp_requests.AddEphKeyRequest) ([]wp_responses.AddEphKeyResponse, error)
- func (nc *NetworkClient) DeletePolicy(cfg *RequestConfig, req *wp_requests.DeletePolicyRequest) (*wp_responses.PolicyChangeResponse, error)
- func (nc *NetworkClient) GetPolicy(cfg *RequestConfig, req *wp_requests.KeyIDOfPolicy) (*wp_responses.GetPolicyResponse, error)
- func (nc *NetworkClient) GetPolicyIntegrations(cfg *RequestConfig) (*wp_responses.IntegrationCatalog, error)
- func (nc *NetworkClient) Keygen(cfg *RequestConfig, req []wp_requests.KeygenOpts) ([]wp_responses.KeyshareIdentifier, error)
- func (nc *NetworkClient) QuorumChange(cfg *RequestConfig, req *wp_requests.QuorumChangeRequest) (*wp_responses.KeyshareIdentifier, error)
- func (nc *NetworkClient) RevokeEphKey(cfg *RequestConfig, req *wp_requests.RevokeEphKeyRequest) (*wp_responses.RevokeEphKeyResponse, error)
- func (nc *NetworkClient) Signgen(cfg *RequestConfig, req *wp_requests.SignOpts) ([]wp_responses.SigngenResponse, error)
- func (nc *NetworkClient) UpdatePolicy(cfg *RequestConfig, req *wp_requests.UpdatePolicyRequest) (*wp_responses.PolicyChangeResponse, 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, ...) (*wp_responses.RevokeEphKeyResponse, 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 Slug
Constants
const ( // DsgRequestTypeEIP1559 specifies an EVM based (EIP-1559) transaction. DsgRequestTypeEIP1559 = wp_requests.DsgRequestTypeEIP1559 // DsgRequestTypeEIP712 specifies an EIP-712 transaction. DsgRequestTypeEIP712 = wp_requests.DsgRequestTypeEIP712 // DsgRequestTypeEIP191 specifies an EIP-191 transaction. DsgRequestTypeEIP191 = wp_requests.DsgRequestTypeEIP191 // DsgRequestTypeRawBytes specifies a raw bytes transaction. DsgRequestTypeRawBytes = wp_requests.DsgRequestTypeRawBytes // DsgRequestTypeLegacyEth specifies legacy eth signing. DsgRequestTypeLegacyEth = wp_requests.DsgRequestTypeLegacyEth // DsgRequestTypeSolanaTx specifies a Solana transaction. DsgRequestTypeSolanaTx = wp_requests.DsgRequestTypeSolanaTx // DsgRequestTypeProvenanceTx specifies a hex-encoded SIGN_MODE_DIRECT SignDoc. DsgRequestTypeProvenanceTx = wp_requests.DsgRequestTypeProvenanceTx )
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 DsgRequestType
type DsgRequestType = wp_requests.DsgRequestType
DsgRequestType represents the type of signing transaction.
func ParseDsgRequestType
func ParseDsgRequestType(s string) (DsgRequestType, error)
ParseDsgRequestType converts a string into a DsgRequestType, returning an error if the value is not a recognized request type.
type NetworkClient
type NetworkClient struct { // contains filtered or unexported fields }
NetworkClient executes distributed-key and policy operations using V2 wallet-provider authentication without a challenge-response exchange.
All operation methods take a non-nil cfg containing the API version and request ID. Its Version must be types.ApiV2, except for NetworkClient.GetPolicyIntegrations, which also supports V1. Request arguments passed as pointers must be non-nil.
Operation methods return an error if request validation, network execution, or JSON response decoding fails.
func NewNetworkClient
func NewNetworkClient(config *NetworkClientConfig) (*NetworkClient, error)
NewNetworkClient creates a client using config's network nodes, API key, and wallet-provider signing key. config must be non-nil.
It returns a client configured to select nodes in round-robin order, or an error if the node configuration is invalid. Network connections are opened when methods such as NetworkClient.Keygen or NetworkClient.GetPolicy are called, and closed when that operation returns.
func (*NetworkClient) AddEphKey
func (nc *NetworkClient) AddEphKey(cfg *RequestConfig, req *wp_requests.AddEphKeyRequest) ([]wp_responses.AddEphKeyResponse, error)
AddEphKey adds an ephemeral key to the specified distributed keys using V2.
req contains the target key IDs and ephemeral-key claim.
It returns a slice of wp_responses.AddEphKeyResponse values containing key IDs and operation statuses.
func (*NetworkClient) DeletePolicy
func (nc *NetworkClient) DeletePolicy(cfg *RequestConfig, req *wp_requests.DeletePolicyRequest) (*wp_responses.PolicyChangeResponse, error)
DeletePolicy removes a distributed key's stored policy using V2.
req contains the key ID and expected authorization epoch. The expected epoch must match the current epoch returned by NetworkClient.GetPolicy.
It returns a wp_responses.PolicyChangeResponse containing the operation status and resulting authorization epoch.
func (*NetworkClient) GetPolicy
func (nc *NetworkClient) GetPolicy(cfg *RequestConfig, req *wp_requests.KeyIDOfPolicy) (*wp_responses.GetPolicyResponse, error)
GetPolicy reads a distributed key's stored policy and authorization epoch using V2.
req identifies the key whose policy is being read.
It returns a wp_responses.GetPolicyResponse containing policy JSON and the current authorization epoch. The policy JSON is null when no policy is stored.
func (*NetworkClient) GetPolicyIntegrations
func (nc *NetworkClient) GetPolicyIntegrations(cfg *RequestConfig) (*wp_responses.IntegrationCatalog, error)
GetPolicyIntegrations fetches the deployment's external-check integrations.
This route receives its catalog immediately and sends no wallet-provider payload or user signatures.
It returns a wp_responses.IntegrationCatalog listing integration IDs, supported operations, and the transaction and context fields each operation may receive.
func (*NetworkClient) Keygen
func (nc *NetworkClient) Keygen( cfg *RequestConfig, req []wp_requests.KeygenOpts, ) ([]wp_responses.KeyshareIdentifier, error)
Keygen generates distributed keys using V2.
req must contain at least one wp_requests.KeygenOpts, with a distinct signing algorithm for each option. Each option specifies the threshold, number of parties, metadata, and an optional initial policy.
It returns a slice of wp_responses.KeyshareIdentifier values containing the generated key IDs, public keys, algorithms, thresholds, and party counts.
func (*NetworkClient) QuorumChange
func (nc *NetworkClient) QuorumChange( cfg *RequestConfig, req *wp_requests.QuorumChangeRequest, ) (*wp_responses.KeyshareIdentifier, error)
QuorumChange changes a distributed key's threshold and participating nodes using V2.
req specifies the existing key, new threshold, and optional replacement nodes. If NewNodes is nil, the current nodes are retained.
It returns a wp_responses.KeyshareIdentifier describing the resulting key and quorum.
func (*NetworkClient) RevokeEphKey
func (nc *NetworkClient) RevokeEphKey(cfg *RequestConfig, req *wp_requests.RevokeEphKeyRequest) (*wp_responses.RevokeEphKeyResponse, error)
RevokeEphKey revokes an ephemeral key associated with a distributed key using V2.
req contains the target key ID and ephemeral-key claim.
It returns a wp_responses.RevokeEphKeyResponse containing the operation status.
func (*NetworkClient) Signgen
func (nc *NetworkClient) Signgen( cfg *RequestConfig, req *wp_requests.SignOpts, ) ([]wp_responses.SigngenResponse, error)
Signgen signs a transaction with an existing distributed key using V2.
req identifies the key, signing algorithm, threshold, and transaction in wp_requests.SignOpts.Message. It may also supply policy integration context.
It returns a slice of wp_responses.SigngenResponse values containing the signatures, transaction IDs, and recovery IDs where applicable.
func (*NetworkClient) UpdatePolicy
func (nc *NetworkClient) UpdatePolicy(cfg *RequestConfig, req *wp_requests.UpdatePolicyRequest) (*wp_responses.PolicyChangeResponse, error)
UpdatePolicy replaces a distributed key's policy using V2.
req contains the key ID and replacement policy JSON. The policy's epoch must be one greater than the current authorization epoch returned by NetworkClient.GetPolicy. The network validates the policy.
It returns a wp_responses.PolicyChangeResponse containing the operation status and resulting authorization epoch.
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, ) (*wp_responses.RevokeEphKeyResponse, 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.
It returns a wp_responses.RevokeEphKeyResponse containing the operation status, or an error if the request is invalid, the network operation fails, or the response cannot be decoded.
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(signAlg) should be assigned to SignOpts.Message.
func NewSignRequestBuilder
func NewSignRequestBuilder() *SignRequestBuilder
NewSignRequestBuilder creates a new SignRequestBuilder.
func (*SignRequestBuilder) Build
func (b *SignRequestBuilder) Build(signAlg types.SignatureAlgorithm) (string, error)
Build validates a single transaction and its algorithm compatibility, then returns the transaction map as canonicalized JSON.
func (*SignRequestBuilder) SetRequest
func (b *SignRequestBuilder) SetRequest(transactionID string, message string, requestType DsgRequestType) *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 DsgRequestType.
Returns the builder instance to allow chaining.
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" SlugGetPolicy Slug = "getPolicy" SlugUpdatePolicy Slug = "updatePolicy" SlugDeletePolicy Slug = "deletePolicy" SlugGetPolicyIntegrations Slug = "getPolicyIntegrations" )
func (Slug) String
func (s Slug) String() string
String implements the fmt.Stringer interface for Slug.
Directories
| docs-server/cmd/docpost | postprocess.go - Apply the Silence Laboratories documentation skin to doc2go output. |
| docs-server/cmd/docserver | Package main provides a static file server for versioned Go documentation. |
| networkclient | |
| setup_sk |