Is there a way to encrypt MicroPython codes?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
kevinscorpionfox
Posts: 11
Joined: Thu May 23, 2019 9:57 am

Is there a way to encrypt MicroPython codes?

Post by kevinscorpionfox » Wed Mar 31, 2021 2:38 pm

We have a unpaid project we write a lib for a Chinese company, now they ask ship them a pyborad to test our lib, so how can we encrypt the py file on pyborad? Bcoz the Chinese company is totally able to duplicate our codes and leave us a penny. :( :(

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Is there a way to encrypt MicroPython codes?

Post by scruss » Thu Apr 01, 2021 7:37 pm

Not on any of the MicroPython systems I've used. Compiling to mpy will keep out the casual code browser, but the whole filesystem can always be cloned.

If one or other of you aren't being paid, that sounds like you don't have a contract in place. I'd fix that first.

anakaine
Posts: 10
Joined: Wed Mar 31, 2021 11:41 am

Re: Is there a way to encrypt MicroPython codes?

Post by anakaine » Fri Apr 02, 2021 6:12 am

Unfortunately, even contracts are not generally enforceable when it comes to Chinese companies. Cross jurisdictional enforcement and a burden of proof are very, very expensive things.

You may need to reconsider your development board. One that natively supports encrypting firmware through the use of a dedicated secure encryption chip might help quite a bit. https://docs.pycom.io/advance/encryption/

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Is there a way to encrypt MicroPython codes?

Post by scruss » Fri Apr 02, 2021 9:42 pm

That's one way to do encryption - but I'm guessing the pyboard removes the whole need for using the company in China.

There's also the very likely possibility that the partner company is far more interested in working with their next customer than keeping your data about and copying it for a possibly quite small and definitely uncertain return.

HermannSW
Posts: 197
Joined: Wed Nov 01, 2017 7:46 am
Contact:

Re: Is there a way to encrypt MicroPython codes?

Post by HermannSW » Tue May 25, 2021 6:20 pm

There is a way to make .uf2 run on exactly one (Raspberry Pico) by encrypting the image with Pico's unique flash ID ...
https://www.raspberrypi.org/forums/view ... 3#p1862153
The .uf2 image can contain MicroPython code builtin as others have described.
Pico-W Access Point static file webserver:
https://github.com/Hermann-SW/pico-w

Tiny MicroPython robots (the PCB IS the robot platform)
viewtopic.php?f=5&t=11454

webrepl_client.py
https://github.com/Hermann-SW/webrepl#webrepl-shell

Xykon
Posts: 6
Joined: Thu Oct 15, 2015 7:33 pm

Re: Is there a way to encrypt MicroPython codes?

Post by Xykon » Wed May 26, 2021 10:22 am

Another option is to use an esp32 based module. First you can compile the py file as frozen code and append it to the firmware binary.

If you enable secure boot + flash encryption, you can ensure that the flash content cannot be cloned as the keys are stored inside fuses on the esp32.
Christian Ehlers - Pycom

Jackli
Posts: 80
Joined: Thu Apr 29, 2021 9:11 am

Re: Is there a way to encrypt MicroPython codes?

Post by Jackli » Fri May 28, 2021 9:12 am

here is a link: viewtopic.php?t=6726

kevinscorpionfox
Posts: 11
Joined: Thu May 23, 2019 9:57 am

Re: Is there a way to encrypt MicroPython codes?

Post by kevinscorpionfox » Fri May 28, 2021 1:09 pm

scruss wrote:
Thu Apr 01, 2021 7:37 pm
Not on any of the MicroPython systems I've used. Compiling to mpy will keep out the casual code browser, but the whole filesystem can always be cloned.

If one or other of you aren't being paid, that sounds like you don't have a contract in place. I'd fix that first.
Oh mpy files, sounds a good idea, thanks. I think they're able to try some API, but they have no chance to scale the project from those mpy files, right?

kevinscorpionfox
Posts: 11
Joined: Thu May 23, 2019 9:57 am

Re: Is there a way to encrypt MicroPython codes?

Post by kevinscorpionfox » Fri May 28, 2021 1:15 pm

anakaine wrote:
Fri Apr 02, 2021 6:12 am
Unfortunately, even contracts are not generally enforceable when it comes to Chinese companies. Cross jurisdictional enforcement and a burden of proof are very, very expensive things.

You may need to reconsider your development board. One that natively supports encrypting firmware through the use of a dedicated secure encryption chip might help quite a bit. https://docs.pycom.io/advance/encryption/
Wow, that may what I'm looking for, moreover i can put some of codes in github. Thanks!

kevinscorpionfox
Posts: 11
Joined: Thu May 23, 2019 9:57 am

Re: Is there a way to encrypt MicroPython codes?

Post by kevinscorpionfox » Fri May 28, 2021 1:24 pm

HermannSW wrote:
Tue May 25, 2021 6:20 pm
There is a way to make .uf2 run on exactly one (Raspberry Pico) by encrypting the image with Pico's unique flash ID ...
https://www.raspberrypi.org/forums/view ... 3#p1862153
The .uf2 image can contain MicroPython code builtin as others have described.
Honestly to say, Raspberry Pico isn't a good choice in China, considering a chip of ESP32 is below 1.2 US dollors, I'm afraid we have to supply ESP32/ESP8266 dev-board to the Chinese company. Thanks anyway.

Post Reply