Skip to content

Commit

Permalink
add convenience codec list
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Huseby <[email protected]>
  • Loading branch information
dhuseby committed Apr 12, 2024
1 parent b96ae33 commit f9bbc01
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 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 = "multisig"
version = "0.3.3"
version = "0.3.4"
edition = "2021"
authors = ["Dave Grantham <[email protected]>"]
description = "Multisig self-describing multicodec implementation for digital signatures"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub use attrid::AttrId;

/// Multisig implementation
pub mod ms;
pub use ms::{Builder, EncodedMultisig, Multisig};
pub use ms::{SIG_CODECS, SIG_SHARE_CODECS, Builder, EncodedMultisig, Multisig};

/// Views on the multisig
pub mod views;
Expand Down
26 changes: 20 additions & 6 deletions src/ms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ use multitrait::{Null, TryDecodeFrom};
use multiutil::{BaseEncoded, CodecInfo, EncodingInfo, Varbytes, Varuint};
use std::{collections::BTreeMap, fmt};

/// the list of signature codecs currently supported
pub const SIG_CODECS: [Codec; 4] = [
Codec::Bls12381G1Sig,
Codec::Bls12381G2Sig,
Codec::Eddsa,
Codec::Es256K];

/// the list of signature share codecs supported
pub const SIG_SHARE_CODECS: [Codec; 2] = [
Codec::Bls12381G1SigShare,
Codec::Bls12381G2SigShare];

/// the multisig sigil
pub const SIGIL: Codec = Codec::Multisig;

Expand Down Expand Up @@ -472,12 +484,14 @@ mod tests {

#[test]
fn test_encoded() {
let ms = Builder::new(Codec::Eddsa)
.with_signature_bytes(&[0u8; 64])
.try_build_encoded()
.unwrap();
let s = ms.to_string();
assert_eq!(ms, EncodedMultisig::try_from(s.as_str()).unwrap());
for codec in SIG_CODECS {
let ms = Builder::new(codec)
.with_signature_bytes(&[0u8; 64])
.try_build_encoded()
.unwrap();
let s = ms.to_string();
assert_eq!(ms, EncodedMultisig::try_from(s.as_str()).unwrap());
}
}

#[test]
Expand Down

0 comments on commit f9bbc01

Please sign in to comment.