Working end to end with in-memory data store.

This commit is contained in:
Mariano Uvalle 2023-11-09 07:34:00 +00:00
parent 320dc46010
commit 426500df45
7 changed files with 313 additions and 27 deletions

View file

@ -0,0 +1,17 @@
package client
import (
"crypto/ecdh"
"github.com/AYM1607/ccclip/pkg/api"
"github.com/AYM1607/ccclip/pkg/crypto"
)
func encryptForAll(plaintext string, pvk *ecdh.PrivateKey, devices []*api.Device) map[string][]byte {
res := map[string][]byte{}
for _, d := range devices {
key := crypto.NewSharedKey(pvk, crypto.PublicKeyFromBytes(d.PublicKey), crypto.SendDirection)
res[d.ID] = crypto.Encrypt(key, []byte(plaintext))
}
return res
}