-
Notifications
You must be signed in to change notification settings - Fork 1
/
ramrsbd_gf_p.h
69 lines (54 loc) · 1.66 KB
/
ramrsbd_gf_p.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Utilities for polynomials built out of Galois-field elements
*
* Copyright (c) 2024, The littlefs authors.
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RAMRSBD_GF_P_H
#define RAMRSBD_GF_P_H
#include "lfs.h"
#include "lfs_util.h"
#include "ramrsbd_gf.h"
#ifdef __cplusplus
extern "C"
{
#endif
// Evaluate a polynomial at x
uint8_t ramrsbd_gf_p_eval(
const uint8_t *p, lfs_size_t p_size,
uint8_t x);
// Evaluate the formal derivative of a polynomial at x
uint8_t ramrsbd_gf_p_deval(
const uint8_t *p, lfs_size_t p_size,
uint8_t x);
// Multiply a polynomial by a constant c
void ramrsbd_gf_p_scale(
uint8_t *p, lfs_size_t p_size,
uint8_t c);
// Xor two polynomials together, this is equivalent to both addition and
// subtraction in a Galois-field
void ramrsbd_gf_p_xor(
uint8_t *a, lfs_size_t a_size,
const uint8_t *b, lfs_size_t b_size);
// Xor two polynomials together after scaling b by a constant c
void ramrsbd_gf_p_xors(
uint8_t *a, lfs_size_t a_size,
uint8_t c,
const uint8_t *b, lfs_size_t b_size);
// Multiply two polynomials together
void ramrsbd_gf_p_mul(
uint8_t *a, lfs_size_t a_size,
const uint8_t *b, lfs_size_t b_size);
// Find both the quotient and remainder after division
void ramrsbd_gf_p_divmod(
uint8_t *a, lfs_size_t a_size,
const uint8_t *b, lfs_size_t b_size);
// Find both the quotient and remainder after division, assuming b has
// an implicit leading 1
void ramrsbd_gf_p_divmod1(
uint8_t *a, lfs_size_t a_size,
const uint8_t *b, lfs_size_t b_size);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif