Clean up EcKey example a bit

This commit is contained in:
Steven Fackler 2017-01-03 15:33:45 -08:00
parent 0897c196e1
commit dbd6134fd6
1 changed files with 6 additions and 8 deletions

View File

@ -295,7 +295,7 @@ impl EcKey {
/// ///
/// # Example /// # Example
/// ///
/// ``` /// ```no_run
/// use openssl::bn::BigNumContext; /// use openssl::bn::BigNumContext;
/// use openssl::ec::*; /// use openssl::ec::*;
/// use openssl::nid; /// use openssl::nid;
@ -304,13 +304,11 @@ impl EcKey {
/// // get bytes from somewhere, i.e. this will not produce a valid key /// // get bytes from somewhere, i.e. this will not produce a valid key
/// let public_key: Vec<u8> = vec![]; /// let public_key: Vec<u8> = vec![];
/// ///
/// // create a PKey from the binary form of a EcPoint /// // create an EcKey from the binary form of a EcPoint
/// EcGroup::from_curve_name(nid::SECP256K1) /// let group = EcGroup::from_curve_name(nid::SECP256K1).unwrap();
/// .and_then(|group| BigNumContext::new().map(|ctx| (group, ctx))) /// let mut ctx = BigNumContext::new().unwrap();
/// .and_then(|(group, mut ctx)| EcPoint::from_bytes(&group, &public_key, &mut ctx) /// let point = EcPoint::from_bytes(&group, &public_key, &mut ctx).unwrap();
/// .map(|point| (group, point) )) /// let key = EcKey::from_public_key(&group, &point);
/// .and_then(|(group, point)| EcKey::from_public_key(&group, &point))
/// .and_then(|ec_key| PKey::from_ec_key(ec_key));
/// ``` /// ```
pub fn from_public_key(group: &EcGroupRef, public_key: &EcPointRef) -> Result<EcKey, ErrorStack> { pub fn from_public_key(group: &EcGroupRef, public_key: &EcPointRef) -> Result<EcKey, ErrorStack> {
unsafe { unsafe {