Commit graph

7 commits

Author SHA1 Message Date
Dave Collins 87968edb1d Import btcec repo into btcec directory. 2015-02-06 10:09:24 -06:00
Josh Rickmar 1dbf389ceb Optimize public key serialization.
This change removes the internal pad function in favor a more opimized
paddedAppend function.  Unlike pad, which would always alloate a new
slice of the desired size and copy the bytes into it, paddedAppend
only appends the leading padding when necesary, and uses the builtin
append to copy the remaining source bytes.  pad was also used in
combination with another call to the builtin copy func to copy into a
zeroed byte slice.  As the slice is now created using make with an
initial length of zero, this copy can also be removed.

As confirmed by poking the bytes with the unsafe package, gc does not
zero array elements between the len and cap when allocating slices
with make().  In combination with the paddedAppend func, this results
in only a single copy of each byte, with no unnecssary zeroing, when
creating the serialized pubkeys.  This has not been tested with other
Go compilers (namely, gccgo and llgo), but the new behavior is still
functionally correct regardless of compiler optimizations.

The TestPad function has been removed as the pad func it tested has
likewise been removed.

ok @davecgh
2014-05-19 23:13:48 -05:00
Dave Collins 58cab817f0 Add 2014 to copyright dates. 2014-01-08 23:51:37 -06:00
Dave Collins cc712827da Add tests for pad function.
This brings the overall test coverage up to 99.88%.
2013-12-28 15:30:10 -06:00
Dave Collins 85ac6b06f7 Make NewFieldVal only avilable to the test package.
Since the function was only exported for use by the test package (and was
commented as such), just move it into the internal_test.go file so it is
only available when the tests run.
2013-12-20 19:19:02 -06:00
Dave Collins ac7e4de201 Add field and point addition/multiplicaiton tests.
This commit adds 100% test coverage for the new code.  This brings the
overall btcec coverage up to 99.76%.
2013-12-20 15:09:58 -06:00
Josh Rickmar 961636c764 Add functions to serialize an ecdsa public key. 2013-09-30 18:18:03 -04:00