ahtree

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2021 CodeNotary, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const DefaultCompressionFormat = appendable.DefaultCompressionFormat
View Source
const DefaultCompressionLevel = appendable.DefaultCompressionLevel
View Source
const DefaultDataCacheSlots = 1_000
View Source
const DefaultDigestsCacheSlots = 100_000
View Source
const DefaultFileMode = os.FileMode(0755)
View Source
const DefaultFileSize = multiapp.DefaultFileSize
View Source
const LeafPrefix = byte(0)
View Source
const (
	MetaVersion = "VERSION"
)
View Source
const NodePrefix = byte(1)
View Source
const Version = 1

Variables

View Source
var ErrAlreadyClosed = errors.New("already closed")
View Source
var ErrCorruptedCLog = errors.New("commit log is corrupted")
View Source
var ErrEmptyTree = errors.New("empty tree")
View Source
var ErrIllegalArguments = errors.New("illegal arguments")
View Source
var ErrReadOnly = errors.New("cannot append when openned in read-only mode")
View Source
var ErrUnexistentData = errors.New("attempt to read unexistent data")
View Source
var ErrorCorruptedData = errors.New("data log is corrupted")
View Source
var ErrorCorruptedDigests = errors.New("hash log is corrupted")
View Source
var ErrorPathIsNotADirectory = errors.New("path is not a directory")

Functions

func EvalConsistency

func EvalConsistency(cproof [][sha256.Size]byte, i, j uint64) ([sha256.Size]byte, [sha256.Size]byte)

func EvalInclusion

func EvalInclusion(iproof [][sha256.Size]byte, i, j uint64, iLeaf [sha256.Size]byte) [sha256.Size]byte

func EvalLastInclusion

func EvalLastInclusion(iproof [][sha256.Size]byte, i uint64, leaf [sha256.Size]byte) [sha256.Size]byte

func VerifyConsistency

func VerifyConsistency(cproof [][sha256.Size]byte, i, j uint64, iRoot, jRoot [sha256.Size]byte) bool

func VerifyInclusion

func VerifyInclusion(iproof [][sha256.Size]byte, i, j uint64, iLeaf, jRoot [sha256.Size]byte) bool

func VerifyLastInclusion

func VerifyLastInclusion(iproof [][sha256.Size]byte, i uint64, leaf, root [sha256.Size]byte) bool

Types

type AHtree

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

AHtree stands for Appendable Hash Tree

func Open

func Open(path string, opts *Options) (*AHtree, error)

func OpenWith

func OpenWith(pLog, dLog, cLog appendable.Appendable, opts *Options) (*AHtree, error)

func (*AHtree) Append

func (t *AHtree) Append(d []byte) (n uint64, h [sha256.Size]byte, err error)

func (*AHtree) Close

func (t *AHtree) Close() error

func (*AHtree) ConsistencyProof

func (t *AHtree) ConsistencyProof(i, j uint64) (p [][sha256.Size]byte, err error)

func (*AHtree) DataAt

func (t *AHtree) DataAt(n uint64) ([]byte, error)

func (*AHtree) InclusionProof

func (t *AHtree) InclusionProof(i, j uint64) (p [][sha256.Size]byte, err error)

func (*AHtree) Root

func (t *AHtree) Root() (n uint64, r [sha256.Size]byte, err error)

func (*AHtree) RootAt

func (t *AHtree) RootAt(n uint64) (r [sha256.Size]byte, err error)

func (*AHtree) Size

func (t *AHtree) Size() uint64

func (*AHtree) Sync

func (t *AHtree) Sync() error

type Options

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

func DefaultOptions

func DefaultOptions() *Options

func (*Options) WithCompresionLevel

func (opts *Options) WithCompresionLevel(compressionLevel int) *Options

func (*Options) WithCompressionFormat

func (opts *Options) WithCompressionFormat(compressionFormat int) *Options

func (*Options) WithDataCacheSlots

func (opts *Options) WithDataCacheSlots(cacheSlots int) *Options

func (*Options) WithDigestsCacheSlots

func (opts *Options) WithDigestsCacheSlots(cacheSlots int) *Options

func (*Options) WithFileMode

func (opts *Options) WithFileMode(fileMode os.FileMode) *Options

func (*Options) WithFileSize

func (opts *Options) WithFileSize(fileSize int) *Options

func (*Options) WithReadOnly

func (opts *Options) WithReadOnly(readOnly bool) *Options

func (*Options) WithSynced

func (opts *Options) WithSynced(synced bool) *Options

Jump to

Keyboard shortcuts

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