ServerDecode addr
(msg string)
| 72 | |
| 73 | // ServerDecode addr |
| 74 | func ServerDecode(msg string) ([]string, error) { |
| 75 | if msg == "" { |
| 76 | return []string{}, nil |
| 77 | } |
| 78 | msgBytes, err2 := base64.StdEncoding.DecodeString(msg) |
| 79 | if err2 != nil { |
| 80 | return nil, err2 |
| 81 | } |
| 82 | bytesPri, err := base64.StdEncoding.DecodeString(priBase64) |
| 83 | if err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | privateSerHex := hex.EncodeToString(bytesPri) |
| 87 | prk, err := ecdsa.GenerateKey(elliptic.P256(), strings.NewReader(privateSerHex)) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | prk2 := ecies.ImportECDSA(prk) |
| 92 | eccDecrypt, err2 := ECCDecrypt(msgBytes, *prk2) |
| 93 | if err2 != nil { |
| 94 | return nil, err2 |
| 95 | } else { |
| 96 | res := []string{} |
| 97 | err = json.Unmarshal(eccDecrypt, &res) |
| 98 | if err != nil { |
| 99 | return nil, err |
| 100 | } else { |
| 101 | return res, nil |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | func ECCDecrypt(ct []byte, prk ecies.PrivateKey) ([]byte, error) { |
| 107 | pt, err := prk.Decrypt(ct, nil, nil) |
nothing calls this directly
no test coverage detected