soc

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: BSD-3-Clause Imports: 6 Imported by: 15

Documentation

Overview

Package soc provides the single-owner chunk implemenation and validator.

Index

Constants

View Source
const (
	IdSize        = 32
	SignatureSize = 65
)

Variables

This section is empty.

Functions

func CreateAddress

func CreateAddress(id Id, owner *Owner) (swarm.Address, error)

CreateAddress creates a new soc address from the soc id and the ethereum address of the signer

func NewChunk

func NewChunk(id Id, ch swarm.Chunk, signer crypto.Signer) (swarm.Chunk, error)

NewChunk is a convenience function to create a single-owner chunk ready to be sent on the network.

func NewSignedChunk added in v0.5.0

func NewSignedChunk(id Id, ch swarm.Chunk, owner, sig []byte) (swarm.Chunk, error)

NewChunk is a convenience function to create a single-owner chunk ready to be sent on the network.

func Valid added in v0.4.1

func Valid(ch swarm.Chunk) bool

Valid checks if the chunk is a valid single-owner chunk.

Types

type Id

type Id []byte

Id is a soc identifier

type Owner

type Owner struct {
	// contains filtered or unexported fields
}

Owner is a wrapper that enforces valid length address of soc owner.

func NewOwner

func NewOwner(address []byte) (*Owner, error)

NewOwner creates a new Owner.

type Soc

type Soc struct {
	Chunk swarm.Chunk
	// contains filtered or unexported fields
}

Soc wraps a single soc.

func FromChunk

func FromChunk(sch swarm.Chunk) (*Soc, error)

FromChunk recreates an Soc representation from swarm.Chunk data.

func New

func New(id Id, ch swarm.Chunk) *Soc

New creates a new Soc representation from arbitrary soc id and a content-addressed chunk.

By default the span of the soc data is set to the length of the payload.

func (*Soc) AddSigner

func (s *Soc) AddSigner(signer crypto.Signer) error

AddSigner currently sets a single signer for the soc.

This method will overwrite any value set with WithOwnerAddress with the address derived from the given signer.

func (*Soc) Address

func (s *Soc) Address() (swarm.Address, error)

Address returns the soc Chunk address.

func (*Soc) OwnerAddress

func (s *Soc) OwnerAddress() []byte

OwnerAddress returns the ethereum address of the signer of the Chunk.

func (*Soc) Signature added in v0.5.0

func (s *Soc) Signature() []byte

func (*Soc) ToChunk

func (s *Soc) ToChunk() (swarm.Chunk, error)

ToChunk generates a signed chunk payload ready for submission to the swarm network.

The method will fail if no signer has been added.

func (*Soc) WithOwnerAddress

func (s *Soc) WithOwnerAddress(ownerAddress *Owner) *Soc

WithOwnerAddress provides the possibility of setting the ethereum address for the owner of an soc in the absence of a signer.

Jump to

Keyboard shortcuts

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