49
Introduction July 16, 2013

Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Introduction

July 16, 2013

Page 2: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Welcome

Acknowledgements:

◮ Benjamin Pierce, André Scedrov, U Penn support team

◮ Office of Naval Research

◮ EasyCrypt users

Organization:

◮ Lectures: overview of key components

◮ Labs: hands-on experience

◮ Workshop (Friday)

School web page:

http://www.easycrypt.info/school.html

Page 3: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

EasyCrypt in a nusthell

◮ EasyCrypt is a tool-assisted platform for proving security of

cryptographic constructions in the computational model

◮ Views cryptographic proofs as relational verification of

open parametric probabilistic programs

◮ Leverage PL and PV techniques for cryptographic proofs

◮ Be accessible to cryptographers (choice of PL)

◮ Support high-level reasoning principles (still ongoing)

◮ Provide reasonable level of automation

◮ Reuse off-the-shelf verification tools (we use Why3)

Page 4: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

EasyCrypt usage

◮ EasyCrypt is generic: no restriction on

☞ primitives and protocols

☞ security notions and assumptions

◮ Can be used interactively or as a certifying back-end

☞ for cryptographic compilers (ZK)

☞ for domain-specific (computational or symbolic) logics

◮ Can verify implementations

☞ C-mode

☞ CompCert as a certifying back-end

Page 5: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Evolution

Started in 2009. One older brother (CertiCrypt), started 2006.

◮ At first, mostly automated proofs

◮ v0.2 Interactive proofs in pRHL

◮ v1.0 Modular proofs, all layers explicit and with support for

interactive proofs

Warning

v1.0 not yet finalized. Still needs to work on

◮ increasing automation

◮ high-level proof steps

◮ small(er) TCB

◮ . . .

Page 6: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

EasyCrypt: Languages

Typed imperative language

C ::= skip skip

| V = E assignment

| V = $D random sampling

| C; C sequence

| if E then C else C conditional

| while E do C while loop

| V = F(E , . . . , E) procedure call

Expression language:

◮ features first-class distributions α distr

◮ allows higher-order expressions

◮ is extensible

Page 7: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Semantics of programs

Discrete sub-distribution transformers

JcK : M → M distr

Probability of an event

Pr [c,m : E ] = JcKm E

Losslessness

Pr [c,m : ⊤] = 1

Page 8: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

EasyCrypt: Logics

◮ Ambient higher-order logic

◮ Hoare Logic c : P =⇒ Q

◮ Probabilistic Hoare Logic (behind compute in v0.2)

[c : P =⇒ Q]≤ δ [c : P =⇒ Q] = δ [c : P =⇒ Q]≥ δ

◮ Probabilistic Relational Hoare Logic c1 ∼ c2 : P =⇒ Q

☞ Logics serve complementary purposes

☞ Some overlaps, many interplays

☞ HL, pHL, pRHL embedded in ambient logic

Page 9: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

PRHL: intuition and preview

Judgment c1 ∼ c2 : P =⇒ Q is valid iff for all memories m1 and

m2

P m1 m2 ⇒ Q# Jc1Km1Jc2Km2

Valid judgments allow deriving probability claims; eg if P m1 m2

and c1 ∼ c2 : P =⇒ Q and Q ⇒ A〈1〉 ⇔ B〈2〉 then

Pr [c1,m1 : A] = Pr [c2,m2 : B]

Example rule:

c1 ∼ c : P ∧ e〈1〉 =⇒ Q c2 ∼ c : P ∧ ¬e〈1〉 =⇒ Q

if e then c1 else c2 ∼ c : P =⇒ Q

P ⇒ e〈1〉=e′〈2〉

c1 ∼ c′

1 : P ∧ e〈1〉 =⇒ Q c2 ∼ c′

2 : P ∧ ¬e〈1〉 =⇒ Q

if e then c1 else c2 ∼ if e′ then c′

1 else c′

2 : P =⇒ Q

Page 10: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

EasyCrypt: modules and theories

Modules (beware memory model)

◮ Instantiating generic transformations (simplified syntax)

forall &m (A <: AdvCCA), exists (B <: AdvCPA),Pr[CCA(FO(S),A) @ &m : b’ = b ] <=Pr[CPA(S,B) @ &m : b’ = b] + ....

◮ Supporting high-level reasoning steps

Theories

◮ Supports code reuse

◮ “Polymorphism” via abstract types

◮ “Quantification” via abstract operators

Plans to implement datatypes and type classes

Page 11: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Page 12: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Primitive

Page 13: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Primitive

Generic

construction

Page 14: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Primitive

Generic

construction

Attack

Page 15: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Primitive

Generic

construction

Attack

Attack

Page 16: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Primitive

Generic

construction

Attack

Attack

Black-box

reduction

Page 17: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Provable security

Scheme

Primitive

Generic

construction

Attack

Attack

Black-box

reduction

Ideally attacks have similar execution times

Page 18: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Public-key encryption

Algorithms (K, E ,D), s.t.:

◮ E takes as inputs a public key and a message, and outputs

a ciphertext

◮ D takes as inputs a secret key and a ciphertext, and

outputs a plaintext; D may be partial

◮ if (sk , pk) is a valid key pair, Dsk (Epk (m)) = m

module type Scheme = {fun kg() : pkey ∗ skeyfun enc(pk:pkey, m:plaintext) : ciphertextfun dec(sk:skey, c:ciphertext) : plaintext option

}.

Page 19: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Correctness

module Correct (S:Scheme) = {fun main(m:plaintext) : bool = {

var pk : pkey;var sk : skey;var c : ciphertext;var m’ : plaintext option;

(pk, sk) = S.kg();c = S.enc(pk, m);m’ = S.dec(sk, c);return (m’ = Some m);

}}.

[Correctness(S, I) : ⊤ =⇒ m’=Some m] = 1

Page 20: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

Page 21: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

Page 22: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

Page 23: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

mb

Page 24: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

mb

Epk

c∗

Page 25: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

mb

Epk

c∗

c∗

Page 26: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

mb

Epk

c∗

c∗ b′

Page 27: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

mb

Epk

c∗

c∗ b′

?=

Page 28: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

m0

m1

$

b

mb

Epk

c∗

c∗ b′

?=

Pr[

IND-CCA(A) : b′ = b]

−1

2

small

Page 29: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Indistinguishability

module CPA (S:Scheme, A:Adversary) = {fun main() : bool = {

var pk : pkey;var sk : skey;var m0, m1 : plaintext;var c : ciphertext;var b, b’ : bool;

(pk, sk) = S.kg();(m0, m1) = A.choose(pk);b = ${0,1};c = S.enc(pk, b ? m1 : m0);b’ = A.guess(c);return (b’ = b);

}}.

Page 30: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

Page 31: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

$

x

Page 32: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

$

x

fpk

y⋆

Page 33: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

$

x

fpk

y⋆

y⋆

Page 34: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

$

x

fpk

y⋆

y⋆x ′

Page 35: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

$

x

fpk

y⋆

y⋆x ′

?=

Page 36: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

$

x

fpk

y⋆

y⋆x ′

?=

Pr[

OW(I) : x ′ = x]

small

Page 37: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

One-way trapdoor permutations

module type Inverter = {fun i(pk : pkey, y : randomness) : randomness

}.

module OW(I :Inverter) ={fun main() : bool ={var x : randomness;var x’ : randomness;var pk : pkey;var sk : skey;x = $uniform_rand;(pk,sk) = $keypairs;x’ = I.i(pk,(f pk x));return (x’ = x);

}}.

Page 38: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Random oracles (excerpts, and a bit of cheating)

module type Oracle ={ fun init():unit

fun o(x:from):to}.

module type O_ext = { fun o(x:from):to }.

theory ROM.module RO:Oracle = {

var m : (from, to) map

fun o(x:from) : to = {var y : to;y = $dsample;if (!in_dom x m) m.[x] = y;return (m.[x]);

}}.

Page 39: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Example: Bellare and Rogaway 1993 encryption

◮ plaintext is the type {0, 1}n of bitstrings of length n

◮ randomness is the type {0, 1}k of bitstrings of length k

◮ ciphertext is the type {0, 1}n+k of bitstrings of length n + k

fun enc(pk:pkey, m:plaintext): ciphertext = {var h, s : plaintext;var r : randomness;

r = ${0,1}k ;h = H.o(r);s = m ⊕ h;return ((f pk r) || s);

}

Page 40: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Security

For every IND-CPA adversary A, there exists an inverter I st

Pr[

IND-CPA(A) : b′ = b]

−1

2

≤ Pr[

OW(I) : x ′ = x]

Formal statement (omitting side conditions, simplified syntax)

forall &m (A <: Adv), exists (I <: Inverter),|Pr[CPA(BR,A).main() @ &m : b’ = b ] − (1%r / 2%r)| <=Pr[OW(I).main() @ &m : x’ = x].

Page 41: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

ProofGame hopping technique

Game INDCPA :(sk, pk) = K();(m0, m1) = A1(pk);b = ${0, 1};c∗ = Epk (mb);

b′ = A2(c∗);

return (b′ = b);

Encryption Epk (m) :

r = ${0, 1}ℓ;h = H(r);s = h ⊕ m;c = fpk (r) ‖ s;return c;

Game G :(sk, pk) = K();(m0, m1) = A1(pk);b = ${0, 1};c∗ = Epk (mb);

b′ = A2(c∗);

return (b′ = b);

Encryption Epk (m) :

r = ${0, 1}ℓ;

h = ${0, 1}k ;s = h ⊕ m;c = fpk (r) ‖ s;return c;

Game G′ :(sk, pk) = K();(m0, m1) = A1(pk);b = ${0, 1};c∗ = Epk (mb);

b′ = A2(c∗);

return (b′ = b);

Encryption Epk (m) :

r = ${0, 1}ℓ;

s = ${0, 1}k ;h = s ⊕ m;c = fpk (r) ‖ s;return c;

Game OW :(sk, pk) = K();

y = ${0, 1}ℓ;y′ = I(fpk (y));

return (y′ = y);

Adversary I(x) :(m0, m1) = A1(pk);

s = ${0, 1}k ;c∗ = x ‖ s;

b′ = A2(c∗);

y′ = [z∈LAH |fpk (z)=x ];

return y′

1. For each hop

◮ prove validity of pRHL judgment

◮ derive probability claim(s)

2. Obtain security bound by combining claims

3. Check execution time of constructed adversary

Page 42: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Conditional equivalence

Epk (m) :r = ${0, 1}ℓ;h = H(r);s = h ⊕ m;c = fpk (r) ‖ s;return c;

Epk (m) :r = ${0, 1}ℓ;

h = ${0, 1}k ;

s = h ⊕ m;c = fpk (r) ‖ s;return c;

IND-CPA ∼ G : ⊤ =⇒ (¬r ∈ LAH )〈2〉 ⇒ ≡

∣Pr[

IND-CPA : b′ = b]

− Pr[

G : b′ = b]∣

∣ ≤ Pr

[

G : r ∈ LAH

]

Page 43: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Equivalence

Epk (m) :r = ${0, 1}ℓ;

h = ${0, 1}k ;s = h ⊕ m;c = fpk (r) ‖ s;return c;

Epk (m) :r = ${0, 1}ℓ;

s = ${0, 1}k ;

h = s ⊕ m;c = fpk (r) ‖ s;return c;

G ∼ G′ : ⊤ =⇒ ≡

Pr

[

G : r ∈ LAH

]

= Pr

[

G′ : r ∈ LAH

]

Pr [G : b′ = b] = Pr [G′ : b′ = b] = 12

Page 44: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Equivalence

Epk (m) :r = ${0, 1}ℓ;

h = ${0, 1}k ;s = h ⊕ m;c = fpk (r) ‖ s;return c;

Epk (m) :r = ${0, 1}ℓ;

s = ${0, 1}k ;

h = s ⊕ m;c = fpk (r) ‖ s;return c;

G ∼ G′ : ⊤ =⇒ ≡

∣Pr [IND-CPA : b′ = b]− 12

∣ ≤ Pr

[

G′ : r ∈ LAH

]

Page 45: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Reduction

Game INDCPA :(sk , pk) = K();(m0,m1) = A1(pk);b = ${0, 1};c∗ = Epk (mb);

b′ = A2(c∗);

return (b′ = b)

Encryption Epk (m) :

r = ${0, 1}ℓ;

s = ${0, 1}k ;c = fpk (r) ‖ s;return c;

Game OW :(sk , pk) = K();

y = ${0, 1}ℓ;y ′ = I(fpk (y));return (y ′ = y);

Adversary I(x) :(m0,m1) = A1(pk);b = ${0, 1};

s = ${0, 1}k ;c∗ = x ‖ s;

b′ = A2(c∗);

y ′ = [z ∈ LAH | fpk (z) = x ];

return y ′;

G′ ∼ OW : ⊤ =⇒ (r ∈ LAH )〈1〉 ⇒ (y ′ = y)〈2〉

Pr

[

G′ : r ∈ LAH

]

≤ Pr [OW(I) : y ′ = y ]

Page 46: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Reduction

Game INDCPA :(sk , pk) = K();(m0,m1) = A1(pk);b = ${0, 1};c∗ = Epk (mb);

b′ = A2(c∗);

return (b′ = b)

Encryption Epk (m) :

r = ${0, 1}ℓ;

s = ${0, 1}k ;c = fpk (r) ‖ s;return c;

Game OW :(sk , pk) = K();

y = ${0, 1}ℓ;y ′ = I(fpk (y));return (y ′ = y);

Adversary I(x) :(m0,m1) = A1(pk);b = ${0, 1};

s = ${0, 1}k ;c∗ = x ‖ s;

b′ = A2(c∗);

y ′ = [z ∈ LAH | fpk (z) = x ];

return y ′;

G′ ∼ OW : ⊤ =⇒ (r ∈ LAH )〈1〉 ⇒ (y ′ = y)〈2〉

∣Pr [IND-CPA(A) : b′ = b]− 12

∣ ≤ Pr [OW(I) : y ′ = y ]

Page 47: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Remarks

◮ In EasyCrypt v0.2, reasoning principles are “embedded ” in

pRHL proofs for the concrete construction

◮ In EasyCrypt v1, one can

☞ prove high-level principles in an abstract setting

☞ instantiate principles

Benefits: much easier! Also favours

☞ libraries of verified high-level principles

☞ better proofs (shorter, faster, more robust)

Page 48: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Variations on IND-CPA

For every adversary A, there exists an adversary B st

Pr[

IND-CPA(A) : b′ = b]

−1

2

= Pr[

IND-CPA(B) : b′ = b]

−1

2

By case analysis on Pr [IND-CPA(A) : b′ = b] ≤ 12

◮ If true, then B returns the result of A

◮ If false, then B returns the negation of the result of A

Page 49: Introduction · EasyCrypt in a nusthell EasyCrypt is a tool-assisted platform for proving security of cryptographic constructions in the computational model Views cryptographic proofs

Summary

Provable security as deductive relational verification

of (open and parametrized) probabilistic programs

◮ EasyCrypt v1.0 is more explicit than its predecessor

◮ EasyCrypt v1.0 supports modular reasoning

◮ Shift of perspective (more instantiation, less pRHL)

◮ Should make tool more accessible to cryptographers