Deterministic signatures

This implements deterministic (RFC6979-based) signatures using libsecp256k1's signing. Note that the test cases here were constructed using an earlier version of this patch (which implemented them on top of OpenSSL), so the deterministism has been consistent.

Earlier version of this message:
The OpenSSL-based deterministic signing implementation is likely very temporary, as we may switch to libsecp256k1 for signing soon (#5220), but it allows testing. The signatures generated by the OpenSSL and libsecp256k1 based implementations should be identical, so the test cases are already useful.

On Sat, Nov 29, 2014 at 07:13:59AM -0800, Pieter Wuille wrote:
> > +
> > +    for (int n = 0; n < 64; n++)
> > +        rkey[n] ^= 0x5c;
> > +    outer.Write(rkey, 64);
> > +
> > +    for (int n = 0; n < 64; n++)
> > +        rkey[n] ^= 0x5c ^ 0x36;
> > +    inner.Write(rkey, 64);
> > +}
> > +
> > +void CHMAC_SHA256::Finalize(unsigned char hash[OUTPUT_SIZE])
> > +{
> > +    unsigned char temp[32];
> > +    inner.Finalize(temp);
> > +    outer.Write(temp, 32).Finalize(hash);
> > +}
> 
> I prefer keeping an extra SHA256 state in memory than keeping the key in memory.
>

Oh, of course. I somehow missed that you avoided storing the key.

-- 
Andrew Poelstra
Mathematics Department, University of Texas at Austin
Email: apoelstra at wpsoftware.net
Web:   http://www.wpsoftware.net/andrew