Skip to content

Commit

Permalink
feature(common): better serialization of cryptographic payloads (#161)
Browse files Browse the repository at this point in the history
* feature(common): add custom serde (de)serialization for base64 and hex

* refactor(common): More appropriate name for byte conversion method

"as_" prefix should be used when nothing needs to be allocated, which is not the case here.

* build(common): import ecdsa directly to enable "der" feature

* refactor(prover): webserver info-log uses actual port

Before it was logging the configured port, which could be 0 (to take an arbitrary free one) and devs wouldn't be able to see the port chosen by axum.

* refactor: new default port for webserver

Setting it to something fixed, so external tools (e.g. API testing tool) can be configured accordingly.

* feature(common): Improve (de)serialization for signatures and keys

* feature(common): digests serialize to hex in JSON

* refactor: rename 'serialization' file to 'serde'

* feature(common): operation data serializes to b64 in JSON

* chore: Incorporate changes in zkvm elf
  • Loading branch information
jns-ps authored Dec 2, 2024
1 parent d510473 commit 976a354
Show file tree
Hide file tree
Showing 13 changed files with 420 additions and 42 deletions.
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

0 comments on commit 976a354

Please sign in to comment.