Skip to content

[New Hints] cairo_secp.json #980

@pefontana

Description

@pefontana

Implement the remaining hints in cairo_secp.json

NewHint#13

assigned: @MegaRedHand
status: #1006

                "ids.quad_bit = (",
                "    8 * ((ids.scalar_v >> ids.m) & 1)",
                "    + 4 * ((ids.scalar_u >> ids.m) & 1)",
                "    + 2 * ((ids.scalar_v >> (ids.m - 1)) & 1)",
                "    + ((ids.scalar_u >> (ids.m - 1)) & 1)",
                ")"

NewHint#14

assigned: @MegaRedHand
status: #1008

                "ids.len_hi = max(ids.scalar_u.d2.bit_length(), ids.scalar_v.d2.bit_length())-1"

NewHint#15

assigned: @MegaRedHand
status: #1009

                "ids.dibit = ((ids.scalar_u >> ids.m) & 1) + 2 * ((ids.scalar_v >> ids.m) & 1)"

NewHint#16

assigned: @mfachal
status: #1014

                "from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_P as SECP_P"

NewHint#17

assigned: @mfachal
status: #1026

                "from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_ALPHA as ALPHA"

NewHint#18

assigned: @mfachal
status: #1026

                "from starkware.cairo.common.cairo_secp.secp256r1_utils import SECP256R1_N as N"

NewHint#19 (there is a similar one, but this one is different)

assigned: @MegaRedHand
status: #1057

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "from starkware.python.math_utils import ec_double_slope",
                "",
                "# Compute the slope.",
                "x = pack(ids.point.x, PRIME)",
                "y = pack(ids.point.y, PRIME)",
                "value = slope = ec_double_slope(point=(x, y), alpha=ALPHA, p=SECP_P)"

NewHint#20 (there is a similar one, but this one is different)

assigned: @mfachal
status: #1014

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "from starkware.python.math_utils import line_slope",
                "",
                "# Compute the slope.",
                "x0 = pack(ids.point0.x, PRIME)",
                "y0 = pack(ids.point0.y, PRIME)",
                "x1 = pack(ids.point1.x, PRIME)",
                "y1 = pack(ids.point1.y, PRIME)",
                "value = slope = line_slope(point1=(x0, y0), point2=(x1, y1), p=SECP_P)"

NewHint#21 (there is a similar one, but this one is different)

assigned: @mfachal
status: #1089

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "",
                "slope = pack(ids.slope, PRIME)",
                "x0 = pack(ids.point0.x, PRIME)",
                "x1 = pack(ids.point1.x, PRIME)",
                "y0 = pack(ids.point0.y, PRIME)",
                "",
                "value = new_x = (pow(slope, 2, SECP_P) - x0 - x1) % SECP_P"

NewHint#22 (there is a similar one, but this one is different)

assigned: @MegaRedHand
status: #1003

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "x = pack(ids.x, PRIME) % SECP_P"

NewHint#23

assigned: @MegaRedHand
status: #996

                "from starkware.python.math_utils import div_mod",
                "",
                "value = x_inv = div_mod(1, x, SECP_P)"

NewHint#24 (there is a similar one, but this one is different)

assigned: @MegaRedHand
status: #994

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "from starkware.python.math_utils import div_mod, safe_div",
                "",
                "a = pack(ids.a, PRIME)",
                "b = pack(ids.b, PRIME)",
                "value = res = div_mod(a, b, N)"

NewHint#25

assigned: @MegaRedHand
status: #994

                "value = k_plus_one = safe_div(res * b - a, N) + 1"

NewHint#26 (there is a similar one, but this one is different)

assigned: @MegaRedHand
status: #992

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "",
                "q, r = divmod(pack(ids.val, PRIME), SECP_P)",
                "assert r == 0, f\"verify_zero: Invalid input {ids.val.d0, ids.val.d1, ids.val.d2}.\"",
                "ids.q = q % PRIME"

NewHint#27 (there is a similar one, but this one is different)

assigned: @MegaRedHand
status: #990

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "",
                "slope = pack(ids.slope, PRIME)",
                "x = pack(ids.point.x, PRIME)",
                "y = pack(ids.point.y, PRIME)",
                "",
                "value = new_x = (pow(slope, 2, SECP_P) - 2 * x) % SECP_P"

NewHint#28 (there is a similar one, but this one is different)

assigned: @MegaRedHand
status: #989

                "from starkware.cairo.common.cairo_secp.secp_utils import SECP_P",
                "q, r = divmod(pack(ids.val, PRIME), SECP_P)",
                "assert r == 0, f\"verify_zero: Invalid input {ids.val.d0, ids.val.d1, ids.val.d2}.\"",
                "ids.q = q % PRIME"

NewHint#29

assigned: @MegaRedHand
status: #986

                "from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack",
                "from starkware.python.math_utils import div_mod",
                "",
                "# Compute the slope.",
                "x = pack(ids.pt.x, PRIME)",
                "y = pack(ids.pt.y, PRIME)",
                "value = slope = div_mod(3 * x ** 2, 2 * y, SECP_P)"

NewHint#30

assigned: @MegaRedHand
status: #984

                "from starkware.cairo.common.cairo_secp.secp_utils import SECP_P, pack",
                "from starkware.python.math_utils import div_mod",
                "",
                "# Compute the slope.",
                "x0 = pack(ids.pt0.x, PRIME)",
                "y0 = pack(ids.pt0.y, PRIME)",
                "x1 = pack(ids.pt1.x, PRIME)",
                "y1 = pack(ids.pt1.y, PRIME)",
                "value = slope = div_mod(y0 - y1, x0 - x1, SECP_P)"

NewHint#31

assigned: @mfachal
status: #991

                "from starkware.cairo.common.cairo_secp.secp_utils import pack",
                "from starkware.python.math_utils import div_mod, safe_div",
                "",
                "N = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",
                "x = pack(ids.x, PRIME) % N",
                "s = pack(ids.s, PRIME) % N",
                "value = res = div_mod(x, s, N)"

NewHint#32

assigned: @MegaRedHand
status: #1010

                "memory[ap] = int(x == 0)"

NewHint#33

assigned: @mfachal
status: #991

                "value = k = safe_div(res * s - x, N)"

Metadata

Metadata

Assignees

Labels

whitelisted-hintImplementation of hint on whitelist directory

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions