objects

package
v0.0.0-...-6fd6c91 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2016 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package objects contains the contnet objects and functions for working with the Cryptographically curated content objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NameSegmentEscape

func NameSegmentEscape(nameSegment string) string

NameSegmentEscape escapes the text of NameSegment

func NameSegmentUnescape

func NameSegmentUnescape(s string) (string, error)

NameSegmentUnescape escapes the text of NameSegment

func NewDString

func NewDString() string

func ObjectTypeEscape

func ObjectTypeEscape(objectType string) string

ObjectTypeEscape escapes the text of types

func ObjectTypeUnescape

func ObjectTypeUnescape(s string) (string, error)

ObjectTypeUnescape unescapes the text of types

func RegisterGeterPoster

func RegisterGeterPoster(
	getPublicKeyForHkid func(hkid HKID) PublicKey,
	getPrivateKeyForHkid func(hkid HKID) (k *PrivateKey, err error),
	PostKey func(p *PrivateKey) error,
	PostBlob func(b Blob) error,
)

RegisterGeterPoster ads a given GeterPoster for use with objects

func SignatureEscape

func SignatureEscape(signature []byte) string

SignatureEscape escapes the text of signature

func SignatureUnescape

func SignatureUnescape(s string) ([]byte, error)

SignatureUnescape escapes the text of signature

func Unmarshal

func Unmarshal(curve elliptic.Curve, data []byte) (x, y *big.Int)

Unmarshal converts a point, serialized by Marshal, into an x, y pair. It is an error if the point is not on the curve. On error, x = nil.

func VersionEscape

func VersionEscape(version int64) (versionstr string)

VersionEscape escapes the text of version

func VersionUnescape

func VersionUnescape(s string) (int64, error)

VersionUnescape escapes the text of version

Types

type Blob

type Blob []byte

Blob holds the Data for CCFS content

func (Blob) Bytes

func (b Blob) Bytes() []byte

Bytes gets the data as a []byte

func (Blob) Hash

func (b Blob) Hash() HCID

Hash gets the sha256 of the Blob

func (Blob) Log

func (b Blob) Log()

Log sends a go string escaped blob to the log

type Byteser

type Byteser interface {
	Bytes() []byte
}

Byteser is a object that can be exported as a slice of byte

type Commit

type Commit struct {
	ListHash  HCID
	Version   int64
	Parents   Parents
	Hkid      HKID
	Signature []byte //131 byte max
}

Commit is the type for defining a repository at a moment in time

func CommitFromBytes

func CommitFromBytes(bytes []byte) (c Commit, err error)

CommitFromBytes build a Commit form a slice of byte or error

func NewCommit

func NewCommit(listHash HCID, hkid HKID) (c Commit)

NewCommit is factory producing a Commit with the given listhash and HKID

func (Commit) Bytes

func (c Commit) Bytes() []byte

Bytes gets the data in a Commit in the form of a []byte

func (Commit) Hash

func (c Commit) Hash() HCID

Hash gets the HCID for the Commit

func (Commit) Log

func (c Commit) Log()

Log sends a go string escaped Commit to the log

func (Commit) Merge

func (c Commit) Merge(pCommits []Commit, listHash HCID) Commit

Merge the Commit with the slice of Commit passed in

func (Commit) String

func (c Commit) String() string

String gets the data in a Commit in the form of a string

func (Commit) Update

func (c Commit) Update(listHash HCID) Commit

Update the Commit to point at the list who's hash is passed in

func (Commit) Verify

func (c Commit) Verify() bool

Verify returns wether the Commit has a valid Signature

type GeterPoster

type GeterPoster struct {
	PostKey  func(p *PrivateKey) error
	PostBlob func(b Blob) error
	// contains filtered or unexported fields
}

GeterPoster is a struct of functions for use with objects

type HCID

type HCID []byte

HCID is the type to represent content by it's cryptographic hash

func HcidFromHex

func HcidFromHex(s string) (HCID, error)

HcidFromHex return an HCID if the string contains 64 digits of Hex

func (HCID) Bytes

func (hcid HCID) Bytes() []byte

Bytes returns a slise of byte representing the hash

func (HCID) Hex

func (hcid HCID) Hex() string

Hex returns a string containing a hexadecimal representation if the hash

func (HCID) String

func (hcid HCID) String() string

String returns a string containing a hexadecimal representation if the hash

type HID

type HID interface {
	Byteser
	Hexer
}

HID is a Hash IDentifier

type HKID

type HKID []byte

HKID is the hash of a public key stored in a slice of byte

func GenHKID

func GenHKID() HKID

GenHKID returns a new HKID and posts the key to the blob store

func HkidFromD

func HkidFromD(D big.Int) HKID

HkidFromD builds a HKID using a number in a big int

func HkidFromDString

func HkidFromDString(str string, base int) HKID

HkidFromDString builds a HKID using a number in base in a string

func HkidFromHex

func HkidFromHex(s string) (HKID, error)

HkidFromHex gives you an HKID form a hex string

func (HKID) Bytes

func (hkid HKID) Bytes() []byte

Bytes reterns the HKID in the form of a slice of byte

func (HKID) Hex

func (hkid HKID) Hex() string

Hex reterns the HKID in the form of a hexidecimal string.

func (HKID) String

func (hkid HKID) String() string

type Hexer

type Hexer interface {
	Hex() string
}

Hexer is a object that can be exported as a string of hex

type List

type List map[string]entry

List is a map from nameSegments to HIDs and TypeStrings

func ListFromBytes

func ListFromBytes(listbytes []byte) (newlist List, err error)

ListFromBytes parses a slice of byte to a list

func NewList

func NewList(objectHash HID, typestring string, nameSegment string) List

NewList creates a new list from an initial HID,TypeString, and NameSegment

func (List) Add

func (l List) Add(nameSegment string, hash HID, typeString string) List

Add a new named content to the list

func (List) Bytes

func (l List) Bytes() []byte

Bytes builds text representation of the list as a slice of byte

func (List) Hash

func (l List) Hash() HCID

Hash calculates the HCID of the list

func (List) HashForNamesegment

func (l List) HashForNamesegment(namesegment string) (string, HID)

HashForNamesegment retrieves the TypeString and HID for a NameSegment

func (List) Log

func (l List) Log()

Log sends the list to the log with a header and footer

func (List) Remove

func (l List) Remove(nameSegment string) List

Remove a named content form the list

func (List) Rename

func (l List) Rename(oldNameSeg, newNameSeg string) (List, error)

Rename something in a List

func (List) String

func (l List) String() string

Sting builds text representation of the list

type Parents

type Parents []HCID

func (Parents) String

func (p Parents) String() string

type PrivateKey

type PrivateKey ecdsa.PrivateKey

PrivateKey wrapper around the ecdsa.PrivateKey type

func KeyGen

func KeyGen() *PrivateKey

KeyGen makes a private new key and returns it

func PrivateKeyFromBytes

func PrivateKeyFromBytes(b []byte) (priv *PrivateKey, err error)

PrivteKeyFromBytes makes a private key from a slice of bytes and returns it.

func PrivateKeyFromD

func PrivateKeyFromD(D big.Int) (*PrivateKey, error)

PrivteKeyFromD makes a private key from a big int and returns it

func (PrivateKey) Bytes

func (p PrivateKey) Bytes() []byte

Bytes returns the marshaled public key as a slice of byte.

func (PrivateKey) Hash

func (p PrivateKey) Hash() HCID

Hash returns the hcid for the PrivateKey

func (PrivateKey) Hkid

func (p PrivateKey) Hkid() HKID

Hkid returns the hkid that for private key. this is the hcid of your public key

func (PrivateKey) Verify

func (p PrivateKey) Verify() bool

Verify returns true if PrivateKey and PrivateKey are a pair.

type PublicKey

type PublicKey ecdsa.PublicKey

PublicKey wrapper around the ecdsa.PrivateKey type

func (PublicKey) Bytes

func (p PublicKey) Bytes() []byte

Bytes returns the marshaled public key as a slice of byte.

func (PublicKey) Hkid

func (p PublicKey) Hkid() HKID

Hkid returns the hkid for the public key.

type Tag

type Tag struct {
	HashBytes   HID
	TypeString  string
	NameSegment string
	Version     int64
	Parents     Parents
	Hkid        HKID
	Signature   []byte
}

Tag is a individually versioned reference to a content object

func NewTag

func NewTag(
	HashBytes HID,
	TypeString string,
	nameSegment string,
	tparent Parents,
	hkid HKID,
) Tag

NewTag build a new tag with the initial content

func TagFromBytes

func TagFromBytes(bytes []byte) (t Tag, err error)

TagFromBytes parses a slice of byte to a tag

func (Tag) Bytes

func (t Tag) Bytes() []byte

Bytes builds text representation of the tag as a slice of byte

func (Tag) Delete

func (t Tag) Delete() Tag

Delete the named content

func (Tag) Hash

func (t Tag) Hash() HCID

Hash caculates the HCID of the tag

func (Tag) Log

func (t Tag) Log()

Log sends the tag to the log with a header and footer

func (Tag) Merge

func (t Tag) Merge(tags []Tag, hashBytes HID, typeString string) Tag

Merge updates the content and add extra the tags to the parents

func (Tag) Rename

func (t Tag) Rename(newNameSegment string) (tombstone, newTag Tag)

Rename a Tag Object

func (Tag) String

func (t Tag) String() string

Sting builds text representation of the tag

func (Tag) Update

func (t Tag) Update(hashBytes HID, typeString string) Tag

Update the named content

func (Tag) Verify

func (t Tag) Verify() bool

Verify that the signature is valid

Jump to

Keyboard shortcuts

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