-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Barkhausen-Institut/rsa-signatures
Rsa signatures
- Loading branch information
Showing
10 changed files
with
2,717 additions
and
431 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This configuration file was generated by running: | ||
# coq_makefile -f _CoqProject -o Makefile.coq | ||
|
||
COQBIN?= | ||
ifneq (,$(COQBIN)) | ||
# add an ending / | ||
COQBIN:=$(COQBIN)/ | ||
endif | ||
COQMKFILE ?= "$(COQBIN)coq_makefile" | ||
|
||
############################################################################### | ||
# # | ||
# Project files. # | ||
# # | ||
############################################################################### | ||
|
||
COQMF_CMDLINE_VFILES := | ||
COQMF_SOURCES := $(shell $(COQMKFILE) -sources-of -f _CoqProject $(COQMF_CMDLINE_VFILES)) | ||
COQMF_VFILES := $(filter %.v, $(COQMF_SOURCES)) | ||
COQMF_MLIFILES := $(filter %.mli, $(COQMF_SOURCES)) | ||
COQMF_MLFILES := $(filter %.ml, $(COQMF_SOURCES)) | ||
COQMF_MLGFILES := $(filter %.mlg, $(COQMF_SOURCES)) | ||
COQMF_MLPACKFILES := $(filter %.mlpack, $(COQMF_SOURCES)) | ||
COQMF_MLLIBFILES := $(filter %.mllib, $(COQMF_SOURCES)) | ||
COQMF_METAFILE = | ||
|
||
############################################################################### | ||
# # | ||
# Path directives (-I, -R, -Q). # | ||
# # | ||
############################################################################### | ||
|
||
COQMF_OCAMLLIBS = | ||
COQMF_SRC_SUBDIRS = | ||
COQMF_COQLIBS = -Q theories vRATLS | ||
COQMF_COQLIBS_NOML = -Q theories vRATLS | ||
COQMF_CMDLINE_COQLIBS = | ||
|
||
############################################################################### | ||
# # | ||
# Coq configuration. # | ||
# # | ||
############################################################################### | ||
|
||
COQMF_COQLIB=/nix/store/51fqh0dc78ggqqy0vp6hhkq242jprpqf-coq-8.18.0/lib/coq/ | ||
COQMF_COQCORELIB=/nix/store/51fqh0dc78ggqqy0vp6hhkq242jprpqf-coq-8.18.0/lib/coq/../coq-core/ | ||
COQMF_DOCDIR=/nix/store/51fqh0dc78ggqqy0vp6hhkq242jprpqf-coq-8.18.0/share/doc/ | ||
COQMF_OCAMLFIND=/nix/store/jfhjb6dlfsyvybzrcr432d7hlvpqngvv-ocaml4.14.2-findlib-1.9.6/bin/ocamlfind | ||
COQMF_CAMLFLAGS=-thread -bin-annot -strict-sequence -w -a+1..3-4+5..8-9+10..26-27+28..39-40-41-42+43-44-45+46..47-48+49..57-58+59..66-67-68+69-70 | ||
COQMF_WARN=-warn-error +a-3 | ||
COQMF_HASNATDYNLINK=true | ||
COQMF_COQ_SRC_SUBDIRS=boot config lib clib kernel library engine pretyping interp gramlib parsing proofs tactics toplevel printing ide stm vernac plugins/btauto plugins/cc plugins/derive plugins/extraction plugins/firstorder plugins/funind plugins/ltac plugins/ltac2 plugins/micromega plugins/nsatz plugins/ring plugins/rtauto plugins/ssr plugins/ssrmatching plugins/syntax | ||
COQMF_COQ_NATIVE_COMPILER_DEFAULT=no | ||
COQMF_WINDRIVE= | ||
|
||
############################################################################### | ||
# # | ||
# Native compiler. # | ||
# # | ||
############################################################################### | ||
|
||
COQMF_COQPROJECTNATIVEFLAG = | ||
|
||
############################################################################### | ||
# # | ||
# Extra variables. # | ||
# # | ||
############################################################################### | ||
|
||
COQMF_OTHERFLAGS = | ||
COQMF_INSTALLCOQDOCROOT = vRATLS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
From Relational Require Import OrderEnrichedCategory GenericRulesSimple. | ||
|
||
Set Warnings "-notation-overridden,-ambiguous-paths". | ||
From mathcomp Require Import all_ssreflect all_algebra reals distr realsum | ||
fingroup.fingroup solvable.cyclic prime ssrnat ssreflect ssrfun ssrbool ssrnum | ||
eqtype choice seq. | ||
Set Warnings "notation-overridden,ambiguous-paths". | ||
|
||
From Crypt Require Import Axioms ChoiceAsOrd SubDistr Couplings | ||
UniformDistrLemmas FreeProbProg Theta_dens RulesStateProb UniformStateProb | ||
pkg_core_definition choice_type pkg_composition pkg_rhl | ||
Package Prelude RandomOracle. | ||
|
||
From Coq Require Import Utf8. | ||
From extructures Require Import ord fset fmap. | ||
|
||
From Equations Require Import Equations. | ||
Require Equations.Prop.DepElim. | ||
Require Import Coq.Init.Logic. | ||
Require Import List. | ||
|
||
Set Equations With UIP. | ||
|
||
(* | ||
The paper: | ||
https://web.archive.org/web/20220121005133id_/https://eprint.iacr.org/2019/779.pdf | ||
*) | ||
|
||
(* | ||
This is needed to make definitions with Equations transparent. | ||
Otherwise they are opaque and code simplifications in the | ||
proofs with [ssprove_code_simpl] does not resolve properly. | ||
*) | ||
Set Equations Transparent. | ||
|
||
Set Bullet Behavior "Strict Subproofs". | ||
Set Default Goal Selector "!". | ||
Set Primitive Projections. | ||
|
||
Import Num.Def. | ||
Import Num.Theory. | ||
Import Order.POrderTheory. | ||
|
||
From vRATLS Require Import examples.Signature. | ||
|
||
Import PackageNotation. | ||
|
||
Obligation Tactic := idtac. | ||
|
||
|
||
Print Run_aux. | ||
|
||
(* TODO new run function needed: [evalState] *) | ||
Fail Theorem CEO seed : | ||
forall pk sk, | ||
Some (pk,sk) = Run sampler KeyGen seed -> | ||
forall msg sig, | ||
Some sig = Run_aux sampler (Sign msg) (λ l, if l == sk_loc then Some sk else Some NSUnit) -> | ||
forall pk', | ||
Some true = Run_aux sampler (Verify sig msg) (λ l, if l == pk_loc then Some pk' else Some NSUnit) -> | ||
pk = pk'. | ||
|
||
Fail Definition Sign_me : package Sig_locs_real Sig_ifce Sig_prot_ifce | ||
:= [package | ||
#def #[sign_me] (msg : 'message) : 'pubkey × 'signature | ||
{ | ||
#import {sig #[get_pk] : 'unit → 'pubkey } as get_pk ;; | ||
#import {sig #[sign] : 'message → 'signature } as sign ;; | ||
|
||
pk ← get_pk tt ;; | ||
sig ← sign msg ;; | ||
|
||
ret (pk, sig) | ||
} | ||
]. | ||
|
||
Fail Definition Verify_me : package Sig_locs_real Sig_ifce Sig_prot_ifce | ||
:= [package | ||
#def #[verify_me] (sig : 'signature) (msg : 'message) : 'pubkey × 'bool | ||
{ | ||
#import {sig #[get_pk] : 'unit → 'pubkey } as get_pk ;; | ||
#import {sig #[sign] : 'message → 'signature } as sign ;; | ||
|
||
pk ← get_pk tt ;; | ||
b ← verify msg sig ;; | ||
ret (pk, b) | ||
} | ||
]. | ||
|
||
|
||
Fail Theorem CEO seed seed': | ||
forall pk pk' msg sig, | ||
Some (pk , sig ) = Run sampler (Sign_me msg) seed -> | ||
Some (pk', true) = Run sampler (Verify_me sig msg) seed -> | ||
pk = pk'. | ||
|
||
(* The below version holds for [KeyGen] implementations | ||
that dependent on the seed. | ||
That is, we need an additional property for [KeyGen]: | ||
[ | ||
Some pk = Run sampler KeyGen seed -> | ||
Some pk' = Run sampler KeyGen seed' -> | ||
seed = seed' -> | ||
pk = pk' | ||
] | ||
*) | ||
Fail Theorem CEO' seed seed': | ||
forall pk pk' msg sig, | ||
Some (pk , sig ) = Run sampler (Sign_me msg) seed -> | ||
Some (pk', true) = Run sampler (Verify_me sig msg) seed' -> | ||
pk = pk' -> | ||
seed = seed'. | ||
(* | ||
The proof is by case on [seed == seed']. | ||
The [true] case is straight-forward. | ||
The [false] case leads to a contradiction in the hypotheses because | ||
then [pk = pk'] does not hold anymore. | ||
*) | ||
|
||
|
||
Fail Theorem DEO seed seed': | ||
forall pk pk' msg msg' sig, | ||
Some (pk, sig ) = Run sampler (Sign_me msg) seed -> | ||
Some (pk, true) = Run sampler (Verify_me sig msg') seed' -> | ||
seed != seed' -> | ||
pk = pk' ∧ msg = msg'. | ||
|
||
Theorem Consistency_verify: | ||
forall pk seed sig msg r r', | ||
Some (pk, r ) = Run sampler (Verify_me sig msg) seed' -> | ||
Some (pk, r') = Run sampler (Verify_me sig msg) seed' -> | ||
r = r'. |
Oops, something went wrong.