normalize

fun normalize(signature: ByteArray, algorithm: Algorithm): ByteArray

Normalizes an EC signature to the org.trustweave.kms.KeyManagementService.sign contract: P1363 encoding, with low-s for secp256k1.

  • For non-ECDSA algorithms (Ed25519, RSA, BLS, custom) the signature is returned unchanged.

  • DER-encoded input is transcoded to P1363.

  • Input that is already the expected P1363 size is passed through.

  • Input in any other format is returned unchanged (the backend produced something this codec does not understand; callers should not silently destroy it).

  • secp256k1 signatures are normalized to low-s.