Преглед изворни кода

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/broker/modules/init.go
master
kidjung пре 4 година
родитељ
комит
d02a70a59e

+ 47
- 46
src/broker/modules/init.go Прегледај датотеку

128
 	//reply.CompleteLog = "received completely"
128
 	//reply.CompleteLog = "received completely"
129
 	return nil
129
 	return nil
130
 }
130
 }
131
-
132
-func (moscato *Moscato) preProcessMsg(originalMsg MsgUnit) MsgUnit {
133
-	if originalMsg.CheckType() == PM {
134
-		pubMsg := originalMsg.(PublishMsg)
135
-		for index := 0; index < len(pubMsg.Topic); index++ {
136
-			pubMsg.Topic[index] = pubMsg.Topic[index] - moscato.SecureManager.GetNodeKey(pubMsg.From)
137
-		}
138
-		for index := 0; index < len(pubMsg.Value); index++ {
139
-			pubMsg.Value[index] = pubMsg.Value[index] - moscato.SecureManager.GetNodeKey(pubMsg.From)
140
-		}
141
-		return pubMsg
142
-	} else if originalMsg.CheckType() == SM {
143
-		subMsg := originalMsg.(SubscriptionMsg)
144
-		for index := 0; index < len(subMsg.Topic); index++ {
145
-			subMsg.Topic[index] = subMsg.Topic[index] - moscato.SecureManager.GetNodeKey(subMsg.From)
146
-		}
147
-		for index := 0; index < len(subMsg.Value); index++ {
148
-			subMsg.Value[index] = subMsg.Value[index] - moscato.SecureManager.GetNodeKey(subMsg.From)
149
-		}
150
-		return subMsg
151
-	}
152
-	return nil
153
-}
154
-
155
-func (moscato *Moscato) SendWithEncrypt() MsgUnit {
156
-	for {
157
-		mt := <-moscato.SendQueue
158
-		//fmt.Println(mt)
159
-		if mt.err == nil {
160
-			for index := 0; index < len(mt.subList); index++ {
161
-				tmpNode := mt.subList[index]
162
-				tmpNodeIpAddr, _ := moscato.MicroServiceManager.GetIpaddr(tmpNode)
163
-				//moscato.SecureManager.ReEncPubMsg(mt.pubMsg.(PublishMsg), tmpNode)
164
-				//fmt.Println("publish: ", mt.pubMsg)
165
-				//moscato.Send2MS(tmpNodeIpAddr, mt.pubMsg)
166
-				moscato.Send2MS(tmpNodeIpAddr, moscato.SecureManager.ReEncPubMsg(mt.pubMsg.(PublishMsg), tmpNode))
167
-			}
168
-		}
169
-		return nil
170
-	}
171
-}
172
-
173
-//Recieve - MM가 msg전달 받음
131
+//Recieve - MM가 MS로부터 메세지 전달받음
174
 func (moscato *Moscato) Receive(msg MsgUnit) (MsgUnit, error) {
132
 func (moscato *Moscato) Receive(msg MsgUnit) (MsgUnit, error) {
175
 	l4g.LoadConfiguration("modules/logConfig.json")
133
 	l4g.LoadConfiguration("modules/logConfig.json")
176
 	//rpc call
134
 	//rpc call
252
 */
210
 */
253
 
211
 
254
 func (moscato *Moscato) Send2MS(ipaddress string, msg MsgUnit) {
212
 func (moscato *Moscato) Send2MS(ipaddress string, msg MsgUnit) {
255
-	//log.LoadConfiguration("logConfig.json")
213
+	l4g.LoadConfiguration("logConfig.json")
256
 	client, err := rpc.Dial("tcp", ipaddress+":8150")
214
 	client, err := rpc.Dial("tcp", ipaddress+":8150")
257
 	if err != nil {
215
 	if err != nil {
258
 		fmt.Println(err)
216
 		fmt.Println(err)
277
 	l4g.LOGGER("Test").Info(reply.CompleteLog)
235
 	l4g.LOGGER("Test").Info(reply.CompleteLog)
278
 }
236
 }
279
 
237
 
238
+//Matching을 용이하게 하기위한 메세지 가공 과정
239
+func (moscato *Moscato) preProcessMsg(originalMsg MsgUnit) MsgUnit {
240
+	if originalMsg.CheckType() == PM {
241
+		pubMsg := originalMsg.(PublishMsg)
242
+		for index := 0; index < len(pubMsg.Topic); index++ {
243
+			pubMsg.Topic[index] = pubMsg.Topic[index] - moscato.SecureManager.GetNodeKey(pubMsg.From)
244
+		}
245
+		for index := 0; index < len(pubMsg.Value); index++ {
246
+			pubMsg.Value[index] = pubMsg.Value[index] - moscato.SecureManager.GetNodeKey(pubMsg.From)
247
+		}
248
+		return pubMsg
249
+	} else if originalMsg.CheckType() == SM {
250
+		subMsg := originalMsg.(SubscriptionMsg)
251
+		for index := 0; index < len(subMsg.Topic); index++ {
252
+			subMsg.Topic[index] = subMsg.Topic[index] - moscato.SecureManager.GetNodeKey(subMsg.From)
253
+		}
254
+		for index := 0; index < len(subMsg.Value); index++ {
255
+			subMsg.Value[index] = subMsg.Value[index] - moscato.SecureManager.GetNodeKey(subMsg.From)
256
+		}
257
+		return subMsg
258
+	}
259
+	return nil
260
+}
261
+
262
+//암호화 해서 보내기
263
+func (moscato *Moscato) SendWithEncrypt() MsgUnit {
264
+	for {
265
+		mt := <-moscato.SendQueue
266
+		if mt.err == nil {
267
+			for index := 0; index < len(mt.subList); index++ { //sublist들을 돌면서 매세지를 encrypt하여 메세지 보냄
268
+				tmpNode := mt.subList[index]
269
+				tmpNodeIpAddr, _ := moscato.MicroServiceManager.GetIpaddr(tmpNode)
270
+				//moscato.SecureManager.ReEncPubMsg(mt.pubMsg.(PublishMsg), tmpNode)
271
+				//fmt.Println("publish: ", mt.pubMsg)
272
+				//moscato.Send2MS(tmpNodeIpAddr, mt.pubMsg)
273
+				moscato.Send2MS(tmpNodeIpAddr, moscato.SecureManager.ReEncPubMsg(mt.pubMsg.(PublishMsg), tmpNode))
274
+			}
275
+		}
276
+		return nil
277
+	}
278
+}
279
+
280
 func (moscato *Moscato) Run() {
280
 func (moscato *Moscato) Run() {
281
 
281
 
282
 	config := AppConfig{moscato}
282
 	config := AppConfig{moscato}
313
 
313
 
314
 	go Listen()
314
 	go Listen()
315
 	color.Blue("initializing complete.")
315
 	color.Blue("initializing complete.")
316
+
316
 	fmt.Scanln()
317
 	fmt.Scanln()
317
 }
318
 }
318
 
319
 
319
 func Listen() {
320
 func Listen() {
320
 	/*
321
 	/*
321
-		MS→MM일때 ⇒ port : 8160으로 열기
322
+	MS→MM일때 ⇒ port : 8160으로 열기
322
 
323
 
323
-		(MM이 Server, MS가 Client)
324
+	(MM이 Server, MS가 Client)
324
 	*/
325
 	*/
325
 
326
 
326
 	l, err1 := net.Listen("tcp", ":8160")
327
 	l, err1 := net.Listen("tcp", ":8160")

+ 4
- 5
src/broker/modules/list.go Прегледај датотеку

22
 }
22
 }
23
 
23
 
24
 type valueNode struct {
24
 type valueNode struct {
25
-	val  []int64 // Encrypted Topic
25
+	val  []int64 // Encrypted value
26
 	next *valueNode
26
 	next *valueNode
27
 	prev *valueNode
27
 	prev *valueNode
28
 
28
 
40
 	range2sub_eb []int // (sub_val >= pub_val) sub#s
40
 	range2sub_eb []int // (sub_val >= pub_val) sub#s
41
 }
41
 }
42
 
42
 
43
-// To delete slice Array
43
+// To delete element in slice Array
44
 func remove(ary []int, i int) []int {
44
 func remove(ary []int, i int) []int {
45
 	return append(ary[:i], ary[i+1:]...)
45
 	return append(ary[:i], ary[i+1:]...)
46
 }
46
 }
56
 }
56
 }
57
 
57
 
58
 
58
 
59
-// Compare ->  To compare (topics, values) in a node
59
+// Compare -> To compare two encrypted arrays
60
 func Compare(a []int64, b []int64) int {
60
 func Compare(a []int64, b []int64) int {
61
 	if len(a) < len(b) {
61
 	if len(a) < len(b) {
62
 		return 1
62
 		return 1
104
 	l.size++
104
 	l.size++
105
 }
105
 }
106
 
106
 
107
-
108
 // To add a Value node to the Value list
107
 // To add a Value node to the Value list
109
 func (l *valueList) addValueNode(value []int64) {
108
 func (l *valueList) addValueNode(value []int64) {
110
 	newValNode := &valueNode{value, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
109
 	newValNode := &valueNode{value, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}
164
 	}
163
 	}
165
 }
164
 }
166
 
165
 
167
-// op와 같은 node내의 operator리스트에서 sub가 있다면 리턴
166
+// To check if sub# is in the Value node's operator list
168
 func (node *valueNode) findOperatorList(op string, sub int, issingle bool) int {
167
 func (node *valueNode) findOperatorList(op string, sub int, issingle bool) int {
169
 	ret := -1
168
 	ret := -1
170
 	if issingle == true {
169
 	if issingle == true {

+ 15
- 8
src/broker/modules/manage.go Прегледај датотеку

7
 
7
 
8
 //각 Microservice에 대한 정보 저장 노드
8
 //각 Microservice에 대한 정보 저장 노드
9
 type MSNode struct {
9
 type MSNode struct {
10
-	nodeName string
10
+	nodeName string //Nodename- 현재 데모에서는 IpAddress와 같음
11
 	ipAddr   string
11
 	ipAddr   string
12
 }
12
 }
13
 
13
 
14
+//Nodename 반환
14
 func (node *MSNode) GetName() string {
15
 func (node *MSNode) GetName() string {
15
 	return node.nodeName
16
 	return node.nodeName
16
 }
17
 }
18
+
19
+//IpAddress 반환
17
 func (node *MSNode) GetIpaddr() string {
20
 func (node *MSNode) GetIpaddr() string {
18
 	return node.ipAddr
21
 	return node.ipAddr
19
 }
22
 }
20
 
23
 
21
 type NodeManager interface {
24
 type NodeManager interface {
22
-	GetIpaddr(nodeName string) (string, bool)
23
-	AddMicroservice(node MSNode) bool
24
-	RemoveMicroservice(nodeName string) bool
25
+	GetIpaddr(nodeName string) (string, bool) //IpAddress반환
26
+	AddMicroservice(node MSNode) bool //MS추가
27
+	RemoveMicroservice(nodeName string) bool //MS삭제
25
 }
28
 }
26
 
29
 
27
 //모든 Microservice정보 저장
30
 //모든 Microservice정보 저장
29
 	NodeTable map[string]MSNode
32
 	NodeTable map[string]MSNode
30
 }
33
 }
31
 
34
 
35
+//MStable 생성자
32
 func NewMStable() *MStable {
36
 func NewMStable() *MStable {
33
 	defer fmt.Println("node manager setting complete.")
37
 	defer fmt.Println("node manager setting complete.")
34
 	return &MStable{NodeTable: make(map[string]MSNode)}
38
 	return &MStable{NodeTable: make(map[string]MSNode)}
35
 }
39
 }
36
 
40
 
41
+//IpAddress반환
37
 func (manager *MStable) GetIpaddr(nodeName string) (string, bool) {
42
 func (manager *MStable) GetIpaddr(nodeName string) (string, bool) {
38
 	//해당 이름의 노드이름이 존재하는지 확인
43
 	//해당 이름의 노드이름이 존재하는지 확인
39
 	node, exists := manager.NodeTable[nodeName]
44
 	node, exists := manager.NodeTable[nodeName]
46
 	}
51
 	}
47
 }
52
 }
48
 
53
 
54
+//MS추가
49
 func (manager *MStable) AddMicroservice(node MSNode) bool {
55
 func (manager *MStable) AddMicroservice(node MSNode) bool {
50
 	//삽입 전 존재여부 확인
56
 	//삽입 전 존재여부 확인
51
-	_, exists := manager.NodeTable[node.GetName()]
57
+	_, exists := manager.NodeTable[node.GetName()] ////해당 Node의 이름이 있는지 검색
52
 
58
 
53
 	if exists {
59
 	if exists {
54
 		return false
60
 		return false
55
-	} else {
61
+	} else { //존재안한다면 추가 (존재할경우 이미 있는것이기 때문에 추가할 필요 없음)
56
 		manager.NodeTable[node.GetName()] = node
62
 		manager.NodeTable[node.GetName()] = node
57
 		return true
63
 		return true
58
 	}
64
 	}
59
 }
65
 }
60
 
66
 
67
+//MS삭제
61
 func (manager *MStable) RemoveMicroservice(nodeName string) bool {
68
 func (manager *MStable) RemoveMicroservice(nodeName string) bool {
62
 	//삭제 전 존재여부 확인
69
 	//삭제 전 존재여부 확인
63
-	_, exists := manager.NodeTable[nodeName]
70
+	_, exists := manager.NodeTable[nodeName] //해당 이름을 가진 Node가 있는지 검색
64
 
71
 
65
 	if exists {
72
 	if exists {
66
-		delete(manager.NodeTable, nodeName)
73
+		delete(manager.NodeTable, nodeName) //존재한다면 삭제
67
 		log.Println("[" + nodeName + "] : service quit")
74
 		log.Println("[" + nodeName + "] : service quit")
68
 		return true
75
 		return true
69
 	} else {
76
 	} else {

+ 37
- 22
src/broker/modules/matching.go Прегледај датотеку

8
 )
8
 )
9
 
9
 
10
 type match_manager struct {
10
 type match_manager struct {
11
-	match_count int
11
+	match_count int // Number of successful matches
12
 }
12
 }
13
 
13
 
14
-// Matching -> Return (list of IP addresses of matched subs, Pub Msg, error)
14
+// Matching operation method
15
+// 1. Traverse TopicList for match (msg.topic == topicNode.topic)
16
+// 2. Traverse TopicNode.ValueList for match (msg.value <operator> valueNode.value)
17
+// 3. Add ipaddr to ipList when successful matching
18
+// 4. Add ipaddr to ipList when range matching
19
+// 5. Delete Duplicated Ipaddrs
20
+// @Return (list of IP addresses of matched subs, Pub Msg, error)
15
 func (moscato *Moscato) Matching(msg MsgUnit) {
21
 func (moscato *Moscato) Matching(msg MsgUnit) {
16
-	//msg := moscato.queue.pop(true)
22
+
17
 	topic := msg.(PublishMsg).Topic
23
 	topic := msg.(PublishMsg).Topic
18
 	value := msg.(PublishMsg).Value
24
 	value := msg.(PublishMsg).Value
19
 	sub_mng := moscato.SubscriptionManager
25
 	sub_mng := moscato.SubscriptionManager
20
 
26
 
21
-	// listß
22
-	ret := make([]string, 0)
27
+	// iplist for return
28
+	ipList := make([]string, 0)
23
 
29
 
24
 	// list for matched range subscriptions
30
 	// list for matched range subscriptions
25
 	big := make([]int, 0)
31
 	big := make([]int, 0)
26
 	small := make([]int, 0)
32
 	small := make([]int, 0)
27
 
33
 
28
-	// 1. Find (topicNode[Topic] == msg.Topic) Node
34
+	// Find (topicNode[Topic] == msg.Topic) Node
29
 	topicPtr := sub_mng.list
35
 	topicPtr := sub_mng.list
30
 	pos := topicPtr.getTopicNodePos(topic)
36
 	pos := topicPtr.getTopicNodePos(topic)
31
 
37
 
33
 	if pos == nil {
39
 	if pos == nil {
34
 		moscato.SendQueue <- myType{nil, msg, errors.New("Don't Exist Matching Topic")}
40
 		moscato.SendQueue <- myType{nil, msg, errors.New("Don't Exist Matching Topic")}
35
 	} else {
41
 	} else {
36
-		// 2. Traverse all valueNode -> and Match
42
+		// Traverse all valueNode -> and Match
37
 		valPtr := pos.list.head
43
 		valPtr := pos.list.head
38
 		for valPtr != nil {
44
 		for valPtr != nil {
39
 			compare := Compare(valPtr.val, value)
45
 			compare := Compare(valPtr.val, value)
44
 				for i := 0; i < len(valPtr.single2sub_b); i++ {
50
 				for i := 0; i < len(valPtr.single2sub_b); i++ {
45
 					sub := valPtr.single2sub_b[i]
51
 					sub := valPtr.single2sub_b[i]
46
 					ip := sub_mng.sub2ip[sub]
52
 					ip := sub_mng.sub2ip[sub]
47
-					ret = append(ret, ip)
53
+					ipList = append(ipList, ip)
48
 				}
54
 				}
49
 
55
 
50
 				// (2) case : >=
56
 				// (2) case : >=
51
 				for i := 0; i < len(valPtr.single2sub_eb); i++ {
57
 				for i := 0; i < len(valPtr.single2sub_eb); i++ {
52
 					sub := valPtr.single2sub_eb[i]
58
 					sub := valPtr.single2sub_eb[i]
53
 					ip := sub_mng.sub2ip[sub]
59
 					ip := sub_mng.sub2ip[sub]
54
-					ret = append(ret, ip)
60
+					ipList = append(ipList, ip)
55
 				}
61
 				}
56
 				// range : { >, >= }
62
 				// range : { >, >= }
57
 
63
 
75
 				for i := 0; i < len(valPtr.single2sub_s); i++ {
81
 				for i := 0; i < len(valPtr.single2sub_s); i++ {
76
 					sub := valPtr.single2sub_s[i]
82
 					sub := valPtr.single2sub_s[i]
77
 					ip := sub_mng.sub2ip[sub]
83
 					ip := sub_mng.sub2ip[sub]
78
-					ret = append(ret, ip)
84
+					ipList = append(ipList, ip)
79
 				}
85
 				}
80
 
86
 
81
 				// (2) case : <=
87
 				// (2) case : <=
82
 				for i := 0; i < len(valPtr.single2sub_es); i++ {
88
 				for i := 0; i < len(valPtr.single2sub_es); i++ {
83
 					sub := valPtr.single2sub_es[i]
89
 					sub := valPtr.single2sub_es[i]
84
 					ip := sub_mng.sub2ip[sub]
90
 					ip := sub_mng.sub2ip[sub]
85
-					ret = append(ret, ip)
91
+					ipList = append(ipList, ip)
86
 				}
92
 				}
87
 
93
 
88
 				// range : { <, <= }
94
 				// range : { <, <= }
106
 				for i := 0; i < len(valPtr.single2sub_es); i++ {
112
 				for i := 0; i < len(valPtr.single2sub_es); i++ {
107
 					sub := valPtr.single2sub_es[i]
113
 					sub := valPtr.single2sub_es[i]
108
 					ip := sub_mng.sub2ip[sub]
114
 					ip := sub_mng.sub2ip[sub]
109
-					ret = append(ret, ip)
115
+					ipList = append(ipList, ip)
110
 				}
116
 				}
111
 
117
 
112
 				// (2) case : >=
118
 				// (2) case : >=
113
 				for i := 0; i < len(valPtr.single2sub_eb); i++ {
119
 				for i := 0; i < len(valPtr.single2sub_eb); i++ {
114
 					sub := valPtr.single2sub_eb[i]
120
 					sub := valPtr.single2sub_eb[i]
115
 					ip := sub_mng.sub2ip[sub]
121
 					ip := sub_mng.sub2ip[sub]
116
-					ret = append(ret, ip)
122
+					ipList = append(ipList, ip)
117
 				}
123
 				}
118
 
124
 
119
 				// (3) case : ==
125
 				// (3) case : ==
120
 				for i := 0; i < len(valPtr.single2sub_e); i++ {
126
 				for i := 0; i < len(valPtr.single2sub_e); i++ {
121
 					sub := valPtr.single2sub_e[i]
127
 					sub := valPtr.single2sub_e[i]
122
 					ip := sub_mng.sub2ip[sub]
128
 					ip := sub_mng.sub2ip[sub]
123
-					ret = append(ret, ip)
129
+					ipList = append(ipList, ip)
124
 				}
130
 				}
125
 
131
 
126
 				// range : { <=, >= }
132
 				// range : { <=, >= }
142
 		}
148
 		}
143
 
149
 
144
 		// Add the intersection IP address of two sets (large and small) to the return list
150
 		// Add the intersection IP address of two sets (large and small) to the return list
145
-		hash := intersect.Hash(small, big)
146
-		list := reflect.ValueOf(hash)
151
+		intersectSubnumbers := intersect.Hash(small, big)
152
+		list := reflect.ValueOf(intersectSubnumbers)
147
 		for i := 0; i < list.Len(); i++ {
153
 		for i := 0; i < list.Len(); i++ {
148
 			sub := list.Index(i).Interface().(int)
154
 			sub := list.Index(i).Interface().(int)
149
 			ip := sub_mng.sub2ip[sub]
155
 			ip := sub_mng.sub2ip[sub]
150
-			ret = append(ret, ip)
156
+			ipList = append(ipList, ip)
151
 		}
157
 		}
152
-		//fmt.Println("big = ", big)
153
-		//fmt.Println("small = ", small)
154
-		//fmt.Println("ret = ", ret)
155
 		moscato.MatchingManager.match_count++
158
 		moscato.MatchingManager.match_count++
156
-		moscato.SendQueue <- myType{ret, msg, nil}
159
+
160
+		// To delete Duplicated Ipaddr
161
+		keys := make(map[string]bool)
162
+		retIpList := []string{}
163
+		for _, val := range ipList {
164
+			if _, saveVal := keys[val]; !saveVal{
165
+				keys[val] = true
166
+				retIpList = append(retIpList, val)
167
+			}
168
+		}
169
+
170
+		// Return {IpaddressList, PubMsg, ErrorMsg} to SendQueue
171
+		moscato.SendQueue <- myType{retIpList, msg, nil}
157
 	}
172
 	}
158
-}
173
+}

+ 6
- 6
src/broker/modules/queue.go Прегледај датотеку

11
 }
11
 }
12
 
12
 
13
 type QueueOperate interface {
13
 type QueueOperate interface {
14
-	//queue 초기화
15
-	queue_init() error
16
-	//queue push
17
-	push(msg Message) bool
18
-	//pop message (wait -> busy waiting 여부 결정)
19
-	pop(wait bool) (Message, error)
14
+	queue_init() error	//Queue 초기화 멤버함수
15
+	push(msg Message) bool //Queue push 멤버함수
16
+	pop(wait bool) (Message, error)	//Queue pop 멤버함수 (wait -> busy waiting 여부 결정)
20
 }
17
 }
21
 
18
 
19
+//Message Queue를 초기화 해주는 함수
22
 func (mq *MsgQueue) queue_init() error {
20
 func (mq *MsgQueue) queue_init() error {
23
 	if mq.queue != nil && len(mq.queue) != 0 {
21
 	if mq.queue != nil && len(mq.queue) != 0 {
24
 		return errors.New("Queue Hadlerer Error: Already initialized.")
22
 		return errors.New("Queue Hadlerer Error: Already initialized.")
34
 	}
32
 	}
35
 }
33
 }
36
 
34
 
35
+//push 함수
37
 func (mq *MsgQueue) push(msg MsgUnit) bool {
36
 func (mq *MsgQueue) push(msg MsgUnit) bool {
38
 	mq.queue <- msg
37
 	mq.queue <- msg
39
 	return true
38
 	return true
40
 }
39
 }
41
 
40
 
41
+//pop 함수
42
 func (mq *MsgQueue) pop(block bool) MsgUnit {
42
 func (mq *MsgQueue) pop(block bool) MsgUnit {
43
 	if block == false {
43
 	if block == false {
44
 		if len(mq.queue) == 0 {
44
 		if len(mq.queue) == 0 {

+ 4
- 45
src/broker/modules/secure.go Прегледај датотеку

11
 	KeyMap map[string]string
11
 	KeyMap map[string]string
12
 }
12
 }
13
 
13
 
14
+//Security 생성자
14
 func NewSecurity() *Security {
15
 func NewSecurity() *Security {
15
 	security := &Security{map[string]string{}}
16
 	security := &Security{map[string]string{}}
16
 	fmt.Println("security setting complete.")
17
 	fmt.Println("security setting complete.")
28
 	//CompareAlpha(topic1 []int64, topic2 []int64) int
29
 	//CompareAlpha(topic1 []int64, topic2 []int64) int
29
 }
30
 }
30
 
31
 
31
-/**
32
+/*
32
 keyShareMsg 에서 각 노드의 private 키를 받아 keyMap 에 저장
33
 keyShareMsg 에서 각 노드의 private 키를 받아 keyMap 에 저장
33
 */
34
 */
34
 func (sc Security) RegKey(rm RegisterMsg) {
35
 func (sc Security) RegKey(rm RegisterMsg) {
48
 	return mKey
49
 	return mKey
49
 }
50
 }
50
 
51
 
51
-/**
52
+/*
52
 reEncrypt 해서 슬라이스 반환
53
 reEncrypt 해서 슬라이스 반환
53
 */
54
 */
54
 func (sc Security) ReEncrypt(fromKey int64, toKey int64, target []int64) []int64 {
55
 func (sc Security) ReEncrypt(fromKey int64, toKey int64, target []int64) []int64 {
83
 	return toPubMsg
84
 	return toPubMsg
84
 }
85
 }
85
 
86
 
87
+//Key제거 함수
86
 func (sc *Security) RemoveSecureKey(nodeName string) bool {
88
 func (sc *Security) RemoveSecureKey(nodeName string) bool {
87
 	//삭제 전 존재여부 확인
89
 	//삭제 전 존재여부 확인
88
 	_, exists := sc.KeyMap[nodeName]
90
 	_, exists := sc.KeyMap[nodeName]
95
 		return false
97
 		return false
96
 	}
98
 	}
97
 }
99
 }
98
-
99
-/**
100
-Compare 함수들은 같으면 0 다르면 -1 (비교가 필요한 경우 오름차순 1 내림차순 -1)
101
-*/
102
-//func (sc Security) CompareTopic(topic1 []int64, topic2 []int64) int {
103
-//	// 길이 같은지 체크
104
-//	if len(topic1) != len(topic2) {
105
-//		return -1
106
-//	}
107
-//	for i := 0; i < len(topic2); i++ {
108
-//		if topic1[i] != topic2[i] {
109
-//			return -1
110
-//		}
111
-//	}
112
-//	return 0
113
-//}
114
-//
115
-//func (sc Security) CompareDigit(topic1 int64, topic2 int64) int {
116
-//	if topic1 < topic2 {
117
-//		return 1
118
-//	} else if topic1 > topic2 {
119
-//		return -1
120
-//	}
121
-//	return 0
122
-//}
123
-//
124
-//func (sc Security) CompareAlpha(topic1 []int64, topic2 []int64) int {
125
-//	// 길이 같은지 체크
126
-//	if len(topic1) != len(topic2) {
127
-//		return -1
128
-//	}
129
-//	for i := 0; i < len(topic2); i++ {
130
-//		if topic1[i] != topic2[i] {
131
-//			return -1
132
-//		}
133
-//	}
134
-//	return 0
135
-//}
136
-
137
-// private key 생성 메세지
138
-//func (sc Security) keyGenPrivate() KeyGenMsg{
139
-//
140
-//}

Loading…
Откажи
Сачувај