SchnorrkelSignature.fromBytes constructor

SchnorrkelSignature.fromBytes(
  1. List<int> signatureBytes
)

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 ArgumentException(
        "Signature not marked as schnorrkel, maybe try ed25519 instead.");
  }

  if (_KeyUtils.isCanonical(s)) {
    return SchnorrkelSignature._(s, r);
  }
  throw ArgumentException("invalid signature");
}