Documentation ¶
Index ¶
- Variables
- func AddEntriesToMerkleTree(ctx context.Context, mt mtAppender, entries []RDFEntry) error
- func HashValue(datatype string, value any) (*big.Int, error)
- func HashValueWithHasher(h Hasher, datatype string, value any) (*big.Int, error)
- func NewDocumentLoader(ipfsCli *shell.Shell, ipfsGW string) ld.DocumentLoader
- func SetDocumentLoader(docLoader ld.DocumentLoader)
- func SetHasher(h Hasher)
- func TypeFromContext(ctxBytes []byte, path string) (string, error)
- func TypeIDFromContext(ctxBytes []byte, typeName string) (string, error)
- type Hasher
- type MerkleTree
- type MerklizeOption
- func WithDocumentLoader(documentLoader ld.DocumentLoader) MerklizeOption
- func WithHasher(h Hasher) MerklizeOption
- func WithIPFSClient(ipfsCli *shell.Shell) MerklizeOption
- func WithIPFSGateway(ipfsGW string) MerklizeOption
- func WithMerkleTree(mt MerkleTree) MerklizeOption
- func WithSafeMode(safeMode bool) MerklizeOption
- type Merklizer
- func (m *Merklizer) Hasher() Hasher
- func (m *Merklizer) JSONLDType(path Path) (string, error)
- func (m *Merklizer) MkValue(val any) (Value, error)
- func (m *Merklizer) Proof(ctx context.Context, path Path) (*merkletree.Proof, Value, error)
- func (m *Merklizer) RawValue(path Path) (any, error)
- func (m *Merklizer) ResolveDocPath(path string) (Path, error)
- func (m *Merklizer) Root() *merkletree.Hash
- type Options
- func (o Options) NewPath(parts ...interface{}) (Path, error)
- func (o Options) NewPathFromDocument(docBytes []byte, path string) (Path, error)
- func (o Options) NewRDFEntry(key Path, value interface{}) (RDFEntry, error)
- func (o Options) PathFromContext(ctxBytes []byte, path string) (Path, error)
- func (o Options) TypeFromContext(ctxBytes []byte, path string) (string, error)
- func (o Options) TypeIDFromContext(ctxBytes []byte, typeName string) (string, error)
- type Path
- type PoseidonHasher
- type RDFEntry
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorFieldIsEmpty is returned when field path to resolve is empty ErrorFieldIsEmpty = errors.New("fieldPath is empty") // ErrorContextTypeIsEmpty is returned when context type tp resolve is empty ErrorContextTypeIsEmpty = errors.New("ctxType is empty") // ErrorUnsupportedType is returned when type is not supported ErrorUnsupportedType = errors.New("unsupported type") )
var ErrIncorrectType = errors.New("incorrect type")
Functions ¶
func AddEntriesToMerkleTree ¶
func HashValueWithHasher ¶
HashValueWithHasher hashes value according to datatype with a provided Hasher.
func NewDocumentLoader ¶
func NewDocumentLoader(ipfsCli *shell.Shell, ipfsGW string) ld.DocumentLoader
NewDocumentLoader creates a new document loader with a cache for http. ipfs cache is not implemented yet.
func SetDocumentLoader ¶
func SetDocumentLoader(docLoader ld.DocumentLoader)
SetDocumentLoader changes default DocumentLoader
func TypeFromContext ¶
TypeFromContext returns type of field from context by path.
Types ¶
type Hasher ¶
type Hasher interface { Hash(inpBI []*big.Int) (*big.Int, error) HashBytes(msg []byte) (*big.Int, error) Prime() *big.Int }
Hasher is an interface to hash data
type MerkleTree ¶
type MerkleTree interface { Add(context.Context, *big.Int, *big.Int) error GenerateProof(context.Context, *big.Int) (*merkletree.Proof, error) Root() *merkletree.Hash }
MerkleTree is merkle tree structure
func MerkleTreeSQLAdapter ¶
func MerkleTreeSQLAdapter(mt *merkletree.MerkleTree) MerkleTree
MerkleTreeSQLAdapter is merkle tree sql adapter
type MerklizeOption ¶
type MerklizeOption func(m *Merklizer)
MerklizeOption is options for merklizer
func WithDocumentLoader ¶
func WithDocumentLoader(documentLoader ld.DocumentLoader) MerklizeOption
WithDocumentLoader sets DocumentLoader
func WithIPFSClient ¶
func WithIPFSClient(ipfsCli *shell.Shell) MerklizeOption
WithIPFSClient sets IPFS client option required to resolve ipfs:// contexts. It works only if documentLoader is not set using WithDocumentLoader option. Otherwise, it will be ignored.
func WithIPFSGateway ¶
func WithIPFSGateway(ipfsGW string) MerklizeOption
WithIPFSGateway sets IPFS gateway URL option required to resolve ipfs:// contexts.
If WithIPFSClient option is set, gateway would be ignored and ipfs requests would be sent directly to the client.
If WithDocumentLoader option is set, gateway would be ignored and documents would be loaded using the document loader.
func WithMerkleTree ¶
func WithMerkleTree(mt MerkleTree) MerklizeOption
WithMerkleTree sets MerkleTree option
func WithSafeMode ¶
func WithSafeMode(safeMode bool) MerklizeOption
WithSafeMode enables the Safe mode when extending a JSON-LD document. The default setting for this mode is "true". If the function encounters an unknown field with an incorrect IRI predicate, it will return an error. However, if the Safe mode is set to "false", the function will simply skip the incorrect field and continue the merklization process without it.
type Merklizer ¶
type Merklizer struct {
// contains filtered or unexported fields
}
Merklizer is a struct to work with json-ld doc merklization
func MerklizeJSONLD ¶
MerklizeJSONLD takes a JSON-LD document, parses it and returns a Merklizer
func (*Merklizer) JSONLDType ¶
JSONLDType returns the JSON-LD type of the given path. If there is no literal by this path, it returns an error.
type Options ¶
type Options struct { Hasher Hasher DocumentLoader ld.DocumentLoader }
Options type allows to change hashing algorithm and create Path and RDFEntry instances with hasher different from default one.
func (Options) NewPathFromDocument ¶
func (Options) NewRDFEntry ¶
func (Options) PathFromContext ¶
func (Options) TypeFromContext ¶
TypeFromContext returns type of field from context by path.
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
func NewFieldPathFromContext ¶
NewFieldPathFromContext resolves field path without type path prefix
func NewPathFromContext ¶
NewPathFromContext parses context and do its best to generate full Path from shortcut line field1.field2.field3...
type PoseidonHasher ¶
type PoseidonHasher struct{}
PoseidonHasher is an applier of poseidon hash algorithm
type RDFEntry ¶
type RDFEntry struct {
// contains filtered or unexported fields
}
func EntriesFromRDF ¶
func EntriesFromRDF(ds *ld.RDFDataset) ([]RDFEntry, error)
EntriesFromRDF creates entries from RDF dataset suitable to add to merkle tree
func EntriesFromRDFWithHasher ¶
func EntriesFromRDFWithHasher(ds *ld.RDFDataset, hasher Hasher) ([]RDFEntry, error)
EntriesFromRDFWithHasher creates entries from RDF dataset suitable to add to with a provided Hasher merkle tree