Documentation
¶
Index ¶
- func AddEntry(store LedgerStore, entry Entry, privateKey *rsa.PrivateKey) error
- func Sign(store LedgerStore, privateKey *rsa.PrivateKey) error
- func Verify(store LedgerStore, publicKey *rsa.PublicKey) error
- type Entry
- type InMemoryLedger
- func (l *InMemoryLedger) AddEntry(entry Entry) error
- func (l *InMemoryLedger) GetEntries() ([]Entry, error)
- func (l *InMemoryLedger) GetEntriesPaged(offset, limit int) ([]Entry, error)
- func (l *InMemoryLedger) GetLastEntry() (*Entry, error)
- func (l *InMemoryLedger) GetSignature() ([]byte, error)
- func (l *InMemoryLedger) SetSignature(signature []byte) error
- type LedgerStore
- type MongoDBLedger
- func (l *MongoDBLedger) AddEntry(entry Entry) error
- func (l *MongoDBLedger) Close(ctx context.Context) error
- func (l *MongoDBLedger) GetEntries() ([]Entry, error)
- func (l *MongoDBLedger) GetEntriesPaged(offset, limit int) ([]Entry, error)
- func (l *MongoDBLedger) GetLastEntry() (*Entry, error)
- func (l *MongoDBLedger) GetSignature() ([]byte, error)
- func (l *MongoDBLedger) SetSignature(signature []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEntry ¶
func AddEntry(store LedgerStore, entry Entry, privateKey *rsa.PrivateKey) error
AddEntry adds a new entry to the ledger and signs it.
func Sign ¶
func Sign(store LedgerStore, privateKey *rsa.PrivateKey) error
Sign signs the current state of the ledger's entries.
Types ¶
type Entry ¶
type Entry struct {
Text string `json:"text"`
Start int `json:"start"`
Stop int `json:"stop"`
FileName string `json:"file_name"`
Timestamp time.Time `json:"timestamp"`
PreviousHash []byte `json:"previous_hash"`
}
Entry represents a single redaction entry in the ledger.
type InMemoryLedger ¶
type InMemoryLedger struct {
Entries []Entry `json:"entries"`
Signature []byte `json:"signature,omitempty"`
}
InMemoryLedger is an in-memory implementation of the LedgerStore interface.
func (*InMemoryLedger) AddEntry ¶
func (l *InMemoryLedger) AddEntry(entry Entry) error
AddEntry adds a new entry to the in-memory ledger.
func (*InMemoryLedger) GetEntries ¶
func (l *InMemoryLedger) GetEntries() ([]Entry, error)
GetEntries returns all entries in the in-memory ledger.
func (*InMemoryLedger) GetEntriesPaged ¶
func (l *InMemoryLedger) GetEntriesPaged(offset, limit int) ([]Entry, error)
GetEntriesPaged returns a slice of entries from the in-memory ledger based on offset and limit.
func (*InMemoryLedger) GetLastEntry ¶
func (l *InMemoryLedger) GetLastEntry() (*Entry, error)
GetLastEntry returns the last entry in the in-memory ledger.
func (*InMemoryLedger) GetSignature ¶
func (l *InMemoryLedger) GetSignature() ([]byte, error)
GetSignature returns the signature of the in-memory ledger.
func (*InMemoryLedger) SetSignature ¶
func (l *InMemoryLedger) SetSignature(signature []byte) error
SetSignature sets the signature of the in-memory ledger.
type LedgerStore ¶
type LedgerStore interface {
AddEntry(entry Entry) error
GetEntries() ([]Entry, error)
GetEntriesPaged(offset, limit int) ([]Entry, error)
GetLastEntry() (*Entry, error)
SetSignature(signature []byte) error
GetSignature() ([]byte, error)
}
LedgerStore defines the interface for ledger storage backends.
type MongoDBLedger ¶
type MongoDBLedger struct {
// contains filtered or unexported fields
}
MongoDBLedger is a MongoDB-backed implementation of the LedgerStore interface.
func NewMongoDBLedger ¶
func NewMongoDBLedger(ctx context.Context, uri string, dbName string, collectionName string) (*MongoDBLedger, error)
NewMongoDBLedger creates a new MongoDB-backed ledger.
func (*MongoDBLedger) AddEntry ¶
func (l *MongoDBLedger) AddEntry(entry Entry) error
AddEntry adds a new entry to the MongoDB ledger.
func (*MongoDBLedger) Close ¶
func (l *MongoDBLedger) Close(ctx context.Context) error
Close closes the MongoDB client.
func (*MongoDBLedger) GetEntries ¶
func (l *MongoDBLedger) GetEntries() ([]Entry, error)
GetEntries returns all entries in the MongoDB ledger.
func (*MongoDBLedger) GetEntriesPaged ¶
func (l *MongoDBLedger) GetEntriesPaged(offset, limit int) ([]Entry, error)
GetEntriesPaged returns entries in the MongoDB ledger based on offset and limit.
func (*MongoDBLedger) GetLastEntry ¶
func (l *MongoDBLedger) GetLastEntry() (*Entry, error)
GetLastEntry returns the last entry in the MongoDB ledger.
func (*MongoDBLedger) GetSignature ¶
func (l *MongoDBLedger) GetSignature() ([]byte, error)
GetSignature returns the signature of the MongoDB ledger.
func (*MongoDBLedger) SetSignature ¶
func (l *MongoDBLedger) SetSignature(signature []byte) error
SetSignature sets the signature of the MongoDB ledger.