Skip to content

Commit

Permalink
sgxencrypt: use alpha key, switch to hex encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
ozwaldorf committed Sep 5, 2024
1 parent bf051a2 commit 043f906
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12843,8 +12843,8 @@ version = "0.0.1"
dependencies = [
"anyhow",
"bpaf",
"bs58 0.5.1",
"ecies",
"hex",
]

[[package]]
Expand Down
4 changes: 2 additions & 2 deletions lib/sgxencrypt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "sgxencrypt"
description = "Cli tool for encrypting content for fleek network sgx enclaves"
version = "0.0.1"
version = "0.0.2"
edition = "2021"
authors = ["ozwaldorf <[email protected]>"]
license = "MIT"

[dependencies]
anyhow.workspace = true
bpaf = { version = "0.9.12", features = ["derive", "dull-color"] } # cli parsing
bs58 = "0.5.1" # encoding/decoding public keys
hex = "0.4.3" # encoding/decoding public keys
ecies = { version = "0.2.7", default-features = false, features = ["pure", "std"] } # encrypting content for the sgx enclave

[[bin]]
Expand Down
15 changes: 5 additions & 10 deletions lib/sgxencrypt/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@ enum Output {
#[derive(Debug, Bpaf)]
#[bpaf(options, version, descr(env!("CARGO_PKG_DESCRIPTION")))]
struct Args {
/// Base58 shared network public key. Should be in compressed format.
/// Hex-encoded network sealing public key. Should be in compressed format.
#[bpaf(
short,
long,
argument::<String>("PUBKEY"),
fallback("27fjvoWaGcupCpT9ZMfok4gAHGcUhuFt1wgpoVjb4Bhka".into()),
fallback("03e1d7803dfa7e5d3ca4b4afa99073caf57b9afcede3b416ad29bb9ce9e4fe0f86".into()),
display_fallback,
parse(|s| {
let bytes = bs58::decode(&s)
.into_vec()
.context("invalid base58")?;
let slice = bytes.as_slice()
.try_into()
.context("invalid key length")?;
PublicKey::parse_compressed(&slice)
.map_err(|e| anyhow!("invalid public key: {e}"))
let bytes = hex::decode(&s).context("invalid base58")?;
let slice = bytes.try_into().map_err(|_| anyhow!("invalid key length"))?;
PublicKey::parse_compressed(&slice).map_err(|e| anyhow!("invalid public key: {e}"))
})
)]
pubkey: PublicKey,
Expand Down

0 comments on commit 043f906

Please sign in to comment.