]> Git Repo - secp256k1.git/blame_incremental - src/scalar.h
Add secp256k1_scalar_add_bit
[secp256k1.git] / src / scalar.h
... / ...
CommitLineData
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
7#ifndef _SECP256K1_SCALAR_
8#define _SECP256K1_SCALAR_
9
10#include "num.h"
11
12#if defined HAVE_CONFIG_H
13#include "libsecp256k1-config.h"
14#endif
15
16#if defined(USE_SCALAR_4X64)
17#include "scalar_4x64.h"
18#elif defined(USE_SCALAR_8X32)
19#include "scalar_8x32.h"
20#else
21#error "Please select scalar implementation"
22#endif
23
24/** Clear a scalar to prevent the leak of sensitive data. */
25static void secp256k1_scalar_clear(secp256k1_scalar_t *r);
26
27/** Access bits from a scalar. */
28static int secp256k1_scalar_get_bits(const secp256k1_scalar_t *a, int offset, int count);
29
30/** Set a scalar from a big endian byte array. */
31static void secp256k1_scalar_set_b32(secp256k1_scalar_t *r, const unsigned char *bin, int *overflow);
32
33/** Convert a scalar to a byte array. */
34static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar_t* a);
35
36/** Add two scalars together (modulo the group order). */
37static void secp256k1_scalar_add(secp256k1_scalar_t *r, const secp256k1_scalar_t *a, const secp256k1_scalar_t *b);
38
39/** Add a power of two to a scalar. The result is not allowed to overflow. */
40static void secp256k1_scalar_add_bit(secp256k1_scalar_t *r, unsigned int bit);
41
42/** Multiply two scalars (modulo the group order). */
43static void secp256k1_scalar_mul(secp256k1_scalar_t *r, const secp256k1_scalar_t *a, const secp256k1_scalar_t *b);
44
45/** Compute the square of a scalar (modulo the group order). */
46static void secp256k1_scalar_sqr(secp256k1_scalar_t *r, const secp256k1_scalar_t *a);
47
48/** Compute the inverse of a scalar (modulo the group order). */
49static void secp256k1_scalar_inverse(secp256k1_scalar_t *r, const secp256k1_scalar_t *a);
50
51/** Compute the complement of a scalar (modulo the group order). */
52static void secp256k1_scalar_negate(secp256k1_scalar_t *r, const secp256k1_scalar_t *a);
53
54/** Check whether a scalar equals zero. */
55static int secp256k1_scalar_is_zero(const secp256k1_scalar_t *a);
56
57/** Check whether a scalar equals one. */
58static int secp256k1_scalar_is_one(const secp256k1_scalar_t *a);
59
60/** Check whether a scalar is higher than the group order divided by 2. */
61static int secp256k1_scalar_is_high(const secp256k1_scalar_t *a);
62
63/** Convert a scalar to a number. */
64static void secp256k1_scalar_get_num(secp256k1_num_t *r, const secp256k1_scalar_t *a);
65
66#endif
This page took 0.021833 seconds and 4 git commands to generate.