field: Document return value of fe_sqrt() #1347

pull real-or-random wants to merge 1 commits into bitcoin-core:master from real-or-random:202306-fe-sqrt-ret-docs changing 1 files +4 −2
  1. real-or-random commented at 9:50 AM on June 15, 2023: contributor

    No description provided.

  2. real-or-random added the label documentation on Jun 15, 2023
  3. real-or-random commented at 9:51 AM on June 15, 2023: contributor

    @stratospher Interested in reviewing this small PR?

  4. in src/field.h:271 in c66c30cd57 outdated
     266 | @@ -267,8 +267,10 @@ static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a);
     267 |  /** Compute a square root of a field element.
     268 |   *
     269 |   * On input, a must be a valid field element with magnitude<=8; r need not be initialized.
     270 | - * Performs {r = sqrt(a)} or {r = sqrt(-a)}, whichever exists. The resulting value
     271 | - * represented by r will be a square itself. Variables r and a must not point to the same object.
     272 | + * Performs {r = sqrt(a)} and returns 1 if sqrt(a) exists.
     273 | + * Performs {r = sqrt(-a) and returns 0 otherwise; then sqrt(-a) exists.
    


    stratospher commented at 3:21 PM on June 15, 2023:

    c66c30c: nit

     * Performs {r = sqrt(-a)} and returns 0 otherwise; then sqrt(-a) exists.
    
  5. stratospher commented at 3:21 PM on June 15, 2023: contributor

    ACK c66c30c.

  6. real-or-random force-pushed on Jun 15, 2023
  7. stratospher commented at 3:26 PM on June 15, 2023: contributor

    ACK cc1ad2f.

  8. in src/field.h:271 in cc1ad2f97e outdated
     266 | @@ -267,8 +267,10 @@ static void secp256k1_fe_sqr(secp256k1_fe *r, const secp256k1_fe *a);
     267 |  /** Compute a square root of a field element.
     268 |   *
     269 |   * On input, a must be a valid field element with magnitude<=8; r need not be initialized.
     270 | - * Performs {r = sqrt(a)} or {r = sqrt(-a)}, whichever exists. The resulting value
     271 | - * represented by r will be a square itself. Variables r and a must not point to the same object.
     272 | + * Performs {r = sqrt(a)} and returns 1 if sqrt(a) exists.
     273 | + * Performs {r = sqrt(-a)} and returns 0 otherwise; then sqrt(-a) exists.
    


    jonasnick commented at 3:22 PM on June 16, 2023:

    nit: maybe case distinction like this is clearer?

     * If sqrt(a) exists, performs {r = sqrt(a)} and returns 1.
     * Otherwise, sqrt(-a) exists. The function performs {r = sqrt(-a)} and returns 0.
    

    real-or-random commented at 10:19 PM on June 20, 2023:

    Done.

  9. field: Document return value of fe_sqrt()
    Co-authored-by: Jonas Nick <jonasd.nick@gmail.com>
    5779137457
  10. real-or-random force-pushed on Jun 20, 2023
  11. sipa commented at 11:45 PM on June 20, 2023: contributor

    ACK 57791374579595bbc5d8d2e55f7fa0bc40d861a4

  12. theStack approved
  13. theStack commented at 3:30 PM on June 21, 2023: contributor

    ACK 57791374579595bbc5d8d2e55f7fa0bc40d861a4

  14. real-or-random merged this on Jun 21, 2023
  15. real-or-random closed this on Jun 21, 2023

  16. vmta referenced this in commit 8f03457eed on Jul 1, 2023
  17. fanquake referenced this in commit 56c05c5ec4 on Jul 17, 2023
  18. fanquake referenced this in commit ff061fde18 on Jul 18, 2023
  19. hebasto referenced this in commit 270d2b37b8 on Jul 21, 2023
  20. delta1 referenced this in commit 3f32c20932 on Aug 8, 2023
  21. delta1 referenced this in commit 31ac0c1081 on Aug 31, 2023
  22. janus referenced this in commit 476a2176e7 on Sep 11, 2023
  23. div72 referenced this in commit af627d47c3 on Apr 12, 2025
  24. str4d referenced this in commit 3b49801869 on Jun 4, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-19 06:52 UTC