Skip to content

Commit 0c52f93

Browse files
put ssh-* behind a feature flag, for non(wasm32) only
1 parent bab8302 commit 0c52f93

File tree

7 files changed

+24
-7
lines changed

7 files changed

+24
-7
lines changed

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "Apache-2.0"
1010

1111
[features]
1212
default = ["serde"]
13+
ssh = ["ssh-key", "ssh-encoding"]
1314

1415
[dependencies]
1516
blsful = { version = "2.5", git = "https://github.com/mikelodder7/blsful.git" }
@@ -18,12 +19,17 @@ multibase = { version = "1.0", git = "https://github.com/cryptidtech/rust-multib
1819
multicodec = { version = "1.0", git = "https://github.com/cryptidtech/rust-multicodec.git" }
1920
multitrait = { version = "1.0", git = "https://github.com/cryptidtech/multitrait.git" }
2021
multiutil = { version = "1.0", git = "https://github.com/cryptidtech/multiutil.git" }
21-
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"], optional = true }
22-
ssh-key = { version = "0.6", features = ["crypto"] }
23-
ssh-encoding = "0.2"
22+
serde = { version = "1.0", default-features = false, features = [
23+
"alloc",
24+
"derive",
25+
], optional = true }
2426
thiserror = "1.0"
2527
unsigned-varint = { version = "0.8", features = ["std"] }
2628

29+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
30+
ssh-key = { version = "0.6", features = ["crypto"], optional = true }
31+
ssh-encoding = { version = "0.2", optional = true }
32+
2733
[dev-dependencies]
2834
hex = "0.4"
2935
serde_test = "1.0"

src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ pub enum SharesError {
126126
#[non_exhaustive]
127127
pub enum ConversionsError {
128128
/// Ssh signature conversion error
129+
#[cfg(feature = "ssh")]
129130
#[error(transparent)]
130131
SshSig(#[from] ssh_key::Error),
131132
/// Ssh label error
133+
#[cfg(feature = "ssh")]
132134
#[error(transparent)]
133135
SshSigLabel(#[from] ssh_encoding::LabelError),
134136
}

src/ms.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ pub const SIG_CODECS: [Codec; 4] = [
2323
// Codec::Es384Msig,
2424
// Codec::Es521Msig,
2525
// Codec::Rs256Msig,
26-
Codec::Es256KMsig//,
27-
//Codec::LamportMsig,
26+
Codec::Es256KMsig, //,
27+
//Codec::LamportMsig,
2828
];
2929

3030
/// the list of signature share codecs supported
3131
pub const SIG_SHARE_CODECS: [Codec; 2] = [
3232
Codec::Bls12381G1ShareMsig,
33-
Codec::Bls12381G2ShareMsig//,
34-
//Codec::LamportShareMsig,
33+
Codec::Bls12381G2ShareMsig, //,
34+
//Codec::LamportShareMsig,
3535
];
3636

3737
/// the multisig sigil
@@ -254,6 +254,7 @@ impl Builder {
254254
}
255255

256256
/// create new multisig from ssh Signature
257+
#[cfg(feature = "ssh")]
257258
pub fn new_from_ssh_signature(sig: &ssh_key::Signature) -> Result<Self, Error> {
258259
let mut attributes = BTreeMap::new();
259260
use ssh_key::Algorithm::*;
@@ -602,6 +603,7 @@ mod tests {
602603
assert_eq!(ms1, ms3);
603604
}
604605

606+
#[cfg(feature = "ssh")]
605607
#[test]
606608
fn test_eddsa_ssh_roundtrip() {
607609
let ms1 = Builder::new(Codec::EddsaMsig)
@@ -617,6 +619,7 @@ mod tests {
617619
assert_eq!(ms1, ms2);
618620
}
619621

622+
#[cfg(feature = "ssh")]
620623
#[test]
621624
fn test_es256k_ssh_roundtrip() {
622625
let ms1 = Builder::new(Codec::Es256KMsig)
@@ -632,6 +635,7 @@ mod tests {
632635
assert_eq!(ms1, ms2);
633636
}
634637

638+
#[cfg(feature = "ssh")]
635639
#[test]
636640
fn test_bls_signature_ssh_roundtrip() {
637641
let sk = blsful::Bls12381G1::new_secret_key();
@@ -658,6 +662,7 @@ mod tests {
658662
assert_eq!(ms1, ms2);
659663
}
660664

665+
#[cfg(feature = "ssh")]
661666
#[test]
662667
fn test_bls_signature_combine_ssh_roundtrip() {
663668
let sk = blsful::Bls12381G2::new_secret_key();

src/views.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub trait DataView {
3131
/// trait for converting Multisigs to other formats
3232
pub trait ConvView {
3333
/// convert the Multisig to an SSH signature
34+
#[cfg(feature = "ssh")]
3435
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error>;
3536
}
3637

src/views/bls12381.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ impl<'a> DataView for View<'a> {
369369

370370
impl<'a> ConvView for View<'a> {
371371
/// convert to SSH signature format
372+
#[cfg(feature = "ssh")]
372373
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
373374
// get the signature data
374375
let dv = self.ms.data_view()?;

src/views/ed25519.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<'a> DataView for View<'a> {
5050

5151
impl<'a> ConvView for View<'a> {
5252
/// convert to SSH signature format
53+
#[cfg(feature = "ssh")]
5354
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
5455
// get the signature data
5556
let dv = self.ms.data_view()?;

src/views/secp256k1.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl<'a> DataView for View<'a> {
5353

5454
impl<'a> ConvView for View<'a> {
5555
/// convert to SSH signature format
56+
#[cfg(feature = "ssh")]
5657
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error> {
5758
// get the signature data
5859
let dv = self.ms.data_view()?;

0 commit comments

Comments
 (0)