better WASM support

This commit is contained in:
satvrn 2023-08-02 14:11:26 +00:00 committed by GitHub
parent 2b559b79f9
commit 84b358c934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View file

@ -1,14 +1,17 @@
[package]
name = "double-ratchet-rs"
version = "0.4.6"
authors = ["satvrn", "Hannes Furmans"]
edition = "2021"
rust-version = "1.60"
description = "A pure Rust implementation of the Double Ratchet algorithm as described by Signal."
documentation = "https://docs.rs/double-ratchet-rs"
readme = "README.md"
homepage = "https://github.com/notsatvrn/double-ratchet-rs"
repository = "https://github.com/notsatvrn/double-ratchet-rs"
readme = "README.md"
keywords = ["double-ratchet", "crypto", "cryptography", "signal"]
version = "0.4.6"
edition = "2021"
license = "MIT"
keywords = ["double-ratchet", "signal"]
categories = ["algorithms", "cryptography", "no-std"]
[dependencies]
x25519-dalek = {version = "2.0.0-rc.3", default-features = false, features = ["serde", "static_secrets", "zeroize"]}
@ -22,9 +25,16 @@ postcard = {version = "1.0", default-features = false, features = ["alloc"]}
hashbrown = {version = "0.14", features = ["serde"], optional = true}
zeroize = {version = "1.6", default-features = false, features = ["zeroize_derive"]}
[dev-dependencies]
[target.'cfg(all(target_family = "wasm", target_vendor = "unknown"))'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
criterion = "0.4"
[target.'cfg(target_family = "wasm")'.dev-dependencies]
criterion = { version = "0.4", default-features = false, features = ["plotters", "cargo_bench_support"] }
wasm-bindgen-test = "0.2"
[[bench]]
name = "double_ratchet_bench"
harness = false

View file

@ -29,7 +29,7 @@ fn criterion_benchmark_2(c: &mut Criterion) {
c.bench_function("Ratchet Enc Skip", |b| b.iter(|| ratchet_enc_skip()));
}
fn ratchet_encryt_decrypt_four() {
fn ratchet_encrypt_decrypt_four() {
let sk = [1; 32];
let data = include_bytes!("../src/dh.rs").to_vec();
let (mut bob_ratchet, public_key) = Ratchet::init_bob(sk);
@ -42,7 +42,7 @@ fn ratchet_encryt_decrypt_four() {
fn criterion_benchmark_3(c: &mut Criterion) {
c.bench_function("Ratchet Dec Four", |b| {
b.iter(|| ratchet_encryt_decrypt_four())
b.iter(|| ratchet_encrypt_decrypt_four())
});
}

View file

@ -1,6 +1,11 @@
use double_ratchet_rs::{Ratchet, RatchetEncHeader};
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std as alloc;
#[test]
fn init() {
let sk = [1; 32];