NethermindEth / cairo-vm-go

A virtual machine for Cairo written in Go
MIT License
79 stars 49 forks source link

EcDoubleAssignNewYV1 #386

Closed TAdev0 closed 3 months ago

TAdev0 commented 3 months ago

EcDoubleAssignNewYV1 hint computes a new y-coordinate for doubling a point on an elliptic curve

Reference: https://github.com/starkware-libs/cairo-lang/blob/efa9648f57568aad8f8a13fbf027d2de7c63c2c0/src/starkware/cairo/common/cairo_secp/ec.cairo#L151

TAdev0 commented 3 months ago

This hints calculates the new y -coordinate when doubling a point on an elliptic curve the computation is obviously similar to the one when adding 2 different points:

new_y when doubling a point:

    %{ value = new_y = (slope * (x - new_x) - y) % SECP_P %}

new_y when adding 2 different points:

    %{ value = new_y = (slope * (x0 - new_x) - y0) % SECP_P %}

The hint to compute new_y when adding 2 different points is already implemented and is called FastEcAddAssignNewY, see https://github.com/NethermindEth/cairo-vm-go/pull/334