Extract BSON/JSON code to separate package #4

Merged
nkuba merged 6 commits from master into master 2018-06-23 09:11:19 -04:00
nkuba commented 2018-06-21 04:56:37 -04:00 (Migrated from github.com)

BSON/JSON serialization and deserialization were moved to separate bson package.

Encoding was split into separate files per each type which is converted.

New public functions had been exposed for objects conversion. These functions should be called for conversion between BSON/JSON and structures.

func SerializeCypher(cypher *paillier.Cypher) ([]byte, error)
func DeserializeCypher(data []byte) (*paillier.Cypher, error)

func SerializePartialDecryptionZKP(pdzkp *paillier.PartialDecryptionZKP) ([]byte, error)
func DeserializePartialDecryptionZKP(data []byte) (*paillier.PartialDecryptionZKP, error)

func SerializePrivateKey(key *paillier.PrivateKey) ([]byte, error)
func DeserializePrivateKey(data []byte) (*paillier.PrivateKey, error)

func SerializePublicKey(publicKey *paillier.PublicKey) ([]byte, error)
func DeserializePublicKey(data []byte) (*paillier.PublicKey, error)

func SerializeThresholdPublicKey(key *paillier.ThresholdPublicKey) ([]byte, error)
func DeserializeThresholdPublicKey(data []byte) (*paillier.ThresholdPublicKey, error)

There are available JSON serialization and deserialization functions for PartialDecryptionZKP.
It is worth considering to move these to separate json package and cover remaining types for consistency. For now these two functions stay in the bson package.

func JsonSerializePartialDecryptionZKP(pdzkp *paillier.PartialDecryptionZKP) ([]byte, error)
func JsonDeserializePartialDecryptionZKP(data []byte) (*paillier.PartialDecryptionZKP, error)
BSON/JSON serialization and deserialization were moved to separate `bson` package. Encoding was split into separate files per each type which is converted. New public functions had been exposed for objects conversion. These functions should be called for conversion between BSON/JSON and structures. ``` func SerializeCypher(cypher *paillier.Cypher) ([]byte, error) func DeserializeCypher(data []byte) (*paillier.Cypher, error) func SerializePartialDecryptionZKP(pdzkp *paillier.PartialDecryptionZKP) ([]byte, error) func DeserializePartialDecryptionZKP(data []byte) (*paillier.PartialDecryptionZKP, error) func SerializePrivateKey(key *paillier.PrivateKey) ([]byte, error) func DeserializePrivateKey(data []byte) (*paillier.PrivateKey, error) func SerializePublicKey(publicKey *paillier.PublicKey) ([]byte, error) func DeserializePublicKey(data []byte) (*paillier.PublicKey, error) func SerializeThresholdPublicKey(key *paillier.ThresholdPublicKey) ([]byte, error) func DeserializeThresholdPublicKey(data []byte) (*paillier.ThresholdPublicKey, error) ``` There are available JSON serialization and deserialization functions for `PartialDecryptionZKP`. It is worth considering to move these to separate `json` package and cover remaining types for consistency. For now these two functions stay in the `bson` package. ``` func JsonSerializePartialDecryptionZKP(pdzkp *paillier.PartialDecryptionZKP) ([]byte, error) func JsonDeserializePartialDecryptionZKP(data []byte) (*paillier.PartialDecryptionZKP, error) ```
Shadowfiend commented 2018-06-21 17:10:01 -04:00 (Migrated from github.com)

For the original discussion around how we approached this and why the interface is as it is, see keep-network/paillier#4.

For the original discussion around how we approached this and why the interface is as it is, see keep-network/paillier#4.
didiercrunch commented 2018-06-23 09:11:15 -04:00 (Migrated from github.com)

Excellent job, I am merging the pull request right now.

Many thanks,

didier

Excellent job, I am merging the pull request right now. Many thanks, didier
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: didier/paillier#4