Skip to content

Commit

Permalink
weird bug. debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Shengtong Zhang committed Jun 27, 2022
1 parent 1f391d5 commit 7da1032
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions daemon/crypto/crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ auto generate_kx_keypair() -> std::pair<string, string> {
string(reinterpret_cast<char*>(secret_key), crypto_kx_SECRETKEYBYTES)};
}

auto generate_friend_request_keypair() -> std::pair<string, string> {
unsigned char public_key[crypto_box_PUBLICKEYBYTES];
unsigned char secret_key[crypto_box_SECRETKEYBYTES];
crypto_box_keypair(public_key, secret_key);
return {
string(reinterpret_cast<char*>(public_key), crypto_box_PUBLICKEYBYTES),
string(reinterpret_cast<char*>(secret_key), crypto_box_SECRETKEYBYTES)};
}

auto generic_hash(string_view data) -> std::string {
unsigned char hash[crypto_generichash_BYTES];
crypto_generichash(hash, sizeof hash,
Expand Down
1 change: 0 additions & 1 deletion daemon/db/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,6 @@ impl DB {
write_key: address_struct.write_key,
};
diesel::insert_into(address::table).values(&address).execute(conn_b)?;

let status = ffi::Status { uid, sent_acked_seqnum: 0, received_seqnum: 0 };
diesel::insert_into(status::table).values(&status).execute(conn_b)?;
Ok(())
Expand Down
7 changes: 6 additions & 1 deletion daemon/rpc/daemon_rpc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ Status DaemonRpc::RegisterUser(
ASPHR_LOG_INFO("Already registered.", rpc_call, "RegisterUser");
return Status(grpc::StatusCode::ALREADY_EXISTS, "already registered");
}

const auto name = registerUserRequest->name();
const auto [friend_request_public_key, friend_request_private_key] =
crypto::generate_friend_request_keypair();

const auto [kx_public_key, kx_secret_key] = crypto::generate_kx_keypair();
const auto [pir_secret_key, pir_galois_keys] = generate_keys();

Expand Down Expand Up @@ -252,6 +252,9 @@ Status DaemonRpc::SendAsyncFriendRequest(
const asphrdaemon::SendAsyncFriendRequestRequest*
sendAsyncFriendRequestRequest,
asphrdaemon::SendAsyncFriendRequestResponse*) {
ASPHR_LOG_INFO("SendAsyncFriendRequest() called.", rpc_call,
"SendAsyncFriendRequest");

auto friend_info = sendAsyncFriendRequestRequest->friend_info();
std::string message = sendAsyncFriendRequestRequest->message();

Expand Down Expand Up @@ -292,6 +295,8 @@ Status DaemonRpc::SendAsyncFriendRequest(
"AddFriend");
return Status(grpc::StatusCode::UNKNOWN, e.what());
}
ASPHR_LOG_INFO("SendAsyncFriendRequest() done.", rpc_call,
"SendAsyncFriendRequest");
return Status::OK;
}

Expand Down

0 comments on commit 7da1032

Please sign in to comment.