I am using an HSM which signs bytes using the secp256k1 curve. For a given set of input bytes, I blake2b hash them and sign them.

My understanding is that most cryptocurrencies use deterministic signatures (RFC 6979) in order to prevent transaction malleability. The particular HSM I am using does not generate deterministic signatures and instead chooses a random k which results varying r and s values.

Is there any way to get this set up to generate a valid signature for Tezos? Specifically:

  • Does Tezos require deterministic signatures?
  • If yes, is it possible to generate a deterministic signature from a non-deterministicly chosen r, s, the input bytes, and the public key?


I've been able to determine that Tezos will accept a non-deterministic signature.

However, sometimes I receive an r or an s value that is 33 bytes long. Is there a way to normalize these values to 32 bytes? It appears that Tezos will only accept two 32 byte values.

1 Answer 1


It shouldn't make a difference how you pick k, deterministically or not. It's random and is supposed to be kept secret by the signer, so there's no way to tell what k was used by just looking at the signature.

Tezos expects exactly 64 bytes for a secp256k1 signature https://gitlab.com/tezos/tezos/-/blob/master/src/lib_crypto/base58.ml

Per this question you might need to normalize (r, s) to lower s form (r, -s mod n) is also a valid signature and Tezos only accepts one. Invalid Signature for Tezos transaction

You are getting 32 bytes and 33 bytes value because of the weird DER encoding. Here's a description that will let you get the actual value for r and s.



  • Great. Lower s form notation was what I was missing. Apr 29, 2020 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.