/
types.go
169 lines (140 loc) · 3.53 KB
/
types.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// wotoCrypto Project
// Copyright (C) 2022 ALiwoto
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of the source code.
package wotoCrypto
import (
"fmt"
ws "github.com/AnimeKaizoku/ssg/ssg"
"github.com/TheGolangHub/wotoCrypto/wotoCrypto/passContainer"
)
type WotoAlgorithm uint16
type WotoLayerLength uint32
type CryptoLayerKind uint8
type blockAction func(first, second singleBlock) singleBlock
type blockAlgorithmId uint8
type KeyLayerCollection []CryptoLayer
type PasswordContainer256 = passContainer.PasswordContainer256
type PasswordContainer512 = passContainer.PasswordContainer256
type LayerLengthContainer struct {
Length WotoLayerLength
LayerKind CryptoLayerKind
}
type CryptoLayer struct {
Kind CryptoLayerKind `json:"kind"`
Hash string `json:"hash"`
lenContainer *LayerLengthContainer `json:"-"`
}
type privateBlock rune
type privateCollection struct {
blocks []privateBlock
}
type blockAlgorithmX917 struct {
identifier int
}
type blockAlgorithmX847 struct {
identifier int
}
type blockAlgorithmX795 struct {
identifier int
}
type blockAlgorithmX649 struct {
identifier int
}
type AlgorithmSupporter interface {
SetAlgorithm(algorithm WotoAlgorithm) bool
HasEqualAlgorithm(algorithm WotoAlgorithm) bool
GetAlgorithm() WotoAlgorithm
GetHashCount() int
}
type LayerBlock interface {
ContainsLayerKind(kind CryptoLayerKind) bool
ContainsLayer(layer *CryptoLayer) bool
AppendLayer(layer *CryptoLayer) bool
RemoveLayer(layer *CryptoLayer) bool
RemoveLayers(layers ...*CryptoLayer)
GetLayerLengthByKind(kind CryptoLayerKind) *LayerLengthContainer
GetLayerLengthByIndex(index int) *LayerLengthContainer
GetKeyLayersCount() int
}
type WotoKey interface {
fmt.Stringer
ws.Validator
ws.SignatureContainer
ws.Serializer
AlgorithmSupporter
LayerBlock
IsFuture() bool
IsPast() bool
IsPresent() bool
IsEmpty() bool
CanBecomeFuture() bool
CanBecomePresent() bool
CanBecomePast() bool
Decrypt(data []byte) []byte
Encrypt(data []byte) []byte
HasEqualKind(key WotoKey) bool
HasEqualSignature(key WotoKey) bool
GetKeyLength() int
GetSignatureRealLength() int
IsRealLengthInvalid() bool
// Deprecated: you can't convert any WotoKey to a FutureKey anymore.
// Please use GenerateFutureKey helper function.
ToFutureKey() WotoKey
ToPresentKey() WotoKey
ToPastKey() WotoKey
Clone() WotoKey
getLayers() KeyLayerCollection
setLayers(layers KeyLayerCollection) bool
}
type KeyCollection interface {
ws.Validator
ContinueLifeCycle()
Sync()
}
type KeysContainer interface {
SetAsKeys(value KeyCollection)
}
type singleBlock interface {
ws.Validator
ws.BitsBlocks
IsEmpty() bool
IsNonZero() bool
ToInt64() int64
ToUInt64() uint64
ToInt32() int32
ToUInt32() uint32
Sum(singleBlock) singleBlock
Min(singleBlock) singleBlock
Mul(singleBlock) singleBlock
Div(singleBlock) singleBlock
}
type blockCollection interface {
ws.BytesObject
GetBlocks() []singleBlock
GetRelativeIndex(int) int
BlockSize() int
AppendBlock(singleBlock)
AppendCollection(blockCollection)
GetBlockByIndex(int) singleBlock
Clone() blockCollection
}
type blockAlgorithm interface {
GetEncryptBlockAction(index int) blockAction
GetDecryptBlockAction(index int) blockAction
}
type futureKey struct {
keyLayers KeyLayerCollection
algorithm WotoAlgorithm
sig string
}
type presentKey struct {
keyLayers KeyLayerCollection
algorithm WotoAlgorithm
sig string
}
type pastKey struct {
keyLayers KeyLayerCollection
algorithm WotoAlgorithm
sig string
}