|
mpt-crypto
Confidential Multi-Purpose Tokens Cryptographic Library
|
Scalar Field Arithmetic Abstraction Layer. More...
#include "secp256k1_mpt.h"#include <string.h>#include <openssl/crypto.h>#include "util.h"#include "int128.h"#include "int128_impl.h"#include "scalar.h"#include "scalar_impl.h"
Go to the source code of this file.
Macros | |
| #define | USE_SCALAR_8X32 |
| #define | USE_FIELD_10X26 |
Functions | |
| void | secp256k1_mpt_scalar_add (unsigned char *res, const unsigned char *a, const unsigned char *b) |
| void | secp256k1_mpt_scalar_mul (unsigned char *res, const unsigned char *a, const unsigned char *b) |
| void | secp256k1_mpt_scalar_inverse (unsigned char *res, const unsigned char *in) |
| void | secp256k1_mpt_scalar_negate (unsigned char *res, const unsigned char *in) |
| void | secp256k1_mpt_scalar_reduce32 (unsigned char out32[32], const unsigned char in32[32]) |
Scalar Field Arithmetic Abstraction Layer.
This module provides a safe, portable interface for performing arithmetic in the scalar field of the secp256k1 curve (integers modulo \( n \), the group order).
Purpose: While libsecp256k1 exposes point operations via its public API, it does not typically expose low-level scalar arithmetic. However, protocols like Bulletproofs and ElGamal require extensive scalar math (e.g., polynomial evaluation, inner products) to be performed by the client.
Implementation: This file includes internal libsecp256k1 headers (scalar.h, scalar_impl.h) to access the optimized, constant-time scalar implementations.
Operations: All operations are performed modulo the curve order \( n \):
Platform Specifics: Includes logic for 128-bit integer support (int128.h) required for efficient computation on modern architectures (e.g., ARM64/Apple Silicon).
Definition in file mpt_scalar.c.
| #define USE_FIELD_10X26 |
Definition at line 44 of file mpt_scalar.c.
| #define USE_SCALAR_8X32 |
Definition at line 41 of file mpt_scalar.c.
| void secp256k1_mpt_scalar_add | ( | unsigned char * | res, |
| const unsigned char * | a, | ||
| const unsigned char * | b ) |
| void secp256k1_mpt_scalar_inverse | ( | unsigned char * | res, |
| const unsigned char * | in ) |
| void secp256k1_mpt_scalar_mul | ( | unsigned char * | res, |
| const unsigned char * | a, | ||
| const unsigned char * | b ) |
| void secp256k1_mpt_scalar_negate | ( | unsigned char * | res, |
| const unsigned char * | in ) |
| void secp256k1_mpt_scalar_reduce32 | ( | unsigned char | out32[32], |
| const unsigned char | in32[32] ) |