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

[New Hints] uint256_improvements.json #978

Closed
pefontana opened this issue Apr 13, 2023 · 0 comments · Fixed by #1025
Closed

[New Hints] uint256_improvements.json #978

pefontana opened this issue Apr 13, 2023 · 0 comments · Fixed by #1025
Assignees
Labels
whitelisted-hint Implementation of hint on whitelist directory

Comments

@pefontana
Copy link
Collaborator

pefontana commented Apr 13, 2023

Implement the remaining hints in uint256_improvements.json

NewHint#42

Assigned: @MegaRedHand
Status: #1013

                "a = (ids.a.high << 128) + ids.a.low",
                "div = (ids.div.b23 << 128) + ids.div.b01",
                "quotient, remainder = divmod(a, div)",
                "",
                "ids.quotient.low = quotient & ((1 << 128) - 1)",
                "ids.quotient.high = quotient >> 128",
                "ids.remainder.low = remainder & ((1 << 128) - 1)",
                "ids.remainder.high = remainder >> 128"

NewHint#43

Assigned: @MegaRedHand
Status: #1016

"def split(num: int, num_bits_shift: int = 128, length: int = 2):",
                "    a = []",
                "    for _ in range(length):",
                "        a.append( num & ((1 << num_bits_shift) - 1) )",
                "        num = num >> num_bits_shift",
                "    return tuple(a)",
                "",
                "def pack(z, num_bits_shift: int = 128) -> int:",
                "    limbs = (z.low, z.high)",
                "    return sum(limb << (num_bits_shift * i) for i, limb in enumerate(limbs))",
                "",
                "a = pack(ids.a)",
                "b = pack(ids.b)",
                "res = (a - b)%2**256",
                "res_split = split(res)",
                "ids.res.low = res_split[0]",
                "ids.res.high = res_split[1]"

NewHint#44

Assigned: @MegaRedHand
Status: #1025

                "from starkware.python.math_utils import isqrt",
                "n = (ids.n.high << 128) + ids.n.low",
                "root = isqrt(n)",
                "assert 0 <= root < 2 ** 128",
                "ids.root = root"

NewHint#45

Assigned: @MegaRedHand
Status: #1024

          "res = ids.a + ids.b",
          "ids.carry = 1 if res >= ids.SHIFT else 0"
@pefontana pefontana moved this to Todo in Starknet Apr 13, 2023
@pefontana pefontana added the whitelisted-hint Implementation of hint on whitelist directory label Apr 13, 2023
@MegaRedHand MegaRedHand moved this from Todo to In Progress in Starknet Apr 18, 2023
@MegaRedHand MegaRedHand self-assigned this Apr 18, 2023
@MegaRedHand MegaRedHand moved this from In Progress to In Review in Starknet Apr 20, 2023
@github-project-automation github-project-automation bot moved this from In Review to Done in Starknet Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
whitelisted-hint Implementation of hint on whitelist directory
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants