斯坦福密码学课程-笔记-01-Introduction绪论

2023-11-09

01-绪论 Introduction

Course Overview

Cryptography is everywhere

Secure communications:
web traffic: HTTPS
wireless traffic: 802.11i WPA2, GSM, Bluetooth
Encrypting files on disk: EFS, TrueCrypt
Content protection(e.g. DVD, Blu-ray): CSS, AACS
User authentication
… and much much more

Secure communication

Laptop ↔ \leftrightarrow web server
protocol: HTTPS (actrual protocol: SSL/TLS)

Make sure that as this data travels across the network:

  1. attacker can’t eavesdrop on this data
  2. attacker can’t modify the data while it’s in the network

[no eavesdropping, no tampering]

Secure Sockets Layer/TLS

Two main parts:

  1. Handshake Protocol: Establish shared secret key using public-key cryptography (2nd part of course)
  2. Record Layer: Transmit data using shared secret key
    Ensure confidentiality and integrity (1st part of course)

Protected files on disk

  1. attacker can’t read the contents in the file
  2. if the attacker tries to modify the data in the file while it’s on disk, it will be detected when decrypting this file

Analogous to secure communication:
Alice today sends a message to Alice tomorrow.

Building block: symmetric encryption

在这里插入图片描述
E, D: cipher
k: secret key(e.g. 128bits)
m, c: plaintext, ciphertext

Encryption algorithm is publicly known
Never use a proprietary cipher

Use Cases

Single use key: (one time key)
Key is only used to encrypt one message
e.g. encrypted email: new key generated for every email

Multi use key: (many time key)
Key used to encrypt multiple messages
e.g. encrypted files: same key used to encrypt many files
Need more machinery than for one-time key

Things to remember

Cryptography is:

  • A tremendous tool
  • The basis for many security mechanisms

Cryptography is not:

  • The solution to all security problems
  • Reliable unless implemented and used properly
  • Something you should try to invest yourself
    many many examples of broken ad-hoc designs

What is cryptography?

Crypto core

  • Secret key establishment
  • Secure communication

But crypto cand do much more

  • Digital signatures
  • Anonymous communication
  • Anonymous digital cash
    Can I spend a “digital coin” without anyone knowing who I am?
    How to prevent double spending?

Protocols

  • Examples:
    -Elections
    -Private auctions
  • Secure multi-party computation

Goal: compute f ( x 1 , x 2 , x 3 , x 4 ) f(x_1,x_2,x_3,x_4) f(x1,x2,x3,x4)
trusted authority?
“Thm:” anything that can be done with a trusted authority, can also be done without a trusted authority.

Crypto magic

  • Privately outsourcing computation
    在这里插入图片描述
  • Zero knowledge(proof of knowledge)
    在这里插入图片描述

A rigorous science

The three steps in cryptography:

  • Precisely specify threat model
  • Propose a construction
  • Prove that breaking construction under threat mode will solve an underlying hard problem

History

David Kahn, “The code breakers”(1996)

Symmetric Ciphers

在这里插入图片描述

Few Historic Examples (all badly broken)

1. Substitution cipher

e.g. Ceaser Cipher (no key)

Q: What is the size of key space in the substitution cipher assuming 26 letters?
A: 26 ! ≈ 2 88 26!\approx 2^{88} 26!288

How to break a substitution cipher?

Q: What is the most common letter in English text?
A: “E”

  1. Use frequency of English letters
  2. Use frequency of pairs of letters (diagrams)

2. Vigener cipher (16’th century, Rome)

在这里插入图片描述

3. Rotor Machines (1870-1943)

Early example: the Hebern machine (single rotor)
在这里插入图片描述
Most famous: the Enigma (3-5 rotors)
# rotor positions = 2 6 4 ≈ 2 18 26^4\approx 2^{18} 264218
[total # keys = 2 36 2^{36} 236 due to optional plugboard]

Data Encryption Standard (1974)

DES: # keys = 2 56 2^{56} 256, block size = 64 bits

Today: AES(2001), Salsa20(2008),… (and others)

Discrete Probability

U: finite set (e.g. U = { 0 , 1 } n U=\{0, 1\}^n U={0,1}n)
Def: Probability distribution P P P over U U U is a function P : U → [ 0 , 1 ] P: U\rightarrow [0, 1] P:U[0,1] such that ∑ x ∈ U P ( x ) = 1 \displaystyle\sum_{x\in U} P(x)=1 xUP(x)=1

Examples:

  1. Uniform distribution: for all x ∈ U x\in U xU: P ( x ) = 1 / ∣ U ∣ P(x)=1/|U| P(x)=1/U
  2. Point distribution at x 0 x_0 x0: P ( x 0 ) = 1 , ∀ x ≠ x 0 : P ( x ) = 0 P(x_0)=1, \forall x\not =x_0: P(x)=0 P(x0)=1,x=x0:P(x)=0

Distribution vector:
(Example) ( P ( 000 ) , P ( 001 ) , P ( 010 ) , . . . , P ( 111 ) ) (P(000), P(001), P(010), ..., P(111)) (P(000),P(001),P(010),...,P(111))

Event

  • For a set A ⊆ U : P r [ A ] = ∑ x ∈ A P ( x ) ∈ [ 0 , 1 ] A\subseteq U: Pr[A]=\displaystyle\sum _{x\in A}P(x)\in [0, 1] AU:Pr[A]=xAP(x)[0,1]
  • The set A A A is called an event
  • note: P r [ U ] = 1 Pr[U]=1 Pr[U]=1

Example:
U = { 0 , 1 } 8 U=\{ 0, 1\}^8 U={0,1}8
A = { A=\{ A={all x x x in U U U that l s b 2 ( x ) = 11 } ⊆ U lsb_2(x)=11\}\subseteq U lsb2(x)=11}U
for the uniform distribution on { 0 , 1 } 8 \{ 0, 1\}^8 {0,1}8 P r [ A ] = 1 / 4 Pr[A]=1/4 Pr[A]=1/4

[ l s b 2 ( x ) = 11 lsb_2(x)=11 lsb2(x)=11: the two least significant bits of the byte is “11”]

The union bond

For events A 1 A_1 A1 and A 2 A_2 A2
P r [ A 1 ∪ A 2 ] ≤ P r [ A 1 ] + P r [ A 2 ] Pr[A_1\cup A_2]\leq Pr[A_1]+Pr[A_2] Pr[A1A2]Pr[A1]+Pr[A2]

A 1 ∩ A 2 = Φ    ⟹    P r [ A 1 ] ∪ A 2 = P r [ A 1 ] + P r [ A 2 ] A_1\cap A_2=\Phi \implies Pr[A_1]\cup A_2= Pr[A_1]+Pr[A_2] A1A2=ΦPr[A1]A2=Pr[A1]+Pr[A2]

Example:
A 1 = { A_1=\{ A1={all x x x in { 0 , 1 } n \{0,1\}^n {0,1}n s.t. l s b 2 ( x ) = 11 } lsb_2(x)=11\} lsb2(x)=11}
A 2 = { A_2=\{ A2={all x x x in { 0 , 1 } n \{0,1\}^n {0,1}n s.t. m s b 2 ( x ) = 11 } msb_2(x)=11\} msb2(x)=11}

P r [ l s b 2 ( x ) = 11 Pr[lsb_2(x)=11 Pr[lsb2(x)=11 or m s b 2 ( x ) = 11 ] = P r [ A 1 ∪ A 2 ] ≤ 1 / 4 + 1 / 4 = 1 / 2 msb_2(x)=11]=Pr[A_1\cup A_2]\leq 1/4+1/4=1/2 msb2(x)=11]=Pr[A1A2]1/4+1/4=1/2

[ l s b 2 ( x ) = 11 lsb_2(x)=11 lsb2(x)=11: end with “11”]
[ m s b 2 ( x ) = 11 msb_2(x)=11 msb2(x)=11: begin with “11”]

Random Variables

Def: a random variable X X X is a function X : U → V X: U\rightarrow V X:UV

Example:
X : { 0 , 1 } n → { 0 , 1 } X: \{ 0, 1\}^n\rightarrow\{0, 1\} X:{0,1}n{0,1}
X ( y ) = l s b ( y ) ∈ { 0 , 1 } X(y)=lsb(y)\in \{0, 1\} X(y)=lsb(y){0,1}

For the uniform distribution on U U U:
P r [ X = 0 ] = 1 / 2 , P r [ X = 1 ] = 1 / 2 Pr[X=0]=1/2, Pr[X=1]=1/2 Pr[X=0]=1/2,Pr[X=1]=1/2
在这里插入图片描述
More generally:
rand.var. X X X induces a distribution on V V V: P r [ X = v ] : = P r [ X − 1 ( v ) ] Pr[X=v]:=Pr[X^{-1}(v)] Pr[X=v]:=Pr[X1(v)]

[ X − 1 ( v ) X^{-1}(v) X1(v): a a a for X ( a ) = v X(a)=v X(a)=v]
Formally we say that the probability that X X X outputs v v v, is the same as the probability of the event that when we sample a random element in the universe, we fall into the pre-image of v v v under the function X X X.

The uniform random variable

Let U U U be some set, e.g. U = { 0 , 1 } n U=\{0, 1\}^n U={0,1}n
We write r ← R U r\xleftarrow{R}U rR U to donate a uniform random variable over U U U
for all a ∈ U a\in U aU: P r [ r = a ] = 1 / ∣ U ∣ Pr[r=a]=1/|U| Pr[r=a]=1/U
(formally, r r r is the identity function: r ( x ) = x r(x)=x r(x)=x for all x ∈ U x\in U xU)

Example:
Let r r r be a uniform random variable on { 0 , 1 } 2 \{ 0, 1\}^2 {0,1}2
Define the random variable X = r 1 + r 2 X=r_1+r_2 X=r1+r2
Then P r [ X = 2 ] = 1 / 4 Pr[X=2]=1/4 Pr[X=2]=1/4

(Hint: P r [ X = 2 ] = P r [ r = 11 ] Pr[X=2]=Pr[r=11] Pr[X=2]=Pr[r=11])

Randomized algorithms

Deterministic algorithm: y ← A ( m ) y\leftarrow A(m) yA(m)

Randomized algorithm:
y ← A ( m ; r ) y\leftarrow A(m;r) yA(m;r) where r ← R { 0 , 1 } n r\xleftarrow{R}\{0, 1\}^n rR {0,1}n
output is a random variable
y ← R A ( m ) y\xleftarrow{R}A(m) yR A(m)

Example:
A ( m ; k ) = E ( k , m ) A(m;k)=E(k, m) A(m;k)=E(k,m), y ← R A ( m ) y\xleftarrow{R}A(m) yR A(m)

Independence

Def: events A and B independent if P r [ A Pr[A Pr[A and B ] = P r [ A ] ⋅ P r [ B ] B]=Pr[A]\cdot Pr[B] B]=Pr[A]Pr[B]
random variables X, Y taking values in V are independent if ∀ a , b ∈ V : P r [ X = a \forall a,b\in V: Pr[X=a a,bV:Pr[X=a and Y = b ] = P r [ X = a ] ⋅ P r [ Y = b ] Y=b]=Pr[X=a]\cdot Pr[Y=b] Y=b]=Pr[X=a]Pr[Y=b]

Example:
U = { 0 , 1 } 2 = { 00 , 01 , 10 , 11 } U=\{ 0, 1\}^2=\{00, 01, 10, 11\} U={0,1}2={00,01,10,11} and r ← R U r\xleftarrow{R}U rR U
Define random variables X X X and Y Y Y as: X = l s b ( r ) X=lsb(r) X=lsb(r), Y = m s b ( r ) Y=msb(r) Y=msb(r)
P r [ X = 0 Pr[X=0 Pr[X=0 and Y = 0 ] = P r [ r = 00 ] = 1 / 4 = P r [ X = 0 ] ⋅ P r [ Y = 0 ] Y=0]=Pr[r=00]=1/4=Pr[X=0]\cdot Pr[Y=0] Y=0]=Pr[r=00]=1/4=Pr[X=0]Pr[Y=0]

XOR

XOR of two strings in { 0 , 1 } n \{ 0, 1\}^n {0,1}n is their bit-wise addition mod 2

An important property of XOR

Y Y Y is a random variable over { 0 , 1 } n \{ 0, 1\}^n {0,1}n
X X X is a uniform random variable over { 0 , 1 } n \{ 0, 1\}^n {0,1}n
X X X and Y Y Y are independent
Then: Z : = Y ⊕ X Z:=Y\oplus X Z:=YX is a uniform variable on { 0 , 1 } n \{ 0, 1\}^n {0,1}n

Proof: (for n=1)
P r [ Z = 0 ] = P r [ ( X , Y ) = ( 0 , 0 ) Pr[Z=0]=Pr[(X,Y)=(0,0) Pr[Z=0]=Pr[(X,Y)=(0,0) or ( X , Y ) = ( 1 , 1 ) ] = P r [ ( X , Y ) = ( 0 , 0 ) ] ⋅ P r [ ( X , Y ) = ( 1 , 1 ) ] = 1 / 2 (X,Y)=(1,1)]=Pr[(X,Y)=(0,0)]\cdot Pr[(X,Y)=(1,1)]=1/2 (X,Y)=(1,1)]=Pr[(X,Y)=(0,0)]Pr[(X,Y)=(1,1)]=1/2
在这里插入图片描述

The birthday paradox

Let r 1 , r 2 , . . . , r n ∈ U r_1, r_2, ..., r_n\in U r1,r2,...,rnU be independent identically distributed random variables.
when n = 1.2 × ∣ U ∣ 1 / 2 n=1.2\times |U|^{1/2} n=1.2×U1/2 then P r [ ∃ i ≠ j : r i = r j ] ≥ 1 / 2 Pr[\exist i\not = j: r_i=r_j]\geq 1/2 Pr[i=j:ri=rj]1/2
[notation: ∣ U ∣ |U| U is the size of U U U]

Example:
Let U = { 0 , 1 } 128 U=\{ 0, 1\}^{128} U={0,1}128
After sampling about 2 64 2^{64} 264 random messages from U U U, some two sampled messages will likely be the same.
在这里插入图片描述

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

斯坦福密码学课程-笔记-01-Introduction绪论 的相关文章

随机推荐

  • Elasticsearch内存那些事儿

    Elasticsearch 内存分配设置详解 前言 该给 ES 分配多少内存 为什么是给 ES 分配服务器的一半内存 为什么内存使用率不断升高 没有释放 为何经常有某个 field 的数据量超出内存限制的异常 为何感觉上没多少数据 也会经常
  • TCP协议 ---可靠传输的各种机制

    目录 一 可靠 确认应答机制 保证数据可靠 有序的到达对端 超时重传机制 二 效率 2 1 提高自身发送数据量 滑动窗口机制 滑动窗口的发送缓冲区是环形队列 滑动窗口的大小会变化吗 滑动窗口的nb之处 滑动窗口丢包问题 2 2 对方的接受能
  • twrp3.3.0刷n9002_【笔刷】iPad Procreate5.0新笔刷分享,巨好用!

    01 Procreate 趣味复古蜡笔纹理笔刷15款 适用软件 Procreate5 0以上 适用系统 ipad系统 笔刷格式 brushset 素材大小 93MB 笔刷视频演示 赠送15款笔刷 29款色卡 一张纸张背景 02 Procre
  • 树莓派Pico

    9 2 在MS Windows上构建 在Microsoft Windows 10或Windows 11上安装工具链与其他平台有些不同 然而安装后 RP2040的构建代码基本类似 Tips 什么是工具链 工具链是指一系列软件 逐个使用这一系列
  • docker run中-v参数的用法解释

    作用 挂载宿主机的一个目录 如 docker run it v 宿主机目录 容器目录 镜像名 bin bash 这里 it是参数作用是 i 以交互模式运行容器 通常与 t 同时使用 t 为容器重新分配一个伪输入终端 通常与 i 同时使用 就
  • keil编译时候产生的错误(Error: L6200E: Symbol....)解决方法

    今天分享一个自己在做实验时候发现的一个错误问题 查了一下网上也有人遇到这样的问题 就拿出来分享了一下自己遇到的情况 首先看keil的错误提示 如图所示 可以看到两个报错为 Error L6200E Symbol usart3 init mu
  • CV Code

    点击我爱计算机视觉标星 更快获取CVML新技术 计算机视觉技术发展迅速 很多时候 可悲的不是我们没有努力 而是没有跟上时代的步伐 努力coding终于出来结果了 却发现早就有人开源了 效果还比自己写的好 CV君汇总了最近过去的一周新出的开源
  • 【Matlab】将Matlab里的几个变量一个存成csv文件

    注意 几个变量类型可以不同 但是长度必须相同 举例说明 1 比如说在workspace里已经有两个变量 a和b如图 每个变量为1列 想把这两个变量存成一个csv文件 2 先给这两个变量名起个名字 分别为A B 存入 datacolumns
  • 数据属性类型

    数据集由数据对象组成 一个数据对象代表一个实体 数据对象又称样本 实例 数据点或对象 属性 attribute 是一个数据字段 表示数据对象的一个特征 属性向量 或特征向量 是用来描述一个给定对象的一组属性 属性有不同类型 标称属性 nom
  • python面试题

    文章目录 Python面试基础题小汇总 1 Python是如何进行内存管理的 2 什么是lambda函数 它有什么好处 3 Python里面如何实现tuple和list的转换 4 请写出一段Python代码实现删除一个list里面的重复元素
  • 常用的运算放大器电路

    在线仿真网站 http scratch trtos com circuitjs html 一 反向比例放大电路 二 同向比例放大电路 三 电压跟随器 四 反向求和运算电路 五 同向求和运算电路 六 加减法运算放大器 七 差分放大器 八 积分
  • 关于自制CMSIS_DAP离线下载器下载算法的代码说明:“0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA“

    关于自制CMSIS DAP离线下载器下载算法的代码说明 0xE00ABE00 0x062D780D 0x24084068 0xD3000040 0x1E644058 0x1C49D1FA 在自制CMSIS DAP离线下载器的时候 利用FLM
  • Mysql篇-第2章,什么是脏读、幻读、不可重复读?如何处理?

    一 Mysql进行事务并发控制时经常遇到的问题 脏读 在事务进行中 读到了其他事务未提交的数据 举个例子 有一个table表 如果执行顺序如下 这种情况下左边查询的结果会是101 正是因为读取到了另一个事务未提交的数据 幻读 在一个事务中
  • selenium 获取cookie 并使用

    selenium 获取cookie 参数设置 以获取阿里云cookie范例 from selenium import webdriver import json url https account aliyun com login logi
  • 使用Python的方式理解Golang的结构体struct

    Go源码 package GoTools import fmt 定义结构体存储密码 type Config struct password string func InitConfig password string Config c ne
  • Vue用户进行页面切换(路由跳转)时,动态改变路由的动画(transition效果)

    当我们在使用Vue Router时 为了用户有更好的视觉效果及体验 我们通常需要实现基于路由的动态过渡效果 github https github com Rise Devin FullStack Product Transport Use
  • retinaface代码讲解_「干货」RetinaFace最强开源人脸识别算法

    看来最早商业化的人脸检测为目标检测算法 依然是各大CV方向AI公司的必争之地 那我们今天主角就是RetinaFace RetinaFace 是今年5月份出现的人脸检测算法 当时取得了state of the art 作者也开源了代码 过去了
  • 集合的知识

    集合 collection集合的常用方法 collection的特点 Collection代表单列集合 每个元素 数据 只包含一个值 Map代表双列集合 每个元素包含两个值 键值对 Collection集合特点 由于collection是一
  • gRpc指南

    本文翻译自官网 原文 https grpc io docs languages java quickstart 快速开始 下面通过一个简单的样例 让你快速上手基于java的gRpc的使用 前置条件 JDK7以上版本 获取示例代码 示例代码是
  • 斯坦福密码学课程-笔记-01-Introduction绪论

    斯坦福密码学课程笔记 01 绪论 Introduction Course Overview Cryptography is everywhere Secure communication Secure Sockets Layer TLS P