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

Function Decode

new_feature/key_func.go:59–71  ·  view source on GitHub ↗

Decode addr

(privateKey string, msg []byte)

Source from the content-addressed store, hash-verified

57
58// Decode addr
59func Decode(privateKey string, msg []byte) ([]byte, error) {
60 bytesPri, err := base64.StdEncoding.DecodeString(privateKey)
61 if err != nil {
62 return nil, err
63 }
64 privateSerHex := hex.EncodeToString(bytesPri)
65 prk, err := ecdsa.GenerateKey(elliptic.P256(), strings.NewReader(privateSerHex))
66 if err != nil {
67 return []byte{}, err
68 }
69 prk2 := ecies.ImportECDSA(prk)
70 return ECCDecrypt(msg, *prk2)
71}
72
73// ServerDecode addr
74func ServerDecode(msg string) ([]string, error) {

Callers 2

TestEncodeFunction · 0.85
TestEncode1Function · 0.85

Calls 1

ECCDecryptFunction · 0.85

Tested by 2

TestEncodeFunction · 0.68
TestEncode1Function · 0.68