How do we keep the vote secret with encryption?كيف نحمي سرية الصوت بالتشفير
Turning a readable voting record into ciphertext with AES, what happens inside the algorithm, and what encryption alone can't hide.كيف يتحول سجل التصويت المقروء إلى نص مشفر بخوارزمية AES وما الذي يجري داخلها وما الذي لا يخفيه التشفير وحده
The voter has reached the list of candidates and picked one. The system can now create a record of the vote: the voter's number, the candidate and the date. But if that record is stored as it is, anyone who can read the data may learn who its owner voted for.وصل الناخب إلى قائمة المرشحين واختار أحدهم ويستطيع النظام الآن إنشاء سجل يحتوي على معلومات عملية التصويت مثل رقم الناخب والمرشح والتاريخ لكن هنا تظهر مشكلة واضحة فإذا حفظنا هذا السجل كما هو فقد يعرف كل من يستطيع قراءة البيانات لمن صوت صاحبه
The project's answer is encryption, specifically the Advanced Encryption Standard, known as AES1.والحل الذي يستخدمه المشروع هو التشفير وتحديدا خوارزمية معيار التشفير المتقدم المعروفة باسم AES1
Readable text and encrypted textما الفرق بين النص المقروء والنص المشفر
Take this illustrative record:لنفترض أننا نملك السجل التوضيحي التالي
ID42|CAND-B|2022It's a teaching example combining a voter ID, a candidate code and a year, and anyone can read its parts. We call this data the plaintext6.هو مثال تعليمي يجمع معرف ناخب ورمز مرشح وسنة ويمكن للإنسان فهم مكوناته مباشرة ونسمي هذه البيانات النص الأصلي6
When the record goes into the algorithm together with a secret key4, it becomes ciphertext3 that doesn't reveal its content. At counting time, the authorized party uses the right key to decrypt it and recover what the count needs.عندما يدخل السجل إلى خوارزمية التشفير مع مفتاح4 سري يتحول إلى نص مشفر3 لا يكشف مضمونه بصورة مباشرة وعند الفرز يستخدم صاحب الصلاحية المفتاح المناسب لفك التشفير واستعادة البيانات اللازمة للعد
Two jobs need separating here: encryption protects the content from unauthorized reading, while the blockchain helps detect changes to the record after it's saved. Neither replaces the other.وهنا يجب التمييز بين مهمتين فالتشفير يحمي المحتوى من القراءة غير المصرح بها أما سلسلة الكتل فتساعد على اكتشاف تعديل السجل بعد حفظه وإحدى المهمتين لا تحل محل الأخرى
Why AES?لماذا استخدمت AES
It's a symmetric10 algorithm: whoever encrypts the data and whoever decrypts it use the same secret key. The standard was established when the Rijndael algorithm was selected and adopted as a US standard in 2001.هي خوارزمية تشفير متماثل10 أي إن الجهة التي تشفر البيانات والجهة التي تفكها تستخدمان المفتاح السري نفسه وقد أصبح المعيار معروفا بعد اختيار خوارزمية ريندال واعتمادها معيارا أمريكيا سنة 2001
AES supports keys of 128, 192 or 256 bits, and always works on data blocks of 128 bits, or 16 bytes. The key length changes the number of rounds, not the size of the block.تدعم AES مفاتيح بأطوال 128 أو 192 أو 256 بت وتعمل دائما على كتل بيانات طول كل منها 128 بت أي 16 بايت ويغير طول المفتاح عدد جولات التشفير لكنه لا يغير حجم كتلة البيانات
In this project, the administrator creates the election key at the start, the votes are encrypted with it, and it's used again to decrypt them at counting time. That's why protecting the key, and deciding who holds it and how it's used, is a central issue, not a minor detail.وفق وصف المشروع ينشئ المشرف مفتاح الانتخاب عند بدايته وتشفر الأصوات به ثم يستخدم لفك البيانات عند الفرز ولهذا تعد حماية المفتاح وتحديد من يملكه وكيف يستخدم قضية أساسية لا تفصيلا صغيرا
Inside the algorithmماذا يحدث داخل الخوارزمية
We don't need every equation to understand the idea. AES takes 16 bytes and arranges them in a grid of 4 rows and 4 columns, called the state9. Then it changes the data in successive stages, so the original is hard to infer from the output.لفهم الفكرة لا نحتاج إلى حل كل المعادلات تخيل أن AES تأخذ 16 بايت وترتبها في جدول من 4 صفوف و4 أعمدة يسمى الحالة9 ثم تغير البيانات على مراحل متتابعة كي يصعب استنتاج الأصل من الناتج
With a 128-bit key the algorithm goes through ten rounds7, built from four main operations.وفي مثال مفتاح طوله 128 بت تمر الخوارزمية بعشر جولات7 وتستخدم أربع عمليات رئيسية
Step 1 · SubBytesالخطوة الأولى استبدال البايتات
Each byte is replaced using a fixed substitution table, the S-box8, so the mapping from input to output is no longer simple.يتغير كل بايت وفق جدول استبدال محدد يسمى صندوق الاستبدال8 فلا يبقى الانتقال من المدخل إلى الناتج بسيطا
Step 2 · ShiftRowsالخطوة الثانية إزاحة الصفوف
Bytes move along the rows, spreading across new positions.تتحرك البايتات داخل الصفوف لتتوزع على مواضع جديدة
Step 3 · MixColumnsالخطوة الثالثة خلط الأعمدة
The bytes in each column are combined mathematically, so they affect one another.تدمج قيم البايتات داخل كل عمود حسابيا بحيث يؤثر بعضها في بعض
Step 4 · AddRoundKeyالخطوة الرابعة إضافة مفتاح الجولة
The data is combined with a key derived from the original key, using an XOR11 operation.تدمج البيانات مع مفتاح مشتق من المفتاح الأصلي باستخدام عملية XOR11
Ten rounds, eleven keysعشر جولات وأحد عشر مفتاحا
An initial key-addition step comes first, then nine full rounds, then a final round without MixColumns. The key schedule5 generates the round keys from the main key; AES-128 has 11 of them, counting the initial one.تسبق الجولات عملية أولية لإضافة المفتاح ثم تنفذ تسع جولات كاملة وتتبعها جولة أخيرة دون خطوة خلط الأعمدة وتولد جدولة المفاتيح5 مفاتيح الجولات المطلوبة من المفتاح الأساسي ففي AES-128 يوجد 11 مفتاح جولة إذا حسبنا المفتاح الأولي
There's a neat detail: if one byte changes at the start, the effect spreads through the rounds into much of the result. This is the avalanche effect2. So a small difference between two voting records doesn't look small at all once they're encrypted.وهناك تفصيل لطيف في العملية فإذا تبدل بايت واحد في البداية انتشر أثره خلال الجولات إلى أجزاء كثيرة من النتيجة وتعرف هذه الفكرة باسم أثر الانهيار2 لذلك لا يبدو اختلاف صغير بين سجلي تصويت اختلافا صغيرا بالضرورة في البيانات المشفرة
How is it decrypted?كيف تفك البيانات
Decryption applies the inverse operations in a calculated order, using the round keys in reverse. With the correct key and the right mode of operation, the data returns to readable form.يطبق فك التشفير العمليات العكسية بترتيب محسوب مستخدما مفاتيح الجولات بالترتيب المعاكس وبوجود المفتاح الصحيح وطريقة التشغيل المناسبة تعود البيانات إلى صورتها المقروءة
Without the key there's no meaningful text. Real dangers come from the key being stolen, encryption being implemented badly, or keys being managed insecurely. Writing "AES" in a system description isn't enough to call the system fully secure.أما من لا يمتلك المفتاح فلا يكون أمامه نص مفهوم وقد تنشأ أخطار حقيقية من سرقة المفتاح أو سوء تنفيذ التشفير أو إدارته بصورة غير آمنة لذلك لا يكفي مجرد كتابة اسم AES في وصف النظام للحكم على أمانه الكامل
Does encryption hide the voter completely?هل تشفير سجل الناخب يعني إخفاء هويته بالكامل
Not necessarily. In the thesis example, the record holds the voter's ID and their choice. If both are decrypted together, whoever holds the key could link the voter to their vote. So keeping data secret while it's stored and making a vote impossible to link to its owner, even at counting time, are two different requirements.ليس بالضرورة ففي المثال الذي تقدمه الرسالة يتضمن السجل معرف الناخب واختياره وإذا جرى فك تشفيرهما معا فقد تستطيع الجهة المالكة للمفتاح ربط الناخب بصوته ولهذا ينبغي التفريق بين سرية البيانات أثناء التخزين وبين عدم إمكان ربط الصوت بصاحبه حتى عند الفرز فهما مطلبان مختلفان
Now that the record is protected from direct reading, we need to see how it's stored inside the system, and how a blockchain is built from it.بعد أن أصبح السجل محميا من القراءة المباشرة نحتاج إلى معرفة كيف يحفظ داخل النظام وكيف تتكون منه سلسلة كتل