aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/storage.go12
-rw-r--r--fsverify-paper.md4
2 files changed, 15 insertions, 1 deletions
diff --git a/core/storage.go b/core/storage.go
index 7475bef..8c76c52 100644
--- a/core/storage.go
+++ b/core/storage.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"os"
+ "strings"
bolt "go.etcd.io/bbolt"
)
@@ -131,3 +132,14 @@ func GetNode(checksum string, db *bolt.DB) (Node, error) {
}
return node, err
}
+
+func VerifyNode(node Node, nextNode Node) error {
+ nodeHash, err := calculateStringHash(fmt.Sprintf("%d%d%s%s", node.BlockStart, node.BlockEnd, node.BlockSum, node.PrevNodeSum))
+ if err != nil {
+ return err
+ }
+ if strings.Compare(nodeHash, nextNode.PrevNodeSum) != 0 {
+ return fmt.Errorf("Node %s is not valid!", node.PrevNodeSum)
+ }
+ return nil
+}
diff --git a/fsverify-paper.md b/fsverify-paper.md
index 6093752..0686c07 100644
--- a/fsverify-paper.md
+++ b/fsverify-paper.md
@@ -33,7 +33,7 @@ Field|Purpose
BlockStart|The Hex offset at which the block begins
BlockEnd|The Hex offset at which the block ends
BlockSum|The checksum of the block
-PrevNodeSum|The checksum of all the fields of the previous field as a checksum
+PrevNodeSum|The checksum of all the fields of the previous field as a checksum and the identifier of the node
Each block is 4kb big, if the partition size does not allow an even split in 4kb sectors, the partition will be split as good as possible, with a smaller block as the last sector.
@@ -60,6 +60,8 @@ through this, the slightest change in one of the nodes will result in a wrong ha
Modified value
```
+The first Node will have `PrevNodeSum` as "Entrypoint" as the PrevNodeSum field is also used to access each node, using EntryPoint allows fsverify to start the verification by always being able to read the first node
+
# Verification Process
The verification step consists of multiple steps: