Avoid signature padding when not required

This commit is contained in:
Olivier Chéron 2020-02-04 21:39:50 +01:00
parent 633879f801
commit 6f70986cb1

View File

@ -178,10 +178,12 @@ encodeSignature :: EllipticCurveEdDSA curve
=> proxy curve => proxy curve
-> (Bytes, Point curve, Scalar curve) -> (Bytes, Point curve, Scalar curve)
-> Signature curve -> Signature curve
encodeSignature prx (bsR, _, sS) = encodeSignature prx (bsR, _, sS) = Signature $
let bsS = encodeScalarLE prx sS :: Bytes if len0 > 0 then B.concat [ bsR, bsS, pad0 ] else B.append bsR bsS
len0 = signatureSize prx - B.length bsR - B.length bsS where
in Signature $ B.concat [ bsR, bsS, B.zero len0 ] bsS = encodeScalarLE prx sS
len0 = signatureSize prx - B.length bsR - B.length bsS
pad0 = B.zero len0
decodeSignature :: EllipticCurveEdDSA curve decodeSignature :: EllipticCurveEdDSA curve
=> proxy curve => proxy curve