Skip to content

Serialization for BigInts is redefined to be in base 10 instead of 16 #25

@vnermolaev

Description

@vnermolaev

I noticed that the crate redefines serialization of curv::BigInts to be in base 10, e.g.,

for KeyPair, p and q are going to be in base 10

rust-paillier/src/lib.rs

Lines 23 to 29 in 7d4958f

pub struct Keypair {
#[serde(with = "crate::serialize::bigint")]
pub p: BigInt, // TODO[Morten] okay to make non-public?
#[serde(with = "crate::serialize::bigint")]
pub q: BigInt, // TODO[Morten] okay to make non-public?
}

because

pub fn serialize<S: ser::Serializer>(x: &BigInt, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(&x.to_str_radix(10))
}

while in the curv crate BigInts are serialized using base 16

https://github.com/ZenGo-X/curv/blob/78cac40a47e145eb845d687cc748f9312d999db9/src/arithmetic/serde_support.rs#L9-L21

Imagine a server defines a struct as such

#[derive(Serialize, Deserialize)]
struct S {
  b: curv::BigInt,
  ek: EncryptionKey
 } 

then a third-party app needs to selectively serialize BigInts of the corresponding fields.

What was the reason behind that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions