Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISO-DH Example #36

Merged
merged 35 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0aa21fe
Total and Stateful code of the DH model
fabian-hk Apr 5, 2024
fd39c27
Updated comment
fabian-hk Apr 5, 2024
d6ee647
Updated key usage in DH example
fabian-hk Apr 5, 2024
faab06c
Executable DH protocol run
fabian-hk Apr 19, 2024
d7c717b
Merge branch 'main' into example/dh
fabian-hk Apr 21, 2024
da35de8
Adapted DH example to folder structure change in the main branch
fabian-hk Apr 21, 2024
6530829
Merge branch 'main' of github.com:REPROSEC/dolev-yao-star-extrinsic i…
fabian-hk Apr 29, 2024
2fe4dc5
DH example trace and crypto predicates; DH security lemmas
fabian-hk May 6, 2024
f3bae42
Merge branch 'main' of github.com:REPROSEC/dolev-yao-star-extrinsic i…
fabian-hk May 6, 2024
1cbf7a5
Merge branch 'main' of github.com:REPROSEC/dolev-yao-star-extrinsic i…
fabian-hk May 6, 2024
b659f3f
DH example add trace printing to debug protocol run
fabian-hk May 6, 2024
b423727
DH example compute_message1_proof and decode_message1_proof
fabian-hk May 8, 2024
872b3e8
DH example compute_message2_proof and decode_message2_proof
fabian-hk May 15, 2024
a89e453
DH example compute_message3_proof and decode_message3_proof
fabian-hk May 16, 2024
d7208b0
DH example add ifuel option to crypto preds
fabian-hk May 16, 2024
07fa39c
Merge branch 'main' of github.com:REPROSEC/dolev-yao-star-extrinsic i…
fabian-hk May 16, 2024
74c5526
DH example compatibility with main branch restored
fabian-hk May 16, 2024
7820c8a
DH example finished stateful proofs
fabian-hk Jun 17, 2024
9ddf423
Merge branch 'main' of github.com:REPROSEC/dolev-yao-star-extrinsic i…
fabian-hk Jun 17, 2024
5bc0106
Make DH example compatible with current main branch and clean up
fabian-hk Jun 18, 2024
50da6db
DH example: changed is_dh_shared_key definition to use `equivalent tr`
fabian-hk Jun 19, 2024
afa6fe2
DH example renamed folder to iso_dh and used 'equivalent tr' function…
fabian-hk Jun 19, 2024
e621fde
DH example added ISO reference
fabian-hk Jun 19, 2024
952037e
DH example: changed names of security properties and added README.md
fabian-hk Jun 20, 2024
4181604
DH example sanity check for trace invariants and proof refactoring
fabian-hk Jun 21, 2024
d1484ed
DH example feedback Théophile
fabian-hk Jun 21, 2024
d153846
DH example proof trace invariants for example trace with SMTPats
fabian-hk Jun 25, 2024
4229af3
cleanup: tighten ISO-DH invariants to simplify proofs
TWal Jun 25, 2024
905d097
DH example improved security properties and changed SMTPats for the s…
fabian-hk Jun 27, 2024
8f93d66
DH example move all crypto functions to the total code; cleanup code
fabian-hk Jul 1, 2024
e78a4f2
DH example feedback Théophile and code cleanup
fabian-hk Jul 2, 2024
990a47d
Updated README to include the ISO-DH example
fabian-hk Jul 3, 2024
581fba9
README changed path to ISO-DH example
fabian-hk Jul 3, 2024
3b0c377
DH example updated README
fabian-hk Jul 3, 2024
cffcd3a
cleanup: rework some ISO-DH security proofs
TWal Jul 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fst.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ "fstar_exe":"fstar.exe",
"options":["--cache_dir", "cache", "--hint_dir", "hints", "--use_hints", "--record_hints"],
"include_dirs":[
"../comparse/src", "src/core", "src/lib", "src/lib/comparse", "src/lib/event", "src/lib/state", "src/lib/utils", "examples/nsl_pk"]
"../comparse/src", "src/core", "src/lib", "src/lib/comparse", "src/lib/event", "src/lib/state", "src/lib/utils", "examples/nsl_pk", "examples/iso_dh"]
}
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ In general the `requires` is a big conjunction,
each hypothesis should be on a separate line.
The `ensures` often contains a `let`, a `match`,
in that case extra parenthesis are needed for F\*'s parser.
Defining variables with the `let` keyword should be
replaced by inlining the statement directly into the function that
requires the variable if it does not blow up the statement too much.

When the lemma is very short, it may be written on one line.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ COMPARSE_HOME ?= $(DY_HOME)/../comparse

INNER_SOURCE_DIRS = core lib lib/comparse lib/event lib/state lib/utils
SOURCE_DIRS = $(addprefix $(DY_HOME)/src/, $(INNER_SOURCE_DIRS))
INNER_EXAMPLE_DIRS = nsl_pk
INNER_EXAMPLE_DIRS = nsl_pk iso_dh
EXAMPLE_DIRS = $(addprefix $(DY_HOME)/examples/, $(INNER_EXAMPLE_DIRS))

INCLUDE_DIRS = $(SOURCE_DIRS) $(EXAMPLE_DIRS) $(COMPARSE_HOME)/src
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ we can find functions and theorems built on top of [`DY.Core`](src/core/DY.Core.

### Examples

The NSL protocol is proved secure in the namespace [`DY.Example.NSL`](examples/nsl_pk/DY.Example.NSL.SecurityProperties.fst).
The NSL protocol has been proven secure in the namespace [`DY.Example.NSL`](examples/nsl_pk/DY.Example.NSL.SecurityProperties.fst), and the ISO-DH protocol has been
proven secure in the namespace [`DY.Example.DH`](examples/iso_dh).

## How to build

Expand Down
30 changes: 30 additions & 0 deletions examples/iso_dh/DY.Example.DH.Debug.Proof.fst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module DY.Example.DH.Debug.Proof

open DY.Core
open DY.Lib
open DY.Example.DH.Protocol.Stateful
open DY.Example.DH.Protocol.Stateful.Proof
open DY.Example.DH.Debug

/// This module proves that the debug function
/// fulfills the trace invariants.
///
/// The proof works automatically because each
/// stateful proof as a SMTPat (`[SMTPat (trace_invariant tr); SMTPat (protocol_function)]`).
/// Another way to do this proof is to basically
/// duplicate the code from the debug function and
/// call all the lemmas for the stateful code manually.

#set-options "--fuel 0 --ifuel 0 --z3rlimit 10 --z3cliopt 'smt.qi.eager_threshold=100'"
val debug_proof:
tr:trace ->
Lemma
(requires
trace_invariant tr
)
(ensures (
let (_, tr_out) = debug () tr in
trace_invariant tr_out
)
)
let debug_proof tr = ()
67 changes: 67 additions & 0 deletions examples/iso_dh/DY.Example.DH.Debug.fst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module DY.Example.DH.Debug

open DY.Core
open DY.Lib
open DY.Example.DH.Protocol.Stateful


let debug () : traceful (option unit) =
let _ = IO.debug_print_string "************* Trace *************\n" in
(*** Initialize protocol run ***)
let alice = "alice" in
let bob = "bob" in

// Generate private key for Alice
let* alice_global_session_priv_key_id = initialize_private_keys alice in
generate_private_key alice alice_global_session_priv_key_id (Sign "DH.SigningKey");*

// Generate private key for Bob
let* bob_global_session_priv_key_id = initialize_private_keys bob in
generate_private_key bob bob_global_session_priv_key_id (Sign "DH.SigningKey");*

// Store Bob's public key in Alice's state
// 1. Retrieve Bob's private key from his session
// 2. Compute the public key from the private key
// 3. Initialize Alice's session to store public keys
// 4. Install Bob's public key in Alice's public key store
let*? priv_key_bob = get_private_key bob bob_global_session_priv_key_id (Sign "DH.SigningKey") in
let pub_key_bob = vk priv_key_bob in
let* alice_global_session_pub_key_id = initialize_pki alice in
install_public_key alice alice_global_session_pub_key_id (Verify "DH.SigningKey") bob pub_key_bob;*

// Store Alice's public key in Bob's state
let*? priv_key_alice = get_private_key alice alice_global_session_priv_key_id (Sign "DH.SigningKey") in
let pub_key_alice = vk priv_key_alice in
let* bob_global_session_pub_key_id = initialize_pki bob in
install_public_key bob bob_global_session_pub_key_id (Verify "DH.SigningKey") alice pub_key_alice;*

let alice_global_session_ids: dh_global_sess_ids = {pki=alice_global_session_pub_key_id; private_keys=alice_global_session_priv_key_id} in
let bob_global_session_ids: dh_global_sess_ids = {pki=bob_global_session_pub_key_id; private_keys=bob_global_session_priv_key_id} in

(*** Run the protocol ***)
// Alice
let* alice_session_id = prepare_msg1 alice bob in
let*? msg1_id = send_msg1 alice alice_session_id in

// Bob
let*? bob_session_id = prepare_msg2 alice bob msg1_id in
let*? msg2_id = send_msg2 bob_global_session_ids bob bob_session_id in

// Alice
prepare_msg3 alice_global_session_ids alice alice_session_id bob msg2_id;*
let*? msg3_id = send_msg3 alice_global_session_ids alice bob alice_session_id in

// Bob
verify_msg3 bob_global_session_ids alice bob msg3_id bob_session_id;*

let* tr = get_trace in
let _ = IO.debug_print_string (
trace_to_string default_trace_to_string_printers tr
) in

return (Some ())

//Run ``debug ()`` when the module loads
#push-options "--warn_error -272"
let _ = debug () Nil
#pop-options
Loading