Silence Laboratories Silence Laboratories Wallet Provider Go SDK All versions Repository ↗

package wp_requests

import "github.com/silence-laboratories/wallet-provider-go-sdk/networkclient/wp_requests"

Index

Functions

func ValidateSigningMessage

func ValidateSigningMessage(message string, alg types.SignatureAlgorithm) error

ValidateSigningMessage validates SignOpts.Message, a string containing a JSON object whose keys are transaction IDs and whose values are Transaction. It reads keys with Decoder.Token to reject duplicate transaction IDs before decoding into a Go map, which would replace an earlier entry with the same key.

See https://pkg.go.dev/encoding/json#Unmarshal for duplicate-key behavior.

Types

type AddEphKeyRequest

type AddEphKeyRequest struct {
	// The list of keys to add the ephemeral key to.
	KeyIDList []string `json:"key_id_list" validate:"required"`

	// The ephemeral key claim in JSON string format.
	EphClaim string `json:"eph_claim" validate:"required"`
}
func (*AddEphKeyRequest) UnmarshalJSON
func (r *AddEphKeyRequest) UnmarshalJSON(data []byte) error

type DeletePolicyRequest

type DeletePolicyRequest struct {
	KeyID                      string `json:"key_id"`
	ExpectedAuthorizationEpoch uint64 `json:"expected_authorization_epoch"`
}

DeletePolicyRequest removes a policy at the specified authorization epoch.

func (*DeletePolicyRequest) UnmarshalJSON
func (p *DeletePolicyRequest) UnmarshalJSON(data []byte) error

type DsgRequestType

type DsgRequestType string

DsgRequestType identifies the signing transaction format.

const (
	DsgRequestTypeEIP1559      DsgRequestType = "EIP1559"
	DsgRequestTypeEIP712       DsgRequestType = "EIP712"
	DsgRequestTypeEIP191       DsgRequestType = "EIP191"
	DsgRequestTypeRawBytes     DsgRequestType = "rawBytes"
	DsgRequestTypeLegacyEth    DsgRequestType = "legacyEth"
	DsgRequestTypeSolanaTx     DsgRequestType = "solanaTransaction"
	DsgRequestTypeProvenanceTx DsgRequestType = "provenanceTransaction"
)
func ParseDsgRequestType
func ParseDsgRequestType(s string) (DsgRequestType, error)
func (DsgRequestType) String
func (s DsgRequestType) String() string

type KeyIDOfPolicy

type KeyIDOfPolicy struct {
	KeyID string `json:"key_id"`
}

KeyIDOfPolicy identifies the key whose policy is being read.

func (*KeyIDOfPolicy) UnmarshalJSON
func (p *KeyIDOfPolicy) UnmarshalJSON(data []byte) error

type KeygenOpts

type KeygenOpts struct {
	// T is the signature threshold (how many key shares are required to generate signature).
	T uint8 `json:"t" validate:"required,min=2"`

	// N is the number of key shares.
	N uint8 `json:"n" validate:"required"`

	// Metadata is a collection of tagged values to be associated with a key share.
	// All shares will contain the same set of pairs.
	Metadata []types.TaggedValue `json:"metadata" validate:"required"`

	// SignAlg is the chosen signature algorithm for key generation.
	SignAlg types.SignatureAlgorithm `json:"signAlg" validate:"required"`

	// Attach eph key to the generated key
	// So having it as string we ensure it's in the same shape during verifying and it was during signing
	EphClaim *string `json:"ephClaim,omitempty"`

	// Policy is the policy JSON string. An initial policy must use epoch 1.
	// Its contents are preserved; policy validation is performed by the network.
	Policy *string `json:"policy,omitempty"`
}

KeygenOpts represents parameters for distributed key generation.

func (KeygenOpts) MarshalJSON
func (k KeygenOpts) MarshalJSON() ([]byte, error)

MarshalJSON represents an unset metadata slice as the required empty array.

func (*KeygenOpts) UnmarshalJSON
func (k *KeygenOpts) UnmarshalJSON(data []byte) error
func (KeygenOpts) Validate
func (k KeygenOpts) Validate() error

Validate checks the key generation constraints shared with el-aggregator-client.

type QuorumChangeRequest

type QuorumChangeRequest struct {
	// New threshold
	NewT uint8 `json:"new_t" validate:"required,min=2"`

	// New quorum nodes (new_n). Old quorum nodes (n).
	//
	// (new_n >= n || new_n <= n) && new_n >= new_t
	NewNodes *[]string `json:"new_nodes,omitempty" validate:"omitempty"`

	// ID of the previously generated distributed key, in hex
	KeyID string `json:"key_id" validate:"required"`

	// Public key of the generated key. Affine representation in hex.
	PublicKey string `json:"public_key" validate:"required"`

	// Signature algorithm of the key
	SignAlg types.SignatureAlgorithm `json:"sign_alg" validate:"required"`
}

Parameters for quorum change protocol.

func (QuorumChangeRequest) MarshalJSON
func (q QuorumChangeRequest) MarshalJSON() ([]byte, error)
func (*QuorumChangeRequest) UnmarshalJSON
func (q *QuorumChangeRequest) UnmarshalJSON(data []byte) error
func (QuorumChangeRequest) Validate
func (q QuorumChangeRequest) Validate() error

Validate checks quorum-change constraints for decoded and constructed requests.

type RevokeEphKeyRequest

type RevokeEphKeyRequest struct {
	// The associated ephemeral key of this key will be revoked.
	KeyID string `json:"key_id" validate:"required"`

	// The ephemeral key claim in JSON string format.
	EphClaim string `json:"eph_claim" validate:"required"`
}
func (*RevokeEphKeyRequest) UnmarshalJSON
func (r *RevokeEphKeyRequest) UnmarshalJSON(data []byte) error

type SignOpts

type SignOpts struct {
	/// Signature threshold (how many key shares are required to generate signature)
	T uint8 `json:"t"`

	/// id of the previously generated distributed key, in hex
	KeyID string `json:"key_id" validate:"required"`

	/// Message to be signed
	/// Structure format: HashMap<TransactionId, Transaction>
	Message string `json:"message" validate:"required"`

	/// Chosen signature algorithm for signing
	SignAlg types.SignatureAlgorithm `json:"signAlg" validate:"required"`

	// PolicyIntegrationContext is a JSON object encoded as a string for policy integrations.
	PolicyIntegrationContext *string `json:"policy_integration_context,omitempty"`
}

Parameters for distributed signature generation.

func (SignOpts) MarshalJSON
func (s SignOpts) MarshalJSON() ([]byte, error)

MarshalJSON uses the network's canonical EdDSA signing algorithm name.

func (*SignOpts) UnmarshalJSON
func (s *SignOpts) UnmarshalJSON(data []byte) error
func (SignOpts) Validate
func (s SignOpts) Validate() error

Validate checks a single signing transaction against the chosen algorithm. The network checks the threshold against the stored key's configuration.

type Transaction

type Transaction struct {
	SigningMessage string         `json:"signingMessage"`
	RequestType    DsgRequestType `json:"requestType"`
}

Transaction is the wire descriptor used inside SignOpts.Message.

func (*Transaction) UnmarshalJSON
func (t *Transaction) UnmarshalJSON(data []byte) error
func (Transaction) Validate
func (t Transaction) Validate() error

Validate rejects unknown request types. Raw-byte, legacyEth, Solana, and Provenance messages must be nonempty hex strings.

func (Transaction) ValidateSignAlgorithm
func (t Transaction) ValidateSignAlgorithm(alg types.SignatureAlgorithm) error

ValidateSignAlgorithm matches el-aggregator-client's algorithm/request-type matrix.

type UpdatePolicyRequest

type UpdatePolicyRequest struct {
	Policy string `json:"policy"`
	KeyID  string `json:"key_id"`
}

UpdatePolicyRequest contains policy JSON with an epoch one greater than the key's current authorization epoch. The network validates the policy.

func (*UpdatePolicyRequest) UnmarshalJSON
func (p *UpdatePolicyRequest) UnmarshalJSON(data []byte) error

type WpRequest

type WpRequest struct {
	Payload WpRequestPayload `json:"payload"`
	// UserSigs is 'None' in chal-resp and available in non-chal-resp mechanism.
	UserSigs *auth.UserSignatures `json:"userSigs,omitempty"` // Use pointer for Option<T> and omitempty
}

Represents the structure of wallet provider requests which will be sent to the network.

type WpRequestPayload

type WpRequestPayload struct {
	Keygen        *[]KeygenOpts        `json:"-"` // untagged, so no direct JSON field name
	Sign          *SignOpts            `json:"-"`
	AddEphKey     *AddEphKeyRequest    `json:"-"`
	RevokeEphKey  *RevokeEphKeyRequest `json:"-"`
	QuorumChange  *QuorumChangeRequest `json:"-"`
	KeyIDOfPolicy *KeyIDOfPolicy       `json:"-"`
	UpdatePolicy  *UpdatePolicyRequest `json:"-"`
	DeletePolicy  *DeletePolicyRequest `json:"-"`
}
func (WpRequestPayload) GetSerializedBatch
func (w WpRequestPayload) GetSerializedBatch() (map[string][]byte, error)

GetSerializedBatch returns a map of serialized request payloads.

func (WpRequestPayload) MarshalJSON
func (w WpRequestPayload) MarshalJSON() ([]byte, error)

ensuring only the active payload is marshaled directly

func (*WpRequestPayload) String
func (w *WpRequestPayload) String() string
func (WpRequestPayload) ToBytes
func (w WpRequestPayload) ToBytes() ([]byte, error)

ToBytes serializes the WpRequestPayload to canonical JSON bytes (JCS).

func (*WpRequestPayload) UnmarshalJSON
func (w *WpRequestPayload) UnmarshalJSON(data []byte) error