Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # public
- $p = 21990309168057383
- $g = 41415082132289
- k = 0 #12348274
- # A: privateKey
- a = 12348715 + k
- # B: privateKey
- b = 79283713 + k
- def power(base, n)
- return 1 if n == 0
- (power(base, n / 2) * (((n % 2) == 0) ? 1 : base) ) % $p
- end
- # A: Public Key
- pa = power($g, a)
- # B: Public Key
- pb = power($g, b)
- # 一致する, 必要なのはお互いの public key の交換
- p power(pa, b)
- p power(pb, a)
Add Comment
Please, Sign In to add comment