Guest User

Untitled

a guest
Nov 18th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. # public
  2. $p = 21990309168057383
  3. $g = 41415082132289
  4.  
  5. k = 0 #12348274
  6.  
  7. # A: privateKey
  8. a = 12348715 + k
  9.  
  10. # B: privateKey
  11. b = 79283713 + k
  12.  
  13. def power(base, n)
  14. return 1 if n == 0
  15. (power(base, n / 2) * (((n % 2) == 0) ? 1 : base) ) % $p
  16. end
  17.  
  18. # A: Public Key
  19. pa = power($g, a)
  20.  
  21. # B: Public Key
  22. pb = power($g, b)
  23.  
  24. # 一致する, 必要なのはお互いの public key の交換
  25. p power(pa, b)
  26. p power(pb, a)
Add Comment
Please, Sign In to add comment