Cointime

Download App
iOS & Android

The Bluffers Guide to secp256k1 ... When Satoshi Said Goodbye to PKI

Validated Individual Expert

If it wasn’t for Satoshi Nakamoto, you probably would never have heard of the secp256k1 Elliptic Curve Cryptography (ECC) method. But, Satoshi used it to take a private key and then produce a public identifier.

At the core of the adoption of Bitcoin is the usage of the ECDSA (Elliptic Curve Digital Signature Algorithm), and where it was possible to verify a transaction from the public Bitcoin identifier. The standard for secp256k1 is published [here]:

This is a Weierstrass form of elliptic curve, and uses:

y²=x³+7 (mod p)

It has a base point of g=(0x79be667ef9dcb … 959f2815b16f81798, 0x483ada77 … 8ffb10d4b8) and a prime number of ²²⁵⁶−²³²−²⁹−²⁸−²⁷−²⁶−²⁴−1. The order of the curve is n=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141.

Overall we have a private key of a and then produce a public key of aG. We do this though point addition. For secp256k1, we have a 256-bit private key value, and a 512-bit public key value (and which is a point on the elliptic curve).

Why secp and not NIST?

Who knows why Satoshi chose the secp256k1 curve over the NIST defined curve of secp256k1. Many have questioned the close relationship between NIST and the NSA, and the possiblity of inserting a backdoor in the curve. And, so, perhaps Satoshi went for secp256k1 for this reason.

Points on secp256k1

The points on an elliptic curve curve do not always give a valid x-co-ordinate. Also there are two points for every valid x-co-ordinate value:

  • Elliptic Curve points for common curves in an x-range. Elliptic Curve points. This example uses Curve 25519, secp256k1, P256 and P512 to show the range of points for a given x-coordinate range.
  • First 20 Elliptic Curve points in Finite Field for common curves. Elliptic Curve points. Locating the first 20 points in an elliptic curve in a finite field for curves including Curve25519 (Tor), secp256k1 (Bitcoin) and NIST P-256.

Montgomery Ladder with secp256k1

The thing that makes elliptic curve cryptography fast, is the ability to multiply a point (G) by a scalar value (normally, the private key) to give a.G. This is fast due to the Montgomery ladder:

  • Montgomery Ladder in calculating kG in a fixed time. Ladder. Calculates kG for secp256k1.

Charting

An elliptic curve is beautiful in its analogue from, but points when discrete:

  • Draw y²=x³+7(mod p) [here].

Point multiplication

At the core of elliptic curve cryptography, we perform point multiplication:

  • Real ECC curves for (1G, 2G and nG). Elliptic Curve real. Curve 25519, secp256k, and so on.
  • Inverse of private key for secp256k1 with Python. Inverse of private key secp256k1. In this example Alice sends aG and Bob sends back abG. Alice then calculates a−1(mod n) and can then determine a^{−1}abG=bG. The secp256k1 curve is in the Weierstrass curve form (y²=x³+ax+b).

Key generation

Basically elliptic curve cryptography focuses on the digital signing process, and where we generate a private key (sk) and a public key (pk). There are defined as a key pair:

  • Elliptic Curve (OpenSSL Key Generator). Elliptic Curve (Keys). Elliptic Curv is a public key method. This page outline the generation of ECC key, including secp128r1.
  • Elliptic Curve (Keys). Elliptic Curve (Keys). Elliptic Curv is a public key method. This page outline the generation of ECC keys in Bitcoin.

ECDH with secp256k1

Along with digital signatures, elliptic curve methods are used in key exchange:

  • Elliptic Curve Diffie-Hellman (ECDH) with secp256k1. ECDH. Elliptic Curve Diffie Hellman is used to create a shared key.
  • Elliptic Curve Diffie-Hellman (ECDH) with different curves. ECDH. Elliptic Curve Diffie Hellman is used to create a shared key using different curves, including secp256k1, p192 and p224.
  • secp256k1 ECDH with Python. secp256k1 ECDH. Elliptic Curve Diffie Hellman using secp256k1 with Python. The secp256k1 curve is in the Weierstrass curve form (y²=x³+ax+b).
  • Authenticated secp256k1 ECDH with Python. Authenticated secp256k1 ECDH. Elliptic Curve Diffie Hellman using secp256k1 with Python, and where we use a long-term key for Bob and Alice to create a shared session key. The secp256k1 curve is in the Weierstrass curve form (y²=x³+ax+b).

ECDSA

A core part of the trust on the Bitcoin and Ethereum is the usage of the ECDSA signature:

  • Elliptic Curve Digital Signature Algorithm (ECDSA). ECDSA. Elliptic Curve Digital Signature Algorithm (ECDSA) is used to sign data.
  • Elliptic Curve Digital Signature Algorithm (ECDSA) with core operations. ECDSA. Elliptic Curve Digital Signature Algorithm (ECDSA) is used to sign data with core operations.

But it needs to be treating with caution:

  • Crack ECDSA from leak of nonce (SECP256k1). ECDSA with nonce. This outlines ECDSA how the private key can be recovered with a leak of the nonce value for SECP256k1.
  • Crack ECDSA with weak nonces. ECDSA with weak nonces. This outlines ECDSA how the private key can be recovered with weak nonce values.
  • Blinded ECDSA. Blinded ECDSA. With a blinded signature, Bob can sign for a message, without knowning what the message is. In this case Alice will create a blinded ECDSA signature, and where Bob can then sign it, and then Alice can unblind it. The method is based on one produced by Oleg Andreev for blinding signatures in Bitcoin.
  • ECDSA: Fault Attack. ECDSA: Fault Attack. In the fault attack in ECDSA we only require two signatures. One is produced without a fault (r,s) , and the other has a fault (rf,sf)

What’s the size of the public key?

As the public key is a point, in its purest form we have a 512 bit public key, and which is made up of 256 bits for the x-coordinate and 256 bits for the y-coordinate. But, we can also compress this, as we can easily derive the y-coordinate from the x-coordinate. In the end, there are only two possible y-coordinates, so all we have to do, is record whether it is odd or even and compress the point with just an identifier and the x-coodinate:

Conclusions

Comments

All Comments

Recommended for you

  • A whale sold 224 WBTC worth $14.4 million in the past three hours

    According to on-chain analyst @ai_9684xtpa, address 0x486...1505e sold 224 WBTC tokens worth $14.4 million through Cowswap in the past three hours, making a profit of $830,000 (selling at an average price of $64,203). The seller had bought 371 WBTC tokens at an average price of $60,504 between November 2023 and April 2024, and still holds 280 WBTC tokens.

  • CryptoQuant CEO: BTC needs to remain above $80,000 for miners to remain profitable after halving

    Bitcoin mining revenue significantly decreased in May due to the impact of the fourth Bitcoin halving event. On May 1st, the total revenue from block rewards and transaction fees reached a new low of only $26.3 million.CryptoQuant CEO Ki Young Ju calculated that, based on current conditions, Bitcoin needs to stay above $80,000 for miners to remain profitable after the halving. However, most miners have taken proactive measures to upgrade their mining equipment to lower long-term operating costs and remain competitive.

  • BTC returns to above 65,000 USDT, up 2.08% in 24 hours

    OKX market shows that BTC has returned to above 65000 USDT, now reporting 65102 USDT, with a 24-hour increase of 2.08%.

  • Hundre Finance attackers have withdrawn 162.2 ETH worth of crypto assets from Curve

    According to PeckShield monitoring, the attacker of Hundre Finance withdrew 784,000 3Crv from Curve and exchanged it for 273 ETH. In addition, they also exchanged 305.6 WOO, 39 PAXG, 200,000 FRAX, and 100,000 DAI, totaling 162.2 ETH. The attacker then bridged 1,034 ETH (2.17 million USD), 842.8K DAI, 1.11 million USDT, 1.27 million USDC, and 457.3 FRAX from Optimism to Ethereum. They also exchanged a total of 480,000 USDC for 142.6 WETH, 306 WOO, and 39 PAXG. They also exchanged 1.11 million USDT for 500.3 thousand USD worth of DAI and 613.8 thousand USD worth of FRAX. Additionally, on April 15, 2023, approximately 786,000 USD worth of USDC was added to Curve3Pool.

  • LayerZero co-founder: "Self-reporting of witch activities" is not aimed at individuals, but at industrial witch studios

    Bryan Pellegrino, co-founder and CEO of LayerZero, stated on social media that the "Self-Report Sybil Activity" is not targeting individual users, but rather large industrial witch farms (studios).Earlier, LayerZero Labs launched the "Self-Report Sybil Activity" plan, which allows witch addresses to self-report related addresses on a designated page and receive an expected allocation of 15%, without answering any questions. The deadline is May 17th, 19:59:59.

  • Argentina’s House of Representatives Passes Bill to Regularize Cryptocurrency Taxation

    The Argentine Chamber of Deputies has passed a cryptocurrency tax normalization bill aimed at advancing a series of important government reforms. The bill introduces the possibility of regularizing previously undeclared cryptocurrency assets, up to a maximum of $100,000, without paying government collection fees. However, if the value of cryptocurrency assets exceeds this limit, the government will apply preferential tax rates based on the taxpayer's declaration date.

  • GNUS on Fantom was attacked, with a loss of about $1.27 million

    According to Beosin's monitoring, GNUS on Fantom was attacked, resulting in a loss of approximately $1.27 million. GNUS stated on the X platform that due to recent vulnerabilities, hackers were able to mint fake GNUS tokens on Fantom, transfer them to Ethereum and Polygon through the Axelar Bridge, and sell them to existing liquidity pools. We will take a snapshot of the blocks before the exploit. To ensure fairness, please do not purchase GNUS tokens after the exploit, as we will issue new tokens.

  • Pandu Financial Group received the first round of strategic equity investment of tens of millions of Hong Kong dollars, led by Longling Capital

    Pando Financial Group announced it has received tens of millions of Hong Kong dollars in strategic equity investment led by Longling Investment. Pando Financial Group stated that it plans to use the newly injected funds for key growth areas, including market expansion, innovative product development, key talent recruitment, and technology upgrades, aiming to accelerate the layout of opportunities in the era of virtual assets through these strategic initiatives. Currently, the group's asset management scale has reached $500 million. Pando Asset, a subsidiary of Pando Financial Group, established its headquarters in Zurich in 2022 and issued the Pando 6 spot virtual asset fund (Bitcoin/Ethereum spot ETPs) on the Swiss Exchange. Another subsidiary of Pando Financial Group, Pando Limited, obtained licenses from the Securities and Futures Commission in Hong Kong, including Type 1 (securities trading), Type 4 (advising on securities), and Type 9 (asset management), as well as public fund qualifications, and was approved to manage investment portfolios with more than 10% invested in virtual assets and issued several excellent performance actively managed ETF products.

  • Hong Kong Monetary Authority launches industry consultation on “renaming virtual banks as licensed digital banks”

    Hong Kong virtual banks released their annual reports for 2023 last week. The eight virtual banks collectively lost about 2.99 billion yuan last year, a decrease of about 12% compared to the total loss of about 3.4 billion yuan in 2022. In response to the occasional feeling of "unreality" brought about by the term "virtual" in recent years, the Hong Kong Monetary Authority has initiated a consultation on renaming with the eight virtual banks, the Hong Kong Bankers Association, the Hong Kong Restricted Licensed Banks and Deposit-taking Companies Association, with the aim of renaming virtual banks as licensed digital banks, for a period of one month. It is reported that in the Asian region, similar banks have different names in different places. South Korea and Singapore issue licenses under the name of "digital bank", with Singapore further dividing them into digital full banks (DFB) and digital wholesale banks (DWB).

  • Chairman of the Russian State Duma Financial Market Committee: I do not support a complete ban on the circulation of cryptocurrencies in Russia

    Anton Gorelkin, Chairman of the Financial Market Committee of the Russian State Duma, said that he does not support a complete ban on the circulation of cryptocurrency in Russia. He explained in a post on Telegram that this restriction is not intended to ban the use of all cryptocurrencies, but rather to regulate the establishment of cryptocurrency exchange platforms within the legal framework of Russia. Anton Gorelkin also believes that the establishment of a legitimate cryptocurrency infrastructure in Russia is influenced by geopolitical realities, and this requires consideration of factors related to international relations. He further added that allowing such infrastructure may expose Russian companies to Western sanctions. In addition, Anton Gorelkin pointed out that this restriction may be lifted in the future, and users can still use foreign cryptocurrency exchanges and over-the-counter trading services as before. However, the impact on many over-the-counter cryptocurrency services in Moscow is still uncertain.