pub struct Point { /* private fields */ }Expand description
P-384 elliptic curve point in affine coordinates (x, y)
Represents points on the NIST P-384 curve. The special point at infinity (identity element) is represented with is_identity = true.
Implementations§
Source§impl Point
impl Point
Sourcepub fn new_uncompressed(x: &[u8; 48], y: &[u8; 48]) -> Result<Self>
pub fn new_uncompressed(x: &[u8; 48], y: &[u8; 48]) -> Result<Self>
Create a new elliptic curve point from uncompressed coordinates
Validates that the given (x, y) coordinates satisfy the P-384 curve equation: y² = x³ - 3x + b (mod p)
Returns an error if the point is not on the curve.
Sourcepub fn identity() -> Self
pub fn identity() -> Self
Create the identity element (point at infinity)
The identity element serves as the additive neutral element for the elliptic curve group operation.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Check if this point is the identity element
Sourcepub fn x_coordinate_bytes(&self) -> [u8; 48]
pub fn x_coordinate_bytes(&self) -> [u8; 48]
Get the x-coordinate as a byte array in big-endian format
Sourcepub fn y_coordinate_bytes(&self) -> [u8; 48]
pub fn y_coordinate_bytes(&self) -> [u8; 48]
Get the y-coordinate as a byte array in big-endian format
Sourcepub fn detect_format(bytes: &[u8]) -> Result<PointFormat>
pub fn detect_format(bytes: &[u8]) -> Result<PointFormat>
Detect point format from serialized bytes
Analyzes the leading byte and length to determine the serialization format.
Sourcepub fn serialize_uncompressed(&self) -> [u8; 97]
pub fn serialize_uncompressed(&self) -> [u8; 97]
Serialize point to uncompressed format: 0x04 || x || y
The identity point is represented as all zeros.
Sourcepub fn deserialize_uncompressed(bytes: &[u8]) -> Result<Self>
pub fn deserialize_uncompressed(bytes: &[u8]) -> Result<Self>
Deserialize point from uncompressed byte format
Supports the standard uncompressed format (0x04 || x || y) and recognizes the all-zeros encoding for the identity element.
Sourcepub fn serialize_compressed(&self) -> [u8; 49]
pub fn serialize_compressed(&self) -> [u8; 49]
Serialize point to SEC 1 compressed format (0x02/0x03 || x)
The compressed format uses:
- 0x02 prefix if y-coordinate is even
- 0x03 prefix if y-coordinate is odd
- Followed by the x-coordinate in big-endian format
Sourcepub fn deserialize_compressed(bytes: &[u8]) -> Result<Self>
pub fn deserialize_compressed(bytes: &[u8]) -> Result<Self>
Deserialize SEC 1 compressed point
Recovers the full point from compressed format by computing y² = x³ - 3x + b and finding the square root.