Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(common): better serialization of cryptographic payloads #161

Merged
merged 10 commits into from
Dec 2, 2024
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ prism-tests = { path = "crates/tests" }
prism-lightclient = { path = "crates/node_types/lightclient" }
rocksdb = { version = "0.21.0", features = ["multi-threaded-cf"] }
p256 = { version = "0.13.2", features = ["serde", "ecdsa"] }

ecdsa = { version = "0.16.0", features = ["der"] }

[patch.crates-io]
sha2-v0-10-8 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" }
Expand Down
1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ celestia-types.workspace = true
bincode.workspace = true
log.workspace = true
ed25519-consensus.workspace = true
ecdsa.workspace = true
secp256k1.workspace = true
base64.workspace = true
rand.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/common/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use bls12_381::Scalar;
use jmt::RootHash;
use serde::{Deserialize, Serialize};

use crate::hasher::Hasher;
use crate::{hasher::Hasher, serde::raw_or_hex_fixed};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Copy)]
pub struct Digest(pub [u8; 32]);
pub struct Digest(#[serde(with = "raw_or_hex_fixed")] pub [u8; 32]);

impl Digest {
pub fn hash(data: impl AsRef<[u8]>) -> Self {
Expand Down
Loading
Loading