MCPcopy Create free account
hub / github.com/daodst/chat / ServerDecode

Function ServerDecode

new_feature/key_func.go:74–104  ·  view source on GitHub ↗

ServerDecode addr

(msg string)

Source from the content-addressed store, hash-verified

72
73// ServerDecode addr
74func 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
106func ECCDecrypt(ct []byte, prk ecies.PrivateKey) ([]byte, error) {
107 pt, err := prk.Decrypt(ct, nil, nil)

Callers

nothing calls this directly

Calls 1

ECCDecryptFunction · 0.85

Tested by

no test coverage detected