Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit 8b04585

Browse files
author
Yu Wei Wu
committed
fix(MAM): Remove psk for public message
Pre-Shared Key is used for encrypt message. Remove psk so every messages can be public in MAM protocol.
1 parent 46c5fcf commit 8b04585

File tree

1 file changed

+1
-33
lines changed

1 file changed

+1
-33
lines changed

accelerator/apis.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
#include "apis.h"
22

3-
// TODO: Generate actual pre shared keys
4-
static mam_psk_t const psk = {
5-
.id = {1, 0, -1, -1, 0, -1, -1, 0, 0, 1, -1, 0, 1, 0, 0, 1, 1,
6-
1, -1, 1, 1, 0, 1, 1, 0, 0, -1, 1, -1, -1, -1, -1, -1, -1,
7-
-1, 1, -1, -1, 0, -1, -1, 1, 0, -1, -1, -1, 1, 1, 1, 0, 0,
8-
-1, 1, -1, -1, -1, 0, -1, 1, -1, -1, -1, 1, 1, -1, 1, 0, 0,
9-
1, 1, 1, -1, -1, 0, 0, -1, -1, 1, 0, -1, 1},
10-
.key = {-1, 1, -1, -1, 1, -1, -1, 0, 0, 0, -1, -1, 1, 1, 1, -1, -1,
11-
-1, 0, 0, 0, 0, -1, -1, 1, 1, 1, 0, -1, -1, -1, 0, 0, 0,
12-
-1, -1, 1, -1, 0, 0, 1, 0, 0, -1, 1, 1, 0, -1, 0, 0, 1,
13-
-1, 1, 0, 1, 0, 0, -1, 1, 1, -1, 1, 0, -1, 0, -1, 1, -1,
14-
-1, -1, 0, -1, -1, 0, -1, -1, 0, 0, -1, -1, 1, -1, 0, 0, -1,
15-
-1, -1, -1, 0, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 0, 1,
16-
0, 1, -1, 0, 0, 1, 0, 1, 0, 0, 1, 0, -1, 0, 1, 1, 0,
17-
0, -1, -1, 1, 1, 0, 0, 1, -1, 1, 1, 1, 0, 1, 1, 1, 0,
18-
0, -1, -1, -1, -1, 1, 1, 1, 0, 0, -1, 0, 1, -1, 1, 1, 1,
19-
0, 0, 1, -1, -1, 0, -1, 1, -1, 1, 0, 0, 1, -1, 0, 1, -1,
20-
0, 0, 1, 1, 1, 1, 1, 0, 0, 1, -1, 1, -1, 1, 0, 1, 1,
21-
1, -1, 0, 0, -1, 1, 1, 0, -1, -1, 0, 0, -1, 1, 0, 1, -1,
22-
0, 0, -1, 1, -1, 1, 1, 1, -1, 0, 1, 1, 0, 0, -1, -1, -1,
23-
0, 0, 1, 0, 1, 0, -1, 1, -1, 0, 1, 0, -1, 1, 1, -1, -1,
24-
0, 0, -1, 0, -1}};
25-
263
status_t api_get_tips(const iota_client_service_t* const service,
274
char** json_result) {
285
status_t ret = SC_OK;
@@ -178,7 +155,6 @@ status_t api_receive_mam_message(const iota_client_service_t* const service,
178155
}
179156

180157
// Set first transaction's address as chid, if no `chid` specified
181-
mam_psk_t_set_add(&mam.psks, &psk);
182158
iota_transaction_t* curr_tx = (iota_transaction_t*)utarray_eltptr(bundle, 0);
183159
none_chid_trytes = (tryte_t*)malloc(sizeof(tryte_t) * NUM_TRYTES_ADDRESS);
184160
flex_trits_to_trytes(none_chid_trytes, NUM_TRYTES_ADDRESS,
@@ -228,7 +204,6 @@ status_t api_mam_send_message(const iota_config_t* const tangle,
228204
mam_api_t mam;
229205
const bool last_packet = true;
230206
bundle_transactions_t* bundle = NULL;
231-
mam_psk_t_set_t psks = NULL;
232207
bundle_transactions_new(&bundle);
233208
tryte_t channel_id[MAM_CHANNEL_ID_SIZE];
234209
trit_t msg_id[MAM_MSG_ID_SIZE];
@@ -256,13 +231,7 @@ status_t api_mam_send_message(const iota_config_t* const tangle,
256231
}
257232

258233
// Write header and packet
259-
if (!mam_psk_t_set_contains(&psks, &psk)) {
260-
if (mam_psk_t_set_add(&psks, &psk) != RC_OK) {
261-
ret = SC_MAM_FAILED_WRITE;
262-
goto done;
263-
}
264-
}
265-
if (mam_api_bundle_write_header_on_channel(&mam, channel_id, psks, NULL, 0,
234+
if (mam_api_bundle_write_header_on_channel(&mam, channel_id, NULL, NULL, 0,
266235
bundle, msg_id) != RC_OK) {
267236
ret = SC_MAM_FAILED_WRITE;
268237
goto done;
@@ -292,7 +261,6 @@ status_t api_mam_send_message(const iota_config_t* const tangle,
292261
ret = SC_MAM_FAILED_DESTROYED;
293262
}
294263
}
295-
mam_psk_t_set_free(&psks);
296264
bundle_transactions_free(&bundle);
297265
send_mam_req_free(&req);
298266
send_mam_res_free(&res);

0 commit comments

Comments
 (0)