From 78f65bb37f86cc50e2a896c67c6a61e304601b54 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 8 Mar 2015 01:21:43 +0000 Subject: [PATCH] some windows fixes --- ed25519/src/fe.cpp | 732 ++++++++++++++++++++++----------------------- ed25519/src/sc.cpp | 248 +++++++-------- examples/print.cpp | 2 +- 3 files changed, 491 insertions(+), 491 deletions(-) diff --git a/ed25519/src/fe.cpp b/ed25519/src/fe.cpp index 1704f3893..a21d00925 100644 --- a/ed25519/src/fe.cpp +++ b/ed25519/src/fe.cpp @@ -300,55 +300,55 @@ void fe_copy(fe h, const fe f) { */ void fe_frombytes(fe h, const unsigned char *s) { - int64_t h0 = load_4(s); - int64_t h1 = load_3(s + 4) << 6; - int64_t h2 = load_3(s + 7) << 5; - int64_t h3 = load_3(s + 10) << 3; - int64_t h4 = load_3(s + 13) << 2; - int64_t h5 = load_4(s + 16); - int64_t h6 = load_3(s + 20) << 7; - int64_t h7 = load_3(s + 23) << 5; - int64_t h8 = load_3(s + 26) << 4; - int64_t h9 = (load_3(s + 29) & 8388607) << 2; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; + i64 h0 = load_4(s); + i64 h1 = load_3(s + 4) << 6; + i64 h2 = load_3(s + 7) << 5; + i64 h3 = load_3(s + 10) << 3; + i64 h4 = load_3(s + 13) << 2; + i64 h5 = load_4(s + 16); + i64 h6 = load_3(s + 20) << 7; + i64 h7 = load_3(s + 23) << 5; + i64 h8 = load_3(s + 26) << 4; + i64 h9 = (load_3(s + 29) & 8388607) << 2; + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; - carry9 = (h9 + (int64_t) (1 << 24)) >> 25; + carry9 = (h9 + (i64) (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry1 = (h1 + (int64_t) (1 << 24)) >> 25; + carry1 = (h1 + (i64) (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry3 = (h3 + (int64_t) (1 << 24)) >> 25; + carry3 = (h3 + (i64) (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry5 = (h5 + (int64_t) (1 << 24)) >> 25; + carry5 = (h5 + (i64) (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry7 = (h7 + (int64_t) (1 << 24)) >> 25; + carry7 = (h7 + (i64) (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry2 = (h2 + (int64_t) (1 << 25)) >> 26; + carry2 = (h2 + (i64) (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry6 = (h6 + (int64_t) (1 << 25)) >> 26; + carry6 = (h6 + (i64) (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry8 = (h8 + (int64_t) (1 << 25)) >> 26; + carry8 = (h8 + (i64) (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; @@ -593,167 +593,167 @@ void fe_mul(fe h, const fe f, const fe g) { i32 f5_2 = 2 * f5; i32 f7_2 = 2 * f7; i32 f9_2 = 2 * f9; - int64_t f0g0 = f0 * (int64_t) g0; - int64_t f0g1 = f0 * (int64_t) g1; - int64_t f0g2 = f0 * (int64_t) g2; - int64_t f0g3 = f0 * (int64_t) g3; - int64_t f0g4 = f0 * (int64_t) g4; - int64_t f0g5 = f0 * (int64_t) g5; - int64_t f0g6 = f0 * (int64_t) g6; - int64_t f0g7 = f0 * (int64_t) g7; - int64_t f0g8 = f0 * (int64_t) g8; - int64_t f0g9 = f0 * (int64_t) g9; - int64_t f1g0 = f1 * (int64_t) g0; - int64_t f1g1_2 = f1_2 * (int64_t) g1; - int64_t f1g2 = f1 * (int64_t) g2; - int64_t f1g3_2 = f1_2 * (int64_t) g3; - int64_t f1g4 = f1 * (int64_t) g4; - int64_t f1g5_2 = f1_2 * (int64_t) g5; - int64_t f1g6 = f1 * (int64_t) g6; - int64_t f1g7_2 = f1_2 * (int64_t) g7; - int64_t f1g8 = f1 * (int64_t) g8; - int64_t f1g9_38 = f1_2 * (int64_t) g9_19; - int64_t f2g0 = f2 * (int64_t) g0; - int64_t f2g1 = f2 * (int64_t) g1; - int64_t f2g2 = f2 * (int64_t) g2; - int64_t f2g3 = f2 * (int64_t) g3; - int64_t f2g4 = f2 * (int64_t) g4; - int64_t f2g5 = f2 * (int64_t) g5; - int64_t f2g6 = f2 * (int64_t) g6; - int64_t f2g7 = f2 * (int64_t) g7; - int64_t f2g8_19 = f2 * (int64_t) g8_19; - int64_t f2g9_19 = f2 * (int64_t) g9_19; - int64_t f3g0 = f3 * (int64_t) g0; - int64_t f3g1_2 = f3_2 * (int64_t) g1; - int64_t f3g2 = f3 * (int64_t) g2; - int64_t f3g3_2 = f3_2 * (int64_t) g3; - int64_t f3g4 = f3 * (int64_t) g4; - int64_t f3g5_2 = f3_2 * (int64_t) g5; - int64_t f3g6 = f3 * (int64_t) g6; - int64_t f3g7_38 = f3_2 * (int64_t) g7_19; - int64_t f3g8_19 = f3 * (int64_t) g8_19; - int64_t f3g9_38 = f3_2 * (int64_t) g9_19; - int64_t f4g0 = f4 * (int64_t) g0; - int64_t f4g1 = f4 * (int64_t) g1; - int64_t f4g2 = f4 * (int64_t) g2; - int64_t f4g3 = f4 * (int64_t) g3; - int64_t f4g4 = f4 * (int64_t) g4; - int64_t f4g5 = f4 * (int64_t) g5; - int64_t f4g6_19 = f4 * (int64_t) g6_19; - int64_t f4g7_19 = f4 * (int64_t) g7_19; - int64_t f4g8_19 = f4 * (int64_t) g8_19; - int64_t f4g9_19 = f4 * (int64_t) g9_19; - int64_t f5g0 = f5 * (int64_t) g0; - int64_t f5g1_2 = f5_2 * (int64_t) g1; - int64_t f5g2 = f5 * (int64_t) g2; - int64_t f5g3_2 = f5_2 * (int64_t) g3; - int64_t f5g4 = f5 * (int64_t) g4; - int64_t f5g5_38 = f5_2 * (int64_t) g5_19; - int64_t f5g6_19 = f5 * (int64_t) g6_19; - int64_t f5g7_38 = f5_2 * (int64_t) g7_19; - int64_t f5g8_19 = f5 * (int64_t) g8_19; - int64_t f5g9_38 = f5_2 * (int64_t) g9_19; - int64_t f6g0 = f6 * (int64_t) g0; - int64_t f6g1 = f6 * (int64_t) g1; - int64_t f6g2 = f6 * (int64_t) g2; - int64_t f6g3 = f6 * (int64_t) g3; - int64_t f6g4_19 = f6 * (int64_t) g4_19; - int64_t f6g5_19 = f6 * (int64_t) g5_19; - int64_t f6g6_19 = f6 * (int64_t) g6_19; - int64_t f6g7_19 = f6 * (int64_t) g7_19; - int64_t f6g8_19 = f6 * (int64_t) g8_19; - int64_t f6g9_19 = f6 * (int64_t) g9_19; - int64_t f7g0 = f7 * (int64_t) g0; - int64_t f7g1_2 = f7_2 * (int64_t) g1; - int64_t f7g2 = f7 * (int64_t) g2; - int64_t f7g3_38 = f7_2 * (int64_t) g3_19; - int64_t f7g4_19 = f7 * (int64_t) g4_19; - int64_t f7g5_38 = f7_2 * (int64_t) g5_19; - int64_t f7g6_19 = f7 * (int64_t) g6_19; - int64_t f7g7_38 = f7_2 * (int64_t) g7_19; - int64_t f7g8_19 = f7 * (int64_t) g8_19; - int64_t f7g9_38 = f7_2 * (int64_t) g9_19; - int64_t f8g0 = f8 * (int64_t) g0; - int64_t f8g1 = f8 * (int64_t) g1; - int64_t f8g2_19 = f8 * (int64_t) g2_19; - int64_t f8g3_19 = f8 * (int64_t) g3_19; - int64_t f8g4_19 = f8 * (int64_t) g4_19; - int64_t f8g5_19 = f8 * (int64_t) g5_19; - int64_t f8g6_19 = f8 * (int64_t) g6_19; - int64_t f8g7_19 = f8 * (int64_t) g7_19; - int64_t f8g8_19 = f8 * (int64_t) g8_19; - int64_t f8g9_19 = f8 * (int64_t) g9_19; - int64_t f9g0 = f9 * (int64_t) g0; - int64_t f9g1_38 = f9_2 * (int64_t) g1_19; - int64_t f9g2_19 = f9 * (int64_t) g2_19; - int64_t f9g3_38 = f9_2 * (int64_t) g3_19; - int64_t f9g4_19 = f9 * (int64_t) g4_19; - int64_t f9g5_38 = f9_2 * (int64_t) g5_19; - int64_t f9g6_19 = f9 * (int64_t) g6_19; - int64_t f9g7_38 = f9_2 * (int64_t) g7_19; - int64_t f9g8_19 = f9 * (int64_t) g8_19; - int64_t f9g9_38 = f9_2 * (int64_t) g9_19; - int64_t h0 = f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38; - int64_t h1 = f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19; - int64_t h2 = f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38; - int64_t h3 = f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19; - int64_t h4 = f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38; - int64_t h5 = f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19; - int64_t h6 = f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38; - int64_t h7 = f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19; - int64_t h8 = f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38; - int64_t h9 = f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 ; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; + i64 f0g0 = f0 * (int64_t) g0; + i64 f0g1 = f0 * (int64_t) g1; + i64 f0g2 = f0 * (int64_t) g2; + i64 f0g3 = f0 * (int64_t) g3; + i64 f0g4 = f0 * (int64_t) g4; + i64 f0g5 = f0 * (int64_t) g5; + i64 f0g6 = f0 * (int64_t) g6; + i64 f0g7 = f0 * (int64_t) g7; + i64 f0g8 = f0 * (int64_t) g8; + i64 f0g9 = f0 * (int64_t) g9; + i64 f1g0 = f1 * (int64_t) g0; + i64 f1g1_2 = f1_2 * (int64_t) g1; + i64 f1g2 = f1 * (int64_t) g2; + i64 f1g3_2 = f1_2 * (int64_t) g3; + i64 f1g4 = f1 * (int64_t) g4; + i64 f1g5_2 = f1_2 * (int64_t) g5; + i64 f1g6 = f1 * (int64_t) g6; + i64 f1g7_2 = f1_2 * (int64_t) g7; + i64 f1g8 = f1 * (int64_t) g8; + i64 f1g9_38 = f1_2 * (int64_t) g9_19; + i64 f2g0 = f2 * (int64_t) g0; + i64 f2g1 = f2 * (int64_t) g1; + i64 f2g2 = f2 * (int64_t) g2; + i64 f2g3 = f2 * (int64_t) g3; + i64 f2g4 = f2 * (int64_t) g4; + i64 f2g5 = f2 * (int64_t) g5; + i64 f2g6 = f2 * (int64_t) g6; + i64 f2g7 = f2 * (int64_t) g7; + i64 f2g8_19 = f2 * (int64_t) g8_19; + i64 f2g9_19 = f2 * (int64_t) g9_19; + i64 f3g0 = f3 * (int64_t) g0; + i64 f3g1_2 = f3_2 * (int64_t) g1; + i64 f3g2 = f3 * (int64_t) g2; + i64 f3g3_2 = f3_2 * (int64_t) g3; + i64 f3g4 = f3 * (int64_t) g4; + i64 f3g5_2 = f3_2 * (int64_t) g5; + i64 f3g6 = f3 * (int64_t) g6; + i64 f3g7_38 = f3_2 * (int64_t) g7_19; + i64 f3g8_19 = f3 * (int64_t) g8_19; + i64 f3g9_38 = f3_2 * (int64_t) g9_19; + i64 f4g0 = f4 * (int64_t) g0; + i64 f4g1 = f4 * (int64_t) g1; + i64 f4g2 = f4 * (int64_t) g2; + i64 f4g3 = f4 * (int64_t) g3; + i64 f4g4 = f4 * (int64_t) g4; + i64 f4g5 = f4 * (int64_t) g5; + i64 f4g6_19 = f4 * (int64_t) g6_19; + i64 f4g7_19 = f4 * (int64_t) g7_19; + i64 f4g8_19 = f4 * (int64_t) g8_19; + i64 f4g9_19 = f4 * (int64_t) g9_19; + i64 f5g0 = f5 * (int64_t) g0; + i64 f5g1_2 = f5_2 * (int64_t) g1; + i64 f5g2 = f5 * (int64_t) g2; + i64 f5g3_2 = f5_2 * (int64_t) g3; + i64 f5g4 = f5 * (int64_t) g4; + i64 f5g5_38 = f5_2 * (int64_t) g5_19; + i64 f5g6_19 = f5 * (int64_t) g6_19; + i64 f5g7_38 = f5_2 * (int64_t) g7_19; + i64 f5g8_19 = f5 * (int64_t) g8_19; + i64 f5g9_38 = f5_2 * (int64_t) g9_19; + i64 f6g0 = f6 * (int64_t) g0; + i64 f6g1 = f6 * (int64_t) g1; + i64 f6g2 = f6 * (int64_t) g2; + i64 f6g3 = f6 * (int64_t) g3; + i64 f6g4_19 = f6 * (int64_t) g4_19; + i64 f6g5_19 = f6 * (int64_t) g5_19; + i64 f6g6_19 = f6 * (int64_t) g6_19; + i64 f6g7_19 = f6 * (int64_t) g7_19; + i64 f6g8_19 = f6 * (int64_t) g8_19; + i64 f6g9_19 = f6 * (int64_t) g9_19; + i64 f7g0 = f7 * (int64_t) g0; + i64 f7g1_2 = f7_2 * (int64_t) g1; + i64 f7g2 = f7 * (int64_t) g2; + i64 f7g3_38 = f7_2 * (int64_t) g3_19; + i64 f7g4_19 = f7 * (int64_t) g4_19; + i64 f7g5_38 = f7_2 * (int64_t) g5_19; + i64 f7g6_19 = f7 * (int64_t) g6_19; + i64 f7g7_38 = f7_2 * (int64_t) g7_19; + i64 f7g8_19 = f7 * (int64_t) g8_19; + i64 f7g9_38 = f7_2 * (int64_t) g9_19; + i64 f8g0 = f8 * (int64_t) g0; + i64 f8g1 = f8 * (int64_t) g1; + i64 f8g2_19 = f8 * (int64_t) g2_19; + i64 f8g3_19 = f8 * (int64_t) g3_19; + i64 f8g4_19 = f8 * (int64_t) g4_19; + i64 f8g5_19 = f8 * (int64_t) g5_19; + i64 f8g6_19 = f8 * (int64_t) g6_19; + i64 f8g7_19 = f8 * (int64_t) g7_19; + i64 f8g8_19 = f8 * (int64_t) g8_19; + i64 f8g9_19 = f8 * (int64_t) g9_19; + i64 f9g0 = f9 * (int64_t) g0; + i64 f9g1_38 = f9_2 * (int64_t) g1_19; + i64 f9g2_19 = f9 * (int64_t) g2_19; + i64 f9g3_38 = f9_2 * (int64_t) g3_19; + i64 f9g4_19 = f9 * (int64_t) g4_19; + i64 f9g5_38 = f9_2 * (int64_t) g5_19; + i64 f9g6_19 = f9 * (int64_t) g6_19; + i64 f9g7_38 = f9_2 * (int64_t) g7_19; + i64 f9g8_19 = f9 * (int64_t) g8_19; + i64 f9g9_38 = f9_2 * (int64_t) g9_19; + i64 h0 = f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38; + i64 h1 = f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + f7g4_19 + f8g3_19 + f9g2_19; + i64 h2 = f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + f7g5_38 + f8g4_19 + f9g3_38; + i64 h3 = f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + f7g6_19 + f8g5_19 + f9g4_19; + i64 h4 = f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + f7g7_38 + f8g6_19 + f9g5_38; + i64 h5 = f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + f8g7_19 + f9g6_19; + i64 h6 = f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + f7g9_38 + f8g8_19 + f9g7_38; + i64 h7 = f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + f8g9_19 + f9g8_19; + i64 h8 = f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + f8g0 + f9g9_38; + i64 h9 = f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0 ; + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry1 = (h1 + (int64_t) (1 << 24)) >> 25; + carry1 = (h1 + (i64) (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry5 = (h5 + (int64_t) (1 << 24)) >> 25; + carry5 = (h5 + (i64) (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry2 = (h2 + (int64_t) (1 << 25)) >> 26; + carry2 = (h2 + (i64) (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry6 = (h6 + (int64_t) (1 << 25)) >> 26; + carry6 = (h6 + (i64) (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry3 = (h3 + (int64_t) (1 << 24)) >> 25; + carry3 = (h3 + (i64) (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry7 = (h7 + (int64_t) (1 << 24)) >> 25; + carry7 = (h7 + (i64) (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry8 = (h8 + (int64_t) (1 << 25)) >> 26; + carry8 = (h8 + (i64) (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - carry9 = (h9 + (int64_t) (1 << 24)) >> 25; + carry9 = (h9 + (i64) (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; @@ -792,38 +792,38 @@ void fe_mul121666(fe h, fe f) { i32 f7 = f[7]; i32 f8 = f[8]; i32 f9 = f[9]; - int64_t h0 = f0 * (int64_t) 121666; - int64_t h1 = f1 * (int64_t) 121666; - int64_t h2 = f2 * (int64_t) 121666; - int64_t h3 = f3 * (int64_t) 121666; - int64_t h4 = f4 * (int64_t) 121666; - int64_t h5 = f5 * (int64_t) 121666; - int64_t h6 = f6 * (int64_t) 121666; - int64_t h7 = f7 * (int64_t) 121666; - int64_t h8 = f8 * (int64_t) 121666; - int64_t h9 = f9 * (int64_t) 121666; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; + i64 h0 = f0 * (int64_t) 121666; + i64 h1 = f1 * (int64_t) 121666; + i64 h2 = f2 * (int64_t) 121666; + i64 h3 = f3 * (int64_t) 121666; + i64 h4 = f4 * (int64_t) 121666; + i64 h5 = f5 * (int64_t) 121666; + i64 h6 = f6 * (int64_t) 121666; + i64 h7 = f7 * (int64_t) 121666; + i64 h8 = f8 * (int64_t) 121666; + i64 h9 = f9 * (int64_t) 121666; + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; - carry9 = (h9 + (int64_t) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry1 = (h1 + (int64_t) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry3 = (h3 + (int64_t) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry5 = (h5 + (int64_t) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry7 = (h7 + (int64_t) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; + carry9 = (h9 + (i64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; + carry1 = (h1 + (i64) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; + carry3 = (h3 + (i64) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; + carry5 = (h5 + (i64) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; + carry7 = (h7 + (i64) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry0 = (h0 + (int64_t) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry2 = (h2 + (int64_t) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry4 = (h4 + (int64_t) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry6 = (h6 + (int64_t) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry8 = (h8 + (int64_t) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; + carry0 = (h0 + (i64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; + carry2 = (h2 + (i64) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; + carry4 = (h4 + (i64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; + carry6 = (h6 + (i64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; + carry8 = (h8 + (i64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; h[0] = h0; h[1] = h1; @@ -1008,115 +1008,115 @@ void fe_sq(fe h, const fe f) { i32 f7_38 = 38 * f7; /* 1.959375*2^30 */ i32 f8_19 = 19 * f8; /* 1.959375*2^30 */ i32 f9_38 = 38 * f9; /* 1.959375*2^30 */ - int64_t f0f0 = f0 * (int64_t) f0; - int64_t f0f1_2 = f0_2 * (int64_t) f1; - int64_t f0f2_2 = f0_2 * (int64_t) f2; - int64_t f0f3_2 = f0_2 * (int64_t) f3; - int64_t f0f4_2 = f0_2 * (int64_t) f4; - int64_t f0f5_2 = f0_2 * (int64_t) f5; - int64_t f0f6_2 = f0_2 * (int64_t) f6; - int64_t f0f7_2 = f0_2 * (int64_t) f7; - int64_t f0f8_2 = f0_2 * (int64_t) f8; - int64_t f0f9_2 = f0_2 * (int64_t) f9; - int64_t f1f1_2 = f1_2 * (int64_t) f1; - int64_t f1f2_2 = f1_2 * (int64_t) f2; - int64_t f1f3_4 = f1_2 * (int64_t) f3_2; - int64_t f1f4_2 = f1_2 * (int64_t) f4; - int64_t f1f5_4 = f1_2 * (int64_t) f5_2; - int64_t f1f6_2 = f1_2 * (int64_t) f6; - int64_t f1f7_4 = f1_2 * (int64_t) f7_2; - int64_t f1f8_2 = f1_2 * (int64_t) f8; - int64_t f1f9_76 = f1_2 * (int64_t) f9_38; - int64_t f2f2 = f2 * (int64_t) f2; - int64_t f2f3_2 = f2_2 * (int64_t) f3; - int64_t f2f4_2 = f2_2 * (int64_t) f4; - int64_t f2f5_2 = f2_2 * (int64_t) f5; - int64_t f2f6_2 = f2_2 * (int64_t) f6; - int64_t f2f7_2 = f2_2 * (int64_t) f7; - int64_t f2f8_38 = f2_2 * (int64_t) f8_19; - int64_t f2f9_38 = f2 * (int64_t) f9_38; - int64_t f3f3_2 = f3_2 * (int64_t) f3; - int64_t f3f4_2 = f3_2 * (int64_t) f4; - int64_t f3f5_4 = f3_2 * (int64_t) f5_2; - int64_t f3f6_2 = f3_2 * (int64_t) f6; - int64_t f3f7_76 = f3_2 * (int64_t) f7_38; - int64_t f3f8_38 = f3_2 * (int64_t) f8_19; - int64_t f3f9_76 = f3_2 * (int64_t) f9_38; - int64_t f4f4 = f4 * (int64_t) f4; - int64_t f4f5_2 = f4_2 * (int64_t) f5; - int64_t f4f6_38 = f4_2 * (int64_t) f6_19; - int64_t f4f7_38 = f4 * (int64_t) f7_38; - int64_t f4f8_38 = f4_2 * (int64_t) f8_19; - int64_t f4f9_38 = f4 * (int64_t) f9_38; - int64_t f5f5_38 = f5 * (int64_t) f5_38; - int64_t f5f6_38 = f5_2 * (int64_t) f6_19; - int64_t f5f7_76 = f5_2 * (int64_t) f7_38; - int64_t f5f8_38 = f5_2 * (int64_t) f8_19; - int64_t f5f9_76 = f5_2 * (int64_t) f9_38; - int64_t f6f6_19 = f6 * (int64_t) f6_19; - int64_t f6f7_38 = f6 * (int64_t) f7_38; - int64_t f6f8_38 = f6_2 * (int64_t) f8_19; - int64_t f6f9_38 = f6 * (int64_t) f9_38; - int64_t f7f7_38 = f7 * (int64_t) f7_38; - int64_t f7f8_38 = f7_2 * (int64_t) f8_19; - int64_t f7f9_76 = f7_2 * (int64_t) f9_38; - int64_t f8f8_19 = f8 * (int64_t) f8_19; - int64_t f8f9_38 = f8 * (int64_t) f9_38; - int64_t f9f9_38 = f9 * (int64_t) f9_38; - int64_t h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; - int64_t h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; - int64_t h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; - int64_t h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; - int64_t h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; - int64_t h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; - int64_t h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; - int64_t h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; - int64_t h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; - int64_t h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + i64 f0f0 = f0 * (int64_t) f0; + i64 f0f1_2 = f0_2 * (int64_t) f1; + i64 f0f2_2 = f0_2 * (int64_t) f2; + i64 f0f3_2 = f0_2 * (int64_t) f3; + i64 f0f4_2 = f0_2 * (int64_t) f4; + i64 f0f5_2 = f0_2 * (int64_t) f5; + i64 f0f6_2 = f0_2 * (int64_t) f6; + i64 f0f7_2 = f0_2 * (int64_t) f7; + i64 f0f8_2 = f0_2 * (int64_t) f8; + i64 f0f9_2 = f0_2 * (int64_t) f9; + i64 f1f1_2 = f1_2 * (int64_t) f1; + i64 f1f2_2 = f1_2 * (int64_t) f2; + i64 f1f3_4 = f1_2 * (int64_t) f3_2; + i64 f1f4_2 = f1_2 * (int64_t) f4; + i64 f1f5_4 = f1_2 * (int64_t) f5_2; + i64 f1f6_2 = f1_2 * (int64_t) f6; + i64 f1f7_4 = f1_2 * (int64_t) f7_2; + i64 f1f8_2 = f1_2 * (int64_t) f8; + i64 f1f9_76 = f1_2 * (int64_t) f9_38; + i64 f2f2 = f2 * (int64_t) f2; + i64 f2f3_2 = f2_2 * (int64_t) f3; + i64 f2f4_2 = f2_2 * (int64_t) f4; + i64 f2f5_2 = f2_2 * (int64_t) f5; + i64 f2f6_2 = f2_2 * (int64_t) f6; + i64 f2f7_2 = f2_2 * (int64_t) f7; + i64 f2f8_38 = f2_2 * (int64_t) f8_19; + i64 f2f9_38 = f2 * (int64_t) f9_38; + i64 f3f3_2 = f3_2 * (int64_t) f3; + i64 f3f4_2 = f3_2 * (int64_t) f4; + i64 f3f5_4 = f3_2 * (int64_t) f5_2; + i64 f3f6_2 = f3_2 * (int64_t) f6; + i64 f3f7_76 = f3_2 * (int64_t) f7_38; + i64 f3f8_38 = f3_2 * (int64_t) f8_19; + i64 f3f9_76 = f3_2 * (int64_t) f9_38; + i64 f4f4 = f4 * (int64_t) f4; + i64 f4f5_2 = f4_2 * (int64_t) f5; + i64 f4f6_38 = f4_2 * (int64_t) f6_19; + i64 f4f7_38 = f4 * (int64_t) f7_38; + i64 f4f8_38 = f4_2 * (int64_t) f8_19; + i64 f4f9_38 = f4 * (int64_t) f9_38; + i64 f5f5_38 = f5 * (int64_t) f5_38; + i64 f5f6_38 = f5_2 * (int64_t) f6_19; + i64 f5f7_76 = f5_2 * (int64_t) f7_38; + i64 f5f8_38 = f5_2 * (int64_t) f8_19; + i64 f5f9_76 = f5_2 * (int64_t) f9_38; + i64 f6f6_19 = f6 * (int64_t) f6_19; + i64 f6f7_38 = f6 * (int64_t) f7_38; + i64 f6f8_38 = f6_2 * (int64_t) f8_19; + i64 f6f9_38 = f6 * (int64_t) f9_38; + i64 f7f7_38 = f7 * (int64_t) f7_38; + i64 f7f8_38 = f7_2 * (int64_t) f8_19; + i64 f7f9_76 = f7_2 * (int64_t) f9_38; + i64 f8f8_19 = f8 * (int64_t) f8_19; + i64 f8f9_38 = f8 * (int64_t) f9_38; + i64 f9f9_38 = f9 * (int64_t) f9_38; + i64 h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; + i64 h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; + i64 h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; + i64 h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; + i64 h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; + i64 h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; + i64 h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; + i64 h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; + i64 h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; + i64 h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry1 = (h1 + (int64_t) (1 << 24)) >> 25; + carry1 = (h1 + (i64) (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry5 = (h5 + (int64_t) (1 << 24)) >> 25; + carry5 = (h5 + (i64) (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry2 = (h2 + (int64_t) (1 << 25)) >> 26; + carry2 = (h2 + (i64) (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry6 = (h6 + (int64_t) (1 << 25)) >> 26; + carry6 = (h6 + (i64) (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry3 = (h3 + (int64_t) (1 << 24)) >> 25; + carry3 = (h3 + (i64) (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry7 = (h7 + (int64_t) (1 << 24)) >> 25; + carry7 = (h7 + (i64) (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry8 = (h8 + (int64_t) (1 << 25)) >> 26; + carry8 = (h8 + (i64) (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - carry9 = (h9 + (int64_t) (1 << 24)) >> 25; + carry9 = (h9 + (i64) (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; h[0] = (i32) h0; @@ -1171,81 +1171,81 @@ void fe_sq2(fe h, const fe f) { i32 f7_38 = 38 * f7; /* 1.959375*2^30 */ i32 f8_19 = 19 * f8; /* 1.959375*2^30 */ i32 f9_38 = 38 * f9; /* 1.959375*2^30 */ - int64_t f0f0 = f0 * (int64_t) f0; - int64_t f0f1_2 = f0_2 * (int64_t) f1; - int64_t f0f2_2 = f0_2 * (int64_t) f2; - int64_t f0f3_2 = f0_2 * (int64_t) f3; - int64_t f0f4_2 = f0_2 * (int64_t) f4; - int64_t f0f5_2 = f0_2 * (int64_t) f5; - int64_t f0f6_2 = f0_2 * (int64_t) f6; - int64_t f0f7_2 = f0_2 * (int64_t) f7; - int64_t f0f8_2 = f0_2 * (int64_t) f8; - int64_t f0f9_2 = f0_2 * (int64_t) f9; - int64_t f1f1_2 = f1_2 * (int64_t) f1; - int64_t f1f2_2 = f1_2 * (int64_t) f2; - int64_t f1f3_4 = f1_2 * (int64_t) f3_2; - int64_t f1f4_2 = f1_2 * (int64_t) f4; - int64_t f1f5_4 = f1_2 * (int64_t) f5_2; - int64_t f1f6_2 = f1_2 * (int64_t) f6; - int64_t f1f7_4 = f1_2 * (int64_t) f7_2; - int64_t f1f8_2 = f1_2 * (int64_t) f8; - int64_t f1f9_76 = f1_2 * (int64_t) f9_38; - int64_t f2f2 = f2 * (int64_t) f2; - int64_t f2f3_2 = f2_2 * (int64_t) f3; - int64_t f2f4_2 = f2_2 * (int64_t) f4; - int64_t f2f5_2 = f2_2 * (int64_t) f5; - int64_t f2f6_2 = f2_2 * (int64_t) f6; - int64_t f2f7_2 = f2_2 * (int64_t) f7; - int64_t f2f8_38 = f2_2 * (int64_t) f8_19; - int64_t f2f9_38 = f2 * (int64_t) f9_38; - int64_t f3f3_2 = f3_2 * (int64_t) f3; - int64_t f3f4_2 = f3_2 * (int64_t) f4; - int64_t f3f5_4 = f3_2 * (int64_t) f5_2; - int64_t f3f6_2 = f3_2 * (int64_t) f6; - int64_t f3f7_76 = f3_2 * (int64_t) f7_38; - int64_t f3f8_38 = f3_2 * (int64_t) f8_19; - int64_t f3f9_76 = f3_2 * (int64_t) f9_38; - int64_t f4f4 = f4 * (int64_t) f4; - int64_t f4f5_2 = f4_2 * (int64_t) f5; - int64_t f4f6_38 = f4_2 * (int64_t) f6_19; - int64_t f4f7_38 = f4 * (int64_t) f7_38; - int64_t f4f8_38 = f4_2 * (int64_t) f8_19; - int64_t f4f9_38 = f4 * (int64_t) f9_38; - int64_t f5f5_38 = f5 * (int64_t) f5_38; - int64_t f5f6_38 = f5_2 * (int64_t) f6_19; - int64_t f5f7_76 = f5_2 * (int64_t) f7_38; - int64_t f5f8_38 = f5_2 * (int64_t) f8_19; - int64_t f5f9_76 = f5_2 * (int64_t) f9_38; - int64_t f6f6_19 = f6 * (int64_t) f6_19; - int64_t f6f7_38 = f6 * (int64_t) f7_38; - int64_t f6f8_38 = f6_2 * (int64_t) f8_19; - int64_t f6f9_38 = f6 * (int64_t) f9_38; - int64_t f7f7_38 = f7 * (int64_t) f7_38; - int64_t f7f8_38 = f7_2 * (int64_t) f8_19; - int64_t f7f9_76 = f7_2 * (int64_t) f9_38; - int64_t f8f8_19 = f8 * (int64_t) f8_19; - int64_t f8f9_38 = f8 * (int64_t) f9_38; - int64_t f9f9_38 = f9 * (int64_t) f9_38; - int64_t h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; - int64_t h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; - int64_t h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; - int64_t h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; - int64_t h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; - int64_t h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; - int64_t h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; - int64_t h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; - int64_t h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; - int64_t h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; + i64 f0f0 = f0 * (int64_t) f0; + i64 f0f1_2 = f0_2 * (int64_t) f1; + i64 f0f2_2 = f0_2 * (int64_t) f2; + i64 f0f3_2 = f0_2 * (int64_t) f3; + i64 f0f4_2 = f0_2 * (int64_t) f4; + i64 f0f5_2 = f0_2 * (int64_t) f5; + i64 f0f6_2 = f0_2 * (int64_t) f6; + i64 f0f7_2 = f0_2 * (int64_t) f7; + i64 f0f8_2 = f0_2 * (int64_t) f8; + i64 f0f9_2 = f0_2 * (int64_t) f9; + i64 f1f1_2 = f1_2 * (int64_t) f1; + i64 f1f2_2 = f1_2 * (int64_t) f2; + i64 f1f3_4 = f1_2 * (int64_t) f3_2; + i64 f1f4_2 = f1_2 * (int64_t) f4; + i64 f1f5_4 = f1_2 * (int64_t) f5_2; + i64 f1f6_2 = f1_2 * (int64_t) f6; + i64 f1f7_4 = f1_2 * (int64_t) f7_2; + i64 f1f8_2 = f1_2 * (int64_t) f8; + i64 f1f9_76 = f1_2 * (int64_t) f9_38; + i64 f2f2 = f2 * (int64_t) f2; + i64 f2f3_2 = f2_2 * (int64_t) f3; + i64 f2f4_2 = f2_2 * (int64_t) f4; + i64 f2f5_2 = f2_2 * (int64_t) f5; + i64 f2f6_2 = f2_2 * (int64_t) f6; + i64 f2f7_2 = f2_2 * (int64_t) f7; + i64 f2f8_38 = f2_2 * (int64_t) f8_19; + i64 f2f9_38 = f2 * (int64_t) f9_38; + i64 f3f3_2 = f3_2 * (int64_t) f3; + i64 f3f4_2 = f3_2 * (int64_t) f4; + i64 f3f5_4 = f3_2 * (int64_t) f5_2; + i64 f3f6_2 = f3_2 * (int64_t) f6; + i64 f3f7_76 = f3_2 * (int64_t) f7_38; + i64 f3f8_38 = f3_2 * (int64_t) f8_19; + i64 f3f9_76 = f3_2 * (int64_t) f9_38; + i64 f4f4 = f4 * (int64_t) f4; + i64 f4f5_2 = f4_2 * (int64_t) f5; + i64 f4f6_38 = f4_2 * (int64_t) f6_19; + i64 f4f7_38 = f4 * (int64_t) f7_38; + i64 f4f8_38 = f4_2 * (int64_t) f8_19; + i64 f4f9_38 = f4 * (int64_t) f9_38; + i64 f5f5_38 = f5 * (int64_t) f5_38; + i64 f5f6_38 = f5_2 * (int64_t) f6_19; + i64 f5f7_76 = f5_2 * (int64_t) f7_38; + i64 f5f8_38 = f5_2 * (int64_t) f8_19; + i64 f5f9_76 = f5_2 * (int64_t) f9_38; + i64 f6f6_19 = f6 * (int64_t) f6_19; + i64 f6f7_38 = f6 * (int64_t) f7_38; + i64 f6f8_38 = f6_2 * (int64_t) f8_19; + i64 f6f9_38 = f6 * (int64_t) f9_38; + i64 f7f7_38 = f7 * (int64_t) f7_38; + i64 f7f8_38 = f7_2 * (int64_t) f8_19; + i64 f7f9_76 = f7_2 * (int64_t) f9_38; + i64 f8f8_19 = f8 * (int64_t) f8_19; + i64 f8f9_38 = f8 * (int64_t) f9_38; + i64 f9f9_38 = f9 * (int64_t) f9_38; + i64 h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; + i64 h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; + i64 h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; + i64 h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; + i64 h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; + i64 h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; + i64 h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; + i64 h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; + i64 h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; + i64 h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; h0 += h0; h1 += h1; h2 += h2; @@ -1256,40 +1256,40 @@ void fe_sq2(fe h, const fe f) { h7 += h7; h8 += h8; h9 += h9; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry1 = (h1 + (int64_t) (1 << 24)) >> 25; + carry1 = (h1 + (i64) (1 << 24)) >> 25; h2 += carry1; h1 -= carry1 << 25; - carry5 = (h5 + (int64_t) (1 << 24)) >> 25; + carry5 = (h5 + (i64) (1 << 24)) >> 25; h6 += carry5; h5 -= carry5 << 25; - carry2 = (h2 + (int64_t) (1 << 25)) >> 26; + carry2 = (h2 + (i64) (1 << 25)) >> 26; h3 += carry2; h2 -= carry2 << 26; - carry6 = (h6 + (int64_t) (1 << 25)) >> 26; + carry6 = (h6 + (i64) (1 << 25)) >> 26; h7 += carry6; h6 -= carry6 << 26; - carry3 = (h3 + (int64_t) (1 << 24)) >> 25; + carry3 = (h3 + (i64) (1 << 24)) >> 25; h4 += carry3; h3 -= carry3 << 25; - carry7 = (h7 + (int64_t) (1 << 24)) >> 25; + carry7 = (h7 + (i64) (1 << 24)) >> 25; h8 += carry7; h7 -= carry7 << 25; - carry4 = (h4 + (int64_t) (1 << 25)) >> 26; + carry4 = (h4 + (i64) (1 << 25)) >> 26; h5 += carry4; h4 -= carry4 << 26; - carry8 = (h8 + (int64_t) (1 << 25)) >> 26; + carry8 = (h8 + (i64) (1 << 25)) >> 26; h9 += carry8; h8 -= carry8 << 26; - carry9 = (h9 + (int64_t) (1 << 24)) >> 25; + carry9 = (h9 + (i64) (1 << 24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; - carry0 = (h0 + (int64_t) (1 << 25)) >> 26; + carry0 = (h0 + (i64) (1 << 25)) >> 26; h1 += carry0; h0 -= carry0 << 26; h[0] = (i32) h0; diff --git a/ed25519/src/sc.cpp b/ed25519/src/sc.cpp index 4fc2f001b..2c4ae8738 100644 --- a/ed25519/src/sc.cpp +++ b/ed25519/src/sc.cpp @@ -33,47 +33,47 @@ Output: */ void sc_reduce(unsigned char *s) { - int64_t s0 = 2097151 & load_3(s); - int64_t s1 = 2097151 & (load_4(s + 2) >> 5); - int64_t s2 = 2097151 & (load_3(s + 5) >> 2); - int64_t s3 = 2097151 & (load_4(s + 7) >> 7); - int64_t s4 = 2097151 & (load_4(s + 10) >> 4); - int64_t s5 = 2097151 & (load_3(s + 13) >> 1); - int64_t s6 = 2097151 & (load_4(s + 15) >> 6); - int64_t s7 = 2097151 & (load_3(s + 18) >> 3); - int64_t s8 = 2097151 & load_3(s + 21); - int64_t s9 = 2097151 & (load_4(s + 23) >> 5); - int64_t s10 = 2097151 & (load_3(s + 26) >> 2); - int64_t s11 = 2097151 & (load_4(s + 28) >> 7); - int64_t s12 = 2097151 & (load_4(s + 31) >> 4); - int64_t s13 = 2097151 & (load_3(s + 34) >> 1); - int64_t s14 = 2097151 & (load_4(s + 36) >> 6); - int64_t s15 = 2097151 & (load_3(s + 39) >> 3); - int64_t s16 = 2097151 & load_3(s + 42); - int64_t s17 = 2097151 & (load_4(s + 44) >> 5); - int64_t s18 = 2097151 & (load_3(s + 47) >> 2); - int64_t s19 = 2097151 & (load_4(s + 49) >> 7); - int64_t s20 = 2097151 & (load_4(s + 52) >> 4); - int64_t s21 = 2097151 & (load_3(s + 55) >> 1); - int64_t s22 = 2097151 & (load_4(s + 57) >> 6); - int64_t s23 = (load_4(s + 60) >> 3); - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - int64_t carry10; - int64_t carry11; - int64_t carry12; - int64_t carry13; - int64_t carry14; - int64_t carry15; - int64_t carry16; + i64 s0 = 2097151 & load_3(s); + i64 s1 = 2097151 & (load_4(s + 2) >> 5); + i64 s2 = 2097151 & (load_3(s + 5) >> 2); + i64 s3 = 2097151 & (load_4(s + 7) >> 7); + i64 s4 = 2097151 & (load_4(s + 10) >> 4); + i64 s5 = 2097151 & (load_3(s + 13) >> 1); + i64 s6 = 2097151 & (load_4(s + 15) >> 6); + i64 s7 = 2097151 & (load_3(s + 18) >> 3); + i64 s8 = 2097151 & load_3(s + 21); + i64 s9 = 2097151 & (load_4(s + 23) >> 5); + i64 s10 = 2097151 & (load_3(s + 26) >> 2); + i64 s11 = 2097151 & (load_4(s + 28) >> 7); + i64 s12 = 2097151 & (load_4(s + 31) >> 4); + i64 s13 = 2097151 & (load_3(s + 34) >> 1); + i64 s14 = 2097151 & (load_4(s + 36) >> 6); + i64 s15 = 2097151 & (load_3(s + 39) >> 3); + i64 s16 = 2097151 & load_3(s + 42); + i64 s17 = 2097151 & (load_4(s + 44) >> 5); + i64 s18 = 2097151 & (load_3(s + 47) >> 2); + i64 s19 = 2097151 & (load_4(s + 49) >> 7); + i64 s20 = 2097151 & (load_4(s + 52) >> 4); + i64 s21 = 2097151 & (load_3(s + 55) >> 1); + i64 s22 = 2097151 & (load_4(s + 57) >> 6); + i64 s23 = (load_4(s + 60) >> 3); + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; + i64 carry10; + i64 carry11; + i64 carry12; + i64 carry13; + i64 carry14; + i64 carry15; + i64 carry16; s11 += s23 * 666643; s12 += s23 * 470296; @@ -360,89 +360,89 @@ Output: */ void sc_muladd(unsigned char *s, const unsigned char *a, const unsigned char *b, const unsigned char *c) { - int64_t a0 = 2097151 & load_3(a); - int64_t a1 = 2097151 & (load_4(a + 2) >> 5); - int64_t a2 = 2097151 & (load_3(a + 5) >> 2); - int64_t a3 = 2097151 & (load_4(a + 7) >> 7); - int64_t a4 = 2097151 & (load_4(a + 10) >> 4); - int64_t a5 = 2097151 & (load_3(a + 13) >> 1); - int64_t a6 = 2097151 & (load_4(a + 15) >> 6); - int64_t a7 = 2097151 & (load_3(a + 18) >> 3); - int64_t a8 = 2097151 & load_3(a + 21); - int64_t a9 = 2097151 & (load_4(a + 23) >> 5); - int64_t a10 = 2097151 & (load_3(a + 26) >> 2); - int64_t a11 = (load_4(a + 28) >> 7); - int64_t b0 = 2097151 & load_3(b); - int64_t b1 = 2097151 & (load_4(b + 2) >> 5); - int64_t b2 = 2097151 & (load_3(b + 5) >> 2); - int64_t b3 = 2097151 & (load_4(b + 7) >> 7); - int64_t b4 = 2097151 & (load_4(b + 10) >> 4); - int64_t b5 = 2097151 & (load_3(b + 13) >> 1); - int64_t b6 = 2097151 & (load_4(b + 15) >> 6); - int64_t b7 = 2097151 & (load_3(b + 18) >> 3); - int64_t b8 = 2097151 & load_3(b + 21); - int64_t b9 = 2097151 & (load_4(b + 23) >> 5); - int64_t b10 = 2097151 & (load_3(b + 26) >> 2); - int64_t b11 = (load_4(b + 28) >> 7); - int64_t c0 = 2097151 & load_3(c); - int64_t c1 = 2097151 & (load_4(c + 2) >> 5); - int64_t c2 = 2097151 & (load_3(c + 5) >> 2); - int64_t c3 = 2097151 & (load_4(c + 7) >> 7); - int64_t c4 = 2097151 & (load_4(c + 10) >> 4); - int64_t c5 = 2097151 & (load_3(c + 13) >> 1); - int64_t c6 = 2097151 & (load_4(c + 15) >> 6); - int64_t c7 = 2097151 & (load_3(c + 18) >> 3); - int64_t c8 = 2097151 & load_3(c + 21); - int64_t c9 = 2097151 & (load_4(c + 23) >> 5); - int64_t c10 = 2097151 & (load_3(c + 26) >> 2); - int64_t c11 = (load_4(c + 28) >> 7); - int64_t s0; - int64_t s1; - int64_t s2; - int64_t s3; - int64_t s4; - int64_t s5; - int64_t s6; - int64_t s7; - int64_t s8; - int64_t s9; - int64_t s10; - int64_t s11; - int64_t s12; - int64_t s13; - int64_t s14; - int64_t s15; - int64_t s16; - int64_t s17; - int64_t s18; - int64_t s19; - int64_t s20; - int64_t s21; - int64_t s22; - int64_t s23; - int64_t carry0; - int64_t carry1; - int64_t carry2; - int64_t carry3; - int64_t carry4; - int64_t carry5; - int64_t carry6; - int64_t carry7; - int64_t carry8; - int64_t carry9; - int64_t carry10; - int64_t carry11; - int64_t carry12; - int64_t carry13; - int64_t carry14; - int64_t carry15; - int64_t carry16; - int64_t carry17; - int64_t carry18; - int64_t carry19; - int64_t carry20; - int64_t carry21; - int64_t carry22; + i64 a0 = 2097151 & load_3(a); + i64 a1 = 2097151 & (load_4(a + 2) >> 5); + i64 a2 = 2097151 & (load_3(a + 5) >> 2); + i64 a3 = 2097151 & (load_4(a + 7) >> 7); + i64 a4 = 2097151 & (load_4(a + 10) >> 4); + i64 a5 = 2097151 & (load_3(a + 13) >> 1); + i64 a6 = 2097151 & (load_4(a + 15) >> 6); + i64 a7 = 2097151 & (load_3(a + 18) >> 3); + i64 a8 = 2097151 & load_3(a + 21); + i64 a9 = 2097151 & (load_4(a + 23) >> 5); + i64 a10 = 2097151 & (load_3(a + 26) >> 2); + i64 a11 = (load_4(a + 28) >> 7); + i64 b0 = 2097151 & load_3(b); + i64 b1 = 2097151 & (load_4(b + 2) >> 5); + i64 b2 = 2097151 & (load_3(b + 5) >> 2); + i64 b3 = 2097151 & (load_4(b + 7) >> 7); + i64 b4 = 2097151 & (load_4(b + 10) >> 4); + i64 b5 = 2097151 & (load_3(b + 13) >> 1); + i64 b6 = 2097151 & (load_4(b + 15) >> 6); + i64 b7 = 2097151 & (load_3(b + 18) >> 3); + i64 b8 = 2097151 & load_3(b + 21); + i64 b9 = 2097151 & (load_4(b + 23) >> 5); + i64 b10 = 2097151 & (load_3(b + 26) >> 2); + i64 b11 = (load_4(b + 28) >> 7); + i64 c0 = 2097151 & load_3(c); + i64 c1 = 2097151 & (load_4(c + 2) >> 5); + i64 c2 = 2097151 & (load_3(c + 5) >> 2); + i64 c3 = 2097151 & (load_4(c + 7) >> 7); + i64 c4 = 2097151 & (load_4(c + 10) >> 4); + i64 c5 = 2097151 & (load_3(c + 13) >> 1); + i64 c6 = 2097151 & (load_4(c + 15) >> 6); + i64 c7 = 2097151 & (load_3(c + 18) >> 3); + i64 c8 = 2097151 & load_3(c + 21); + i64 c9 = 2097151 & (load_4(c + 23) >> 5); + i64 c10 = 2097151 & (load_3(c + 26) >> 2); + i64 c11 = (load_4(c + 28) >> 7); + i64 s0; + i64 s1; + i64 s2; + i64 s3; + i64 s4; + i64 s5; + i64 s6; + i64 s7; + i64 s8; + i64 s9; + i64 s10; + i64 s11; + i64 s12; + i64 s13; + i64 s14; + i64 s15; + i64 s16; + i64 s17; + i64 s18; + i64 s19; + i64 s20; + i64 s21; + i64 s22; + i64 s23; + i64 carry0; + i64 carry1; + i64 carry2; + i64 carry3; + i64 carry4; + i64 carry5; + i64 carry6; + i64 carry7; + i64 carry8; + i64 carry9; + i64 carry10; + i64 carry11; + i64 carry12; + i64 carry13; + i64 carry14; + i64 carry15; + i64 carry16; + i64 carry17; + i64 carry18; + i64 carry19; + i64 carry20; + i64 carry21; + i64 carry22; s0 = c0 + a0 * b0; s1 = c1 + a0 * b1 + a1 * b0; diff --git a/examples/print.cpp b/examples/print.cpp index 14ba44f89..b4fd51add 100644 --- a/examples/print.cpp +++ b/examples/print.cpp @@ -303,7 +303,7 @@ void print(char const* str) { COORD pos = sbi.dwCursorPosition; int width = sbi.dwSize.X; - int run = (width - pos.X) + width * (sbi.swSize.Y - pos.Y - 1); + int run = (width - pos.X) + width * (sbi.dwSize.Y - pos.Y - 1); DWORD n; FillConsoleOutputAttribute(out, 0x7, run, pos, &n); FillConsoleOutputCharacter(out, ' ', run, pos, &n);