-
Notifications
You must be signed in to change notification settings - Fork 109
/
kv.go
88 lines (67 loc) · 2.44 KB
/
kv.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package executor
import (
"fmt"
)
var (
verifyKeys string
authPubKeys string
receivingKey string
commitTreeCurrentStatus string
commitTreeSubRoots string
commitTreeSubLeaves string
commitTreeArchiveRoots string
commitTreeRootLeaves string
authorizeHash string
authorizeSpendHash string
nullifierHash string
)
func setPrefix() {
verifyKeys = "mavl-mix-verify-keys-"
authPubKeys = "mavl-mix-auth-pubkeys-"
receivingKey = "mavl-mix-receiving-key-"
commitTreeCurrentStatus = "mavl-mix-commitTree-current-status-"
commitTreeSubRoots = "mavl-mix-commitTree-sub-roots-"
commitTreeSubLeaves = "mavl-mix-commitTree-sub-leaves-"
commitTreeRootLeaves = "mavl-mix-commitTree-root-Leaves-"
commitTreeArchiveRoots = "mavl-mix-commitTree-archive-roots-"
authorizeHash = "mavl-mix-authorizeHash"
authorizeSpendHash = "mavl-mix-authorizeSpendHash-"
nullifierHash = "mavl-mix-nullifierHash"
}
//support multi version verify parameter setting
func getVerifyKeysKey(ty int32) []byte {
return []byte(fmt.Sprintf(verifyKeys+"%d", ty))
}
func getAuthPubKeysKey() []byte {
return []byte(fmt.Sprintf(authPubKeys))
}
func calcReceivingKey(addr string) []byte {
return []byte(fmt.Sprintf(receivingKey+"%s", addr))
}
func calcCommitTreeCurrentStatusKey(exec, symbol string) []byte {
return []byte(fmt.Sprintf(commitTreeCurrentStatus+"%s-%s", exec, symbol))
}
func calcArchiveRootsKey(exec, symbol string, seq uint64) []byte {
return []byte(fmt.Sprintf(commitTreeArchiveRoots+"%s-%s-%022d", exec, symbol, seq))
}
func calcSubRootsKey(exec, symbol string, seq int32) []byte {
return []byte(fmt.Sprintf(commitTreeSubRoots+"%s-%s-%010d", exec, symbol, seq))
}
func calcSubLeavesKey(exec, symbol string, seq int32) []byte {
return []byte(fmt.Sprintf(commitTreeSubLeaves+"%s-%s-%010d", exec, symbol, seq))
}
func calcCommitTreeRootLeaves(exec, symbol string, rootHash string) []byte {
return []byte(fmt.Sprintf(commitTreeRootLeaves+"%s-%s-%s", exec, symbol, rootHash))
}
func calcAuthorizeHashKey(hash string) []byte {
return []byte(fmt.Sprintf(authorizeHash+"%s", hash))
}
func calcAuthorizeSpendHashKey(hash string) []byte {
return []byte(fmt.Sprintf(authorizeSpendHash+"%s", hash))
}
func calcNullifierHashKey(hash string) []byte {
return []byte(fmt.Sprintf(nullifierHash+"%s", hash))
}