Skip to content

Commit

Permalink
dusk-core: added serde support
Browse files Browse the repository at this point in the history
  • Loading branch information
d-sonuga committed Dec 30, 2024
1 parent 9a47c2d commit 21089d6
Show file tree
Hide file tree
Showing 7 changed files with 1,488 additions and 1 deletion.
15 changes: 15 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ ark-bn254 = { workspace = true, features = ["curve"], optional = true }
ark-relations = { workspace = true, optional = true }
ark-serialize = { workspace = true, optional = true }

# serde support dependencies
serde = { workspace = true, features = ["derive"], optional = true }
hex = { workspace = true, optional = true }
base64 = { workspace = true, optional = true }

[dev-dependencies]
rand = { workspace = true, features = ["std", "std_rng"] }
serde_json = { workspace = true }

[features]
parallel = [
Expand Down Expand Up @@ -63,3 +69,12 @@ groth16 = [

# Enables std feature for dusk-plonk
std = ["dusk-plonk/std"]

serde = [
"dep:serde",
"hex",
"base64",
"piecrust-uplink/serde",
"bls12_381-bls/serde",
"phoenix-core/serde",
]
2 changes: 1 addition & 1 deletion core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

test:
cargo test --release --features zk
cargo test --release --features zk,serde
cargo test --release --no-run

clippy: ## Run clippy
Expand Down
10 changes: 10 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub use error::Error;
mod dusk;
pub use dusk::{dusk, from_dusk, Dusk, LUX};

#[cfg(feature = "serde")]
mod serde_support;

// elliptic curve types
pub use dusk_bls12_381::BlsScalar;
pub use dusk_jubjub::{
Expand Down Expand Up @@ -135,3 +138,10 @@ fn read_arr<const N: usize>(buf: &mut &[u8]) -> Result<[u8; N], BytesError> {
*buf = &buf[N..];
Ok(a)
}

#[cfg(test)]
mod tests {
// the `unused_crate_dependencies` lint complains for dev-dependencies that
// are only used in integration tests, so adding this work-around here
use serde_json as _;
}
Loading

0 comments on commit 21089d6

Please sign in to comment.