Skip to content

Commit

Permalink
bump bls12_381_plus to 0.8.16 and blastkids to v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DougAnderson444 committed Jul 1, 2024
1 parent a01e7cc commit 0ab6835
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 36 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
members = [".", "crates/*"]
resolver = "2"

[workspace.package]
version = "0.1.0"
authors = ["Doug Anderson"]
description = "Delanocreds, Delegatable Anonymous Credentials in pure Rust"
repository = "https://github.com/DougAnderson444/delanocreds"

[workspace.dependencies]
delanocreds = { path = "crates/delanocreds" }
delano-keys = { path = "crates/delano-keys" }
delano-wit-ui = { path = "crates/delano-wit-ui" }
delano-events = { path = "crates/delano-events" }
bls12_381_plus = { version = "0.8.13", git="https://github.com/mikelodder7/bls12_381_plus.git", rev = "91a399e9a5f326816f13a0feab898ff40a7a1599", features = ["expose-fields", "alloc"] }
bls12_381_plus = { version = "0.8.16", features = ["expose-fields", "alloc"] }

secrecy = "0.8"

Expand Down
9 changes: 3 additions & 6 deletions crates/delano-events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,9 @@ pub struct SubscribeTopic {
pub key: String,
}

/// From<impl ToString> for SubscribeTopic
impl<T> From<T> for SubscribeTopic
where
T: ToString,
{
fn from(key: T) -> Self {
impl SubscribeTopic {
/// Creates a new SubscribeTopic from a string
pub fn new(key: impl ToString) -> Self {
Self {
key: key.to_string(),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/delano-keys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"
crate-type = ["cdylib", "lib"]

[dependencies]
blastkids = { git = "https://github.com/DougAnderson444/blastkids.git", version ="0.1.6" }
bls12_381_plus = { version = "0.8.13", git= "https://github.com/mikelodder7/bls12_381_plus.git", rev = "91a399e9a5f326816f13a0feab898ff40a7a1599", features = ["expose-fields", "alloc"] }
blastkids = { version ="0.2.0" }
bls12_381_plus = { workspace = true, features = ["expose-fields", "alloc"] }
cid = { version = "0.10.1", optional = true }
secrecy = "0.8.0"
serde = { version = "1.0.130", features = ["derive"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/delano-wit-ui/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl State {

/// Helper function that subscribes to a key
fn subscribe_to_topic(key: impl ToString) {
let message_data = Context::Event(Events::Subscribe(SubscribeTopic::from(key)));
let message_data = Context::Event(Events::Subscribe(SubscribeTopic::new(key)));
let message = serde_json::to_string(&message_data).unwrap_or_default();
wurbo_in::emit(&message);
}
Expand Down
3 changes: 2 additions & 1 deletion crates/delanocreds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.2.0"
crate-type = ["cdylib", "lib"]

[dependencies]
bls12_381_plus = { version = "0.8.13", git="https://github.com/mikelodder7/bls12_381_plus.git", rev = "91a399e9a5f326816f13a0feab898ff40a7a1599", features = ["expose-fields", "alloc"] }
bls12_381_plus = { workspace = true, features = ["expose-fields", "alloc"] }
delano-keys = { path = "../delano-keys" }
anyhow = "1.0.70"
cid = "0.10.1"
Expand All @@ -34,6 +34,7 @@ wasm-bindgen-test = "0.3"
# serde feature turns on all the optional serde deps
[features]
default = ["serde", "serde_json"]
zkp = []
# json = ["serde_json"]

[target.wasm32-unknown-unknown.dependencies]
Expand Down
9 changes: 0 additions & 9 deletions crates/delanocreds/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
//!
//! // select from the attributes
//! `let selected_attrs = attributes.select(vec![vec![], vec![0, 1], vec![0, 1]]);`
use crate::ec::Scalar;
use crate::error::Error;
use bls12_381_plus::elliptic_curve::bigint;
use cid::multibase;
use cid::multihash;
use cid::multihash::{Code, MultihashDigest};
Expand Down Expand Up @@ -178,13 +176,6 @@ impl From<Attribute> for multihash::Multihash {
}
}

impl From<Attribute> for Scalar {
fn from(attribute: Attribute) -> Self {
let bytes = attribute.0.hash().digest();
bigint::U256::from_be_slice(bytes).into()
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down
18 changes: 2 additions & 16 deletions crates/delanocreds/src/zkp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ impl Default for Nonce {
}
}

impl From<Scalar> for Nonce {
fn from(scalar: Scalar) -> Self {
Self(scalar)
}
}

/// Attempts to convert from [u8; 32] directly into a Nonce
impl TryFrom<[u8; 32]> for Nonce {
type Error = Error;
Expand Down Expand Up @@ -109,12 +103,6 @@ impl PartialEq<bls12_381_plus::Scalar> for &Nonce {
}
}

impl From<Nonce> for Scalar {
fn from(nonce: Nonce) -> Self {
nonce.0.into()
}
}

impl From<Option<&[u8]>> for Nonce {
fn from(bytes: Option<&[u8]>) -> Self {
match bytes {
Expand Down Expand Up @@ -529,9 +517,7 @@ impl std::convert::TryFrom<PedersenOpenCompressed> for PedersenOpen {
})
.transpose()?;
Ok(Self {
open_randomness: Nonce::from(try_into_scalar(
pedersen_open_compressed.open_randomness,
)?),
open_randomness: Nonce(try_into_scalar(pedersen_open_compressed.open_randomness)?),
announce_randomness: try_into_scalar(pedersen_open_compressed.announce_randomness)?,
announce_element,
})
Expand Down Expand Up @@ -699,7 +685,7 @@ mod tests {
// test to/from Vec<u8>
let nonce = Nonce::new(b);
let bytes: Vec<u8> = nonce.clone().into();
let nonce2 = Nonce::from(try_into_scalar(bytes).unwrap());
let nonce2 = Nonce(try_into_scalar(bytes).unwrap());
assert_eq!(nonce, nonce2);
}

Expand Down

0 comments on commit 0ab6835

Please sign in to comment.