open_len method

Uint8List open_len(
  1. Uint8List signedMessage,
  2. int smoff,
  3. int smlen
)

Implementation

Uint8List open_len(
    Uint8List signedMessage, final int smoff, final int smlen) {
  // check sm length
  if (!(signedMessage != null &&
      signedMessage.length >= (smoff + smlen) &&
      smlen >= signatureLength)) return null;

  // temp buffer
  Uint8List tmp = Uint8List(smlen);

  if (0 !=
      TweetNaclFast.crypto_sign_open(
          tmp, -1, signedMessage, smoff, smlen, _theirPublicKey)) return null;

  // message
  Uint8List msg = Uint8List(smlen - signatureLength);
  for (int i = 0; i < msg.length; i++)
    msg[i] = signedMessage[smoff + i + signatureLength];

  return msg;
}