bitwiseshiftleft / sjcl

Stanford Javascript Crypto Library
http://bitwiseshiftleft.github.com/sjcl/
Other
7.18k stars 987 forks source link

How do I serialize signature #354

Open albertdiones opened 6 years ago

albertdiones commented 6 years ago

I'm looking for a function that would serialize the signature produced by sjcl.ecc.ecdsa.secretKey.sign() ;

I'm trying to get it to work with PHPECC's DerSignatureSerializer() (DER format?)

(is it even right to post question here?)

cnasikas commented 6 years ago

You mean to convert it to a hex format ?

cnasikas commented 6 years ago

Sign returns a bitArray so you can convert it to hex by using codec utility:

var pair = sjcl.ecc.ecdsa.generateKeys(256)
var sig = pair.sec.sign(sjcl.hash.sha256.hash("Hello World!"))
var hexSig = sjcl.codec.hex.fromBits(sig)