SIGBlockchain / project_aurum

SIG Blockchain blockchain project in Go
https://acm.cs.uic.edu/sigblockchain
MIT License
7 stars 0 forks source link

Add error returns to keys functions. #228

Closed kastolars closed 5 years ago

kastolars commented 5 years ago

Currently the encoding & decoding functions in the keys package are simply ignoring errors within the function body instead of returning them if they are faulty. If a conversion fails we should know about it and handle it gracefully instead of panicking.

This may cause some tests in the project overall to fail because of their current usage.

Example of area where an error needs to be handled: https://github.com/SIGBlockchain/project_aurum/blob/dev/internal/publickey/publickey.go#L23

bashbashbash commented 5 years ago

via #306, this issue was resolved

ramirez915 commented 5 years ago

Changes on the WIP regarding publickey.Encode() and publickey.Decode() for error handling look good to me and the changes throughout the project to account for these changes make sense to me.

ramirez915 commented 5 years ago

The GenerateNRandomKeys() on line 80 in privatekey.go, the line currently is x509Encoded, _ := x509.MarshalECPrivateKey(p) but the function x509.MarshalECPrivateKey() returns an error that is not handled. I think this should be changed to handle the error it returns but I'm not entirely sure. Aside from this, all tests pass.

kastolars commented 5 years ago

@ramirez915 Do we use that function anywhere? The GenerateNRandomKeys

ramirez915 commented 5 years ago

I pulled from dev to check and did not find the GenerateNRandomKeys used anywhere in the project besides in privatekey_test.go file

ramirez915 commented 5 years ago

I created a card regarding GenerateNRandomKeys in the backlog. Since GenerateNRandomKeys is not currently used anywhere in the project besides in privatekey_test.go the handling for the x509.MarshalECPrivateKey() can be ignored for now.