Documentation
¶
Overview ¶
Package typeddata implements EIP-712 typed data signing for storage provider authentication.
Supported message types:
- CreateDataSet: authorize dataset creation on a provider
- AddPieces: authorize adding pieces to a dataset
- TerminateService: authorize service termination
- SchedulePieceRemovals: authorize piece removal scheduling
Domain: FilecoinWarmStorageService with chain-specific separation.
Index ¶
- Variables
- func AddPiecesMessage(clientDataSetID, nonce *big.Int, pieceCIDs []cid.Cid, ...) (apitypes.TypedDataMessage, error)
- func CompactPieceMetadata(metadata [][]MetadataEntry) [][]MetadataEntry
- func CreateDataSetMessage(clientDataSetID *big.Int, payee common.Address, metadata []MetadataEntry) apitypes.TypedDataMessage
- func NewDomain(chainID *big.Int, fwssAddr common.Address) apitypes.TypedDataDomain
- func NewERC20PermitDomain(chainID *big.Int, tokenName, tokenVersion string, token common.Address) apitypes.TypedDataDomain
- func SchedulePieceRemovalsMessage(clientDataSetID *big.Int, pieceIDs []*big.Int) apitypes.TypedDataMessage
- func TerminateServiceMessage(dataSetID *big.Int) apitypes.TypedDataMessage
- type MetadataEntry
- type Signature
- func Sign(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, ...) (*Signature, error)
- func SignAddPieces(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, ...) (*Signature, error)
- func SignCreateDataSet(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, ...) (*Signature, error)
- func SignERC20Permit(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, ...) (*Signature, error)
- func SignSchedulePieceRemovals(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, ...) (*Signature, error)
- func SignTerminateService(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, ...) (*Signature, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSignatureLength = errors.New("signature must be 65 bytes") ErrInvalidRecoveryID = errors.New("signature recovery id must be one of 0, 1, 27, 28") )
var Types = apitypes.Types{
"EIP712Domain": {
{Name: "name", Type: "string"},
{Name: "version", Type: "string"},
{Name: "chainId", Type: "uint256"},
{Name: "verifyingContract", Type: "address"},
},
"MetadataEntry": {
{Name: "key", Type: "string"},
{Name: "value", Type: "string"},
},
"CreateDataSet": {
{Name: "clientDataSetId", Type: "uint256"},
{Name: "payee", Type: "address"},
{Name: "metadata", Type: "MetadataEntry[]"},
},
"Cid": {
{Name: "data", Type: "bytes"},
},
"PieceMetadata": {
{Name: "pieceIndex", Type: "uint256"},
{Name: "metadata", Type: "MetadataEntry[]"},
},
"AddPieces": {
{Name: "clientDataSetId", Type: "uint256"},
{Name: "nonce", Type: "uint256"},
{Name: "pieceData", Type: "Cid[]"},
{Name: "pieceMetadata", Type: "PieceMetadata[]"},
},
"SchedulePieceRemovals": {
{Name: "clientDataSetId", Type: "uint256"},
{Name: "pieceIds", Type: "uint256[]"},
},
"TerminateService": {
{Name: "dataSetId", Type: "uint256"},
},
}
Types contains all EIP-712 type definitions for the FWSS protocol.
Functions ¶
func AddPiecesMessage ¶
func AddPiecesMessage(clientDataSetID, nonce *big.Int, pieceCIDs []cid.Cid, metadata [][]MetadataEntry) (apitypes.TypedDataMessage, error)
AddPiecesMessage builds the EIP-712 message for adding pieces.
func CompactPieceMetadata ¶ added in v0.6.0
func CompactPieceMetadata(metadata [][]MetadataEntry) [][]MetadataEntry
CompactPieceMetadata returns the compact add-pieces representation when no piece in the batch has metadata. Mixed batches retain one entry per piece.
func CreateDataSetMessage ¶
func CreateDataSetMessage(clientDataSetID *big.Int, payee common.Address, metadata []MetadataEntry) apitypes.TypedDataMessage
CreateDataSetMessage builds the EIP-712 message for dataset creation.
func NewERC20PermitDomain ¶
func NewERC20PermitDomain(chainID *big.Int, tokenName, tokenVersion string, token common.Address) apitypes.TypedDataDomain
NewERC20PermitDomain builds an ERC-2612 EIP-712 domain for the given token. The name and version must be fetched from the token itself at runtime (see payments.fetchPermitInputs); the chainID and token address complete the domain.
func SchedulePieceRemovalsMessage ¶
func SchedulePieceRemovalsMessage(clientDataSetID *big.Int, pieceIDs []*big.Int) apitypes.TypedDataMessage
SchedulePieceRemovalsMessage builds the EIP-712 message for scheduling piece removals.
func TerminateServiceMessage ¶ added in v0.4.0
func TerminateServiceMessage(dataSetID *big.Int) apitypes.TypedDataMessage
TerminateServiceMessage builds the EIP-712 message for service termination.
Types ¶
type MetadataEntry ¶
MetadataEntry represents a key-value metadata pair.
type Signature ¶
Signature holds the components of an EIP-712 signature.
func Sign ¶
func Sign(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, primaryType string, message apitypes.TypedDataMessage) (*Signature, error)
Sign signs an EIP-712 typed data message using the provided hash-signing function (typically obtained via signer.SignHash).
func SignAddPieces ¶
func SignAddPieces(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, clientDataSetID, nonce *big.Int, pieceCIDs []cid.Cid, metadata [][]MetadataEntry) (*Signature, error)
SignAddPieces signs an AddPieces EIP-712 message.
func SignCreateDataSet ¶
func SignCreateDataSet(signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, clientDataSetID *big.Int, payee common.Address, metadata []MetadataEntry) (*Signature, error)
SignCreateDataSet signs a CreateDataSet EIP-712 message.
func SignERC20Permit ¶
func SignERC20Permit( signHash func([]byte) ([]byte, error), domain apitypes.TypedDataDomain, owner, spender common.Address, value, nonce, deadline *big.Int, ) (*Signature, error)
SignERC20Permit signs an ERC-2612 Permit message and returns v/r/s suitable for direct use with Solidity `permit(owner, spender, value, deadline, v, r, s)` or Filecoin Pay `depositWithPermit(token, to, amount, deadline, v, r, s)`.