From e8d6c189525299c8da95bc9a52796cd920010997 Mon Sep 17 00:00:00 2001 From: Dave Huseby Date: Sun, 7 Apr 2024 16:44:08 -0600 Subject: [PATCH] fix README, add license tags, fix CI action Signed-off-by: Dave Huseby --- .github/workflows/rust.yml | 2 +- README.md | 35 ++++++++++++++++++----------------- src/attrid.rs | 1 + src/cipher.rs | 1 + src/error.rs | 1 + src/kdf.rs | 1 + src/lib.rs | 1 + src/mk.rs | 7 ++++--- src/nonce.rs | 1 + src/serde/de.rs | 1 + src/serde/mod.rs | 1 + src/serde/ser.rs | 1 + src/views.rs | 1 + src/views/bcrypt.rs | 1 + src/views/bls12381.rs | 1 + src/views/chacha20.rs | 1 + src/views/ed25519.rs | 1 + src/views/secp256k1.rs | 1 + 18 files changed, 38 insertions(+), 21 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 31000a2..9fd45e0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build run: cargo build --verbose - name: Run tests diff --git a/README.md b/README.md index 4143e87..dc855e7 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ -# Multikey +[![](https://img.shields.io/badge/made%20by-Cryptid%20Technologies-gold.svg?style=flat-square)][CRYPTID] +[![](https://img.shields.io/badge/project-provenance-purple.svg?style=flat-square)][PROVENANCE] +[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)][MULTIFORMATS] +![](https://github.com/cryptidtech/multikey/actions/workflows/rust.yml/badge.svg) -[![](https://img.shields.io/badge/made%20by-Cryptid%20Technologies-gold.svg?style=flat-square)][0] -[![](https://img.shields.io/badge/project-provenance-purple.svg?style=flat-square)][1] -[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)][2] +# Multikey -A Rust implementation of the [multiformats][2] [multikey specification][3] and -[nonce specification][4]. +A Rust implementation of the [multiformats][MULTIFORMATS] [multikey specification][MULTIKEY] and +[nonce specification][NONCE]. ## Current Status @@ -21,10 +22,10 @@ When using BLS12-381 keys, this implementations supports threshold key splitting and combining as well as threshold signing and verifying. This crate also supports converting to/from SSH format keys using the -[`ssh-key`][5] crate. This gives full OpenSSH compatibility for reading in +[`ssh-key`][SSHKEY] crate. This gives full OpenSSH compatibility for reading in OpenSSH serialized keys and converting them to Multikey format. This even includes non-standard SSH key protocols such as secp256k1 and BLS12-381 G1/G2 -keys through the use of [RFC 4251][6] standard for "additional algorithms" +keys through the use of [RFC 4251][RFC4251] standard for "additional algorithms" names using the "@multikey" domain suffix. For instance, using this crate, an secp256k1 Multikey converted to an SSH format key has the algorithm name "secp256k1@multikey". A BLS12-381 G1 key share converted to SSH format has the @@ -70,17 +71,17 @@ hashing codec, a KDF view (`multikey::KdfView`) for generating cipher keys for use by a cipher view to encrypt/decrypt the Multikey, a threshold view (`multikey::ThresholdView`) for key splitting and combining keys, and lastly a sign view (`multikey::SignView`) and verify view (`multikey::VerifyView`) for -creating and verifying [`Multisig`][7] digital signatures. +creating and verifying [`Multisig`][MULTISIG] digital signatures. It is important to note that the operations that seem to mutate the Multikey (e.g. encrypt, decrypt, convert, etc) in fact do a copy-on-write (CoW) operation and return a new Multikey with the mutation applied. -[0]: https://cryptid.tech -[1]: https://github.com/cryptidtech/provenance-specifications/ -[2]: https://github.com/multiformats/multiformats -[3]: https://github.com/cryptidtech/provenance-specifications/blob/main/specifications/multikey.md -[4]: https://github.com/cryptidtech/provenance-specifications/blob/main/specifications/nonce.md -[5]: https://crates.io/crates/ssh-key -[6]: https://www.rfc-editor.org/rfc/rfc4251.html#page-11 -[7]: https://github.com/cryptidtech/multisig +[CRYPTID]: https://cryptid.tech +[PROVENANCE]: https://github.com/cryptidtech/provenance-specifications/ +[MULTIFORMATS]: https://github.com/multiformats/multiformats +[MULTIKEY]: https://github.com/cryptidtech/provenance-specifications/blob/main/specifications/multikey.md +[NONCE]: https://github.com/cryptidtech/provenance-specifications/blob/main/specifications/nonce.md +[SSHKEY]: https://crates.io/crates/ssh-key +[RFC4251]: https://www.rfc-editor.org/rfc/rfc4251.html#page-11 +[MULTISIG]: https://github.com/cryptidtech/multisig diff --git a/src/attrid.rs b/src/attrid.rs index 59b10c3..f0c1dac 100644 --- a/src/attrid.rs +++ b/src/attrid.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{error::AttributesError, Error}; use multitrait::{EncodeInto, TryDecodeFrom}; use std::fmt; diff --git a/src/cipher.rs b/src/cipher.rs index 650436d..630f1e2 100644 --- a/src/cipher.rs +++ b/src/cipher.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{mk::Attributes, AttrId, Error, Multikey}; use multicodec::Codec; use rand::{CryptoRng, RngCore}; diff --git a/src/error.rs b/src/error.rs index 4418821..b38eeff 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 /// Errors created by this library #[derive(Clone, Debug, thiserror::Error)] #[non_exhaustive] diff --git a/src/kdf.rs b/src/kdf.rs index a61a4d5..6346fa0 100644 --- a/src/kdf.rs +++ b/src/kdf.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{mk::Attributes, AttrId, Error, Multikey}; use multicodec::Codec; use multiutil::Varuint; diff --git a/src/lib.rs b/src/lib.rs index 9f79c69..862543b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 //! #![warn(missing_docs)] #![deny( diff --git a/src/mk.rs b/src/mk.rs index bdb7a56..cbda9b0 100644 --- a/src/mk.rs +++ b/src/mk.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ error::{AttributesError, CipherError, ConversionsError, KdfError}, views::{bcrypt, bls12381, chacha20, ed25519, secp256k1}, @@ -1156,15 +1157,15 @@ mod tests { let pk = EncodedMultikey::new(Base::Base16Lower, conv.to_public_key().unwrap()); println!("ed25519 pubkey: {}", pk.to_string()); - let msg = b"for great justice, move every zig!".to_vec(); + let msg = "for great justice, move every zig!"; let signmk = mk.sign_view().unwrap(); - let signature = signmk.sign(msg.as_slice(), false, None).unwrap(); + let signature = signmk.sign(msg.as_bytes(), false, None).unwrap(); let sig = EncodedMultisig::new(Base::Base16Lower, signature.clone()); println!("signaure: {}", sig.to_string()); let verifymk = mk.verify_view().unwrap(); - assert!(verifymk.verify(&signature, Some(&msg)).is_ok()); + assert!(verifymk.verify(&signature, Some(msg.as_bytes())).is_ok()); } #[test] diff --git a/src/nonce.rs b/src/nonce.rs index d1962ad..07ed1f4 100644 --- a/src/nonce.rs +++ b/src/nonce.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{error::NonceError, Error}; use core::fmt; use multibase::Base; diff --git a/src/serde/de.rs b/src/serde/de.rs index 287d6bf..1d2a8ad 100644 --- a/src/serde/de.rs +++ b/src/serde/de.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ mk::{self, Attributes}, nonce, AttrId, Multikey, Nonce, diff --git a/src/serde/mod.rs b/src/serde/mod.rs index f625359..184702c 100644 --- a/src/serde/mod.rs +++ b/src/serde/mod.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 //! Serde (de)serialization for [`crate::Multikey`]. mod de; mod ser; diff --git a/src/serde/ser.rs b/src/serde/ser.rs index e111517..4bdf4c1 100644 --- a/src/serde/ser.rs +++ b/src/serde/ser.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{mk, nonce, AttrId, Multikey, Nonce}; use multiutil::{EncodedVarbytes, EncodingInfo, Varbytes}; use serde::ser::{self, SerializeStruct}; diff --git a/src/views.rs b/src/views.rs index 8b9ddcc..b533500 100644 --- a/src/views.rs +++ b/src/views.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{Error, Multikey}; use multicodec::Codec; use multihash::Multihash; diff --git a/src/views/bcrypt.rs b/src/views/bcrypt.rs index 867b8f3..82f648e 100644 --- a/src/views/bcrypt.rs +++ b/src/views/bcrypt.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{error::KdfError, AttrId, Error, KdfAttrView, KdfView, Multikey, Views}; use multicodec::Codec; use multiutil::Varuint; diff --git a/src/views/bls12381.rs b/src/views/bls12381.rs index b93d273..6ee914c 100644 --- a/src/views/bls12381.rs +++ b/src/views/bls12381.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ error::{ AttributesError, CipherError, ConversionsError, KdfError, SignError, ThresholdError, diff --git a/src/views/chacha20.rs b/src/views/chacha20.rs index 1c0e033..2620279 100644 --- a/src/views/chacha20.rs +++ b/src/views/chacha20.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ error::{AttributesError, CipherError, KdfError}, AttrId, AttrView, CipherAttrView, CipherView, DataView, Error, FingerprintView, KdfAttrView, diff --git a/src/views/ed25519.rs b/src/views/ed25519.rs index 1b80bfc..0455c45 100644 --- a/src/views/ed25519.rs +++ b/src/views/ed25519.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ error::{AttributesError, CipherError, ConversionsError, KdfError, SignError, VerifyError}, AttrId, AttrView, Builder, CipherAttrView, ConvView, DataView, Error, FingerprintView, diff --git a/src/views/secp256k1.rs b/src/views/secp256k1.rs index 7354785..ce2fb52 100644 --- a/src/views/secp256k1.rs +++ b/src/views/secp256k1.rs @@ -1,3 +1,4 @@ +// SPDX-License-Idnetifier: Apache-2.0 use crate::{ error::{AttributesError, CipherError, ConversionsError, KdfError, SignError, VerifyError}, AttrId, AttrView, Builder, CipherAttrView, ConvView, DataView, Error, FingerprintView,