allow passing an arg to curl script to switch between public and one to one w/ burnettk

This commit is contained in:
jasquat 2022-09-26 14:34:57 -04:00
parent 3613d11d8d
commit 342054a914
2 changed files with 25 additions and 16 deletions

32
run.go
View File

@ -94,25 +94,31 @@ func sendMessage(c *gin.Context) {
if err != nil {
panic(err)
}
fmt.Printf("publicKey.X: '%v'\n", publicKey.X)
fmt.Printf("publicKey.Y: '%v'\n", publicKey.Y)
fmt.Printf("publicKey.Y.Sign(): '%v'\n", publicKey.Y.Sign())
fmt.Printf("publicKey.X.Sign(): '%v'\n", publicKey.X.Sign())
// fmt.Printf("publicKey.X: '%v'\n", publicKey.X)
// fmt.Printf("publicKey.Y: '%v'\n", publicKey.Y)
// fmt.Printf("publicKey.Y.Sign(): '%v'\n", publicKey.Y.Sign())
// fmt.Printf("publicKey.X.Sign(): '%v'\n", publicKey.X.Sign())
// The messages need to be encrypted before they're broadcasted
payload := node.Payload{}
payload.Data = wrappedPayload
payload.Key = &node.KeyInfo{
PrivKey: authorKey, // Key used to sign the message
// // For sending to a public channel
// Kind: node.Symmetric,
// SymKey: generateSymKey(topic),
// For 1:1
Kind: node.Asymmetric,
PubKey: publicKey,
var keyInfo node.KeyInfo
if messageBody.MessageType == "public" {
keyInfo = node.KeyInfo{
PrivKey: authorKey, // Key used to sign the message
Kind: node.Symmetric,
SymKey: generateSymKey(topic),
}
} else if messageBody.MessageType == "one_to_one" {
keyInfo = node.KeyInfo{
PrivKey: authorKey, // Key used to sign the message
Kind: node.Asymmetric,
PubKey: publicKey,
}
}
payload.Key = &keyInfo
payloadBytes, err := payload.Encode(1)
if err != nil {
panic(err)

View File

@ -11,7 +11,10 @@ rramosKey="04ca2cf0599ace5def8543cb53e7fbd1d54ba65ab89f8794a08f9bf0406a7895c8074
jasonKey="04aa379d2661d6358f41b47a866f2674ca987e3398e93318ec08ea58b9f7035df491131a62ad3a469af609df9af58bcad698dac7f01e160130b7e187c60b824973"
kbKey="04e3ec4eb8a7c6b78f30b25ee2b2c34040ede4b9e51627ac82051bb37c4c3de21da0709bced20619566c545ff7b69fd58b8840cd48a686fffe68608f879bf9155b"
mikeKey="04622248490465b1d0cd5ec48375484682bec9a16f550ffd461cb803d4a8970a88cf8f99390a8e2216012602a9f8a0882ae86d773667d2802939150f3a14f1963a"
publicKey=$kbKey
publicKey=$rramosKey
# curl localhost:7005/sendMessage -X POST --data '{"message": "new_message1", "recipient": "testrramos", "message_type": "public"}'
curl -v localhost:7005/sendMessage -X POST --data '{"message": "new_message1", "recipient": "'$publicKey'", "message_type": "one_to_one"}'
if [[ "${1-}" == "public" ]]; then
curl localhost:7005/sendMessage -X POST --data '{"message": "new_message2", "recipient": "testrramos", "message_type": "public"}'
else
curl -v localhost:7005/sendMessage -X POST --data '{"message": "new_message1", "recipient": "'$publicKey'", "message_type": "one_to_one"}'
fi