ebfull
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    12
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Wait, what are these isomorphic elliptic curves doing on the secp256k1/secq256k1 cycle? _Written by [Daira Hopwood](https://twitter.com/feministPLT) and [Sean Bowe](https://twitter.com/ebfull)._ -------- The [secp256k1](https://en.bitcoin.it/wiki/Secp256k1) elliptic curve is $y^2 = x^3 + 7$ defined over $\mathbb{F}_p$, with order $q$, given the primes: ``` p = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F q = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 ``` It's commonly known that another curve we'll call "sec**q**256k1" exists (with the same curve equation!) defined instead over $\mathbb{F}_q$, and its order is $p$. This means the two curves form a $2$-cycle, and such a cycle is _very_ useful for things like [proof-carrying data](https://eprint.iacr.org/2014/595) implemented using discrete-log assumptions. But open [SageMath](https://www.sagemath.org/) up and look what happens when you do this: ``` sage: EllipticCurve(GF(p), [0, 1]).order() == EllipticCurve(GF(q), [0, 1]).order() True ``` Wait, what? There are two elliptic curves, each with the equation $y^2 = x^3 + 1$, _and with the same group order_, but defined over $\mathbb{F}_p$ and $\mathbb{F}_q$, respectively. It's kind of surprising that we could so easily find two large and isomorphic curves for which these fields share access. Normally, if we pick a random curve over a given field, the order can be anywhere within a very large [Hasse interval](https://en.wikipedia.org/wiki/Hasse%27s_theorem_on_elliptic_curves), and so it would be vanishingly unlikely that two such curves over different fields would have the same order. This is no coincidence, and so we dug in to find out why. ## secp256k1's origins secp256k1 was published by Certicom a couple decades ago as part of a general effort to encourage the adoption of elliptic curve cryptography, and probably also as a way to monetize the multiple patents they had on ECC-adjacent ideas. One of these patents was over a technique for quickly performing scalar multiplication through the use of an endomorphism that exists for Koblitz curves of the form $y^2 = x^3 + b$ defined over a field $\mathbb{F}_p$ with $p \equiv 1 \pmod{3}$. These patents [expired in 2020](https://twitter.com/feministPLT/status/1212509061205430278). secp256k1 is indeed one of these curves, though how it was chosen was never clearly specified. [[SEC 2]](https://www.secg.org/sec2-v2.pdf) only says that "The recommended parameters associated with a Koblitz curve were chosen by repeatedly selecting parameters admitting an efficiently computable endomorphism until a prime order curve was found." — which is quite vague. One of the caveats of searching for a curve like secp256k1 is that this particular class of curves only has six distinct curves (up to isomorphism) for each prime field. Due to the sparsity of primes, Certicom likely searched through a space of finite fields until a point counting algorithm and primality test told them they found a prime order curve over one of them. ## CM curves Koblitz curves over prime fields are also part of a class of curves called CM curves for which a simple relationship exists between the field characteristic and the group order. In particular, given $p \equiv 1 \pmod{3}$ the six possible orders of any j-invariant $0$ curve over $\mathbb{F}_p$ are given by * $p + 1 \pm T_p$ * $p + 1 \pm \frac{3V_p}{2} \pm \frac{T_p}{2}$ where $V_p, T_p$ are integers. This presents another way to search for curves like secp256k1 that avoids point counting algorithms and relies only on primality testing. (We developed [a tool](https://github.com/daira/curvesearch) to find curves with special properties, leading to the [Pasta curves](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) that we now use in Zcash.) Interestingly, these curves _always_ form a $2$-cycle when the curve's order is prime. As an example, suppose that $q = p + 1 - T_p$ is the group order. We can write $T_q = T_p - 2$ and rearrange to see $p = q + 1 + T_q$, which is one of the group orders written above but with $p$ swapped with $q$! This implies a j-invariant $0$ curve exists on $\mathbb{F}_q$ that has order $p$, forming a $2$-cycle. This is true for the other cases as well. ## Isomorphic Curves The reason a curve exists over secp256k1's base field that is isomorphic to a curve over its scalar field stems from the fact that secp256k1's group order happens to be in the $q = p + 1 \pm T_p$ case mentioned before. Here's why. Supposing that $q = p + 1 - T_p$ (and therefore that $p = q + 1 + T_q$, and without loss of generality) we can look at the orders of some of the other CM curves involved: * $p + 1 \pm \frac{3V_p}{2} \pm \frac{T_p}{2}$ are the orders of other $j$-invariant $0$ curves over $\mathbb{F}_p$. * $q + 1 \pm \frac{3V_p}{2} \pm \frac{T_q}{2}$ are the orders of other $j$-invariant $0$ curves over $\mathbb{F}_q$. But with some simple arithmetic we see that e.g. $$ \begin{array}{rl} p + 1 + \frac{3V_p}{2} - \frac{T_p}{2} &= (q + 1 + T_q) + 1 + \frac{3V_p}{2} - \frac{T_p}{2} \\ &= q + 2 + \frac{3V_p}{2} - \frac{T_p}{2} + T_q \\ &= q + 2 + \frac{3V_p}{2} - \frac{T_q + 2}{2} + T_q \\ &= q + 1 + \frac{3V_p}{2} - \frac{T_q}{2} + T_q\\ &= q + 1 + \frac{3V_p}{2} + \frac{T_q}{2} \end{array} $$ which shows that one of the curves over $\mathbb{F}_p$ will have the same order as a curve over $\mathbb{F}_q$ whenever we're in the case that $q = p + 1 - T_p$. Accounting for the sign of $\pm \frac{3V_p}{2}$ we see that there is another pair of isomorphic curves in this case as well. ## Implications There's no reason for us to think that these isomorphic curves pose any security danger for secp256k1. One reason we were interested in investigating this is that if they did, it would have implications for Zcash as well because Halo 2 is built using the Pasta curves, which are also a $2$-cycle of $j$-invariant $0$ curves that have these isomorphic curves attached. Our main interest is in exploiting the isomorphic curves inside of Halo-style proof-carrying data, where it is convenient (for performance reasons) whenever the two fields $\mathbb{F}_p$ and $\mathbb{F}_q$ can "speak the same language" in a sense. As an example, a Pedersen vector commitment over one of the isomorphic curves can be provably transformed into a vector commitment over the other curve using random point testing, and in fact this test can be "accumulated" within recursive proofs in a similar sense to what is done in Halo. The main stumbling block is that although the two curves are isomorphic, the actual isomorphism is not efficiently computable --- as far as we're aware. This limits us from the full range of possible tricks and techniques. Here's to hoping that someone can figure out a way to extend this observation to something useful lest it remains just an interesting footnote.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully