signatureFromString method
Makes sure that the specified sig
, if too short, is extended to be of
valid signature length.
Throws InvalidSignatureException if sig
is too long, because trimming
signatures blindly can lead to distinct signatures becoming identical.
Implementation
String signatureFromString(String sig) {
if (sig.length > SignatureAndVersion.requiredSignatureLength) {
throw (InvalidSignatureException('Signature "$sig" is too long: '
'${sig.length} > ${SignatureAndVersion.requiredSignatureLength}'));
}
// Ensure the sig is not too short.
var result = sig.padRight(SignatureAndVersion.requiredSignatureLength, '-');
return result;
}