domain

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSignature = errors.New("invalid signature")

Functions

This section is empty.

Types

type Ack added in v0.1.4

type Ack struct {
	Timestamp     *time.Time
	Gas           uint64
	PublicKey     []byte
	Nonce         []byte
	RequestId     string
	SessionId     []byte
	Cid           string
	Signature     []byte
	Schema        string
	MultiHashType uint64
	Chunks        []string
}

func (*Ack) MarshalProto added in v0.1.4

func (a *Ack) MarshalProto() ([]byte, error)

func (*Ack) ToDomain added in v0.1.4

func (a *Ack) ToDomain(ack *pb.Ack)

func (*Ack) ToProto added in v0.1.4

func (a *Ack) ToProto() *pb.Ack

func (*Ack) UnmarshalProto added in v0.1.4

func (a *Ack) UnmarshalProto(bytes []byte) error

type AckRecord added in v0.1.4

type AckRecord struct {
	Ack       *Ack
	PublicKey []byte
	Timestamp *time.Time
}

func (*AckRecord) MarshalProto added in v0.1.4

func (a *AckRecord) MarshalProto() ([]byte, error)

func (*AckRecord) ToDomain added in v0.1.4

func (a *AckRecord) ToDomain(record *pb.AckRecord)

func (*AckRecord) ToProto added in v0.1.4

func (a *AckRecord) ToProto() *pb.AckRecord

func (*AckRecord) UnmarshalProto added in v0.1.4

func (a *AckRecord) UnmarshalProto(bytes []byte) error

type AckRecordList added in v0.1.4

type AckRecordList []*AckRecord

func (*AckRecordList) MarshalProto added in v0.1.4

func (a *AckRecordList) MarshalProto() ([]byte, error)

func (*AckRecordList) ToDomain added in v0.1.4

func (a *AckRecordList) ToDomain(records *pb.AckRecordList)

func (*AckRecordList) ToProto added in v0.1.4

func (a *AckRecordList) ToProto() *pb.AckRecordList

func (*AckRecordList) UnmarshalProto added in v0.1.4

func (a *AckRecordList) UnmarshalProto(bytes []byte) error

type Code added in v0.1.4

type Code = pb.Code
const (
	Code_SUCCESS                    Code = 0
	Code_CREATED                    Code = 1
	Code_NOT_FOUND                  Code = 2
	Code_FAILED_READ_BODY           Code = 3
	Code_FAILED_UNMARSHAL_BODY      Code = 4
	Code_FAILED_MARSHAL_BODY        Code = 5
	Code_FAILED_GET_BLOCKCHAIN_DATA Code = 6
	Code_BUCKET_RENT_EXPIRED        Code = 7
	Code_INVALID_PUBLIC_KEY         Code = 8
	Code_INVALID_SIGNATURE          Code = 9
	Code_INVALID_PARAMETER          Code = 10
	Code_BUCKET_NO_ACCESS           Code = 11
	Code_INTERNAL_ERROR             Code = 12
	Code_BAD_GATEWAY                Code = 13
	Code_INVALID_SESSION_ID         Code = 14
	Code_ACCOUNT_DEPOSIT_REQUIRED   Code = 15
	Code_GAS_EXPIRED                Code = 16
	Code_REQUEST_TOO_LARGE          Code = 17
)

type IsRequest added in v0.1.4

type IsRequest interface {
	// contains filtered or unexported methods
}
type Link struct {
	Cid  string
	Size uint64
	Name string
}

func (*Link) MarshalProto

func (l *Link) MarshalProto() ([]byte, error)

func (*Link) ToDomain

func (l *Link) ToDomain(pbLink *pb.Link)

func (*Link) ToProto

func (l *Link) ToProto() *pb.Link

func (*Link) UnmarshalProto

func (l *Link) UnmarshalProto(linkAsBytes []byte) error

type LogRecord added in v0.1.4

type LogRecord struct {
	Request        IsRequest
	Timestamp      *time.Time
	Address        string
	Gas            uint32
	PublicKey      []byte
	SessionId      []byte
	RequestId      string
	Signature      *Signature
	ResponsePieces []*ResponsePiece
}

func (*LogRecord) MarshalProto added in v0.1.4

func (l *LogRecord) MarshalProto() ([]byte, error)

func (*LogRecord) ToDomain added in v0.1.4

func (l *LogRecord) ToDomain(pbLogRecord *pb.LogRecord)

func (*LogRecord) ToProto added in v0.1.4

func (l *LogRecord) ToProto() *pb.LogRecord

func (*LogRecord) UnmarshalProto added in v0.1.4

func (l *LogRecord) UnmarshalProto(logRecordAsBytes []byte) error

type LogRecordList added in v0.1.4

type LogRecordList []*LogRecord

func (*LogRecordList) MarshalProto added in v0.1.4

func (l *LogRecordList) MarshalProto() ([]byte, error)

func (*LogRecordList) ToDomain added in v0.1.4

func (l *LogRecordList) ToDomain(pbLogRecordList *pb.LogRecordList)

func (*LogRecordList) ToProto added in v0.1.4

func (l *LogRecordList) ToProto() *pb.LogRecordList

func (*LogRecordList) UnmarshalProto added in v0.1.4

func (l *LogRecordList) UnmarshalProto(logRecordAsBytes []byte) error

type Piece

type Piece struct {
	Data     []byte
	BucketId uint32
	Tags     []*Tag
	Links    []*Link
}

func (*Piece) MarshalProto

func (p *Piece) MarshalProto() ([]byte, error)

func (*Piece) ToDomain

func (p *Piece) ToDomain(pbPiece *pb.Piece)

func (*Piece) ToProto

func (p *Piece) ToProto() *pb.Piece

func (*Piece) UnmarshalProto

func (p *Piece) UnmarshalProto(pieceAsBytes []byte) error

type Protobufable

type Protobufable interface {
	MarshalProto() ([]byte, error)
	UnmarshalProto(bytes []byte) error
}

type Query

type Query struct {
	BucketId uint32
	Tags     []*Tag
	SkipData bool
}

func (*Query) MarshalProto

func (q *Query) MarshalProto() ([]byte, error)

func (*Query) ToDomain

func (q *Query) ToDomain(pbQuery *pb.Query)

func (*Query) ToProto

func (q *Query) ToProto() *pb.Query

func (*Query) UnmarshalProto

func (q *Query) UnmarshalProto(queryAsBytes []byte) error

type QueryRequest added in v0.1.4

type QueryRequest struct {
	Query *Query
}

type ReadRequest added in v0.1.4

type ReadRequest struct {
	Cid      string
	BucketId uint32
}

type Request added in v0.1.4

type Request struct {
	Body          []byte
	PublicKey     []byte
	Signature     []byte
	Scheme        string
	MultiHashType uint64
	SessionId     []byte
}

func (*Request) MarshalProto added in v0.1.4

func (r *Request) MarshalProto() ([]byte, error)

func (*Request) ToDomain added in v0.1.4

func (r *Request) ToDomain(pbRequest *pb.Request)

func (*Request) ToProto added in v0.1.4

func (r *Request) ToProto() *pb.Request

func (*Request) UnmarshalProto added in v0.1.4

func (r *Request) UnmarshalProto(bytes []byte) error

type Response added in v0.1.4

type Response struct {
	Body          []byte
	PublicKey     []byte
	Signature     []byte
	Scheme        string
	Gas           uint32
	ResponseCode  Code
	MultiHashType uint64
}

func (*Response) MarshalProto added in v0.1.4

func (r *Response) MarshalProto() ([]byte, error)

func (*Response) ToDomain added in v0.1.4

func (r *Response) ToDomain(pbRequest *pb.Response)

func (*Response) ToProto added in v0.1.4

func (r *Response) ToProto() *pb.Response

func (*Response) UnmarshalProto added in v0.1.4

func (r *Response) UnmarshalProto(bytes []byte) error

type ResponsePiece added in v0.1.6

type ResponsePiece struct {
	Cid  string
	Size uint32
}

type SearchResult

type SearchResult struct {
	SearchedPieces []*SearchedPiece
}

func (*SearchResult) MarshalProto

func (sr *SearchResult) MarshalProto() ([]byte, error)

func (*SearchResult) ToDomain

func (sr *SearchResult) ToDomain(pbSearchResult *pb.SearchResult) error

func (*SearchResult) ToProto

func (sr *SearchResult) ToProto() *pb.SearchResult

func (*SearchResult) UnmarshalProto

func (sr *SearchResult) UnmarshalProto(searchResultAsBytes []byte) error

type SearchedPiece added in v0.1.3

type SearchedPiece struct {
	SignedPiece *SignedPiece
	Cid         string
}

func (*SearchedPiece) MarshalProto added in v0.1.3

func (sp *SearchedPiece) MarshalProto() ([]byte, error)

func (*SearchedPiece) ToDomain added in v0.1.3

func (sp *SearchedPiece) ToDomain(pbSearchPiece *pb.SearchedPiece) error

func (*SearchedPiece) ToProto added in v0.1.3

func (sp *SearchedPiece) ToProto() *pb.SearchedPiece

func (*SearchedPiece) UnmarshalProto added in v0.1.3

func (sp *SearchedPiece) UnmarshalProto(searchedPieceAsBytes []byte) error

type SessionStatus added in v0.1.4

type SessionStatus struct {
	PublicKey  []byte
	Gas        uint32
	SessionId  []byte
	EndOfEpoch uint64
	BucketId   uint32
}

func (*SessionStatus) MarshalProto added in v0.1.4

func (s *SessionStatus) MarshalProto() ([]byte, error)

func (*SessionStatus) ToDomain added in v0.1.4

func (s *SessionStatus) ToDomain(pbSessionStatus *pb.SessionStatus)

func (*SessionStatus) ToProto added in v0.1.4

func (s *SessionStatus) ToProto() *pb.SessionStatus

func (*SessionStatus) UnmarshalProto added in v0.1.4

func (s *SessionStatus) UnmarshalProto(bytes []byte) error

type SessionStatusRecord added in v0.1.4

type SessionStatusRecord struct {
	SessionStatus *SessionStatus
	PublicKey     []byte
	Signature     []byte
	Timestamp     uint64
}

func (*SessionStatusRecord) MarshalProto added in v0.1.4

func (s *SessionStatusRecord) MarshalProto() ([]byte, error)

func (*SessionStatusRecord) ToDomain added in v0.1.4

func (s *SessionStatusRecord) ToDomain(pbSessionStatusRecord *pb.SessionStatusRecord)

func (*SessionStatusRecord) ToProto added in v0.1.4

func (*SessionStatusRecord) UnmarshalProto added in v0.1.4

func (s *SessionStatusRecord) UnmarshalProto(bytes []byte) error

type Signature

type Signature struct {
	Value         []byte
	Signer        []byte
	Scheme        string
	MultiHashType uint64
	Timestamp     uint64
}

func (*Signature) DecodedSigner added in v0.1.4

func (s *Signature) DecodedSigner() ([]byte, error)

func (*Signature) DecodedValue added in v0.1.4

func (s *Signature) DecodedValue() ([]byte, error)

func (*Signature) MarshalProto

func (s *Signature) MarshalProto() ([]byte, error)

func (*Signature) ToDomain

func (s *Signature) ToDomain(pbSignature *pb.Signature)

func (*Signature) ToProto

func (s *Signature) ToProto() *pb.Signature

func (*Signature) UnmarshalProto

func (s *Signature) UnmarshalProto(signatureAsBytes []byte) error

type SignedPiece

type SignedPiece struct {
	Signature *Signature
	// contains filtered or unexported fields
}

## Generation of a SignedPiece:

1. Prepare a `Piece` structure and its ProtoBuf serialization. 2. Prepare a `Signature` structure with its details except `Value`. 3. Pass those to `NewSignedPiece(…)`. 4. Use `SigneableCid()` to generate a signeable message, and a CID of the piece. 5. Generate a signature of the `signeable` message using `crypto.CreateScheme(…)`. 6. Store the signature with `SetSignature()`. 7. Serialize the SignedPiece with `MarshalProto()` for transmission or storage. 8. Use the CID above as a permanent identifier of the piece.

## Verification of a SignedPiece:

1. Deserialize using `UnmarshalProto()`. 2. Call `Verify()`. 3. If the piece is to be forwarded or stored, use the original serialization (do not re-serialize).

func NewSignedPiece added in v0.1.4

func NewSignedPiece(piece *Piece, pieceSerial []byte, sig *Signature) *SignedPiece

func (*SignedPiece) MarshalProto

func (sp *SignedPiece) MarshalProto() ([]byte, error)

func (*SignedPiece) Piece

func (sp *SignedPiece) Piece() *Piece

func (*SignedPiece) PieceCid added in v0.1.4

func (sp *SignedPiece) PieceCid() (string, error)

func (*SignedPiece) PieceSerial added in v0.1.4

func (sp *SignedPiece) PieceSerial() []byte

func (*SignedPiece) SetSignature added in v0.1.4

func (sp *SignedPiece) SetSignature(sig []byte)

func (*SignedPiece) SigneableCid added in v0.1.4

func (sp *SignedPiece) SigneableCid() (signeable []byte, pieceCid string, err error)

func (*SignedPiece) ToDomain

func (sp *SignedPiece) ToDomain(pbSignedPiece *pb.SignedPiece) error

func (*SignedPiece) ToProto

func (sp *SignedPiece) ToProto() *pb.SignedPiece

func (*SignedPiece) UnmarshalProto

func (sp *SignedPiece) UnmarshalProto(signedPieceAsBytes []byte) error

func (*SignedPiece) Verify added in v0.1.4

func (sp *SignedPiece) Verify() (string, []byte, error)

type Tag

type Tag struct {
	Key        []byte
	Value      []byte
	Searchable pb.SearchType
}

func (*Tag) MarshalProto

func (t *Tag) MarshalProto() ([]byte, error)

func (*Tag) ToDomain

func (t *Tag) ToDomain(pbTag *pb.Tag)

func (*Tag) ToProto

func (t *Tag) ToProto() *pb.Tag

func (*Tag) UnmarshalProto

func (t *Tag) UnmarshalProto(tagAsBytes []byte) error

type WriteRequest added in v0.1.4

type WriteRequest struct {
	Cid      string
	BucketId uint32
	Size     uint32
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL