Skip to content

Commit

Permalink
fix codec values in SigViews
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Huseby <dwh@linuxprogrammer.org>
  • Loading branch information
dhuseby committed May 10, 2024
1 parent 9f23686 commit 45ac1e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "multikey"
version = "1.0.2"
version = "1.0.3"
edition = "2021"
authors = ["Dave Grantham <dwg@linuxprogrammer.org>"]
description = "Multikey self-describing cryptographic key data"
Expand Down
18 changes: 14 additions & 4 deletions src/mk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,30 @@ use zeroize::Zeroizing;
pub const KEY_CODECS: [Codec; 4] = [
Codec::Ed25519Priv,
/*
Codec::LamportSha3256Priv,
Codec::LamportSha3384Priv,
Codec::LamportSha3512Priv,
Codec::P256Priv,
Codec::P384Priv,
Codec::P521Priv,
*/
Codec::Secp256K1Priv,
Codec::Bls12381G1Priv,
Codec::Bls12381G2Priv];
Codec::Bls12381G2Priv
];

/// the list of key share codecs supported
pub const KEY_SHARE_CODECS: [Codec; 4] = [
Codec::Bls12381G1PubShare,
Codec::Bls12381G1PrivShare,
Codec::Bls12381G2PubShare,
Codec::Bls12381G2PrivShare];
Codec::Bls12381G2PrivShare
/*
Codec::LamportSha3256PrivShare,
Codec::LamportSha3384PrivShare,
Codec::LamportSha3512PrivShare,
*/
];

/// the multicodec sigil for multikey
pub const SIGIL: Codec = Codec::Multikey;
Expand Down Expand Up @@ -905,12 +915,12 @@ mod tests {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
.with_base_encoding(Base::Base58Btc)
.with_base_encoding(Base::Base32Lower)
.with_comment("test key")
.try_build_encoded()
.unwrap();
let s = mk.to_string();
println!("ed25519: {}", s);
println!("{}: {}", codec, s);
assert_eq!(mk, EncodedMultikey::try_from(s.as_str()).unwrap());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<'a> SignView for View<'a> {
.try_sign(msg)
.map_err(|e| SignError::SigningFailed(e.to_string()))?;

let mut ms = ms::Builder::new(Codec::Eddsa).with_signature_bytes(&signature.to_bytes());
let mut ms = ms::Builder::new(Codec::EddsaMsig).with_signature_bytes(&signature.to_bytes());
if combined {
ms = ms.with_message_bytes(&msg);
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a> SignView for View<'a> {
.try_sign(msg)
.map_err(|e| SignError::SigningFailed(e.to_string()))?;

let mut ms = ms::Builder::new(Codec::Es256K).with_signature_bytes(&signature.to_bytes());
let mut ms = ms::Builder::new(Codec::Es256KMsig).with_signature_bytes(&signature.to_bytes());
if combined {
ms = ms.with_message_bytes(&msg);
}
Expand Down

0 comments on commit 45ac1e8

Please sign in to comment.