From 29d389b92a808e27bba61ce7b877b1a12097b703 Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Thu, 4 Nov 2021 14:27:37 +0200 Subject: [PATCH] Use the serde_as crate to serialize potentially big arrays --- Cargo.toml | 4 +++- src/keygen.rs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3c9c4c6..b7f0c6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,13 @@ rand_core = "0.6.3" curv-kzen = { git = "https://github.com/ZenGo-X/curv", branch = "ffts" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -criterion = "0.3" +serde_with = "1.11.0" [dev-dependencies] quickcheck = "0.9" quickcheck_macros = "0.9" +criterion = "0.3" + [[bench]] name = "dpf_bench" diff --git a/src/keygen.rs b/src/keygen.rs index a14342a..a4bb9fe 100644 --- a/src/keygen.rs +++ b/src/keygen.rs @@ -10,18 +10,24 @@ use curv::cryptographic_primitives::secret_sharing::{ use curv::elliptic::curves::{Point, Scalar, Secp256k1}; use curv::BigInt; use serde::{Deserialize, Serialize}; +use serde_with::serde_as; use std::convert::TryInto; use std::ops::{Add, Neg}; use std::ptr; use std::{fs, mem}; +#[serde_as] #[derive(Debug, Serialize, Deserialize)] pub struct LongTermKey { pub alpha_i: Scalar, pub sk_i: Scalar, + #[serde_as(as = "[[_; t]; c]")] pub w_i: [[BigInt; t]; c], + #[serde_as(as = "[[_; t]; c]")] pub eta_i: [[BigInt; t]; c], + #[serde_as(as = "[[_; t]; c]")] pub beta_i: [[Scalar; t]; c], + #[serde_as(as = "[[_; t]; c]")] pub gamma_i: [[Scalar; t]; c], pub u_i_0: [[DSPF; (n - 1)]; c], pub u_i_1: [[DSPF; (n - 1)]; c],