Skip to content

Commit cd87c8d

Browse files
authored
Merge pull request #305 from decentralized-identity/vasilis/rm-pairing-friendly-curves-id
Making Pairing Friendly Curves draft reference informative
2 parents 3bd6abe + b398c96 commit cd87c8d

File tree

1 file changed

+206
-14
lines changed

1 file changed

+206
-14
lines changed

draft-irtf-cfrg-bbs-signatures.md

Lines changed: 206 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ length(input)
187187
X\[i\]
188188
: Denotes the element of array `X` at index `i`. Note that arrays in this document are considered "zero-indexed", meaning that element indexing starts from 0 rather than 1. For example, if `X = [a, b, c, d]` then `X[0] = a`, `X[1] = b`, `X[2] = c` and `X[3] = d`.
189189

190-
Terms specific to pairing-friendly elliptic curves that are relevant to this document are restated below, originally defined in [@!I-D.irtf-cfrg-pairing-friendly-curves].
190+
Terms specific to pairing-friendly elliptic curves that are relevant to this document are restated below, originally defined in [@I-D.irtf-cfrg-pairing-friendly-curves].
191191

192192
E1, E2
193193
: elliptic curve groups defined over finite fields. This document assumes that E1 has a more compact representation than E2, i.e., because E1 is defined over a smaller field than E2. For a pairing-friendly curve, this document denotes operations in E1 and E2 in additive notation, i.e., P + Q denotes point addition and x \* P denotes scalar multiplication.
@@ -588,9 +588,10 @@ The operations defined in this section perform the low-level cryptographic funct
588588

589589
The operations of this section make use of functions and sub-routines defined in [Utility Operations](#utility-operations). More specifically,
590590

591-
- `hash_to_scalar` as defined in (#hash-to-scalar).
592-
- `calculate_domain` and `calculate_challenge` as defined in (#domain-calculation) and (#challenge-calculation) correspondingly.
593-
- `serialize`, `signature_to_octets`, `octets_to_signature`, `proof_to_octets`, `octets_to_proof` and `octets_to_pubkey` as defined in (#serialization).
591+
- `hash_to_scalar` is defined in (#hash-to-scalar)
592+
- `calculate_domain` is defined in (#domain-calculation).
593+
- `serialize`, `signature_to_octets`, `octets_to_signature`, `proof_to_octets`, `octets_to_proof` and `octets_to_pubkey` are defined in (#serialization).
594+
- `e` is the pairing operation used (see (#notation)), defined as part of the ciphersuite.
594595

595596
Each core operation will accept a vector of `generators` (points of G1) and optionally, a vector of `messages`. The generators MUST be unique and pseudo-random i.e., with no known relationship to each other. See (#defining-new-generators) for more details. Each message is represented as a scalar value. See (#messages-to-scalars) for ways to map a message to a scalar and the corresponding security requirements.
596597

@@ -1735,7 +1736,7 @@ On the other hand, data confidentiality cannot be broken, even by adversaries wi
17351736

17361737
# Ciphersuites
17371738

1738-
This section defines the format for a BBS ciphersuite. It also gives concrete ciphersuites based on the BLS12-381 pairing-friendly elliptic curve [@!I-D.irtf-cfrg-pairing-friendly-curves].
1739+
This section defines the format for a BBS ciphersuite. It also gives concrete ciphersuites based on the BLS12-381 pairing-friendly elliptic curve [@I-D.irtf-cfrg-pairing-friendly-curves].
17391740

17401741
## Ciphersuite Format
17411742

@@ -1770,6 +1771,8 @@ The parameters that each ciphersuite needs to define are generally divided into
17701771

17711772
- P1: A fixed point in the G1 subgroup, different from the point BP1 (i.e., the base point of G1, see (#terminology)). This leaves the base point "free", to be used with other protocols, like key commitment and proof of possession schemes (for example, like the one described in Section 3.3 of [@I-D.irtf-cfrg-bls-signature]).
17721773

1774+
- e: The pairing operation used.
1775+
17731776
**Serialization functions**:
17741777

17751778
- point\_to\_octets\_E1:
@@ -1786,7 +1789,7 @@ a function that returns the point P in the elliptic curve E2 corresponding to th
17861789

17871790
## BLS12-381 Ciphersuites
17881791

1789-
The following two ciphersuites are based on the BLS12-381 elliptic curves defined in Section 4.2.1 of [@!I-D.irtf-cfrg-pairing-friendly-curves]. The targeted security level of both suites in bits is `k = 128`. The number of bits of the order `r`, of the G1 and G2 subgroups, is `log2(r) = 255`. The base points `BP1` and `BP2` of G1 and G2 are the points `BP` and `BP'` correspondingly, as defined in Section 4.2.1 of [@!I-D.irtf-cfrg-pairing-friendly-curves].
1792+
The following two ciphersuites are based on the BLS12-381 elliptic curves defined in Section 4.2.1 of [@I-D.irtf-cfrg-pairing-friendly-curves]. The targeted security level of both suites in bits is `k = 128` (the actual security leven is closer to 126 bits). The number of bits of the order `r`, of the G1 and G2 subgroups, is `log2(r) = 255`. The base points `BP1` and `BP2` of G1 and G2 are the points `BP` and `BP'` correspondingly, as defined in Section 4.2.1 of [@I-D.irtf-cfrg-pairing-friendly-curves]. For completeness, BLS12-381 and the relevant functionality (base points `BP1` and `BP2`, the pairing `e` as well as the point encoding and decoding operations) are defined in (#the-bls12-381-curve).
17901793

17911794
The first ciphersuite uses the hash-to-curve suite `BLS12381G1_XOF:SHAKE-256_SSWU_RO_`, defined by this document in [Appendix A.1](#bls12-381-hash_to_curve-def), which is based on the SHAKE-256 extendable output function, as defined in Section 6.2 of [@!SHA3].
17921795

@@ -1829,15 +1832,17 @@ Note that these two ciphersuites differ only in the hash-to-curve suites used. T
18291832
P1 = {{ $generatorFixtures.bls12-381-shake-256.generators.P1 }}
18301833
```
18311834
1835+
- e: the optimal Ate pairing (Appendix A.2 of [@I-D.irtf-cfrg-pairing-friendly-curves]), defined in (#optimal-ate-pairing).
1836+
18321837
**Serialization functions**:
18331838
1834-
- point\_to\_octets\_E1: follows the format documented in Appendix C section 1 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E1 elliptic curve, using compression (i.e., setting C\_bit = 1).
1839+
- point\_to\_octets\_E1: as defined in (#point-serialization) for points of the curve `E1` (which follows the format documented in Appendix C.1 of [@I-D.irtf-cfrg-pairing-friendly-curves] for the `E1` elliptic curve, using compression).
18351840
1836-
- point\_to\_octets\_E2: follows the format documented in Appendix C section 1 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E2 elliptic curve, using compression (i.e., setting C\_bit = 1).
1841+
- point\_to\_octets\_E2: as defined in (#point-serialization) for points of the curve `E2` (which follows the format documented in Appendix C.1 of [@I-D.irtf-cfrg-pairing-friendly-curves] for the `E2` elliptic curve, using compression).
18371842
1838-
- octets\_to\_point\_E1: follows the format documented in Appendix C section 2 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E1 elliptic curve.
1843+
- octets\_to\_point\_E1: as defined in (#point-de-serialization) (which follows the format documented in Appendix C.2 of [@I-D.irtf-cfrg-pairing-friendly-curves]), returning INVALID if the resulting point is not in `E1`.
18391844
1840-
- octets\_to\_point\_E2: follows the format documented in Appendix C section 2 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E2 elliptic curve.
1845+
- octets\_to\_point\_E2: as defined in (#point-de-serialization) (which follows the format documented in Appendix C.2 of [@I-D.irtf-cfrg-pairing-friendly-curves]), returning INVALID if the resulting point is not in `E2`.
18411846
18421847
### BLS12-381-SHA-256
18431848
@@ -1858,15 +1863,17 @@ Note that these two ciphersuites differ only in the hash-to-curve suites used. T
18581863
P1 = {{ $generatorFixtures.bls12-381-sha-256.generators.P1 }}
18591864
```
18601865
1866+
- e: the optimal Ate pairing (Appendix A.2 of [@I-D.irtf-cfrg-pairing-friendly-curves]), defined in (#optimal-ate-pairing).
1867+
18611868
**Serialization functions**:
18621869
1863-
- point\_to\_octets\_E1: follows the format documented in Appendix C section 1 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E1 elliptic curve, using compression (i.e., setting C\_bit = 1).
1870+
- point\_to\_octets\_E1: as defined in (#point-serialization) for points of the curve `E1` (which follows the format documented in Appendix C.1 of [@I-D.irtf-cfrg-pairing-friendly-curves] for the `E1` elliptic curve, using compression).
18641871
1865-
- point\_to\_octets\_E2: follows the format documented in Appendix C section 1 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E2 elliptic curve, using compression (i.e., setting C\_bit = 1).
1872+
- point\_to\_octets\_E2: as defined in (#point-serialization) for points of the curve `E2` (which follows the format documented in Appendix C.1 of [@I-D.irtf-cfrg-pairing-friendly-curves] for the `E2` elliptic curve, using compression).
18661873
1867-
- octets\_to\_point\_E1: follows the format documented in Appendix C section 2 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E1 elliptic curve.
1874+
- octets\_to\_point\_E1: as defined in (#point-de-serialization) (which follows the format documented in Appendix C.2 of [@I-D.irtf-cfrg-pairing-friendly-curves]), returning INVALID if the resulting point is not in `E1`.
18681875
1869-
- octets\_to\_point\_E2: follows the format documented in Appendix C section 2 of [@!I-D.irtf-cfrg-pairing-friendly-curves] for the E2 elliptic curve.
1876+
- octets\_to\_point\_E2: as defined in (#point-de-serialization) (which follows the format documented in Appendix C.2 of [@I-D.irtf-cfrg-pairing-friendly-curves]), returning INVALID if the resulting point is not in `E2`.
18701877
18711878
# Test Vectors
18721879
@@ -2514,6 +2521,191 @@ Note that the h_eff values for this suite are copied from that defined for the `
25142521
25152522
An optimized example implementation of the Simplified SWU mapping to the curve E' isogenous to BLS12-381 G1 is given in Appendix F.2 [@!I-D.irtf-cfrg-hash-to-curve].
25162523
2524+
# The BLS12-381 Curve
2525+
2526+
This section defines BLS12-381. The definitions of this section have been originally described in [@I-D.irtf-cfrg-pairing-friendly-curves], where they are discussed in greater detail.
2527+
2528+
BLS12-381 are Barreto-Lynn-Scott curves, defined by two elliptic curves `E1` and `E2`, parameterized by an integer `t`. In the case of BLS12-381, `t` is defined as,
2529+
2530+
```
2531+
t = -2^63 - 2^62 - 2^60 - 2^57 - 2^48 - 2^16
2532+
```
2533+
2534+
The curves `E1` and `E2` are defined over the finite fields `GF(p)` and `GF(p^2)` correspondingly, where `p` is defined as,
2535+
2536+
```
2537+
p = (t - 1)^2 * (t^4 - t^2 + 1) / 3 + t
2538+
```
2539+
2540+
Let `(1, I)` be the bases of the finite field `GF(p^2)`, where `I ^ 2 + 1 = 0` in `GF(p^2)`. We will denote an element `y` of `GF(p^2)` as a tuple `y = (y_0, y_1)`, where `y_0` and `y_1` elements of `GF(p)` for which it holds `y = y_0 * 1 + y_1 * I`. The two elliptic curves are defined by the following equations,
2541+
2542+
```
2543+
E1: y ^ 2 = x ^ 3 + 4
2544+
E2: y ^ 2 = x ^ 3 + 4 * (I + 1)
2545+
```
2546+
2547+
The group `G1` and `G2` are defined as the the order `r` subgroup of `E1` defined over `GF(p)` and `E2` defined over `GF(p^2)` correspondingly, where `r` is defined as,
2548+
2549+
```
2550+
r = 0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001
2551+
```
2552+
2553+
Note that `r` is a prime factor of `p`. The target group `G_T` is defined as the finite group `GF(p^12)` minus the element `0`.
2554+
2555+
The base points of BLS12-381, encoded to octets using the procedure defined in (#point-serialization) and then represented in hexadecimal format, are defined as,
2556+
2557+
```
2558+
BP1 = "97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586
2559+
c55e83ff97a1aeffb3af00adb22c6bb"
2560+
BP2 = "93e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f50493
2561+
34cf11213945d57e5ac7d055d042b7e024aa2b2f08f0a91260805272dc51051c6
2562+
e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb8"
2563+
```
2564+
2565+
## Optimal Ate pairing
2566+
2567+
This section describes the optimal Ate pairing for BLS12-381. The pairing computation uses the following utility function.
2568+
2569+
```
2570+
res = Line_function(Q1, Q2, P)
2571+
2572+
Inputs:
2573+
2574+
- Q1 (REQUIRED), point of G2.
2575+
- Q2 (REQUIRED), point of G2.
2576+
- P (REQUIRED), point of G1.
2577+
2578+
Outputs:
2579+
2580+
- res: an element on the target group G_T.
2581+
2582+
Procedure:
2583+
2584+
1. (x_1, y_1) = Q1
2585+
2. (x_2, y_2) = Q2
2586+
3. (x, y) = P
2587+
4. if Q1 = Q2, set l = (3 * x_1^2) / (2 * y_1)
2588+
5. else if Q1 = - Q2, return x - x_1
2589+
6. else set l = (y_2 - y_1) / (x_2 - x_1)
2590+
7. return (l * (x - x_1) + y_1 - y)
2591+
```
2592+
2593+
Let `c = t` for `t` as defined above ((#the-bls12-381-curve)) and `c_0, c_1, ... , c_L` in `(-1, 0, 1)` such that the sum of `c_i * 2^i` for `i = 0, 1, ..., L` equals `c`.
2594+
2595+
Given a point `P` of `G1`, and a point `Q` of `G2`, the output `e(P, Q)` where `e` the Ate pairing for BLS12-381 is calculated as follows,
2596+
2597+
```
2598+
1. set f = 1 and T = Q
2599+
2. if c_L = -1, set T = -T
2600+
3. for i in (L-1, L-2, ..., 1, 0)
2601+
4. f = f^2 * Line_function(T, T, P)
2602+
5. T = T + T
2603+
6. if c_i = 1,
2604+
7. f = f * Line_function(T, Q, P)
2605+
8. T = T + Q
2606+
9. else if c_i = -1,
2607+
10. f = f * Line_function(T, -Q, P)
2608+
11. T = T - Q
2609+
12. f = f ^ ((p ^ 12 - 1) / r)
2610+
13. return f
2611+
```
2612+
2613+
## Point Encoding
2614+
2615+
This section defines point encoding and decoding procedures for BLS12-381. Although more flexible point encoding procedures may exist (for example [@I-D.ietf-lwig-curve-representations]), the vast majority of current libraries implementing BLS12-381 use (most of them explicitly) the encoding method defined in Appendix C of [@I-D.irtf-cfrg-pairing-friendly-curves]. For this reason, the ciphersuites defined in (#bls12-381-ciphersuites), use those encoding and decoding procedures. For completeness, those operations are defined in this section as well. See [@I-D.irtf-cfrg-pairing-friendly-curves] for a more detailed explanation of the encoding and decoding steps. Note also that we will only consider compressed point encoding (in contrast to [@I-D.irtf-cfrg-pairing-friendly-curves], which supports both compressed and uncompressed point encoding).
2616+
2617+
In this section we will use the following notation,
2618+
2619+
- For an octet string `x`, `x[0]` will denote the first octet (i.e., 8 most significant bits) of `x`.
2620+
- On input an element `y` of `GF(p)` or `GF(p^2)`, `sqrt(y)` will return the square root of that element in the respective group, i.e., an element `a` such that `a^2 = y`, or INVALID.
2621+
- For clarity, we will use `Identity_E1`, `Identity_E2` to denote the identity points of `E1` and `E2` correspondingly (note that `Identity_E1` is the same point as `Identity_G1` and `Identity_E2` is the same point as `Identity_G2`).
2622+
2623+
We first have to define the following utility operations.
2624+
2625+
The following procedure returns one bit corresponding to the sign of an element of `GF(p)`.
2626+
2627+
```
2628+
res = sign_GF_p(y)
2629+
2630+
Inputs:
2631+
2632+
- y (REQUIRED), point of the GF(p) group
2633+
2634+
Outputs:
2635+
2636+
- res, either 0 or 1
2637+
2638+
Procedure:
2639+
2640+
1. if y > (p - 1) / 2, return 1
2641+
2. return 0
2642+
```
2643+
2644+
The following procedure returns one bit corresponding to the sign of an element in `GF(p^2)`.
2645+
2646+
```
2647+
res = sign_GF_p^2(y)
2648+
2649+
Inputs:
2650+
2651+
- y (REQUIRED), point of the GF(p^2) group
2652+
2653+
Outputs:
2654+
2655+
- res, either 0 or 1
2656+
2657+
Procedure:
2658+
2659+
1. (y_0, y_1) = y
2660+
2. if y_1 is 0, return sign_GF_p(y_0)
2661+
3. if y_1 > (p - 1) / 2, return 1
2662+
4. return 0
2663+
```
2664+
2665+
### Point Serialization
2666+
2667+
Let `P = (x, y)` the point to be serialized.
2668+
2669+
Compute three metadata bits `C_bit`, `I_bit`, and `S_bit`, as follows,
2670+
2671+
1. `C_bit` is set to 1 (indicating that point compression is used).
2672+
2. `I_bit` is 1 if `P` is either the `Identity_E1` or `Identity_E2` points, otherwise it is 0.
2673+
3. `S_bit` is 0 if `I_bit` is 1 (again note that the ciphersuites described in this document always use point compression). Otherwise (i.e., when point compression is used and `P` is not the identity point of its respective curve), if `P` is a point on `E1`, set `S_bit = sign_GF_p(y)`, else if `P` is a point on `E2`, `S_bit = sign_GF_p^2(y)`.
2674+
2675+
Let `m = (C_bit * 2^7) + (I_bit * 2^6) + (S_bit * 2^5)` and set `m_byte = I2OSP(m, 1)`. Define `x_string` as follows,
2676+
2677+
1. If `P = Identity_E1`, set `x_string = I2OSP(0, 48)`.
2678+
2. If `P` is a point on `E1` and `P != Identity_E1`, set `x_string = I2OSP(x, 48)`.
2679+
3. If `P = Identity_E2`, set `x_string = I2OSP(0, 96)`.
2680+
4. If `P` is a point on `E2` and `P != Identity_E2`, then let `x_0` and `x_1` elements of `GF(p)` such that `x = (x_0, x_1)` and set `x_string = I2OSP(x_1, 48) || I2OSP(x_0, 48)`.
2681+
2682+
Let `s_string = x_string`. Set `s_string[0] = x_string[0] OR m_byte`, where `OR` is computed for each bit. Output `s_string` as the serialization result of the point `P`.
2683+
2684+
### Point De-serialization
2685+
2686+
Let `m_byte = s_string[0] AND 0xE0`, where `AND` is computed bitwise. If `m_byte` equals `0x20` or `0x60` or `0xE0`, output INVALID and abort the operation. Otherwise, let `C_bit` equal the most significant bit of `m_byte`, `I_bit` equal the second most significant bit of `m_byte`, and `S_bit` equal the third most significant bit of `m_byte`. If `C_bit` is 0 return INVALID and abort the operation (note again that we only consider compressed encoding).
2687+
2688+
1. Determine the curve of the encoded point as follows,
2689+
- If `s_string` has length 48 octets, the encoded point is on the curve `E1`.
2690+
- If `s_string` has length 96 octets, the encoded point is on the curve `E2`.
2691+
- If `s_string` has any other length, output INVALID and abort the operation.
2692+
2693+
2694+
2. Let `s_string[0] = s_string[0] AND 0x1F`, where `AND` is computed bitwise (this will set the three most significant bits of `s_string[0]` to 0).
2695+
2696+
3. If `I_bit` is 1, then the encoded point must be the Identity point of the curve determined on step 1. If `s_string` is not the all zeros string, output INVALID and abort the operation. Otherwise, output the Identity point of the curve that was determined in step 1 (i.e., either `Identity_E1` or `Identity_E2`).
2697+
2698+
4. Let `x = OS2IP(s_string)`.
2699+
5. If the curve that was determined in step 1 is `E1`,
2700+
- Let `y2 = x^3 + 4` in `GF(p)`.
2701+
- If `y2` is not square in `GF(p)`, output INVALID and abort the operation. Otherwise, let `y = sqrt(y2)` in `GF(p)` and set `Y_bit = sign_GF_p(y)`.
2702+
2703+
6. If the curve that was determined in step 1 is `E2`,
2704+
- Let `y2 = x^3 + 4 * (I + 1)` in `GF(p^2)`.
2705+
- If `y2` is not square in `GF(p^2)`, output INVALID and abort the operation. Otherwise, let `y = sqrt(y2)` in `GF(p^2)` and set `Y_bit = sign_GF_p^2(y)`.
2706+
2707+
7. If `S_bit` equals `Y_bit`, output `P = (x, y)`. Otherwise, output `P = (x, -y)`.
2708+
25172709
# Use Cases
25182710
25192711
## Non-correlating Security Token

0 commit comments

Comments
 (0)