Implementing Pairing Based Crypto on arduino uno

Also, is the memory limitations a major issue here or the computational capabilities of the microcontroller? I read in an article that a SD card may be used to increase the SRAM. Is that possible?

simsam:
Also, is the memory limitations a major issue here or the computational capabilities of the microcontroller? I read in an article that a SD card may be used to increase the SRAM. Is that possible?

Why would you even consider such extremes just to stay with an 8-bit processor? It's already been suggested (twice) that you move to a 32-bit machine.

gfvalvo:
Why would you even consider such extremes just to stay with an 8-bit processor? It's already been suggested (twice) that you move to a 32-bit machine.

I looked it up and found arduino Due, it has a 32-bit processor.
Should i go ahead and buy it if this code will execute on it.

So, check if the code fits by looking at it. Does it assign any large buffers? How big are they?

Program storage is unlikely to be the issue, so you don't need to know how may bytes the program itself takes, just its SRAM storage while it's running.

MorganS:
Program storage is unlikely to be the issue...

Probably should at least glance at the on-disk size of the two libraries before claiming "unlikely". :wink:

MorganS:
So, check if the code fits by looking at it. Does it assign any large buffers? How big are they?

Program storage is unlikely to be the issue, so you don't need to know how may bytes the program itself takes, just its SRAM storage while it's running.

Yes it does assign large buffers, there is a large string i was provided which is used in generating the private key, around 400 character long.

Should i switch boards to arduino due instead? Or someone other board.

I dont have much knowledge regarding this so i need some help in deciding.
As mentioned in the earlier comments a 32 bit processor is required so i looked up DUE

What does that tell you about a large crypto library that the Arduino side only needs to compile and link a few functions to do the 'signing'' side of the transaction? You may as well look at the size of the math.h library on disk and claim that won't fit on an Arduino.

Simsam: the internal storage of the core cryptography is probably many times larger than the key. It will teach you a lot by going through the code to find out what functions it actually uses and what storage they use. It is entirely possible that it assigns static buffers for the decryption routines that you aren't even going to use on the Arduino.

MorganS:
What does that tell you about a large crypto library that the Arduino side only needs to compile and link a few functions to do the 'signing'' side of the transaction?

A few functions. How quaint.

You may as well look at the size of the math.h library on disk and claim that won't fit on an Arduino.

When elliptic curve functions have been added to "math.h" let me know. Until then that is a false analogy.

But, there is no point discussing hypothetical with you when there is a trivial practical path to follow...

simsam:
I have implemented Digital Signature using PBC and GMP libraries.( I have taken the code from the PBC library as liked above.)My code works correctly when i compile it on Visual Studios 2010.

Post the MAP file. Armed with that it will be possible to assess the size processor.

I have attached the map file.

pbcNewProj.map.txt (50.2 KB)

simsam:
Sorry i think i didnt use the correct word, i should have used technique instead of requirement.
Though what you're saying is absolutely correct, the thing is that my supervisor has told me to use PBC here, i cant use an alternative.

Yes i understand that asymmetric crypto is more heavy weight, is there no way to implement this at all? What if i were to change from UNO to MEGA? Even that wouldnt suffice?

No, its ~ 10000 times slower than stock computer hardware, its an 8-bit microcontroller.

We are talking 3 to 5 orders of magnitude difference in performance, basically, between a
small micricontroller and a general purpose processor, considering memory, speed or transistor count.

For a small microcontroller an efficient block-cipher based MAC is feasible, asymmetric crypto systems are not.

Even on the Due or similar with 32 bit architecture you'll find the performance is dissappointingly slow, and
typically you'd only use asymmetric crypto to set up a secure channel using standard symmetric crypto, so that the heavyweight step only
has to happen once (or perhaps once per day or similar). I recommend reading "Cryptography Engineering: Design Principles and Practical Applications" by Ferguson/Schneier/Kohno.

MarkT:
No, its ~ 10000 times slower than stock computer hardware, its an 8-bit microcontroller.

For a small microcontroller an efficient block-cipher based MAC is feasible, asymmetric crypto systems are not.

Even on the Due or similar with 32 bit architecture you'll find the performance is dissappointingly slow, and
typically you'd only use asymmetric crypto to set up a secure channel using standard symmetric crypto, so that the heavyweight step only
has to happen once (or perhaps once per day or similar). I recommend reading "Cryptography Engineering: Design Principles and Practical Applications" by Ferguson/Schneier/Kohno.

Thank you for your detailed answer. I will discuss this with my supervisor.
So the conclusion being that running an asymmetric crypto (PBC) will not be possible on any arduino board. I will have to move to something else.
Thank you again for your help.

simsam:
So the conclusion being that running an asymmetric crypto (PBC) will not be possible on any arduino board.

If you’re really interested, I’d say get a Teensy 3.6 (32-Bit ARM Cortex-M4, 180/360 MHz, 256 KB RAM, 1 MB Program Space) and give it a try. It will set you back all of $30.

gfvalvo:
If you’re really interested, I’d say get a Teensy 3.6 (32-Bit ARM Cortex-M4, 180/360 MHz, 256 KB RAM, 1 MB Program Space) and give it a try. It will set you back all of $30.

Alright i will give that a try as well, using a digital signature is a key factor in the project i am given. So anything that'll make it work i'm up for it.
Thank you for helping me out.

simsam:
I have attached the map file.

sha.obj is the only module bound to the executable: 1953 bytes (Pentium class processor). There are at least three SHA implementations for AVR processors so it is not too surprising that something named "sha" would be small enough to fit in an Uno's memory. The rest (memory management, pbc, and floating-point) is dynamically linked.

The program uses structured exceptions which will be troublesome in the best case and non-existent in the worst case. I believe the libraries are "pure C" in which case structured exceptions can be easily managed / avoided.

Yes the libraries are pure C, could be please elaborate a little that what do you mean by structured exceptions.

When the code was compiles visual micro, there were a lot of errors regarding the cmath library, none of its functions were being recognized.

Should i also attach the code?

simsam:
Yes the libraries are pure C, could be please elaborate a little that what do you mean by structured exceptions.

try ... catch

In your case that gets broadened to include Microsoft extensions...
https://www.google.com/search?q=c%2B%2B+structured+exception+handling

simsam:
Should i also attach the code?

I suggest you create a test program that builds for an Arduino using stubs for the PBC calls. Then get that to build and run correctly on a PC. Doing that will eliminate most / all of the PC specific junk (like basic_string) and give you a starting point for building something that works correctly on an Arduino.

Hello everyone,

Wholeheartedly thank you for valuable comments and discussion.

How to implement Digital Signature using PBC and GMP libraries on Arduino Uno or arm cortex-M3?

kindly contact me "abhijeetthakare241093@gmail.com"

Sincerely
Abhijeet Thakare

This is a public forum, answers are publically accessible to help everyone.

What is your specific question that hasn't been answered already in this thread?