Commit 17c1988b authored by Stephane Glondu's avatar Stephane Glondu

s/channel_msg/signed_msg/g

parent 97ce1d4d
......@@ -129,18 +129,18 @@ type 'a result = {
result : plaintext;
}
(** {2 Channel messages support} *)
(** {2 PKI support} *)
type signed_msg = {
message : string;
signature : proof;
} <ocaml field_prefix="s_">
type 'a raw_channel_msg = {
recipient : 'a;
message : string;
} <ocaml field_prefix="raw_">
type channel_msg = {
message : string; (* raw_channel_msg *)
signature : proof;
} <ocaml field_prefix="channel_">
(** {2 Threshold decryption support} *)
type 'a cert_keys = {
......
......@@ -158,18 +158,18 @@ module MakeChannels (G : GROUP) (M : RANDOM)
let send sk raw_recipient raw_message =
let msg = { raw_recipient; raw_message } in
let channel_message = string_of_raw_channel_msg G.write msg in
M.bind (P.sign sk channel_message) (fun channel_signature ->
let msg = { channel_message; channel_signature } in
P.encrypt raw_recipient (string_of_channel_msg msg)
let s_message = string_of_raw_channel_msg G.write msg in
M.bind (P.sign sk s_message) (fun s_signature ->
let msg = { s_message; s_signature } in
P.encrypt raw_recipient (string_of_signed_msg msg)
)
let recv dk vk msg =
let msg = P.decrypt dk msg |> channel_msg_of_string in
let { channel_message; channel_signature } = msg in
if not (P.verify vk channel_message channel_signature) then
let msg = P.decrypt dk msg |> signed_msg_of_string in
let { s_message; s_signature } = msg in
if not (P.verify vk s_message s_signature) then
failwith "invalid signature on received message";
let msg = raw_channel_msg_of_string G.read channel_message in
let msg = raw_channel_msg_of_string G.read s_message in
let { raw_recipient; raw_message } = msg in
if not G.(raw_recipient =~ g **~ dk) then
failwith "invalid recipient on received message";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment