Skip to content

Object signing helpers

Luke Champine requested to merge sign-object into master

Add two functions to the crypto package: WriteSignedObject and ReadSignedObject. They function identicially to encoding.WriteObject and encoding.ReadObject, except that WriteSignedObject also writes a signature of the encoded object's hash, and ReadSignedObject reads and verifies that hash. These functions will be useful in the new host/renter protocol, which requires reading and writing signed data. Both have 100% code coverage. (Question: could we sign the object directly, instead of its hash?)

There is one quirk to the implementation, which is that the signature is not included in the length prefix. Most objects sent over a network carry a length-prefix, so that the receiver knows how much data to expect. Since the signature size is constant, we can remove its length prefix, saving 8 bytes.

Also add proper testing of the PublicKey method.

Merge request reports