Skip to content

Commit dbd6134

Browse files
committed
Clean up EcKey example a bit
1 parent 0897c19 commit dbd6134

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

openssl/src/ec.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl EcKey {
295295
///
296296
/// # Example
297297
///
298-
/// ```
298+
/// ```no_run
299299
/// use openssl::bn::BigNumContext;
300300
/// use openssl::ec::*;
301301
/// use openssl::nid;
@@ -304,13 +304,11 @@ impl EcKey {
304304
/// // get bytes from somewhere, i.e. this will not produce a valid key
305305
/// let public_key: Vec<u8> = vec![];
306306
///
307-
/// // create a PKey from the binary form of a EcPoint
308-
/// EcGroup::from_curve_name(nid::SECP256K1)
309-
/// .and_then(|group| BigNumContext::new().map(|ctx| (group, ctx)))
310-
/// .and_then(|(group, mut ctx)| EcPoint::from_bytes(&group, &public_key, &mut ctx)
311-
/// .map(|point| (group, point) ))
312-
/// .and_then(|(group, point)| EcKey::from_public_key(&group, &point))
313-
/// .and_then(|ec_key| PKey::from_ec_key(ec_key));
307+
/// // create an EcKey from the binary form of a EcPoint
308+
/// let group = EcGroup::from_curve_name(nid::SECP256K1).unwrap();
309+
/// let mut ctx = BigNumContext::new().unwrap();
310+
/// let point = EcPoint::from_bytes(&group, &public_key, &mut ctx).unwrap();
311+
/// let key = EcKey::from_public_key(&group, &point);
314312
/// ```
315313
pub fn from_public_key(group: &EcGroupRef, public_key: &EcPointRef) -> Result<EcKey, ErrorStack> {
316314
unsafe {

0 commit comments

Comments
 (0)