pub struct Point { /* private fields */ }Expand description
A point on the secp256k1 elliptic curve in affine coordinates
Implementations§
Source§impl Point
impl Point
Sourcepub fn new_uncompressed(x: &[u8; 32], y: &[u8; 32]) -> Result<Self>
pub fn new_uncompressed(x: &[u8; 32], y: &[u8; 32]) -> Result<Self>
Create a new point from uncompressed coordinates.
Returns an error if the coordinates don’t satisfy the curve equation.
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; 32]
pub fn x_coordinate_bytes(&self) -> [u8; 32]
Get the x-coordinate of this point as bytes.
Sourcepub fn y_coordinate_bytes(&self) -> [u8; 32]
pub fn y_coordinate_bytes(&self) -> [u8; 32]
Get the y-coordinate of this point as bytes.
Sourcepub fn serialize_uncompressed(&self) -> [u8; 65]
pub fn serialize_uncompressed(&self) -> [u8; 65]
Serialize this point in uncompressed format.
For the identity this fixed-width API returns an all-zero internal
sentinel. SEC 1 encodes identity as the single byte 0x00, so the
sentinel is deliberately rejected by the deserializer and must not be
placed on the wire.
Sourcepub fn deserialize_uncompressed(bytes: &[u8]) -> Result<Self>
pub fn deserialize_uncompressed(bytes: &[u8]) -> Result<Self>
Deserialize a point from uncompressed format.
Returns an error if the bytes don’t represent a valid point.
Sourcepub fn serialize_compressed(&self) -> [u8; 33]
pub fn serialize_compressed(&self) -> [u8; 33]
Serialize this point in compressed format.
For the identity this fixed-width API returns an all-zero internal sentinel, which is not a canonical SEC 1 encoding and is rejected by the deserializer.
Sourcepub fn deserialize_compressed(bytes: &[u8]) -> Result<Self>
pub fn deserialize_compressed(bytes: &[u8]) -> Result<Self>
Deserialize a point from compressed format.
Returns an error if the bytes don’t represent a valid point.