-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecker.c
39 lines (33 loc) · 784 Bytes
/
checker.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "checker.h"
static bignum256 r_rhs, r_lhs;
extern bignum256 a, b, c_, d_;
void print(bool t)
{
printf(t ? "Success!\n" : "Failure!\n");
printf("a:\n");
bn_print(&a);
printf("b:\n");
bn_print(&b);
printf("LHS = a x b :\n");
bn_print(&r_lhs);
printf("c:\n");
bn_print(&c_);
printf("d:\n");
bn_print(&d_);
printf("RHS = c + d :\n");
bn_print(&r_rhs);
}
void validate()
{
//compute rhs of result
bn_copy(&c_, &r_rhs);
bn_add(&r_rhs, &d_);
bn_mod(&r_rhs, &secp256k1.prime);
//compute lhs of result
bn_copy(&r_lhs, &r_lhs);
bn_multiply(&b, &r_lhs, &secp256k1.prime);
bn_mod(&r_rhs, &secp256k1.prime);
compute_dec2pow();
//compare lhs and rhs
print(bn_is_equal(&r_rhs, &r_lhs));
}