> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::starknet::secp256_trait::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.

## Signature

```rust theme={null}
pub trait Secp256Trait
```

## Examples

```rust theme={null}
use starknet::secp256k1::Secp256k1Point;
use starknet::secp256_trait::Secp256Trait;
use starknet::SyscallResultTrait;

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

let generator = Secp256Trait::::get_generator_point();

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

let random_point = Secp256Trait::::secp256_ec_get_point_from_x_syscall(
0x4aebd3099c618202fcfe16ae7770b0c49ab5eadf74b754204a3bb6060e44eff3, true,
);
```

## 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.

#### Signature

```rust theme={null}
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.

#### Signature

```rust theme={null}
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.

#### Signature

```rust theme={null}
fn secp256_ec_new_syscall(
    x: u256, y: u256,
) -> Result, Array>
```

### secp256\_ec\_get\_point\_from\_x\_syscall

Creates a curve point on the curve given its x-coordinate and y-parity.

#### Arguments

* `x` - The x coordinate of the point
* `y_parity` - If true, choose the odd y value; if false, choose the even y value

#### Returns

Returns `Some(point)` if a point exists with the given x coordinate,
`None` otherwise.

#### Signature

```rust theme={null}
fn secp256_ec_get_point_from_x_syscall(
    x: u256, y_parity: bool,
) -> Result, Array>
```
