diff --git a/README.md b/README.md index 85d3c6d..471906b 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,6 @@ -# Tari Crypto +# Tari Crypto WASM Wrapper -![](https://github.com/tari-project/tari-crypto/workflows/Security%20audit/badge.svg) -![](https://github.com/tari-project/tari-crypto/workflows/Clippy/badge.svg) -[![Coverage Status](https://coveralls.io/repos/github/tari-project/tari-crypto/badge.svg?branch=main)](https://coveralls.io/github/tari-project/tari-crypto?branch=main) - -This crate is part of the [Tari Cryptocurrency](https://tari.com) project. - -Major features of this library include: - -- Pedersen commitments -- Schnorr Signatures -- Generic Public and Secret Keys -- [Musig!](https://blockstream.com/2018/01/23/musig-key-aggregation-schnorr-signatures/) **NOT PRODUCTION READY** - -The `tari_crypto` crate makes heavy use of the excellent [Dalek](https://github.com/dalek-cryptography/curve25519-dalek) -libraries. The default implementation for Tari ECC is the [Ristretto255 curve](https://ristretto.group). +This is a WASM library wrapper for (Tari Crypto)[https://github.com/tari-project/tari-crypto] # Compiling to WebAssembly diff --git a/src/commitments.rs b/src/commitments.rs index c4f1b54..faadb08 100644 --- a/src/commitments.rs +++ b/src/commitments.rs @@ -4,9 +4,6 @@ //! Functions for creating and opening commitments use serde::{Deserialize, Serialize}; -use tari_utilities::hex::Hex; -use wasm_bindgen::prelude::*; - use tari_crypto::{ commitment::HomomorphicCommitmentFactory, ristretto::{ @@ -15,6 +12,8 @@ use tari_crypto::{ RistrettoSecretKey, }, }; +use tari_utilities::hex::Hex; +use wasm_bindgen::prelude::*; /// Returned from [commit()] #[derive(Default, Serialize, Deserialize)] @@ -84,10 +83,10 @@ pub fn opens(key: &str, value: u64, commitment: &str) -> bool { #[cfg(test)] mod test { use rand::rngs::OsRng; + use tari_crypto::keys::SecretKey; use wasm_bindgen_test::*; use super::*; - use tari_crypto::keys::SecretKey; mod commit { use super::*; diff --git a/src/key_utils.rs b/src/key_utils.rs index f453023..7f23241 100644 --- a/src/key_utils.rs +++ b/src/key_utils.rs @@ -12,9 +12,6 @@ use blake2::{Blake2b, Digest}; use digest::consts::U32; use rand_core::OsRng; use serde::{Deserialize, Serialize}; -use tari_utilities::hex::{from_hex, Hex}; -use wasm_bindgen::prelude::*; - use tari_crypto::{ keys::{PublicKey, SecretKey}, ristretto::{ @@ -26,6 +23,8 @@ use tari_crypto::{ RistrettoSecretKey, }, }; +use tari_utilities::hex::{from_hex, Hex}; +use wasm_bindgen::prelude::*; /// Result of calling [check_signature] and [check_comsig_signature] and [check_comandpubsig_signature] #[derive(Debug, Serialize, Deserialize, Default)] @@ -717,14 +716,14 @@ pub fn multiply_secret_keys(private_key_a: &str, private_key_b: &str) -> JsValue #[cfg(test)] mod test { use blake2::digest::Output; - use wasm_bindgen_test::*; - - use super::*; use tari_crypto::{ commitment::HomomorphicCommitmentFactory, signatures::{CommitmentAndPublicKeySignature, CommitmentSignature, SchnorrSignature}, tari_utilities::{hex, ByteArray}, }; + use wasm_bindgen_test::*; + + use super::*; const SAMPLE_CHALLENGE: &str = "Cormac was completely aware that he was being manipulated, but how he could not see."; diff --git a/src/keyring.rs b/src/keyring.rs index 7c8d712..489a224 100644 --- a/src/keyring.rs +++ b/src/keyring.rs @@ -1,10 +1,9 @@ // Copyright 2020. The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use rand_core::OsRng; -use tari_utilities::hex::Hex; -use wasm_bindgen::prelude::*; use std::collections::HashMap; + +use rand_core::OsRng; use tari_crypto::{ commitment::HomomorphicCommitmentFactory, keys::PublicKey, @@ -13,8 +12,10 @@ use tari_crypto::{ RistrettoPublicKey, RistrettoSecretKey, }, - }; +use tari_utilities::hex::Hex; +use wasm_bindgen::prelude::*; + use crate::{ commitments::CommitmentResult, key_utils::{sign_message_with_key, SignResult}, @@ -147,10 +148,10 @@ impl KeyRing { #[cfg(test)] mod test { + use tari_crypto::{keys::SecretKey, ristretto::RistrettoSchnorr}; use wasm_bindgen_test::*; use super::*; - use tari_crypto::{keys::SecretKey, ristretto::RistrettoSchnorr}; const SAMPLE_CHALLENGE: &str = "გამარჯობა"; diff --git a/src/lib.rs b/src/lib.rs index b291469..1da172a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,15 +1,12 @@ // Copyright 2022 The Tari Project // SPDX-License-Identifier: BSD-3-Clause - - +//! Tari-Crypto-Wasm #[macro_use] extern crate std; - mod keyring; pub mod commitments; pub mod key_utils; pub mod range_proofs; pub use keyring::KeyRing; - diff --git a/src/range_proofs.rs b/src/range_proofs.rs index fd2353b..8fe895c 100644 --- a/src/range_proofs.rs +++ b/src/range_proofs.rs @@ -6,9 +6,6 @@ use std::string::{String, ToString}; use serde::{Deserialize, Serialize}; -use tari_utilities::hex::Hex; -use wasm_bindgen::prelude::*; - use tari_crypto::{ extended_range_proof::ExtendedRangeProofService, range_proof::RangeProofService, @@ -19,6 +16,8 @@ use tari_crypto::{ }, tari_utilities::hex::from_hex, }; +use tari_utilities::hex::Hex; +use wasm_bindgen::prelude::*; /// Generated from [RangeProofFactory::create_proof] #[derive(Default, Serialize, Deserialize)] @@ -186,10 +185,10 @@ impl Default for ExtendedRangeProofFactory { #[cfg(test)] mod test { use rand::rngs::OsRng; + use tari_crypto::{commitment::HomomorphicCommitmentFactory, keys::PublicKey, ristretto::RistrettoPublicKey}; use wasm_bindgen_test::*; use super::*; - use tari_crypto::{commitment::HomomorphicCommitmentFactory, keys::PublicKey, ristretto::RistrettoPublicKey}; #[wasm_bindgen_test] fn bulletproof_plus_fails_with_invalid_hex_input() {