Secp256Trait

A trait for interacting with Secp256{k/r}1 curves.Provides operations needed to work with Secp256k1 and Secp256r1 elliptic curves. It includes methods for accessing curve parameters and creating curve points. # Examples

use starknet::secp256k1::Secp256k1Point;
use starknet::secp256_trait::Secp256Trait;
use starknet::SyscallResultTrait;

assert!(
    Secp256Trait::<
        Secp256k1Point,
    >::get_curve_size() == 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141,
);

let generator = Secp256Trait::<Secp256k1Point>::get_generator_point();

let generator = Secp256Trait::<
Secp256k1Point,
>::secp256_ec_new_syscall(
0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,
0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8,
)
.unwrap_syscall();

let random_point = Secp256Trait::<
Secp256k1Point,
>::secp256_ec_get_point_from_x_syscall(
0x4aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff3, true,
);

Fully qualified path: core::starknet::secp256_trait::Secp256Trait

pub trait Secp256Trait<Secp256Point>

Trait functions

get_curve_size

Returns the order (size) of the curve's underlying field.This is the number of points on the curve, also known as the curve order.

Fully qualified path: core::starknet::secp256_trait::Secp256Trait::get_curve_size

fn get_curve_size() -> u256

get_generator_point

Returns the generator point (G) for the curve.The generator point is a standard base point on the curve from which other points can be generated through scalar multiplication.

Fully qualified path: core::starknet::secp256_trait::Secp256Trait::get_generator_point

fn get_generator_point() -> Secp256Point

secp256_ec_new_syscall

Creates a new curve point from its x and y coordinates.Returns None if the provided coordinates don't represent a valid point on the curve.

Fully qualified path: core::starknet::secp256_trait::Secp256Trait::secp256_ec_new_syscall

fn secp256_ec_new_syscall(x: u256, y: u256) -> SyscallResult<Option<Secp256Point>>

secp256_ec_get_point_from_x_syscall

Creates a curve point on the curve given its x-coordinate and y-parity. # Argumentsx - The x coordinate of the point * y_parity - If true, choose the odd y value; if false, choose the even y value # ReturnsReturns Some(point) if a point exists with the given x coordinate, None otherwise.

Fully qualified path: core::starknet::secp256_trait::Secp256Trait::secp256_ec_get_point_from_x_syscall

fn secp256_ec_get_point_from_x_syscall(
    x: u256, y_parity: bool,
) -> SyscallResult<Option<Secp256Point>>