Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Sage code to Python 3 (as used by Sage >= 9) #849

Merged
merged 1 commit into from
Nov 23, 2020

Conversation

real-or-random
Copy link
Contributor

This adds one more commit on top of #848 and squashes the commits.

Thanks to @fchapoton for spotting the issue and suggesting initial fixes.

# Compatibility wrapper for Sage versions based on Python 2
def __div__(self,other):
"""Divide two fractions."""
return __truediv__(self,other)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NameError: global name '__truediv__' is not defined. This should be return self.__truediv__(other)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I assumed I'm clever enough to write three lines of Python code without testing. But apparently I was wrong. (Sorry, it's a lot of work for me to install an older sage version...) Should work now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw, nix-shell -p sage would work but the tests take forever. Therefore you can use nix-shell '-p sage.overrideAttrs (oldAttrs: rec { buildInputs = [ makeWrapper ]; })' to disable the tests.

Co-authored-by: Tim Ruffing <crypto@timruffing.de>
Copy link
Contributor

@jonasnick jonasnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 13c88ef

@jonasnick jonasnick merged commit 3a10696 into bitcoin-core:master Nov 23, 2020
@jonasnick jonasnick mentioned this pull request Nov 23, 2020
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Apr 8, 2021
Summary: Backport of [[bitcoin-core/secp256k1#849 | secp256k1#849]]

Test Plan:
Run from the sage dir
  sage group_prover.sage
  sage weierstrass_prover.sage

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D9374
deadalnix pushed a commit to Bitcoin-ABC/secp256k1 that referenced this pull request Apr 9, 2021
Summary: Backport of [[bitcoin-core/secp256k1#849 | secp256k1#849]]

Test Plan:
Run from the sage dir
  sage group_prover.sage
  sage weierstrass_prover.sage

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D9374
theStack added a commit to theStack/secp256k1 that referenced this pull request Jun 11, 2023
Some of the C source files include Sage code in comments. This PR
updates these to work with a current version based on Python3 (Sage
9.0+, see https://wiki.sagemath.org/Python3-Switch).

This can be seen as a small follow-up to PR bitcoin-core#849 (commit
13c88ef).
theStack added a commit to theStack/secp256k1 that referenced this pull request Jul 7, 2023
… to Python3)

Some of the C source files contain contain in-comment Sage code
calculating secp256k1 parameters that are already defined in the file
secp256k1_params.sage.  Replace that by a corresponding load instruction
and access the necessary variables. In ecdsa_impl.h, update the comment
to use a one-line shell command calling sage to get the values.

The remaining code (test `test_add_neg_y_diff_x` in tests.c) is updated
to work with a current version based on Python3 (Sage 9.0+, see
https://wiki.sagemath.org/Python3-Switch).

The latter can be seen as a small follow-up to PR bitcoin-core#849 (commit
13c88ef).
theStack added a commit to theStack/secp256k1 that referenced this pull request Jul 7, 2023
… to Python3)

Some of the C source files contain contain in-comment Sage code
calculating secp256k1 parameters that are already defined in the file
secp256k1_params.sage.  Replace that by a corresponding load instruction
and access the necessary variables. In ecdsa_impl.h, update the comment
to use a one-line shell command calling sage to get the values.

The remaining code (test `test_add_neg_y_diff_x` in tests.c) is updated
to work with a current version based on Python3 (Sage 9.0+, see
https://wiki.sagemath.org/Python3-Switch).

The latter can be seen as a small follow-up to PR bitcoin-core#849 (commit
13c88ef).
theStack added a commit to theStack/secp256k1 that referenced this pull request Jul 10, 2023
… to Python3)

Some of the C source files contain contain in-comment Sage code
calculating secp256k1 parameters that are already defined in the file
secp256k1_params.sage.  Replace that by a corresponding load instruction
and access the necessary variables. In ecdsa_impl.h, update the comment
to use a one-line shell command calling sage to get the values.

The remaining code (test `test_add_neg_y_diff_x` in tests.c) is updated
to work with a current version based on Python3 (Sage 9.0+, see
https://wiki.sagemath.org/Python3-Switch).

The latter can be seen as a small follow-up to PR bitcoin-core#849 (commit
13c88ef).
real-or-random added a commit that referenced this pull request Jul 10, 2023
….sage, update to Python3)

600c5ad clean up in-comment Sage code (refer to secp256k1_params.sage, update to Python3) (Sebastian Falbesoner)

Pull request description:

  Some of the C source files contain contain in-comment Sage code calculating secp256k1 parameters that are already defined in the file secp256k1_params.sage.  Replace that by a corresponding load instruction and access the necessary variables. In ecdsa_impl.h, update the comment to use a one-line shell command calling sage to get the values.

  The remaining code (test `test_add_neg_y_diff_x` in tests.c) is updated to work with a current version based on Python3 (Sage 9.0+, see https://wiki.sagemath.org/Python3-Switch).

  The latter can be seen as a small follow-up to PR #849 (commit 13c88ef).

ACKs for top commit:
  sipa:
    ACK 600c5ad
  real-or-random:
    ACK 600c5ad

Tree-SHA512: a9e52f6afbce65edd9ab14203612c3d423639f450fe8f0d269a3dda04bebefa95b607f7aa0faec864cb78b46d49f281632bb1277118749b7d8613e9f5dcc8f3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants