Skip to content

Commit

Permalink
Remove ecparams jplevyak (#152)
Browse files Browse the repository at this point in the history
* Remove EC PARAMETERS in PEM file to match dfx.

Signed-off-by: John Plevyak <[email protected]>
  • Loading branch information
jplevyak authored Jan 31, 2023
1 parent 0565fe1 commit a525012
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
- remove the `EC PARAMETERS` section in the PEM file to match dfx

## [0.3.2] - 2023-01-13

Expand Down
13 changes: 1 addition & 12 deletions src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ use std::{env::VarError, path::Path};

pub const IC_URL: &str = "https://ic0.app";

// The OID of secp256k1 curve is `1.3.132.0.10`.
// Encoding in DER results in following bytes.
const EC_PARAMETERS: [u8; 7] = [6, 5, 43, 129, 4, 0, 10];

pub fn get_ic_url() -> String {
std::env::var("IC_URL").unwrap_or_else(|_| IC_URL.to_string())
}
Expand Down Expand Up @@ -321,17 +317,10 @@ pub fn mnemonic_to_pem(mnemonic: &Mnemonic) -> AnyhowResult<String> {
public_key.to_encoded_point(false).to_bytes().into(),
secret_key.to_be_bytes().to_vec(),
)?;
let pem = Pem {
tag: String::from("EC PARAMETERS"),
contents: EC_PARAMETERS.to_vec(),
};
let parameters_pem = encode(&pem);
let pem = Pem {
tag: String::from("EC PRIVATE KEY"),
contents: der,
};
let key_pem = encode(&pem);
Ok((parameters_pem + &key_pem)
.replace('\r', "")
.replace("\n\n", "\n"))
Ok(key_pem.replace('\r', "").replace("\n\n", "\n"))
}

0 comments on commit a525012

Please sign in to comment.