@@ -970,93 +970,6 @@ static SECP256K1_INLINE void secp256k1_scalar_cmov(secp256k1_scalar *r, const se
970970 r -> d [3 ] = (r -> d [3 ] & mask0 ) | (a -> d [3 ] & mask1 );
971971}
972972
973- #define ROTL32 (x ,n ) ((x) << (n) | (x) >> (32-(n)))
974- #define QUARTERROUND (a ,b ,c ,d ) \
975- a += b; d = ROTL32(d ^ a, 16); \
976- c += d; b = ROTL32(b ^ c, 12); \
977- a += b; d = ROTL32(d ^ a, 8); \
978- c += d; b = ROTL32(b ^ c, 7);
979-
980- #if defined(SECP256K1_BIG_ENDIAN )
981- #define LE32 (p ) ((((p) & 0xFF) << 24) | (((p) & 0xFF00) << 8) | (((p) & 0xFF0000) >> 8) | (((p) & 0xFF000000) >> 24))
982- #elif defined(SECP256K1_LITTLE_ENDIAN )
983- #define LE32 (p ) (p)
984- #endif
985-
986- static void secp256k1_scalar_chacha20 (secp256k1_scalar * r1 , secp256k1_scalar * r2 , const unsigned char * seed , uint64_t idx ) {
987- size_t n ;
988- size_t over_count = 0 ;
989- uint32_t seed32 [8 ];
990- uint32_t x0 , x1 , x2 , x3 , x4 , x5 , x6 , x7 , x8 , x9 , x10 , x11 , x12 , x13 , x14 , x15 ;
991- int over1 , over2 ;
992-
993- memcpy ((void * ) seed32 , (const void * ) seed , 32 );
994- do {
995- x0 = 0x61707865 ;
996- x1 = 0x3320646e ;
997- x2 = 0x79622d32 ;
998- x3 = 0x6b206574 ;
999- x4 = LE32 (seed32 [0 ]);
1000- x5 = LE32 (seed32 [1 ]);
1001- x6 = LE32 (seed32 [2 ]);
1002- x7 = LE32 (seed32 [3 ]);
1003- x8 = LE32 (seed32 [4 ]);
1004- x9 = LE32 (seed32 [5 ]);
1005- x10 = LE32 (seed32 [6 ]);
1006- x11 = LE32 (seed32 [7 ]);
1007- x12 = idx ;
1008- x13 = idx >> 32 ;
1009- x14 = 0 ;
1010- x15 = over_count ;
1011-
1012- n = 10 ;
1013- while (n -- ) {
1014- QUARTERROUND (x0 , x4 , x8 ,x12 )
1015- QUARTERROUND (x1 , x5 , x9 ,x13 )
1016- QUARTERROUND (x2 , x6 ,x10 ,x14 )
1017- QUARTERROUND (x3 , x7 ,x11 ,x15 )
1018- QUARTERROUND (x0 , x5 ,x10 ,x15 )
1019- QUARTERROUND (x1 , x6 ,x11 ,x12 )
1020- QUARTERROUND (x2 , x7 , x8 ,x13 )
1021- QUARTERROUND (x3 , x4 , x9 ,x14 )
1022- }
1023-
1024- x0 += 0x61707865 ;
1025- x1 += 0x3320646e ;
1026- x2 += 0x79622d32 ;
1027- x3 += 0x6b206574 ;
1028- x4 += LE32 (seed32 [0 ]);
1029- x5 += LE32 (seed32 [1 ]);
1030- x6 += LE32 (seed32 [2 ]);
1031- x7 += LE32 (seed32 [3 ]);
1032- x8 += LE32 (seed32 [4 ]);
1033- x9 += LE32 (seed32 [5 ]);
1034- x10 += LE32 (seed32 [6 ]);
1035- x11 += LE32 (seed32 [7 ]);
1036- x12 += idx ;
1037- x13 += idx >> 32 ;
1038- x14 += 0 ;
1039- x15 += over_count ;
1040-
1041- r1 -> d [3 ] = (((uint64_t ) x0 ) << 32 ) | x1 ;
1042- r1 -> d [2 ] = (((uint64_t ) x2 ) << 32 ) | x3 ;
1043- r1 -> d [1 ] = (((uint64_t ) x4 ) << 32 ) | x5 ;
1044- r1 -> d [0 ] = (((uint64_t ) x6 ) << 32 ) | x7 ;
1045- r2 -> d [3 ] = (((uint64_t ) x8 ) << 32 ) | x9 ;
1046- r2 -> d [2 ] = (((uint64_t ) x10 ) << 32 ) | x11 ;
1047- r2 -> d [1 ] = (((uint64_t ) x12 ) << 32 ) | x13 ;
1048- r2 -> d [0 ] = (((uint64_t ) x14 ) << 32 ) | x15 ;
1049-
1050- over1 = secp256k1_scalar_check_overflow (r1 );
1051- over2 = secp256k1_scalar_check_overflow (r2 );
1052- over_count ++ ;
1053- } while (over1 | over2 );
1054- }
1055-
1056- #undef ROTL32
1057- #undef QUARTERROUND
1058- #undef LE32
1059-
1060973static void secp256k1_scalar_from_signed62 (secp256k1_scalar * r , const secp256k1_modinv64_signed62 * a ) {
1061974 const uint64_t a0 = a -> v [0 ], a1 = a -> v [1 ], a2 = a -> v [2 ], a3 = a -> v [3 ], a4 = a -> v [4 ];
1062975
0 commit comments