You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
6.8 KiB

  1. # Shamir's Secret Sharing
  2. <img src="https://arnaucube.com/img/logoArnauCubeTransparent.png" style="max-width:20%; float:right;" />
  3. - https://arnaucube.com
  4. - https://github.com/arnaucube
  5. - https://twitter.com/arnaucube
  6. <br><br><br>
  7. <div style="float:right;font-size:80%;">
  8. <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png" /></a>
  9. <br>
  10. 2019-07-05
  11. </div>
  12. ---
  13. # Intro
  14. - I'm not an expert on the field, neither a mathematician. Just an engineer with interest for cryptography
  15. - Short talk (15 min), with the objective to make a practical introduction to the Shamir's Secret Sharing algorithm
  16. - Is not a talk about mathematical demostrations, is a talk with the objective to get the basic notions to be able to do a practical implementation of the algorithm
  17. - After the talk, we will do a practical workshop to implement the concepts. We can offer support for Go, Rust, Python and Nodejs (you can choose any other language, but we will not be able to help)
  18. ---
  19. - Cryptographic algorithm
  20. - Created by Adi Shamir, in 1979
  21. - also known by the $RSA$ cryptosystem
  22. - explained in few months ago in a similar talk: https://github.com/arnaucube/slides/rsa
  23. ---
  24. ## What's this about?
  25. - imagine having a password that you want to share with 5 persons, in a way that they need to join their parts to get the original password
  26. - take the password, split it in 5 parts, and give one part to each one
  27. - when they need to recover it, they just need to get together, put all the pieces and recover the password (the `secret`)
  28. - this, has the problem that if a person looses its part, the secret will not be recovered anymore.. luckly we have a solution here:
  29. ---
  30. - Shamir's Secret Sharing:
  31. - from a secret to be shared, we generate 5 parts, but we can specify a number of parts that are needed to recover the secret
  32. - so for example, we generate 5 parts, where we will need only 3 of that 5 parts to recover the secret, and the order doesn't matter
  33. - we have the ability to define the thresholds of $M$ parts to be created, and $N$ parts to be able the recover
  34. ---
  35. - 2 points are sufficient to define a line
  36. - 3 points are sufficient to define a parabola
  37. - 4 points are sufficient to define a cubic curve
  38. - $K$ points are suficient to define a polynomial of degree $k-1$
  39. We can create infinity of polynomials of degree 2, that goes through 2 points, but with 3 points, we can define a polynomial of degree 2 unique.
  40. ![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/66/3_polynomials_of_degree_2_through_2_points.svg/220px-3_polynomials_of_degree_2_through_2_points.svg.png)
  41. ---
  42. ## Naming
  43. - `s`: secret
  44. - `m`: number of parts to be created
  45. - `n`: number of minimum parts necessary to recover the secret
  46. - `p`: random prime number, the Finite Field will be over that value
  47. ---
  48. ## Secret generation
  49. - we want that are necessary $n$ parts of $m$ to recover $s$
  50. - where $n<m$
  51. - need to create a polynomial of degree $n-1$
  52. $f(x) = \alpha_0 + \alpha_1 x + \alpha_2 x^2 + \alpha_3 x^3 + ... + + \alpha_{n-1} x^{n-1}$
  53. - where $\alpha_0$ is the secret $s$
  54. - $\alpha_i$ are random values that build the polynomial
  55. *where $\alpha_0$ is the secret to share, and $\alpha_i$ are the random values inside the $Finite Field$
  56. ---
  57. $f(x) = \alpha_0 + \alpha_1 x + \alpha_2 x^2 + \alpha_3 x^3 + ... + + \alpha_{n-1} x^{n-1}$
  58. - the packets that we will generate are $P = (x, f(x))$
  59. - where $x$ is each one of the values between $1$ and $m$
  60. - $P_1=(1, f(1))$
  61. - $P_2=(2, f(2))$
  62. - $P_3=(3, f(3))$
  63. - ...
  64. - $P_m=(m, f(m))$
  65. ---
  66. ## Secret recovery
  67. - in order to recover the secret $s$, we will need a minimum of $n$ points of the polynomial
  68. - the order doesn't matter
  69. - with that $n$ parts, we do Lagrange Interpolation/Polynomial Interpolation
  70. ---
  71. ## Polynomial Interpolation / Lagrange Interpolation
  72. - for a group of points, we can find the smallest degree polynomial that goees through all that points
  73. - this polynomial is unique for each group of points
  74. ![](https://upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Lagrange_polynomial.svg/440px-Lagrange_polynomial.svg.png)
  75. ---
  76. ![](https://www.researchgate.net/profile/Chinthanie_Weerakoon/publication/319703488/figure/fig4/AS:614100010799117@1523424260513/Lagrange-Interpolation-Technique.png)
  77. ---
  78. $L(x) = \sum_{j=0}^{n} y_j l_j(x)$
  79. <br><br>
  80. ![](https://wikimedia.org/api/rest_v1/media/math/render/svg/6e2c3a2ab16a8723c0446de6a30da839198fb04b)
  81. ---
  82. ## Wikipedia example
  83. *example over real numbers, in the practical world, we use the algorithm in the Finite Field over $p$
  84. <span style="font-size:70%;float:right;">(more details: https://en.wikipedia.org/wiki/Shamir's_Secret_Sharing#Problem)</span><br>
  85. - $s=1234$
  86. - $m=6$
  87. - $n=3$
  88. - $f(x) = \alpha_0 + \alpha_1 x + \alpha_2 x^2$
  89. - $\alpha_0 = s = 1234$
  90. - $\alpha_1 = 166$ *(random)*
  91. - $\alpha_2 = 94$ *(random)*
  92. - $f(x) = 1234 + 166 x + 94 x^2$
  93. ---
  94. - $f(x) = 1234 + 166 x + 94 x^2$
  95. - we calculate the points $P = (x, f(x))$
  96. - where $x$ is each one of the values between $1$ and $m$
  97. - $P_1=(1, f(1)) = (1, 1494)$
  98. - $P_2=(2, f(2)) = (2, 1942)$
  99. - $P_3=(3, f(3)) = (3, 2578)$
  100. - $P_4=(4, f(4)) = (4, 3402)$
  101. - $P_5=(5, f(5)) = (5, 4414)$
  102. - $P_6=(6, f(6)) = (6, 5614)$
  103. ---
  104. - to recover the secret, let's imagine that we take the packets 2, 4, 5
  105. - $(x_0, y_0) = (2, 1942)$
  106. - $(x_0, y_0) = (4, 3402)$
  107. - $(x_0, y_0) = (5, 4414)$
  108. ---
  109. - let's calculate the Lagrange Interpolation
  110. - ![](https://wikimedia.org/api/rest_v1/media/math/render/svg/388471f79b8d3bdb75851b99ed15e5849329cc84)
  111. - ![](https://wikimedia.org/api/rest_v1/media/math/render/svg/3c853bdf0daa2db92cd70a6ab21dfd858296cfdd)
  112. - ![](https://wikimedia.org/api/rest_v1/media/math/render/svg/2013ee56aba68b07d8d4a2c6578e77ff8e8940ff)
  113. - ![](https://wikimedia.org/api/rest_v1/media/math/render/svg/32fc145272d82d9ebf62b4e30a05eac2b7d2873a)
  114. - obtaining $f(x) = \alpha_0 + \alpha_1 x + \alpha_2 x^2$, where $\alpha_0$ is the secret $s$ recovered
  115. - where we eavluate the polynomial at $f(0)$, obtaining $\alpha_0 = s$
  116. - *we are not going into details now, but if you want in the practical workshop we can analyze the 'mathematical' part of all of this
  117. ---
  118. # And now... practical implementation
  119. - full night long
  120. - big ints are your friends
  121. - $L(x) = \sum_{j=0}^{n} y_j l_j(x)$
  122. ![](https://wikimedia.org/api/rest_v1/media/math/render/svg/6e2c3a2ab16a8723c0446de6a30da839198fb04b)
  123. # About
  124. <img src="https://arnaucube.com/img/logoArnauCubeTransparent.png" style="max-width:20%; float:right;" />
  125. - https://arnaucube.com
  126. - https://github.com/arnaucube
  127. - https://twitter.com/arnaucube
  128. <br>
  129. <div style="float:right;font-size:80%;">
  130. <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png" /></a>
  131. <br>
  132. 2019-07-05
  133. </div>