secp256k1 Field 5x52 Int128 Arithmetic (src/field_5x52_int128_impl.h)

bitcoin · src/secp256k1/src/field_5x52_int128_impl.h · c · MIT
infra, security, tag:secp256k1, tag:field-arithmetic, tag:int128, tag:elliptic-curve

Low-level 128-bit integer implementation of field element multiplication and squaring for secp256k1's 5x52 representation. Reuse when implementing elliptic curve finite field math requiring high-performance modular arithmetic.

// Source: https://github.com/bitcoin/bitcoin | License: MIT | Copyright 2009-2026 The Bitcoin Core developers
// Provided via justclaw.it.com; keep this notice with the code.
/***********************************************************************
 * Copyright (c) 2013, 2014 Pieter Wuille                              *
 * Distributed under the MIT software license, see the accompanying    *
 * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
 ***********************************************************************/

#ifndef SECP256K1_FIELD_INNER5X52_IMPL_H
#define SECP256K1_FIELD_INNER5X52_IMPL_H

#include <stdint.h>

#include "int128.h"
#include "util.h"

#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0)
#define VERIFY_BITS_128(x, n) VERIFY_CHECK(secp256k1_u12

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key