Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a rough key verification feature for Meshtastic, allowing manual key verification from Python. The implementation adds three new methods to handle the key verification process and corresponding command-line interface options.
- Adds three key verification methods: initiate verification, provide security number, and confirm verification
- Implements command-line arguments to access the key verification functionality
- Uses protobuf messages to handle the key verification admin protocol
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| meshtastic/node.py | Adds three key verification methods to handle the verification workflow |
| meshtastic/main.py | Adds command-line argument parsing and handlers for key verification operations |
| else: | ||
| onResponse = self.onAckNak | ||
| return self._sendAdmin(a, onResponse=onResponse) | ||
| def keyVerificationNumber(self, number: int, nonce: int,): |
There was a problem hiding this comment.
Remove the trailing comma after the last parameter in the function definition.
| def keyVerificationNumber(self, number: int, nonce: int,): | |
| def keyVerificationNumber(self, number: int, nonce: int): |
| print(int(number)) | ||
| print(int(nonce)) |
There was a problem hiding this comment.
Debug print statements should be removed from production code. Consider using proper logging instead.
| print(int(number)) | |
| print(int(nonce)) | |
| logging.debug(f"Key verification number: {int(number)}") | |
| logging.debug(f"Key verification nonce: {int(nonce)}") |
| print(int(number)) | ||
| print(int(nonce)) |
There was a problem hiding this comment.
Debug print statements should be removed from production code. Consider using proper logging instead.
| print(int(number)) | |
| print(int(nonce)) | |
| logging.debug(f"Security number: {int(number)}") | |
| logging.debug(f"Nonce: {int(nonce)}") |
| else: | ||
| onResponse = self.onAckNak | ||
| return self._sendAdmin(a, onResponse=onResponse) | ||
| def keyVerificationConfirm(self, nonce: int,): |
There was a problem hiding this comment.
Remove the trailing comma after the last parameter in the function definition.
| def keyVerificationConfirm(self, nonce: int,): | |
| def keyVerificationConfirm(self, nonce: int): |
| onResponse = self.onAckNak | ||
| return self._sendAdmin(a, onResponse=onResponse) | ||
| def keyVerificationConfirm(self, nonce: int,): | ||
| print(int(nonce)) |
There was a problem hiding this comment.
Debug print statements should be removed from production code. Consider using proper logging instead.
| print(int(nonce)) | |
| logging.debug(f"Nonce value: {int(nonce)}") |
| p = admin_pb2.KeyVerificationAdmin() | ||
| p.message_type = p.MessageType.INITIATE_VERIFICATION | ||
| p.remote_nodenum = nodeId | ||
| p.nonce = 0 |
There was a problem hiding this comment.
The hardcoded nonce value of 0 appears to be a magic number. Consider using a named constant or adding a comment explaining why 0 is used for initiation.
| p.nonce = 0 | |
| p.nonce = DEFAULT_NONCE |
| ) | ||
| group.add_argument( | ||
| "--key-verification-number", | ||
| help="start key verification. " |
There was a problem hiding this comment.
The help text is incorrect for this argument. It should describe providing a security number, not starting key verification.
| help="start key verification. " | |
| help="Provide a security number for key verification. " |
| ) | ||
| group.add_argument( | ||
| "--key-verification-confirm", | ||
| help="start key verification. " |
There was a problem hiding this comment.
The help text is incorrect for this argument. It should describe confirming key verification, not starting it.
| help="start key verification. " | |
| help="confirm key verification. " |
|
|
||
| group.add_argument( | ||
| "--key-verification-nonce", | ||
| help="start key verification. " |
There was a problem hiding this comment.
The help text is incorrect for this argument. It should describe providing a nonce value, not starting key verification.
| help="start key verification. " | |
| help="Provide a nonce value for key verification. " |
Probably not done the right way, but works to do manual key-verification from python. Needs a protobuf update to go with it.