didiercrunch / paillier

Paillier cryptosystem implemented in Go
MIT License
20 stars 16 forks source link

Let to pass an arbitrary number of cyphers to PublicKey.Add #5

Closed pdyraga closed 6 years ago

pdyraga commented 6 years ago

PublicKey.Add accepts now an arbitrary number of *Cyphers. Previously, it was possible to add only two *Cypher instances and it was quite unwieldy for a lot of use cases.

The current implementation is backward compatible. It's still possible to pass just two *Cypher arguments, so every project referencing the library will observe no compilation issues.

// backward-compatibility
cypherA := privateKey.Add(cypher1, cypher2)

// you can pass any number of cyphers now
cypherB := privateKey.Add(cypher1, cypher2, cypher3, cypher4)

// or even a slice of them
cyphers := []*Cypher{cypher1, cypher2, cypher3, cypher4}
cypherC := privateKey.Add(cyphers...)

The original PR: https://github.com/keep-network/paillier/pull/5

didiercrunch commented 6 years ago

Thousand thanks for that one. Sorry for delay, I forgot about it.

cheers,

didier