Skip to content

Commit

Permalink
fix README, add license tags, fix CI action
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 7, 2024
1 parent cb80c0f commit e8d6c18
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions src/attrid.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{error::AttributesError, Error};
use multitrait::{EncodeInto, TryDecodeFrom};
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions src/cipher.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{mk::Attributes, AttrId, Error, Multikey};
use multicodec::Codec;
use rand::{CryptoRng, RngCore};
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
/// Errors created by this library
#[derive(Clone, Debug, thiserror::Error)]
#[non_exhaustive]
Expand Down
1 change: 1 addition & 0 deletions src/kdf.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{mk::Attributes, AttrId, Error, Multikey};
use multicodec::Codec;
use multiutil::Varuint;
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
//!
#![warn(missing_docs)]
#![deny(
Expand Down
7 changes: 4 additions & 3 deletions src/mk.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{
error::{AttributesError, CipherError, ConversionsError, KdfError},
views::{bcrypt, bls12381, chacha20, ed25519, secp256k1},
Expand Down Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions src/nonce.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{error::NonceError, Error};
use core::fmt;
use multibase::Base;
Expand Down
1 change: 1 addition & 0 deletions src/serde/de.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{
mk::{self, Attributes},
nonce, AttrId, Multikey, Nonce,
Expand Down
1 change: 1 addition & 0 deletions src/serde/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
//! Serde (de)serialization for [`crate::Multikey`].
mod de;
mod ser;
Expand Down
1 change: 1 addition & 0 deletions src/serde/ser.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
1 change: 1 addition & 0 deletions src/views.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{Error, Multikey};
use multicodec::Codec;
use multihash::Multihash;
Expand Down
1 change: 1 addition & 0 deletions src/views/bcrypt.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/views/bls12381.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{
error::{
AttributesError, CipherError, ConversionsError, KdfError, SignError, ThresholdError,
Expand Down
1 change: 1 addition & 0 deletions src/views/chacha20.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Idnetifier: Apache-2.0
use crate::{
error::{AttributesError, CipherError, KdfError},
AttrId, AttrView, CipherAttrView, CipherView, DataView, Error, FingerprintView, KdfAttrView,
Expand Down
1 change: 1 addition & 0 deletions src/views/ed25519.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/views/secp256k1.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit e8d6c18

Please sign in to comment.