SchnorrkelSignature.fromBytes constructor
Creates a signature from raw bytes.
Implementation
factory SchnorrkelSignature.fromBytes(List<int> signatureBytes) {
_KeyUtils._checkKeysBytes(
signatureBytes, SchnorrkelKeyCost.signatureLength, "signature");
final r = signatureBytes.sublist(0, 32);
final s = signatureBytes.sublist(32, SchnorrkelKeyCost.signatureLength);
if (s[31] & 128 == 0) {
throw const ArgumentException(
"Signature not marked as schnorrkel, maybe try ed25519 instead.");
}
final canonicalS = _KeyUtils.toCanonical(s);
if (canonicalS != null) {
return SchnorrkelSignature._(
BytesUtils.toBytes(canonicalS, unmodifiable: true),
BytesUtils.toBytes(r, unmodifiable: true));
}
throw const ArgumentException("invalid schnorrkel signature");
}