# Class BSV::Primitives::Signature <a id="class-BSV-Primitives-Signature"></a>

**Inherits:** `Object`

An ECDSA signature consisting of (r, s) components.

Supports DER encoding/decoding with strict BIP-66 validation, low-S
normalisation (BIP-62 rule 5), and hex convenience methods.

**@example Parse a DER-encoded signature**
```ruby
sig = BSV::Primitives::Signature.from_der(der_bytes)
sig.low_s? #=> true
```

## Attributes
### `r` [R] <a id="attribute-i-r"></a> <a id="r-instance_method"></a>
- **@return** [OpenSSL::BN] the r component

### `s` [R] <a id="attribute-i-s"></a> <a id="s-instance_method"></a>
- **@return** [OpenSSL::BN] the s component

## Public Class Methods
### `from_der(der_bytes)` <a id="method-c-from_der"></a> <a id="from_der-class_method"></a>
Parse a signature from DER-encoded bytes with strict BIP-66 validation.
- **@param** `der_bytes` [String] DER-encoded signature bytes
- **@raise** [ArgumentError] if the DER encoding is invalid
- **@return** [Signature]

### `from_hex(hex)` <a id="method-c-from_hex"></a> <a id="from_hex-class_method"></a>
Parse a signature from a hex-encoded DER string.
- **@param** `hex` [String] hex-encoded DER signature
- **@return** [Signature]

## Public Instance Methods
### `==(other)` <a id="method-i--3D-3D"></a> <a id="==-instance_method"></a>
- **@param** `other` [Object] the object to compare
- **@return** [Boolean] +true+ if both signatures have equal r and s values

### `initialize(r, s)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
- **@param** `r` [OpenSSL::BN, Integer] the r component
- **@param** `s` [OpenSSL::BN, Integer] the s component
- **@return** [Signature] a new instance of Signature

### `low_s?()` <a id="method-i-low_s-3F"></a> <a id="low_s?-instance_method"></a>
Check whether the S value is in the lower half of the curve order.

BIP-62 rule 5 requires S <= N/2 for transaction malleability protection.
- **@return** [Boolean] +true+ if S is in the lower half

### `to_der()` <a id="method-i-to_der"></a> <a id="to_der-instance_method"></a>
Serialise the signature in DER format.
- **@return** [String] DER-encoded binary string

### `to_hex()` <a id="method-i-to_hex"></a> <a id="to_hex-instance_method"></a>
Serialise the signature as a hex-encoded DER string.
- **@return** [String] hex-encoded DER signature

### `to_low_s()` <a id="method-i-to_low_s"></a> <a id="to_low_s-instance_method"></a>
Return a new signature with S normalised to the lower half of the curve order.
- **@return** [Signature] a new signature with low-S, or +self+ if already low-S
