PRCYCoin  2.0.0.7rc1
P2P Digital Currency
bench_inv.c
Go to the documentation of this file.
1 /**********************************************************************
2  * Copyright (c) 2014 Pieter Wuille *
3  * Distributed under the MIT software license, see the accompanying *
4  * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5  **********************************************************************/
6 #include <stdio.h>
7 
8 #include "include/secp256k1.h"
9 
10 #include "util.h"
11 #include "num_impl.h"
12 #include "field_impl.h"
13 #include "group_impl.h"
14 #include "scalar_impl.h"
15 
16 int main(void) {
17  static const unsigned char init[32] = {
18  0x02, 0x03, 0x05, 0x07, 0x0b, 0x0d, 0x11, 0x13,
19  0x17, 0x1d, 0x1f, 0x25, 0x29, 0x2b, 0x2f, 0x35,
20  0x3b, 0x3d, 0x43, 0x47, 0x49, 0x4f, 0x53, 0x59,
21  0x61, 0x65, 0x67, 0x6b, 0x6d, 0x71, 0x7f, 0x83
22  };
23  static const unsigned char fini[32] = {
24  0xba, 0x28, 0x58, 0xd8, 0xaa, 0x11, 0xd6, 0xf2,
25  0xfa, 0xce, 0x50, 0xb1, 0x67, 0x19, 0xb1, 0xa6,
26  0xe0, 0xaa, 0x84, 0x53, 0xf6, 0x80, 0xfc, 0x23,
27  0x88, 0x3c, 0xd6, 0x74, 0x9f, 0x27, 0x09, 0x03
28  };
29  secp256k1_ge_start();
30  secp256k1_scalar_t base, x;
31  secp256k1_scalar_set_b32(&base, init, NULL);
32  secp256k1_scalar_set_b32(&x, init, NULL);
33  for (int i=0; i<1000000; i++) {
34  secp256k1_scalar_inverse(&x, &x);
35  secp256k1_scalar_add(&x, &x, &base);
36  }
37  unsigned char res[32];
38  secp256k1_scalar_get_b32(res, &x);
39  CHECK(memcmp(res, fini, 32) == 0);
40  return 0;
41 }
field_impl.h
util.h
main
int main(void)
Definition: bench_inv.c:16
secp256k1.h
group_impl.h
num_impl.h
secp256k1_scalar_t
A scalar modulo the group order of the secp256k1 curve.
Definition: scalar_4x64.h:13
CHECK
#define CHECK(cond)
Definition: util.h:43
scalar_impl.h