vulpemventures / go-secp256k1-zkp

Go bindings for the Elements' secp256k1-zkp C library.
MIT License
1 stars 5 forks source link

Fix BlindGeneratorBlindSum test #1

Closed altafan closed 4 years ago

altafan commented 4 years ago

This fixes the previously commented test for the BlindGeneratorBlindSum binding.

Before this, the byte slice returned by this method was not matching the expected one. After investigating, the problem was actually in the conversion of number values from the json to the uint64 go built-in type.

By using the generic interface{} for converting a json into a golang type when Unmarshaling, every number is automatically converted into a float64, and this was causing loss of information when then casting to uint64.

The fix for this is to create the custom types testType and testVectorType that reflect the json structure. In particular, the testVectorType contains a Values field, among the others, that is declared []uint64 so no information is lost in the conversion.

This closes #57.