Skip to content

Commit

Permalink
add convenience key share codec list
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Huseby <dwh@linuxprogrammer.org>
  • Loading branch information
dhuseby committed Apr 12, 2024
1 parent e9faee6 commit c4b0a5e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub use views::{

/// Multikey type and functions
pub mod mk;
pub use mk::{KEY_GEN_CODECS, Builder, EncodedMultikey, Multikey};
pub use mk::{KEY_CODECS, KEY_SHARE_CODECS, Builder, EncodedMultikey, Multikey};

/// Nonce type
pub mod nonce;
Expand Down
25 changes: 16 additions & 9 deletions src/mk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{collections::BTreeMap, fmt};
use zeroize::Zeroizing;

/// the list of key codecs supported for key generation
pub const KEY_GEN_CODECS: [Codec; 4] = [
pub const KEY_CODECS: [Codec; 4] = [
Codec::Ed25519Priv,
/*
Codec::P256Priv,
Expand All @@ -31,6 +31,13 @@ pub const KEY_GEN_CODECS: [Codec; 4] = [
Codec::Bls12381G1Priv,
Codec::Bls12381G2Priv];

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

/// the multicodec sigil for multikey
pub const SIGIL: Codec = Codec::Multikey;

Expand Down Expand Up @@ -881,7 +888,7 @@ mod tests {

#[test]
fn test_random() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand All @@ -894,7 +901,7 @@ mod tests {

#[test]
fn test_encoded_random() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand All @@ -910,7 +917,7 @@ mod tests {

#[test]
fn test_random_public_ssh_key_roundtrip() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand All @@ -930,7 +937,7 @@ mod tests {

#[test]
fn test_random_private_ssh_key_roundtrip() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand All @@ -949,7 +956,7 @@ mod tests {

#[test]
fn test_ssh_key_roundtrip() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let sk1 = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand Down Expand Up @@ -979,7 +986,7 @@ mod tests {

#[test]
fn test_encryption_roundtrip() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk1 = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand Down Expand Up @@ -1068,7 +1075,7 @@ mod tests {

#[test]
fn test_signing_detached_roundtrip() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand Down Expand Up @@ -1105,7 +1112,7 @@ mod tests {

#[test]
fn test_signing_merged_roundtrip() {
for codec in KEY_GEN_CODECS {
for codec in KEY_CODECS {
let mut rng = rand::rngs::OsRng::default();
let mk = Builder::new_from_random_bytes(codec, &mut rng)
.unwrap()
Expand Down

0 comments on commit c4b0a5e

Please sign in to comment.