### Question:
PasetoLocal { static String decrypt(byte[] key, String token, String footer) { checkNotNull(key); checkNotNull(token); checkArgument(key.length == 32, "Public key should be 32 bytes"); String[] tokenParts = token.split("\\."); Verify.verify(tokenParts.length == 3 || tokenParts.length == 4, "Token should contain at least 3 parts"); if (!isNullOrEmpty(footer)) { verify(MessageDigest.isEqual(base64Decode(tokenParts[3].getBytes(UTF_8)), footer.getBytes(UTF_8)), "footer does not match"); } verify(token.startsWith(LOCAL), "Token should start with " + LOCAL); byte[] ct = base64Decode(tokenParts[2].getBytes(UTF_8)); byte[] nonce = Arrays.copyOfRange(ct, 0, XChaCha20Poly1305.Nonce.length()); byte[] encryptedMessage = Arrays.copyOfRange(ct, XChaCha20Poly1305.Nonce.length(), ct.length); byte[] preAuth = Util.pae(LOCAL.getBytes(UTF_8), nonce, footer.getBytes(UTF_8)); byte[] message = XChaCha20Poly1305.decrypt( encryptedMessage, preAuth, XChaCha20Poly1305.Key.fromBytes(key), XChaCha20Poly1305.Nonce.fromBytes(nonce)); return new String(message, UTF_8); } private  PasetoLocal();   }### Answer:
@Test public void invalidTokenShouldGiveException() { assertThrows( VerifyException.class, () -> PasetoLocal.decrypt(Util.hexToBytes("707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f"), "v2.local.", "")); }
@Test public void shouldThrowErrorWhenTokenDoesNotStartWithLocal() { byte[] key = CryptoCavaWrapper.randomBytes(32); assertThrows(VerifyException.class, () -> PasetoLocal.decrypt(key, "test.sdfsfs.sdfsdf", "")); }