From 2b5ed95df5c1f176bfcc0d4632d05e22270f5bcc Mon Sep 17 00:00:00 2001 From: rvcas Date: Thu, 7 Mar 2024 19:29:57 -0500 Subject: [PATCH] feat: serialize as cbor --- Cargo.lock | 46 ++++++++++++++++++++++++++++++++- crates/aiken-project/Cargo.toml | 1 + crates/aiken-project/src/lib.rs | 6 +++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d5740c49..3527dad8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -128,6 +128,7 @@ dependencies = [ "askama", "blst", "built", + "ciborium", "cryptoxide", "dirs", "fslock", @@ -556,6 +557,33 @@ dependencies = [ "stacker", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half 2.4.0", +] + [[package]] name = "cipher" version = "0.4.4" @@ -756,6 +784,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-bigint" version = "0.5.5" @@ -1195,6 +1229,16 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" +[[package]] +name = "half" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5eceaaeec696539ddaf7b333340f1af35a5aa87ae3e4f3ead0532f72affab2e" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1730,7 +1774,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d15f4203d71fdf90903c2696e55426ac97a363c67b218488a73b534ce7aca10" dependencies = [ - "half", + "half 1.8.3", "minicbor-derive", ] diff --git a/crates/aiken-project/Cargo.toml b/crates/aiken-project/Cargo.toml index dd8d4913..14a77119 100644 --- a/crates/aiken-project/Cargo.toml +++ b/crates/aiken-project/Cargo.toml @@ -47,6 +47,7 @@ num-bigint = "0.4.4" cryptoxide = "0.4.4" vec1 = "1.10.1" patricia_tree = "0.8.0" +ciborium = "0.2.2" [dev-dependencies] blst = "0.3.11" diff --git a/crates/aiken-project/src/lib.rs b/crates/aiken-project/src/lib.rs index c4f6a1f0..adef5cd9 100644 --- a/crates/aiken-project/src/lib.rs +++ b/crates/aiken-project/src/lib.rs @@ -728,6 +728,12 @@ where input_path: path, }; + let mut module_bytes = vec![]; + + ciborium::into_writer(&checked_module, &mut module_bytes).unwrap(); + + println!("{name}\n{}", hex::encode(&module_bytes)); + self.checked_modules.insert(name, checked_module); } }