File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
elliptic-curve/src/weierstrass Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use generic_array::{
1616 typenum:: { Unsigned , U1 } ,
1717 ArrayLength , GenericArray ,
1818} ;
19+ use subtle:: CtOption ;
1920
2021/// Size of an untagged point for given elliptic curve.
2122pub type UntaggedPointSize < C > = <<C as crate :: Curve >:: ElementSize as Add >:: Output ;
@@ -206,3 +207,21 @@ where
206207 PublicKey :: Uncompressed ( point)
207208 }
208209}
210+
211+ /// Trait for deserializing a value from a public key.
212+ ///
213+ /// This is intended for use with the `AffinePoint` type for a given elliptic curve.
214+ pub trait FromPublicKey < C : Curve > : Sized
215+ where
216+ C :: ElementSize : Add < U1 > ,
217+ <C :: ElementSize as Add >:: Output : Add < U1 > ,
218+ CompressedPointSize < C > : ArrayLength < u8 > ,
219+ UncompressedPointSize < C > : ArrayLength < u8 > ,
220+ {
221+ /// Deserialize this value from a [`PublicKey`]
222+ ///
223+ /// # Returns
224+ ///
225+ /// `None` if the public key is not on the curve.
226+ fn from_public_key ( public_key : & PublicKey < C > ) -> CtOption < Self > ;
227+ }
You can’t perform that action at this time.
0 commit comments