-
Notifications
You must be signed in to change notification settings - Fork 179
/
ledger.go
29 lines (24 loc) · 1.69 KB
/
ledger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package storage
import (
"github.com/onflow/flow-go/model/flow"
)
// Ledger takes care of storing registers (key, value pairs) providing proof of correctness
// we aim to store a state of the order of 10^10 registers with up to 1M historic state versions
type Ledger interface {
EmptyStateCommitment() flow.StateCommitment
// Trusted methods (without proof)
// Get registers at specific StateCommitment by a list of register ids
GetRegisters(registerIDs []flow.RegisterID, stateCommitment flow.StateCommitment) (values []flow.RegisterValue, err error)
// Batched atomic updates of a subset of registers at specific state
UpdateRegisters(registerIDs []flow.RegisterID, values []flow.RegisterValue, stateCommitment flow.StateCommitment) (newStateCommitment flow.StateCommitment, err error)
// Untrusted methods (providing proofs)
// Get registers at specific StateCommitment by a list of register ids with proofs
GetRegistersWithProof(registerIDs []flow.RegisterID, stateCommitment flow.StateCommitment) (values []flow.RegisterValue, proofs []flow.StorageProof, err error)
// Batched atomic updates of a subset of registers at specific state with proofs
UpdateRegistersWithProof(registerIDs []flow.RegisterID, values []flow.RegisterValue, stateCommitment flow.StateCommitment) (newStateCommitment flow.StateCommitment, proofs []flow.StorageProof, err error)
}
// LedgerVerifier should be designed as an standalone package to verify proofs of storage
type LedgerVerifier interface {
// verify if a provided proof for getRegisters is accurate
VerifyRegistersProof(registerIDs []flow.RegisterID, stateCommitment flow.StateCommitment, values []flow.RegisterValue, proof []flow.StorageProof) (verified bool, err error)
}