You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently signatures are returned as raw bits. It's also common to need DER-encoded signatures. These are a few bytes longer, and it can be confusing since other APIs often assume one or the other without going into the details. It would be nice to have better documentation in this area and a helper function to return the DER-encoded version.
defmoduleECDSASignaturedorequireRecordRecord.defrecord(:ecdsa_signature,:"ECDSA-Sig-Value",Record.extract(:"ECDSA-Sig-Value",from_lib: "public_key/include/OTP-PUB-KEY.hrl"))defnew(r,s)whenis_integer(r)andis_integer(s)doecdsa_signature(r: r,s: s)enddefnew(raw)whenis_binary(raw)dosize=raw|>byte_size()|>div(2)<<r::size(size)-unit(8),s::size(size)-unit(8)>>=rawnew(r,s)end# Export to DER binary format, for use with :public_key.verify/4defto_der(ecdsa_signature()=signature)do:public_key.der_encode(:"ECDSA-Sig-Value",signature)endend
The text was updated successfully, but these errors were encountered:
Currently signatures are returned as raw bits. It's also common to need DER-encoded signatures. These are a few bytes longer, and it can be confusing since other APIs often assume one or the other without going into the details. It would be nice to have better documentation in this area and a helper function to return the DER-encoded version.
Here's some code from https://gist.githubusercontent.com/voltone/d3c0bb3ee821703f52d439e00262cb88/raw/e90117c60dceb07f3a674cbf5102ef6f2722e0c8/ecdsa_signature.ex:
The text was updated successfully, but these errors were encountered: