| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package modules
-
- import (
- "fmt"
- "strconv"
- )
-
- // 키관리 부분, 노드 입력받고 키 반환하는 부분 구현
- type Security struct{
- KeyMap map[string] string
- }
-
- type SecurityManage interface {
- reEncrypt()
- keyGenPrivate()
- compare()
- }
-
- /**
- keyShareMsg 에서 각 노드의 private 키를 받아 keyMap 에 저장
- */
- func (sc Security) RegKey(ksm KeyShareMsg) {
- sc.KeyMap[ksm.Message.From()] = ksm.key
- }
-
- /**
- 각 노드의 키를 주소를 이용하여 맵에서 가져옴
- */
- func (sc Security) GetNodeKey(message Message) int{
-
- messageStringKey := sc.KeyMap[message.From()]
- mKey, err := strconv.Atoi(messageStringKey)
- if err != nil {
- fmt.Println("reEncrypt Error: key string to int error.")
- }
- return mKey
- }
-
- /**
- reEncrypt 해서 슬라이스 반환
- */
- func (sc Security) ReEncrypt(fromKey int, toKey int, target []int) []int{
- for index := range target {
- target[index] = target[index] - fromKey + toKey
- }
-
- return target
- }
-
-
- // private key 생성 메세지
- //func (sc Security) keyGenPrivate() KeyGenMsg{
- //
- //}
|