# Module BSV::Primitives::Curve <a id="module-BSV-Primitives-Curve"></a>

Low-level secp256k1 elliptic curve operations.

Backed by the pure Ruby {Secp256k1} module via an OpenSSL compatibility shim.
The shim preserves the <code>OpenSSL::PKey::EC</code> interface so consumer
code is unchanged. All constants and methods operate on the secp256k1 curve.

## Constants
### `G` <a id="constant-G"></a> <a id="G-constant"></a>
The generator point (base point).

### `GROUP` <a id="constant-GROUP"></a> <a id="GROUP-constant"></a>
The secp256k1 curve group.

### `HALF_N` <a id="constant-HALF_N"></a> <a id="HALF_N-constant"></a>
Half the curve order, used for low-S normalisation.

### `N` <a id="constant-N"></a> <a id="N-constant"></a>
The curve order (number of points on the curve).

## Public Class Methods
### `add_points(point_a, point_b)` <a id="method-c-add_points"></a> <a id="add_points-class_method"></a>
Add two curve points together.
- **@param** `point_a` [OpenSSL::PKey::EC::Point] first point
- **@param** `point_b` [OpenSSL::PKey::EC::Point] second point
- **@return** [OpenSSL::PKey::EC::Point] the sum of the two points

### `multiply_generator(scalar_bn)` <a id="method-c-multiply_generator"></a> <a id="multiply_generator-class_method"></a>
Multiply the generator point by a scalar (constant-time).

Uses the Montgomery ladder by default, matching OpenSSL convention. Safe for
both secret and public scalars. For explicit variable-time multiplication of
public scalars, use {multiply_generator_vt}.
- **@param** `scalar_bn` [OpenSSL::BN] the scalar multiplier
- **@return** [OpenSSL::PKey::EC::Point] the resulting curve point

### `multiply_generator_ct(scalar_bn)` <a id="method-c-multiply_generator_ct"></a> <a id="multiply_generator_ct-class_method"></a>
Multiply the generator point by a secret scalar (constant-time).

Alias for {multiply_generator} — retained for backward compatibility and
expressiveness.
- **@param** `scalar_bn` [OpenSSL::BN] the secret scalar multiplier
- **@return** [OpenSSL::PKey::EC::Point] the resulting curve point

### `multiply_generator_vt(scalar_bn)` <a id="method-c-multiply_generator_vt"></a> <a id="multiply_generator_vt-class_method"></a>
Multiply the generator point by a public scalar (variable-time, wNAF).

Faster than {multiply_generator} but leaks timing information about the
scalar. Use only for public scalars (e.g. signature verification).
- **@param** `scalar_bn` [OpenSSL::BN] the public scalar multiplier
- **@return** [OpenSSL::PKey::EC::Point] the resulting curve point

### `multiply_point(point, scalar_bn)` <a id="method-c-multiply_point"></a> <a id="multiply_point-class_method"></a>
Multiply an arbitrary curve point by a scalar (constant-time).

Uses the Montgomery ladder by default, matching OpenSSL convention. Safe for
both secret and public scalars. For explicit variable-time multiplication of
public scalars, use {multiply_point_vt}.
- **@param** `point` [OpenSSL::PKey::EC::Point] the point to multiply
- **@param** `scalar_bn` [OpenSSL::BN] the scalar multiplier
- **@return** [OpenSSL::PKey::EC::Point] the resulting curve point

### `multiply_point_ct(point, scalar_bn)` <a id="method-c-multiply_point_ct"></a> <a id="multiply_point_ct-class_method"></a>
Multiply an arbitrary curve point by a secret scalar (constant-time).

Alias for {multiply_point} — retained for backward compatibility and
expressiveness.
- **@param** `point` [OpenSSL::PKey::EC::Point] the base point
- **@param** `scalar_bn` [OpenSSL::BN] the secret scalar multiplier
- **@return** [OpenSSL::PKey::EC::Point] the resulting curve point

### `multiply_point_vt(point, scalar_bn)` <a id="method-c-multiply_point_vt"></a> <a id="multiply_point_vt-class_method"></a>
Multiply an arbitrary curve point by a public scalar (variable-time, wNAF).

Faster than {multiply_point} but leaks timing information about the scalar.
Use only for public scalars (e.g. signature verification).
- **@param** `point` [OpenSSL::PKey::EC::Point] the point to multiply
- **@param** `scalar_bn` [OpenSSL::BN] the public scalar multiplier
- **@return** [OpenSSL::PKey::EC::Point] the resulting curve point

### `point_from_bytes(bytes)` <a id="method-c-point_from_bytes"></a> <a id="point_from_bytes-class_method"></a>
Reconstruct a curve point from its byte representation.
- **@param** `bytes` [String] compressed (33 bytes) or uncompressed (65 bytes) point encoding
- **@return** [OpenSSL::PKey::EC::Point] the decoded curve point

### `point_x(point)` <a id="method-c-point_x"></a> <a id="point_x-class_method"></a>
Extract the x-coordinate from a curve point as a big number.
- **@param** `point` [OpenSSL::PKey::EC::Point] the curve point
- **@return** [OpenSSL::BN] the x-coordinate
