|
| 1 | +"""Implementation of Edwards Digital Signature Algorithm.""" |
| 2 | + |
| 3 | +from . import ellipticcurve |
| 4 | +from ._compat import remove_whitespace |
| 5 | + |
| 6 | +# edwards25519, defined in RFC7748 |
| 7 | +_p = 2 ** 255 - 19 |
| 8 | +_a = -1 |
| 9 | +_d = int( |
| 10 | + remove_whitespace( |
| 11 | + "370957059346694393431380835087545651895421138798432190163887855330" |
| 12 | + "85940283555" |
| 13 | + ) |
| 14 | +) |
| 15 | +_h = 8 |
| 16 | + |
| 17 | +_Gx = int( |
| 18 | + remove_whitespace( |
| 19 | + "151122213495354007725011514095885315114540126930418572060461132" |
| 20 | + "83949847762202" |
| 21 | + ) |
| 22 | +) |
| 23 | +_Gy = int( |
| 24 | + remove_whitespace( |
| 25 | + "463168356949264781694283940034751631413079938662562256157830336" |
| 26 | + "03165251855960" |
| 27 | + ) |
| 28 | +) |
| 29 | +_r = 2 ** 252 + 0x14DEF9DEA2F79CD65812631A5CF5D3ED |
| 30 | + |
| 31 | +curve_ed25519 = ellipticcurve.CurveEdTw(_p, _a, _d, _h) |
| 32 | +generator_ed25519 = ellipticcurve.PointEdwards( |
| 33 | + curve_ed25519, _Gx, _Gy, 1, _Gx * _Gy % _p, _r |
| 34 | +) |
| 35 | + |
| 36 | + |
| 37 | +# edwards448, defined in RFC7748 |
| 38 | +_p = 2 ** 448 - 2 ** 224 - 1 |
| 39 | +_a = 1 |
| 40 | +_d = -39081 % _p |
| 41 | +_h = 4 |
| 42 | + |
| 43 | +_Gx = int( |
| 44 | + remove_whitespace( |
| 45 | + "224580040295924300187604334099896036246789641632564134246125461" |
| 46 | + "686950415467406032909029192869357953282578032075146446173674602635" |
| 47 | + "247710" |
| 48 | + ) |
| 49 | +) |
| 50 | +_Gy = int( |
| 51 | + remove_whitespace( |
| 52 | + "298819210078481492676017930443930673437544040154080242095928241" |
| 53 | + "372331506189835876003536878655418784733982303233503462500531545062" |
| 54 | + "832660" |
| 55 | + ) |
| 56 | +) |
| 57 | +_r = 2 ** 446 - 0x8335DC163BB124B65129C96FDE933D8D723A70AADC873D6D54A7BB0D |
| 58 | + |
| 59 | +curve_ed448 = ellipticcurve.CurveEdTw(_p, _a, _d, _h) |
| 60 | +generator_ed448 = ellipticcurve.PointEdwards( |
| 61 | + curve_ed448, _Gx, _Gy, 1, _Gx * _Gy % _p, _r |
| 62 | +) |
0 commit comments