Saturday, August 9, 2025
No Result
View All Result
Crypeto News
Smarter_way_USA
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Blockchain
    • Ethereum
    • Altcoin
    • Mining
    • Crypto Exchanges
  • NFT
  • DeFi
  • Web3
  • Metaverse
  • Analysis
  • Regulations
  • Scam Alert
  • Videos
CRYPTO MARKETCAP
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Blockchain
    • Ethereum
    • Altcoin
    • Mining
    • Crypto Exchanges
  • NFT
  • DeFi
  • Web3
  • Metaverse
  • Analysis
  • Regulations
  • Scam Alert
  • Videos
CRYPTO MARKETCAP
Crypeto News
No Result
View All Result

Safegcd’s Implementation Formally Verified

by crypetonews
November 25, 2024
in Bitcoin
Reading Time: 4 mins read
0 0
A A
0
Home Bitcoin
Share on FacebookShare on Twitter



Introduction

The security of Bitcoin, and other blockchains, such as Liquid, hinges on the use of digital signatures algorithms such as ECDSA and Schnorr signatures. A C library called libsecp256k1, named after the elliptic curve that the library operates on, is used by both Bitcoin Core and Liquid, to provide these digital signature algorithms. These algorithms make use of a mathematical computation called a modular inverse, which is a relatively expensive component of the computation.

In “Fast constant-time gcd computation and modular inversion,” Daniel J. Bernstein and Bo-Yin Yang develop a new modular inversion algorithm. In 2021, this algorithm, referred to as “safegcd,” was implemented for libsecp256k1 by Peter Dettman. As part of the vetting process for this novel algorithm, Blockstream Research was the first to complete a formal verification of the algorithm’s design by using the Coq proof assistant to formally verify that the algorithm does indeed terminate with the correct modular inverse result on 256-bit inputs.

The Gap between Algorithm and Implementation

The formalization effort in 2021 only showed that the algorithm designed by Bernstein and Yang works correctly. However, using that algorithm in libsecp256k1 requires implementing the mathematical description of the safegcd algorithm within the C programming language. For example, the mathematical description of the algorithm performs matrix multiplication of vectors that can be as wide as 256 bit signed integers, however the C programming language will only natively provide integers up to 64 bits (or 128 bits with some language extensions).

Implementing the safegcd algorithm requires programming the matrix multiplication and other computations using C’s 64 bit integers. Additionally, many other optimizations have been added to make the implementation fast. In the end, there are four separate implementations of the safegcd algorithm in libsecp256k1: two constant time algorithms for signature generation, one optimized for 32-bit systems and one optimized for 64-bit systems, and two variable time algorithms for signature verification, again one for 32-bit systems and one for 64-bit systems.

Verifiable C

In order to verify the C code correctly implements the safegcd algorithm, all the implementation details must be checked. We use Verifiable C, part of the Verified Software Toolchain for reasoning about C code using the Coq theorem prover.

Verification proceeds by specifying preconditions and postconditions using separation logic for every function undergoing verification. Separation logic is a logic specialized for reasoning about subroutines, memory allocations, concurrency and more.

Once each function is given a specification, verification proceeds by starting from a function’s precondition, and establishing a new invariant after each statement in the body of the function, until finally establishing the post condition at the end of the function body or the end of each return statement. Most of the formalization effort is spent “between” the lines of code, using the invariants to translate the raw operations of each C expression into higher level statements about what the data structures being manipulated represent mathematically. For example, what the C language regards as an array of 64-bit integers may actually be a representation of a 256-bit integer.

The end result is a formal proof, verified by the Coq proof assistant, that libsecp256k1’s 64-bit variable time implementation of the safegcd modular inverse algorithm is functionally correct.

Limitations of the Verification

There are some limitations to the functional correctness proof. The separation logic used in Verifiable C implements what is known as partial correctness. That means it only proves the C code returns with the correct result if it returns, but it doesn’t prove termination itself. We mitigate this limitation by using our previous Coq proof of the bounds on the safegcd algorithm to prove that the loop counter value of the main loop in fact never exceeds 11 iterations.

Another issue is that the C language itself has no formal specification. Instead the Verifiable C project uses the CompCert compiler project to provide a formal specification of a C language. This guarantees that when a verified C program is compiled with the CompCert compiler, the resulting assembly code will meet its specification (subject to the above limitation). However this doesn’t guarantee that the code generated by GCC, clang, or any other compiler will necessarily work. For example, C compilers are allowed to have different evaluation orders for arguments within a function call. And even if the C language had a formal specification any compiler that isn’t itself formally verified could still miscompile programs. This does occur in practice.

Lastly, Verifiable C doesn’t support passing structures, returning structures or assigning structures. While in libsecp256k1, structures are always passed by pointer (which is allowed in Verifiable C), there are a few occasions where structure assignment is used. For the modular inverse correctness proof, there were 3 assignments that had to be replaced by a specialized function call that performs the structure assignment field by field.

Summary

Blockstream Research has formally verified the correctness of libsecp256k1’s modular inverse function. This work provides further evidence that verification of C code is possible in practice. Using a general purpose proof assistant allows us to verify software built upon complex mathematical arguments.

Nothing prevents the rest of the functions implemented in libsecp256k1 from being verified as well. Thus it is possible for libsecp256k1 to obtain the highest possible software correctness guarantees.

This is a guest post by Russell O’Connor and Andrew Poelstra. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc or Bitcoin Magazine.



Source link

Tags: FormallyimplementationSafegcdsVerified
Previous Post

What Does FOMC Minutes Tomorrow Mean for Bitcoin Price?

Next Post

BITCOIN CRASH: It's NOT What You Think (IMPORTANT)!! Bitcoin News Today & Bitcoin Price Prediction!

Related Posts

Harvard Reveals 7M BlackRock Bitcoin ETF Stake In SEC Filing – Details
Bitcoin

Harvard Reveals $117M BlackRock Bitcoin ETF Stake In SEC Filing – Details

August 9, 2025
SBI Clarifies XRP ETF Status With Filing Timed For Regulatory Breakthrough
Bitcoin

SBI Clarifies XRP ETF Status With Filing Timed For Regulatory Breakthrough

August 9, 2025
This XRP Signal Consistently Foreshadows Price Jumps: Analytics Firm
Bitcoin

This XRP Signal Consistently Foreshadows Price Jumps: Analytics Firm

August 8, 2025
Will America Become The Bitcoin And Crypto Capital Of The World? Here’s An Expert’s Take.
Bitcoin

Will America Become The Bitcoin And Crypto Capital Of The World? Here’s An Expert’s Take.

August 8, 2025
Analyst Shares Where Bitcoin, Ethereum, And XRP Prices Will Be By 2032
Bitcoin

Analyst Shares Where Bitcoin, Ethereum, And XRP Prices Will Be By 2032

August 8, 2025
Know-Your-Customer: The Quiet Kill Switch
Bitcoin

Know-Your-Customer: The Quiet Kill Switch

August 8, 2025
Next Post
BITCOIN CRASH: It's NOT What You Think (IMPORTANT)!! Bitcoin News Today & Bitcoin Price Prediction!

BITCOIN CRASH: It's NOT What You Think (IMPORTANT)!! Bitcoin News Today & Bitcoin Price Prediction!

Optimizing Zoom Transcriptions with Multichannel Audio Recording

Optimizing Zoom Transcriptions with Multichannel Audio Recording

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECOMMENDED

Bluefin Forges Strategic Partnership with Cassa Centrale Raiffeisen, ICIT, and Worldline
DeFi

Bluefin Forges Strategic Partnership with Cassa Centrale Raiffeisen, ICIT, and Worldline

by crypetonews
August 6, 2025
0

Payment and data security company Bluefin has teamed up with Cassa Centrale Raiffeisen, ICIT, and Worldline to enhance payment and...

Bitcoin Price Watch: Potential Bear Flag Pattern Forms on 4-Hour Chart

Bitcoin Price Watch: Potential Bear Flag Pattern Forms on 4-Hour Chart

August 5, 2025
California Duo Charged for Smuggling AI Chips to China

California Duo Charged for Smuggling AI Chips to China

August 6, 2025
Tornado Cash’s Storm Receives 0K For Upcoming Appeal

Tornado Cash’s Storm Receives $500K For Upcoming Appeal

August 8, 2025
SBI Holdings Plans BTC-XRP ETF Launch, Make Stablecoin Push

SBI Holdings Plans BTC-XRP ETF Launch, Make Stablecoin Push

August 6, 2025
FLOKI and ONDO extend gains as Robinhood listing boosts bullish momentum

FLOKI and ONDO extend gains as Robinhood listing boosts bullish momentum

August 7, 2025

Please enter CoinGecko Free Api Key to get this plugin works.
  • Trending
  • Comments
  • Latest
Top 10 NFTs to Watch in 2025 for High-Return Investments

Top 10 NFTs to Watch in 2025 for High-Return Investments

November 22, 2024
Uniswap v4 Teases Major Updates for 2025

Uniswap v4 Teases Major Updates for 2025

January 2, 2025
Enforceable Human-Readable Transactions: Can They Prevent Bybit-Style Hacks?

Enforceable Human-Readable Transactions: Can They Prevent Bybit-Style Hacks?

February 27, 2025
Best Cryptocurrency Portfolio Tracker Apps to Use in 2025

Best Cryptocurrency Portfolio Tracker Apps to Use in 2025

April 24, 2025
What’s the Difference Between Polygon PoS vs Polygon zkEVM?

What’s the Difference Between Polygon PoS vs Polygon zkEVM?

November 20, 2023
FTT jumps 7% as Backpack launches platform to help FTX victims liquidate claims

FTT jumps 7% as Backpack launches platform to help FTX victims liquidate claims

July 18, 2025
XRP Official CRYPTO VOTE LIVE NEWS!🔴GENIUS, CLARITY Act

XRP Official CRYPTO VOTE LIVE NEWS!🔴GENIUS, CLARITY Act

46
IMP UPDATE : BILLS PASSED || BITCOIN DOMINANCE FALLING

IMP UPDATE : BILLS PASSED || BITCOIN DOMINANCE FALLING

38
🚨BIG UPDATE ON WAZIRX || ALT COIN PORTFOLIO NO 1

🚨BIG UPDATE ON WAZIRX || ALT COIN PORTFOLIO NO 1

37
BITCOIN: IT'S HAPPENING NOW (Urgent Update)!!! Bitcoin News Today, Ethereum, Solana, XRP & Chainlink

BITCOIN: IT'S HAPPENING NOW (Urgent Update)!!! Bitcoin News Today, Ethereum, Solana, XRP & Chainlink

33
JUST IN XRP RIPPLE DUBAI NEWS!

JUST IN XRP RIPPLE DUBAI NEWS!

25
Flash USDT | How It Became the Biggest Crypto Scam Worldwide

Flash USDT | How It Became the Biggest Crypto Scam Worldwide

31
Harvard Reveals 7M BlackRock Bitcoin ETF Stake In SEC Filing – Details

Harvard Reveals $117M BlackRock Bitcoin ETF Stake In SEC Filing – Details

August 9, 2025
CoinDesk Data: TRON Surpasses 0B in Monthly Stablecoin Transfers

CoinDesk Data: TRON Surpasses $600B in Monthly Stablecoin Transfers

August 9, 2025
SBI Clarifies XRP ETF Status With Filing Timed For Regulatory Breakthrough

SBI Clarifies XRP ETF Status With Filing Timed For Regulatory Breakthrough

August 9, 2025
This XRP Signal Consistently Foreshadows Price Jumps: Analytics Firm

This XRP Signal Consistently Foreshadows Price Jumps: Analytics Firm

August 8, 2025
Tornado Cash’s Storm Receives 0K For Upcoming Appeal

Tornado Cash’s Storm Receives $500K For Upcoming Appeal

August 8, 2025
Relocation of popular public sculpture called off after Vancouver residents claim it would block their views – The Art Newspaper

Relocation of popular public sculpture called off after Vancouver residents claim it would block their views – The Art Newspaper

August 8, 2025
Crypeto News

Find the latest Bitcoin, Ethereum, blockchain, crypto, Business, Fintech News, interviews, and price analysis at Crypeto News.

CATEGORIES

  • Altcoin
  • Analysis
  • Bitcoin
  • Blockchain
  • Crypto Exchanges
  • Crypto Updates
  • DeFi
  • Ethereum
  • Metaverse
  • Mining
  • NFT
  • Regulations
  • Scam Alert
  • Uncategorized
  • Videos
  • Web3

LATEST UPDATES

  • Harvard Reveals $117M BlackRock Bitcoin ETF Stake In SEC Filing – Details
  • CoinDesk Data: TRON Surpasses $600B in Monthly Stablecoin Transfers
  • SBI Clarifies XRP ETF Status With Filing Timed For Regulatory Breakthrough
  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2022 Crypeto News.
Crypeto News is not responsible for the content of external sites.

No Result
View All Result
  • Home
  • Bitcoin
  • Crypto Updates
    • General
    • Blockchain
    • Ethereum
    • Altcoin
    • Mining
    • Crypto Exchanges
  • NFT
  • DeFi
  • Web3
  • Metaverse
  • Analysis
  • Regulations
  • Scam Alert
  • Videos

Copyright © 2022 Crypeto News.
Crypeto News is not responsible for the content of external sites.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In