-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseal.go
More file actions
40 lines (32 loc) · 715 Bytes
/
Copy pathseal.go
File metadata and controls
40 lines (32 loc) · 715 Bytes
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
30
31
32
33
34
35
36
37
38
39
40
package gatering
import (
"crypto/sha256"
"encoding/hex"
)
/*
a seal represents the final result produced by
the chamber.
the hash field contains the generated digest.
the route field contains the sequence of gates
that participated in the transformation process.
the size field contains the payload size at the
moment the seal was generated.
*/
type Seal struct {
Hash string
Size int
Route []string
}
/*
createseal generates a sha256 digest from the
provided payload and associates metadata about
the transformation route.
*/
func CreateSeal(data []byte, route []string) Seal {
sum := sha256.Sum256(data)
return Seal{
Hash: hex.EncodeToString(sum[:]),
Size: len(data),
Route: route,
}
}