]> Git Repo - secp256k1.git/blame - src/scalar.h
Add secp256k1_scalar_add_bit
[secp256k1.git] / src / scalar.h
CommitLineData
71712b27
GM
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 **********************************************************************/
a9f5c8b8
PW
6
7#ifndef _SECP256K1_SCALAR_
8#define _SECP256K1_SCALAR_
9
10#include "num.h"
11
1d52a8b1
PW
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
a9f5c8b8 23
a9f5c8b8 24/** Clear a scalar to prevent the leak of sensitive data. */
a4a43d75 25static void secp256k1_scalar_clear(secp256k1_scalar_t *r);
a9f5c8b8 26
a9f5c8b8 27/** Access bits from a scalar. */
a4a43d75 28static int secp256k1_scalar_get_bits(const secp256k1_scalar_t *a, int offset, int count);
a9f5c8b8
PW
29
30/** Set a scalar from a big endian byte array. */
a4a43d75 31static void secp256k1_scalar_set_b32(secp256k1_scalar_t *r, const unsigned char *bin, int *overflow);
a9f5c8b8
PW
32
33/** Convert a scalar to a byte array. */
a4a43d75 34static void secp256k1_scalar_get_b32(unsigned char *bin, const secp256k1_scalar_t* a);
a9f5c8b8
PW
35
36/** Add two scalars together (modulo the group order). */
a4a43d75 37static void secp256k1_scalar_add(secp256k1_scalar_t *r, const secp256k1_scalar_t *a, const secp256k1_scalar_t *b);
a9f5c8b8 38
52132078
PW
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
a9f5c8b8 42/** Multiply two scalars (modulo the group order). */
a4a43d75 43static void secp256k1_scalar_mul(secp256k1_scalar_t *r, const secp256k1_scalar_t *a, const secp256k1_scalar_t *b);
a9f5c8b8 44
1d52a8b1 45/** Compute the square of a scalar (modulo the group order). */
a4a43d75 46static void secp256k1_scalar_sqr(secp256k1_scalar_t *r, const secp256k1_scalar_t *a);
1d52a8b1 47
a9f5c8b8 48/** Compute the inverse of a scalar (modulo the group order). */
a4a43d75 49static void secp256k1_scalar_inverse(secp256k1_scalar_t *r, const secp256k1_scalar_t *a);
a9f5c8b8
PW
50
51/** Compute the complement of a scalar (modulo the group order). */
a4a43d75 52static void secp256k1_scalar_negate(secp256k1_scalar_t *r, const secp256k1_scalar_t *a);
a9f5c8b8
PW
53
54/** Check whether a scalar equals zero. */
a4a43d75 55static int secp256k1_scalar_is_zero(const secp256k1_scalar_t *a);
a9f5c8b8 56
79359302 57/** Check whether a scalar equals one. */
a4a43d75 58static int secp256k1_scalar_is_one(const secp256k1_scalar_t *a);
79359302 59
a9f5c8b8 60/** Check whether a scalar is higher than the group order divided by 2. */
a4a43d75 61static int secp256k1_scalar_is_high(const secp256k1_scalar_t *a);
a9f5c8b8
PW
62
63/** Convert a scalar to a number. */
a4a43d75 64static void secp256k1_scalar_get_num(secp256k1_num_t *r, const secp256k1_scalar_t *a);
a9f5c8b8
PW
65
66#endif
This page took 0.030569 seconds and 4 git commands to generate.