// 蒙哥马利域 1 mod p
static const gm_bn_t GM_BN_MONT_PONE = {
        0x00000001, 0x00000000, 0xFFFFFFFF, 0x00000000,
        0x00000000, 0x00000000, 0x00000000, 0x00000001
};

// 蒙哥马利域 1 mod n
static const gm_bn_t GM_BN_MONT_NONE = {
        0xC62ABEDD, 0xAC440BF6, 0xDE39FAD4, 0x8DFC2094,
        0x00000000, 0x00000000, 0x00000000, 0x00000001
};

// 将r设置为0
void gm_bn_set_zero(gm_bn_t r) {
    gm_bn_copy(r, GM_BN_ZERO);
}

// 将r设置为蒙哥马利域 1 mod p
void gm_bn_set_mont_one(gm_bn_t r) {
    gm_bn_copy(r, GM_BN_MONT_PONE);
}

// 判断r是否为蒙哥马利域 1 mod p
int gm_bn_is_mont_one(const gm_bn_t r){
    return memcmp(r, GM_BN_MONT_PONE, sizeof(uint64_t) * 8) == 0;
}

// 判断r是否为0
int gm_bn_is_zero(const gm_bn_t r) {
    return gm_bn_cmp(r, GM_BN_ZERO) == 0;
}
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

这些在后续点相关算法中用的上。