diff --git a/.gitignore b/.gitignore index 57510a2..ab35e56 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ _site/ +.jekyll-cache/ diff --git a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/29/c4ddad0b5b07ee5b1fec1d50613fcaafd570128f39296074057a70f65d36b6 b/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/29/c4ddad0b5b07ee5b1fec1d50613fcaafd570128f39296074057a70f65d36b6 deleted file mode 100644 index 8618dbf..0000000 --- a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/29/c4ddad0b5b07ee5b1fec1d50613fcaafd570128f39296074057a70f65d36b6 +++ /dev/null @@ -1,61 +0,0 @@ -I"ą

Elliptic Curves

-

These curves have the form $y^{2} = x^{3} + ax + b$.

- -

For the purposes of cryptography, those elliptic curves are considered whose variables and coefficients are restricted to a finite field (either $Z_{p}$ or $GF(2^{n})$; we will consider only the former).

- -

Elliptic Curves over $Z_{p}$

-

We consider the congruence $y^{2} \equiv x^{3} + ax + b$ (mod $p$), where $a$ and $b$ are constants in $Z_{p}$ such that $4a^{3} + 27b^{2} \not\equiv 0$ (mod $p$). This is equivalent to the set $E_{p}(a,b)$, consisting of solutions to the congruence together with the point at infinity $\mathfrak{O}$.

- -

The number of points in $E_{p}(a,b)$ is denoted by $\mypound E$ and satisfies $p + 1 - 2\sqrt{p} \leq \mypound E \leq p + 1 + 2\sqrt{p}$.

- -

A binary operation, called “addition” and denoted by $+$, is defined on $E_{p}(a,b)$. Under this operation, $E_{p}(a,b)$ forms an abelian group. Refer to slides (21 to 26) for details of addition, doubling, scalar multiplication and additive inverses of points.

- -

Elliptic Curve Cryptography (ECC)

-

ECC relies on the computational infeasibility of determining $k$ given $kP$ and $P$, even though it is relatively easy to determine $kP$ given $k$ and $P$. This is called the elliptic curve discrete logarithm problem (ECDLP).

- -

Hierarchical Access Control using ECC

-

Refer to slides (32 to 34) for a general overview of hierarchical access control. In the system described by Chung et al., the security classes having higher clearance use publicly available information to determine the secret keys of any lower-clearance classes. Here and elsewhere, the terms “higher-clearance class” and “lower-clearance class” are equivalent to “predecessor class” and “successor class” respectively.

- -

Relationship-building Phase

-

The central authority or CA determines the hierarchical structure among the security classes and their relative clearances.

- -

Key Generation Phase

-

First, a large prime $p$, an elliptic curve $E_{p}(a,b)$ and a function $m: E_{p}(a,b) \rightarrow \mathbb{Z}$ over $Z_{p}$ are selected.

- -

For each security class $SC_{j}$, the CA now:

- -

Step 1. Assigns a base point $G_{j}$, a secret key $sk_{j}$ and a sub-secret key $s_{j}$.

- -

Step 2. Computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$ for all predecessor classes $SC_{i}$ of $SC_{j}$. In other words, it computes the product of the base point with the sub-secret key of each of the higher-clearance classes. The resulting point is converted into a number $m(a_{j,i},b_{j,i})$ using the function $m(\cdot)$.

- -

Step 3. Computes a polynomial $f_{j}(x)$ using the above numbers as:

- -

$f_{j}(x) \equiv \prod_{SC_{i} \geq SC_{j}} (x - m(a_{j,i},b_{j,i})) + sk_{j}$ (mod $p$). [*]

- -

Step 4. Sends $sk_{j}$ and $s_{j}$ through a secure channel and announces $p$, $m(\cdot)$, $G_{j}$ and $f_{j}(x)$ publicly.

- -

[*] Note that the zeroes of $f_{j}(x) - sk_{j}$ are the numbers obtained from $s_{i}G_{j}$ using $m(\cdot)$.

- -

Key Derivation Phase

-

In this phase, a security class $SC_{i}$ finds the secret keys $sk_{j}$ of all successor classes $SC_{j} \geq SC_{i}$, i.e., all classes with lower clearance.

- -

First it computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$, i.e., multiplies its sub-secret key with the lower class’s base point. It converts this point to a number using $m(\cdot)$. This number is $m(a_{j,i},b_{j,i})$.

- -

By the definiton of $f_{j}$, this number is a root of $f_{j}(x) - sk_{j}$, i.e., $f_{j}(m(a_{j,i},b_{j,i})) - sk_{j} \equiv 0$ (mod $p$). Therefore, $f_{j}(m(a_{j,i},b_{j,i})) \equiv sk_{j}$ (mod $p$), and $SC_{i}$ has found $sk_{j}$.

- -

Note. The function $m(x,y)$ is generally defined using a hash function as $m(x,y) = h(x \Vert y)$, where $\Vert$ is a bit concatenation operator. The intermediate $m(\cdot)$ was introduced in this description for convenience.

- -

An Example

-

Let us assume that the CA has completed the relationship-building phase and the key generation phase. Further, suppose that $SC_{2}$ would like to find the secret key $sk_{5}$ of its successor class $SC_{5}$. Other predecessor classes of $SC_{5}$ are, say, $SC_{1}$ and $SC_{4}$.

- -

Therefore, for $SC_{5}$, the CA has computed $s_{1}G_{5} = (a_{5,1},b_{5,1})$, $s_{2}G_{5} = (a_{5,2},b_{5,2})$ and $s_{4}G_{5} = (a_{5,4},b_{5,4})$. From these, the public polynomial $f_{5}$ is computed and announced: $f_{5} \equiv (x - m(a_{5,1},b_{5,1}))(x - m(a_{5,2},b_{5,2}))(x - m(a_{5,4},b_{5,4})) + sk_{5}$ (mod $p$).

- -

Now, $SC_{2}$ needs to find $sk_{5}$. It does this using $s_{2}$ (which only it knows), $m(\cdot)$, $G_{5}$ and $f_{5}$ (which are public).

- -

First, it computes $s_{2}G_{5} = (a_{5,2},b_{5,2})$. This is converted to a number using $m(\cdot)$ ( i.e., $m(a_{5,2},b_{5,2})$ is calculated) and substituted in $f_{5}(x)$.

- -

By the definiton of $f_{5}$, this number is a root of $f_{5}(x) - sk_{5}$. Therefore, $f_{5}(m(a_{5,2},b_{5,2})) \equiv sk_{5}$ (mod $p$), and $SC_{2}$ has found $sk_{5}$.

- -

It is clear the successor classes of $SC_{5}$ have no way to determine $sk_{5}$ using $f_{5}$.

- -:ET \ No newline at end of file diff --git a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/37/2e0e2cadfb98a5b94ad69057fe9eed58dbb26296654cee8329864cac78f18a b/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/37/2e0e2cadfb98a5b94ad69057fe9eed58dbb26296654cee8329864cac78f18a deleted file mode 100644 index 394498e..0000000 --- a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/37/2e0e2cadfb98a5b94ad69057fe9eed58dbb26296654cee8329864cac78f18a +++ /dev/null @@ -1,61 +0,0 @@ -I"«

Elliptic Curves

-

These curves have the form $y^{2} = x^{3} + ax + b$.

- -

For the purposes of cryptography, those elliptic curves are considered whose variables and coefficients are restricted to a finite field (either $Z_{p}$ or $GF(2^{n})$; we will consider only the former).

- -

Elliptic Curves over $Z_{p}$

-

We consider the congruence $y^{2} \equiv x^{3} + ax + b$ (mod $p$), where $a$ and $b$ are constants in $Z_{p}$ such that $4a^{3} + 27b^{2} \not\equiv 0$ (mod $p$). This is equivalent to the set $E_{p}(a,b)$, consisting of solutions to the congruence together with the point at infinity $\mathfrak{O}$.

- -

The number of points in $E_{p}(a,b)$ is denoted by $# E$ and satisfies $p + 1 - 2\sqrt{p} \leq # E \leq p + 1 + 2\sqrt{p}$.

- -

A binary operation, called “addition” and denoted by $+$, is defined on $E_{p}(a,b)$. Under this operation, $E_{p}(a,b)$ forms an abelian group. Refer to slides (21 to 26) for details of addition, doubling, scalar multiplication and additive inverses of points.

- -

Elliptic Curve Cryptography (ECC)

-

ECC relies on the computational infeasibility of determining $k$ given $kP$ and $P$, even though it is relatively easy to determine $kP$ given $k$ and $P$. This is called the elliptic curve discrete logarithm problem (ECDLP).

- -

Hierarchical Access Control using ECC

-

Refer to slides (32 to 34) for a general overview of hierarchical access control. In the system described by Chung et al., the security classes having higher clearance use publicly available information to determine the secret keys of any lower-clearance classes. Here and elsewhere, the terms “higher-clearance class” and “lower-clearance class” are equivalent to “predecessor class” and “successor class” respectively.

- -

Relationship-building Phase

-

The central authority or CA determines the hierarchical structure among the security classes and their relative clearances.

- -

Key Generation Phase

-

First, a large prime $p$, an elliptic curve $E_{p}(a,b)$ and a function $m: E_{p}(a,b) \rightarrow \mathbb{Z}$ over $Z_{p}$ are selected.

- -

For each security class $SC_{j}$, the CA now:

- -

Step 1. Assigns a base point $G_{j}$, a secret key $sk_{j}$ and a sub-secret key $s_{j}$.

- -

Step 2. Computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$ for all predecessor classes $SC_{i}$ of $SC_{j}$. In other words, it computes the product of the base point with the sub-secret key of each of the higher-clearance classes. The resulting point is converted into a number $m(a_{j,i},b_{j,i})$ using the function $m(\cdot)$.

- -

Step 3. Computes a polynomial $f_{j}(x)$ using the above numbers as:

- -

$f_{j}(x) \equiv \prod_{SC_{i} \geq SC_{j}} (x - m(a_{j,i},b_{j,i})) + sk_{j}$ (mod $p$). [*]

- -

Step 4. Sends $sk_{j}$ and $s_{j}$ through a secure channel and announces $p$, $m(\cdot)$, $G_{j}$ and $f_{j}(x)$ publicly.

- -

[*] Note that the zeroes of $f_{j}(x) - sk_{j}$ are the numbers obtained from $s_{i}G_{j}$ using $m(\cdot)$.

- -

Key Derivation Phase

-

In this phase, a security class $SC_{i}$ finds the secret keys $sk_{j}$ of all successor classes $SC_{j} \geq SC_{i}$, i.e., all classes with lower clearance.

- -

First it computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$, i.e., multiplies its sub-secret key with the lower class’s base point. It converts this point to a number using $m(\cdot)$. This number is $m(a_{j,i},b_{j,i})$.

- -

By the definiton of $f_{j}$, this number is a root of $f_{j}(x) - sk_{j}$, i.e., $f_{j}(m(a_{j,i},b_{j,i})) - sk_{j} \equiv 0$ (mod $p$). Therefore, $f_{j}(m(a_{j,i},b_{j,i})) \equiv sk_{j}$ (mod $p$), and $SC_{i}$ has found $sk_{j}$.

- -

Note. The function $m(x,y)$ is generally defined using a hash function as $m(x,y) = h(x \Vert y)$, where $\Vert$ is a bit concatenation operator. The intermediate $m(\cdot)$ was introduced in this description for convenience.

- -

An Example

-

Let us assume that the CA has completed the relationship-building phase and the key generation phase. Further, suppose that $SC_{2}$ would like to find the secret key $sk_{5}$ of its successor class $SC_{5}$. Other predecessor classes of $SC_{5}$ are, say, $SC_{1}$ and $SC_{4}$.

- -

Therefore, for $SC_{5}$, the CA has computed $s_{1}G_{5} = (a_{5,1},b_{5,1})$, $s_{2}G_{5} = (a_{5,2},b_{5,2})$ and $s_{4}G_{5} = (a_{5,4},b_{5,4})$. From these, the public polynomial $f_{5}$ is computed and announced: $f_{5} \equiv (x - m(a_{5,1},b_{5,1}))(x - m(a_{5,2},b_{5,2}))(x - m(a_{5,4},b_{5,4})) + sk_{5}$ (mod $p$).

- -

Now, $SC_{2}$ needs to find $sk_{5}$. It does this using $s_{2}$ (which only it knows), $m(\cdot)$, $G_{5}$ and $f_{5}$ (which are public).

- -

First, it computes $s_{2}G_{5} = (a_{5,2},b_{5,2})$. This is converted to a number using $m(\cdot)$ ( i.e., $m(a_{5,2},b_{5,2})$ is calculated) and substituted in $f_{5}(x)$.

- -

By the definiton of $f_{5}$, this number is a root of $f_{5}(x) - sk_{5}$. Therefore, $f_{5}(m(a_{5,2},b_{5,2})) \equiv sk_{5}$ (mod $p$), and $SC_{2}$ has found $sk_{5}$.

- -

It is clear the successor classes of $SC_{5}$ have no way to determine $sk_{5}$ using $f_{5}$.

- -:ET \ No newline at end of file diff --git a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/ae/8b9de44a83c542582581c5ff532ad98c6000788089f15478032c385a23c6ce b/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/ae/8b9de44a83c542582581c5ff532ad98c6000788089f15478032c385a23c6ce deleted file mode 100644 index f56a058..0000000 --- a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/ae/8b9de44a83c542582581c5ff532ad98c6000788089f15478032c385a23c6ce +++ /dev/null @@ -1,61 +0,0 @@ -I"©

Elliptic Curves

-

These curves have the form $y^{2} = x^{3} + ax + b$.

- -

For the purposes of cryptography, those elliptic curves are considered whose variables and coefficients are restricted to a finite field (either $Z_{p}$ or $GF(2^{n})$; we will consider only the former).

- -

Elliptic Curves over $Z_{p}$

-

We consider the congruence $y^{2} \equiv x^{3} + ax + b$ (mod $p$), where $a$ and $b$ are constants in $Z_{p}$ such that $4a^{3} + 27b^{2} \not\equiv 0$ (mod $p$). This is equivalent to the set $E_{p}(a,b)$, consisting of solutions to the congruence together with the point at infinity $\mathfrak{O}$.

- -

The number of points in $E_{p}(a,b)$ is denoted by $#E$ and satisfies $p + 1 - 2\sqrt{p} \leq #E \leq p + 1 + 2\sqrt{p}$.

- -

A binary operation, called “addition” and denoted by $+$, is defined on $E_{p}(a,b)$. Under this operation, $E_{p}(a,b)$ forms an abelian group. Refer to slides (21 to 26) for details of addition, doubling, scalar multiplication and additive inverses of points.

- -

Elliptic Curve Cryptography (ECC)

-

ECC relies on the computational infeasibility of determining $k$ given $kP$ and $P$, even though it is relatively easy to determine $kP$ given $k$ and $P$. This is called the elliptic curve discrete logarithm problem (ECDLP).

- -

Hierarchical Access Control using ECC

-

Refer to slides (32 to 34) for a general overview of hierarchical access control. In the system described by Chung et al., the security classes having higher clearance use publicly available information to determine the secret keys of any lower-clearance classes. Here and elsewhere, the terms “higher-clearance class” and “lower-clearance class” are equivalent to “predecessor class” and “successor class” respectively.

- -

Relationship-building Phase

-

The central authority or CA determines the hierarchical structure among the security classes and their relative clearances.

- -

Key Generation Phase

-

First, a large prime $p$, an elliptic curve $E_{p}(a,b)$ and a function $m: E_{p}(a,b) \rightarrow \mathbb{Z}$ over $Z_{p}$ are selected.

- -

For each security class $SC_{j}$, the CA now:

- -

Step 1. Assigns a base point $G_{j}$, a secret key $sk_{j}$ and a sub-secret key $s_{j}$.

- -

Step 2. Computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$ for all predecessor classes $SC_{i}$ of $SC_{j}$. In other words, it computes the product of the base point with the sub-secret key of each of the higher-clearance classes. The resulting point is converted into a number $m(a_{j,i},b_{j,i})$ using the function $m(\cdot)$.

- -

Step 3. Computes a polynomial $f_{j}(x)$ using the above numbers as:

- -

$f_{j}(x) \equiv \prod_{SC_{i} \geq SC_{j}} (x - m(a_{j,i},b_{j,i})) + sk_{j}$ (mod $p$). [*]

- -

Step 4. Sends $sk_{j}$ and $s_{j}$ through a secure channel and announces $p$, $m(\cdot)$, $G_{j}$ and $f_{j}(x)$ publicly.

- -

[*] Note that the zeroes of $f_{j}(x) - sk_{j}$ are the numbers obtained from $s_{i}G_{j}$ using $m(\cdot)$.

- -

Key Derivation Phase

-

In this phase, a security class $SC_{i}$ finds the secret keys $sk_{j}$ of all successor classes $SC_{j} \geq SC_{i}$, i.e., all classes with lower clearance.

- -

First it computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$, i.e., multiplies its sub-secret key with the lower class’s base point. It converts this point to a number using $m(\cdot)$. This number is $m(a_{j,i},b_{j,i})$.

- -

By the definiton of $f_{j}$, this number is a root of $f_{j}(x) - sk_{j}$, i.e., $f_{j}(m(a_{j,i},b_{j,i})) - sk_{j} \equiv 0$ (mod $p$). Therefore, $f_{j}(m(a_{j,i},b_{j,i})) \equiv sk_{j}$ (mod $p$), and $SC_{i}$ has found $sk_{j}$.

- -

Note. The function $m(x,y)$ is generally defined using a hash function as $m(x,y) = h(x \Vert y)$, where $\Vert$ is a bit concatenation operator. The intermediate $m(\cdot)$ was introduced in this description for convenience.

- -

An Example

-

Let us assume that the CA has completed the relationship-building phase and the key generation phase. Further, suppose that $SC_{2}$ would like to find the secret key $sk_{5}$ of its successor class $SC_{5}$. Other predecessor classes of $SC_{5}$ are, say, $SC_{1}$ and $SC_{4}$.

- -

Therefore, for $SC_{5}$, the CA has computed $s_{1}G_{5} = (a_{5,1},b_{5,1})$, $s_{2}G_{5} = (a_{5,2},b_{5,2})$ and $s_{4}G_{5} = (a_{5,4},b_{5,4})$. From these, the public polynomial $f_{5}$ is computed and announced: $f_{5} \equiv (x - m(a_{5,1},b_{5,1}))(x - m(a_{5,2},b_{5,2}))(x - m(a_{5,4},b_{5,4})) + sk_{5}$ (mod $p$).

- -

Now, $SC_{2}$ needs to find $sk_{5}$. It does this using $s_{2}$ (which only it knows), $m(\cdot)$, $G_{5}$ and $f_{5}$ (which are public).

- -

First, it computes $s_{2}G_{5} = (a_{5,2},b_{5,2})$. This is converted to a number using $m(\cdot)$ ( i.e., $m(a_{5,2},b_{5,2})$ is calculated) and substituted in $f_{5}(x)$.

- -

By the definiton of $f_{5}$, this number is a root of $f_{5}(x) - sk_{5}$. Therefore, $f_{5}(m(a_{5,2},b_{5,2})) \equiv sk_{5}$ (mod $p$), and $SC_{2}$ has found $sk_{5}$.

- -

It is clear the successor classes of $SC_{5}$ have no way to determine $sk_{5}$ using $f_{5}$.

- -:ET \ No newline at end of file diff --git a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/e9/b5f11945fc22d1bc0ee79f7a7212c4dea52f3f88fcacbc3c251cc3cc841519 b/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/e9/b5f11945fc22d1bc0ee79f7a7212c4dea52f3f88fcacbc3c251cc3cc841519 deleted file mode 100644 index 6afbce3..0000000 --- a/.jekyll-cache/Jekyll/Cache/Jekyll--Converters--Markdown/e9/b5f11945fc22d1bc0ee79f7a7212c4dea52f3f88fcacbc3c251cc3cc841519 +++ /dev/null @@ -1,61 +0,0 @@ -I"Ş

Elliptic Curves

-

These curves have the form $y^{2} = x^{3} + ax + b$.

- -

For the purposes of cryptography, those elliptic curves are considered whose variables and coefficients are restricted to a finite field (either $Z_{p}$ or $GF(2^{n})$; we will consider only the former).

- -

Elliptic Curves over $Z_{p}$

-

We consider the congruence $y^{2} \equiv x^{3} + ax + b$ (mod $p$), where $a$ and $b$ are constants in $Z_{p}$ such that $4a^{3} + 27b^{2} \not\equiv 0$ (mod $p$). This is equivalent to the set $E_{p}(a,b)$, consisting of solutions to the congruence together with the point at infinity $\mathfrak{O}$.

- -

The number of points in $E_{p}(a,b)$ is denoted by #$E$ and satisfies $p + 1 - 2\sqrt{p} \leq # E \leq p + 1 + 2\sqrt{p}$.

- -

A binary operation, called “addition” and denoted by $+$, is defined on $E_{p}(a,b)$. Under this operation, $E_{p}(a,b)$ forms an abelian group. Refer to slides (21 to 26) for details of addition, doubling, scalar multiplication and additive inverses of points.

- -

Elliptic Curve Cryptography (ECC)

-

ECC relies on the computational infeasibility of determining $k$ given $kP$ and $P$, even though it is relatively easy to determine $kP$ given $k$ and $P$. This is called the elliptic curve discrete logarithm problem (ECDLP).

- -

Hierarchical Access Control using ECC

-

Refer to slides (32 to 34) for a general overview of hierarchical access control. In the system described by Chung et al., the security classes having higher clearance use publicly available information to determine the secret keys of any lower-clearance classes. Here and elsewhere, the terms “higher-clearance class” and “lower-clearance class” are equivalent to “predecessor class” and “successor class” respectively.

- -

Relationship-building Phase

-

The central authority or CA determines the hierarchical structure among the security classes and their relative clearances.

- -

Key Generation Phase

-

First, a large prime $p$, an elliptic curve $E_{p}(a,b)$ and a function $m: E_{p}(a,b) \rightarrow \mathbb{Z}$ over $Z_{p}$ are selected.

- -

For each security class $SC_{j}$, the CA now:

- -

Step 1. Assigns a base point $G_{j}$, a secret key $sk_{j}$ and a sub-secret key $s_{j}$.

- -

Step 2. Computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$ for all predecessor classes $SC_{i}$ of $SC_{j}$. In other words, it computes the product of the base point with the sub-secret key of each of the higher-clearance classes. The resulting point is converted into a number $m(a_{j,i},b_{j,i})$ using the function $m(\cdot)$.

- -

Step 3. Computes a polynomial $f_{j}(x)$ using the above numbers as:

- -

$f_{j}(x) \equiv \prod_{SC_{i} \geq SC_{j}} (x - m(a_{j,i},b_{j,i})) + sk_{j}$ (mod $p$). [*]

- -

Step 4. Sends $sk_{j}$ and $s_{j}$ through a secure channel and announces $p$, $m(\cdot)$, $G_{j}$ and $f_{j}(x)$ publicly.

- -

[*] Note that the zeroes of $f_{j}(x) - sk_{j}$ are the numbers obtained from $s_{i}G_{j}$ using $m(\cdot)$.

- -

Key Derivation Phase

-

In this phase, a security class $SC_{i}$ finds the secret keys $sk_{j}$ of all successor classes $SC_{j} \geq SC_{i}$, i.e., all classes with lower clearance.

- -

First it computes $s_{i}G_{j} = (a_{j,i},b_{j,i})$, i.e., multiplies its sub-secret key with the lower class’s base point. It converts this point to a number using $m(\cdot)$. This number is $m(a_{j,i},b_{j,i})$.

- -

By the definiton of $f_{j}$, this number is a root of $f_{j}(x) - sk_{j}$, i.e., $f_{j}(m(a_{j,i},b_{j,i})) - sk_{j} \equiv 0$ (mod $p$). Therefore, $f_{j}(m(a_{j,i},b_{j,i})) \equiv sk_{j}$ (mod $p$), and $SC_{i}$ has found $sk_{j}$.

- -

Note. The function $m(x,y)$ is generally defined using a hash function as $m(x,y) = h(x \Vert y)$, where $\Vert$ is a bit concatenation operator. The intermediate $m(\cdot)$ was introduced in this description for convenience.

- -

An Example

-

Let us assume that the CA has completed the relationship-building phase and the key generation phase. Further, suppose that $SC_{2}$ would like to find the secret key $sk_{5}$ of its successor class $SC_{5}$. Other predecessor classes of $SC_{5}$ are, say, $SC_{1}$ and $SC_{4}$.

- -

Therefore, for $SC_{5}$, the CA has computed $s_{1}G_{5} = (a_{5,1},b_{5,1})$, $s_{2}G_{5} = (a_{5,2},b_{5,2})$ and $s_{4}G_{5} = (a_{5,4},b_{5,4})$. From these, the public polynomial $f_{5}$ is computed and announced: $f_{5} \equiv (x - m(a_{5,1},b_{5,1}))(x - m(a_{5,2},b_{5,2}))(x - m(a_{5,4},b_{5,4})) + sk_{5}$ (mod $p$).

- -

Now, $SC_{2}$ needs to find $sk_{5}$. It does this using $s_{2}$ (which only it knows), $m(\cdot)$, $G_{5}$ and $f_{5}$ (which are public).

- -

First, it computes $s_{2}G_{5} = (a_{5,2},b_{5,2})$. This is converted to a number using $m(\cdot)$ ( i.e., $m(a_{5,2},b_{5,2})$ is calculated) and substituted in $f_{5}(x)$.

- -

By the definiton of $f_{5}$, this number is a root of $f_{5}(x) - sk_{5}$. Therefore, $f_{5}(m(a_{5,2},b_{5,2})) \equiv sk_{5}$ (mod $p$), and $SC_{2}$ has found $sk_{5}$.

- -

It is clear the successor classes of $SC_{5}$ have no way to determine $sk_{5}$ using $f_{5}$.

- -:ET \ No newline at end of file diff --git a/_posts/2020-09-05-c-pro-lecture-10.md b/_posts/2020-09-05-c-pro-lecture-10.md new file mode 100644 index 0000000..7f0e2e4 --- /dev/null +++ b/_posts/2020-09-05-c-pro-lecture-10.md @@ -0,0 +1,125 @@ +--- +code: cs0.101 +title: C Pro Lecture 10 +number: 10 +--- +### Precedence and expression trees + +```c +main() +{ + int N = 6; + if (N % 2 == 0 && N % 3 == 0) + printf("N has factors 2 and 3\n"); + if (N % 2 == 0 && N % 3 != 0) + printf("N has factor 2 but not 3\n"); + if (N % 2 != 0 && N % 3 == 0) + printf("N has factor 3 but not 2\n"); + if (N % 2 != 0 && N % 3 != 0) + printf("N has neither factors 2 and 3\n"); +} +``` + +If we look at the above code, and focus in on a certain `if` expression, we can break it down in a **expression tree**, which helps us understand how the expression is parsed, and the relative precedences of the operators in the expression. + +```mermaid +graph TD + +A[&&] --- B[==] +A --- C[==] + +B --- D[%] +B --- E(0) +D --- F(N) +D --- G(2) + +C --- H[%] +C --- I(0) +H --- J(N) +H --- K(3) + +``` + +The `&&` symbol represents a logical 'AND' expression, which returns a true value if both lhs and rhs are true. +The compiler uses something known as *short-circuit evaluation* in order to optimise such expressions. In the `&&` expression, the lhs expression is evaluated first, and if it comes out to be false, a false value is immediately returned, without evaluating the rhs expression. +This optimization saves computation time, since the rhs expression doesn't matter if the lhs expression is false; the `&&` operator requires both to be true for it to return a true value. + +```c +int N = 23; +if ( N++ % 3 == 0 && N % 2 == 0) + printf("Expression is true"); +``` +Also consider the above code. Since the left subtree is evaluated first, the value of N tested in the right subtree is is not 23, but 24. + +## if-else trees and switch-case + +```c +#include + +#define A_CUTOFF 90 +#define B_CUTOFF 80 +#define C_CUTOFF 70 +#define D_CUTOFF 60 + +int main() +{ + char grade; + int marks; + + printf("Enter student marks: "); + scanf("%d", &marks); + + if(marks >= A_CUTOFF) + grade = 'A'; + else if(marks >= B_CUTOFF) + grade = 'B'; + else if(marks >= C_CUTOFF) + grade = 'C'; + else if(marks >= D_CUTOFF) + grade = 'D'; + else + grade = 'F'; + + printf("Student Grade: %c, ", grade); + fflush(stdout); + + switch(grade) + { + case 'A': + printf("Excellent\n") + break; + case 'B': + printf("Good\n") + break; + case 'C': + printf("Average\n") + break; + case 'D': + printf("Poor\n") + break; + case 'F': + printf("Failed\n"); + break; + default: + printf("Illegal grade\n"); + } +} +``` +(talk a bit about above code) + +## GDB: GNU DeBugger + +If we compile a program in `gcc` using the `-g` flag, it generates extra debugging information for `gdb` +for eg: `gcc -g marks.c` + +Now we can open up an executable with the debugger by entering the command `gdb a.out`. +We are greeted with some warranty and licensing information, followed by the gdb prompt: +``` +(gdb) +``` +We can add a *break point* in front of the main function, where the debugger pauses the program, and then run the program. +``` +(gdb) b main +(gdb) run +``` +(more on gdb)