Skip to content

feat: 🎸 Add support for decrypting messages from ios using v1 protocol#19

Merged
highesttt merged 1 commit into
mainfrom
18-bug-messages-sent-from-line-ios-are-unsupported
Jan 20, 2026
Merged

feat: 🎸 Add support for decrypting messages from ios using v1 protocol#19
highesttt merged 1 commit into
mainfrom
18-bug-messages-sent-from-line-ios-are-unsupported

Conversation

@highesttt

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for decrypting messages sent from the iOS LINE app using the v1 encryption protocol. The implementation detects the protocol version from message metadata and routes to the appropriate decryption method.

Changes:

  • Added ChannelDecryptV1 function in the Go runner to handle v1 decryption
  • Implemented channel_decrypt_v1 handler in the JavaScript runner
  • Modified DecryptMessageV2 to detect v1 protocol version and route accordingly
  • Added assembleCipherV1 helper function to reconstruct ciphertext from message chunks

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
pkg/runner.go Adds new ChannelDecryptV1 function to call the JavaScript v1 decryption handler
pkg/internal/runner.js Implements channel_decrypt_v1 handler to perform actual v1 decryption using the channel's decryptV1 method
pkg/e2ee/manager.go Adds version detection logic and assembleCipherV1 function; routes v1 messages to new decryption path

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/internal/runner.js
Comment on lines +402 to +405
const {
channelId,
ciphertext,
} = query;

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The senderKeyId and receiverKeyId parameters are extracted from the query but never used. If these parameters are not needed for v1 decryption, they should be removed from the query destructuring. If they are needed, they should be passed to the decryptV1 method or validated.

Copilot uses AI. Check for mistakes.
Comment thread pkg/e2ee/manager.go
}

if ver == 1 {
cipher, err := assembleCipherV1(msg.Chunks)

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'cipher' is assigned on line 324 from assembleCipher(msg.Chunks) but then shadowed on line 339 within the v1 block by declaring a new cipher variable with assembleCipherV1(msg.Chunks). This creates unnecessary confusion and wastes the initial computation. The first cipher assignment should be moved inside the 'else' or 'if ver == 2' block to avoid this shadowing and unnecessary computation when ver is 1.

Copilot uses AI. Check for mistakes.
Comment thread pkg/runner.go
return ct, nil
}

// decrypts ciphertext with channel v1 (ios)

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should follow Go documentation conventions. It should start with the function name and use proper capitalization: "ChannelDecryptV1 decrypts ciphertext with channel v1 (iOS)." Note that "iOS" should be capitalized as it's a proper noun.

Suggested change
// decrypts ciphertext with channel v1 (ios)
// ChannelDecryptV1 decrypts ciphertext with channel v1 (iOS).

Copilot uses AI. Check for mistakes.
Comment thread pkg/internal/runner.js
process.stdout.write(
JSON.stringify({ ciphertext: u8ToB64(ct) }) + "\n"
);
} else if (type === "channel_decrypt_v1") { // messages sent from ios LINE app use v1

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment should capitalize "iOS" as it's a proper noun. It should read: "messages sent from iOS LINE app use v1"

Suggested change
} else if (type === "channel_decrypt_v1") { // messages sent from ios LINE app use v1
} else if (type === "channel_decrypt_v1") { // messages sent from iOS LINE app use v1

Copilot uses AI. Check for mistakes.
Comment thread pkg/e2ee/manager.go
Comment on lines +357 to +374
func assembleCipherV1(chunks []string) ([]byte, error) {
if len(chunks) < 3 {
return nil, fmt.Errorf("not enough chunks")
}
decode := func(s string) ([]byte, error) { return base64.StdEncoding.DecodeString(strings.TrimSpace(s)) }
b0, err := decode(chunks[0])
if err != nil {
return nil, err
}
b1, err := decode(chunks[1])
if err != nil {
return nil, err
}
b2, err := decode(chunks[2])
if err != nil {
return nil, err
}
return append(append(b0, b1...), b2...), nil

Copilot AI Jan 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assembleCipherV1 function concatenates chunks in the order [first, middle, tag] which differs from assembleCipher (v2) that reorders them to [first, tag, middle] as noted in its comment. Please verify that this difference in chunk ordering is intentional for the v1 protocol. If this is intentional, consider adding a comment explaining the chunk order for v1, similar to the comment in assembleCipher.

Copilot uses AI. Check for mistakes.
@highesttt highesttt merged commit ca56020 into main Jan 20, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

bug: 🐛 Messages sent from LINE ios are unsupported

2 participants