provendb

package
v0.0.0-...-b1cb840 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DocKeyMetadata represents the key path to the metadata of a ProvenDB doc
	DocKeyMetadata = "_provendb_metadata"
	// DocKeyMetadataMinVersion represents the key path to the min version of a ProvenDB doc
	DocKeyMetadataMinVersion = DocKeyMetadata + ".minVersion"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentProof

type DocumentProof struct {
	Collection     string      `json:"collection" bson:"collection"`
	Version        int64       `json:"version" bson:"version"`
	DocumentID     interface{} `json:"documentId" bson:"documentId"`
	VersionProofID string      `json:"versionProofId" bson:"versionProofId"`
	Status         string      `json:"status" bson:"status"`
	StatusMsg      string      `json:"errmsg" bson:"errmsg"`
	DocumentHash   string      `json:"documentHash" bson:"documentHash"`
	VersionHash    string      `json:"versionHash" bson:"versionHash"`
	Proof          interface{} `json:"proof" bson:"proof"`
}

DocumentProof represents a ProvenDB document proof

type GetDocumentProofResult

type GetDocumentProofResult struct {
	Proofs []DocumentProof `json:"proofs" bson:"proofs"`
}

GetDocumentProofResult represents the result of a `GetDocumentProof` command

type GetProofResult

type GetProofResult struct {
	Proofs []VersionProof `json:"proofs" bson:"proofs"`
}

GetProofResult represents the result of a `GetProof` command

type GetVersionResult

type GetVersionResult struct {
	Response string `json:"reponse" bson:"reponse"`
	Version  int64  `json:"version" bson:"version"`
	Status   string `json:"status" bson:"status"`
}

GetVersionResult represents the result of a `GetVersion` command

type Metadata

type Metadata struct {
	ID         interface{} `json:"_id" bson:"_id"`
	MongoID    interface{} `json:"_mongoId,omitempty" bson:"_mongoId,omitempty"`
	MinVersion int64       `json:"minVersion" bson:"minVersion"`
	Hash       string      `json:"hash,omitempty" bson:"hash,omitempty"`
	MaxVersion int64       `json:"maxVersion,omitempty" bson:"maxVersion,omitempty"`
}

Metadata represents a ProvenDB document's metadata

type ProvenDB

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

ProvenDB represents a ProvenDB database instance

func NewProvenDB

func NewProvenDB(db *mongo.Database) *ProvenDB

NewProvenDB creates a new ProvenDB functional wrapper around a `*mongo.Database`

func (*ProvenDB) Database

func (p *ProvenDB) Database() *mongo.Database

Database returns the wrapped `*mongo.Database`

func (*ProvenDB) GetDocumentProof

func (p *ProvenDB) GetDocumentProof(
	ctx context.Context,
	collection string,
	filter interface{},
	version int64,
	format string,
) (*GetDocumentProofResult, error)

GetDocumentProof returns a structured chainpoint format receipt, which cryptographically proves that a document for a specific version is included within that versions hash. This can be used to prove an individual document is included within a version without having to access other documents in a version

func (*ProvenDB) GetProof

func (p *ProvenDB) GetProof(
	ctx context.Context,
	proofIDOrVersion interface{},
	format string,
	listCollections bool,
) (*GetProofResult, error)

GetProof returns a structured document similar to a chainpoint receipt, which cryptographically proves that a version proof is valid and on the blockchain

func (*ProvenDB) GetVersion

func (p *ProvenDB) GetVersion(
	ctx context.Context,
) (*GetVersionResult, error)

GetVersion retrieves the active version for the current session. If no version has been set by the user using the setVersion command, the current version from the database will be returned

func (*ProvenDB) ShowMetaData

func (p *ProvenDB) ShowMetaData(
	ctx context.Context,
	show bool,
) error

ShowMetaData controls the display of `_provendb_metadata` information document for find commands on user collections. ProvenDB metadata defines the version numbers for which a given document is valid, and contains the document hash value which is used to pin the document to the blockchain.

func (*ProvenDB) SubmitProof

func (p *ProvenDB) SubmitProof(
	ctx context.Context,
	version int64,
) (*SubmitProofResult, error)

SubmitProof submits a proof to the blockchain for the specified version and returns a receipt

func (*ProvenDB) VerifyProof

func (p *ProvenDB) VerifyProof(
	ctx context.Context,
	proofID string,
	format string,
) (*VerifyProofResult, error)

VerifyProof verifies a proof by recalculating the root hash and comparing that to the hash found in the Chainpoint receipt and verifying receipt on the blockchain

type SubmitProofResult

type SubmitProofResult struct {
	DateTime time.Time `json:"dateTime" bson:"dateTime"`
	Hash     string    `json:"hash" bson:"hash"`
	ProofID  string    `json:"proofId" bson:"proofId"`
	Status   string    `json:"status" bson:"status"`
}

SubmitProofResult represents the result of a `SubmitProof` command

type VerifyProofResult

type VerifyProofResult struct {
	Version        int64       `json:"version" bson:"version"`
	DateTime       time.Time   `json:"dateTime" bson:"dateTime"`
	ProofID        string      `json:"proofId" bson:"proofId"`
	ProofStatus    string      `json:"proofStatus" bson:"proofStatus"`
	BTCTransaction string      `json:"btcTransaction" bson:"btcTransaction"`
	BTCBlockNumber int64       `json:"btcBlockNumber" bson:"btcBlockNumber"`
	Proof          interface{} `json:"proof" bson:"proof"`
}

VerifyProofResult represents the result of a `VerifyProof` command

type VersionProof

type VersionProof struct {
	ProofID   string              `json:"proofId" bson:"proofId"`
	Version   int64               `json:"version" bson:"version"`
	Submitted time.Time           `json:"submitted" bson:"submitted"`
	Type      string              `json:"type" bson:"type"`
	Hash      string              `json:"hash" bson:"hash"`
	Status    string              `json:"status" bson:"status"`
	Details   VersionProofDetails `json:"details" bson:"details"`
	Proof     interface{}         `json:"proof" bson:"proof"`
}

VersionProof represents a ProvenDB version proof

type VersionProofDetails

type VersionProofDetails struct {
	Protocol        VersionProofDetailsProtocol `json:"protocol" bson:"protocol"`
	BTCTxn          string                      `json:"btcTxn" bson:"btcTxn"`
	BTCTxnReceived  string                      `json:"btcTxnReceived" bson:"btcTxnReceived"`
	BTCTxnConfirmed string                      `json:"btcTxnConfirmed" bson:"btcTxnConfirmed"`
	BTCBlock        string                      `json:"btcBlock" bson:"btcBlock"`
}

VersionProofDetails represents the details in a VersionProof

type VersionProofDetailsProtocol

type VersionProofDetailsProtocol struct {
	Name               string `json:"name" bson:"name"`
	URI                string `json:"uri" bson:"uri"`
	HashIDNode         string `json:"hashIdNode" bson:"hashIdNode"`
	ChainpointLocation string `json:"chainpointLocation" bson:"chainpointLocation"`
}

VersionProofDetailsProtocol represents the protocol in a VersionProofDetails

Jump to

Keyboard shortcuts

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