This week have been full of testing, finding bugs resolving issues and finally merging the Banderwagon curve to the constantine library. While testing I was scrating my head for a 2 days as no matter what I tried, the tests were failing. Later after much searching here and there & fidgeting with the code I realized that I mis-interpreted the serialization specs and thus the tests were failing. After correcting the serialization specs, the tests were passing. PS - Do not worry about the serialization specs, in my previous blog, those have been corrected later. So this week I worked on the following things:

  • Adding the generator for the Banderwagon curve
  • Adding the pre-compute for $\frac{p-1}{2}$ for the Banderwagon curve
  • Testing the serialization and deserialization of the points on the Banderwagon curve
  • Testing the subgroup check for the points on the Banderwagon curve
  • Testing the point doubling, addition, subtraction for the points on the Banderwagon curve
  • Testing the equality check using two torsion points on the Banderwagon curve
  • Finally getting the PR approved from @mamy and merging it to the constantine library

Track the issue -> here and the PR -> here.

Let us explore the testing approach

In abstract terms, the provided code is a set of tests for a software library that deals with elliptic curve cryptography (ECC). These tests aim to ensure the correctness and reliability of the ECC library by checking various aspects of its functionality:

  1. Serialization Tests: These tests verify that the library can correctly convert ECC points into a format that can be stored or transmitted, and then convert them back to their original form without loss of information. It also checks if the library can detect points that do not belong to the ECC curve.
  2. Banderwagon Points Tests: This suite focuses on verifying the correctness of ECC point operations, such as addition, subtraction, and doubling. It also checks whether points that differ by certain characteristics (two-torsion points) are considered equal, which is important for ECC security.

Overall, these tests are essential for ensuring that the ECC library performs as expected and can be trusted in cryptographic applications where data security is critical. They help identify and prevent potential issues or vulnerabilities in the library’s ECC implementation.

Details of Test’s Structure

  1. Test Suite Setup:
    • The code begins with several import statements, bringing in necessary modules and libraries.
    • It defines custom types, EC and Bytes, which seem to be related to ECC operations and byte arrays, respectively.
  2. Generator Point:
    • The code initializes a generator point from some source called “Banderwagon.”
    • It also defines two arrays of serialized point representations: expected_bit_strings and bad_bit_string. These arrays likely contain serialized ECC points in hexadecimal format.
  3. Serialization Tests:
    • A test suite titled “Banderwagon Serialization Tests” is defined.
    • Within this suite, there are several tests related to serialization and deserialization of ECC points:
      • Test Encoding from Fixed Vectors: This test serializes ECC points using a loop and checks if the serialized representations match the expected bit strings.
      • Decoding Each bit string: This test deserializes the previously serialized ECC points and checks if the deserialized points match the original ones.
      • Decoding Points Not on Curve: This test checks if points that are not on the ECC curve result in errors during deserialization, specifically the error cttCodecEcc_PointNotInSubgroup.
  4. Banderwagon Points Tests:
    • A test suite titled “Banderwagon Points Tests” is defined.
    • Within this suite, there are two tests:
      • Test for Addition, Subtraction, Doubling: This test checks the consistency of ECC point addition, subtraction, and doubling operations.
      • Test Two Torsion Equality: This test verifies that points that differ by a two-torsion point (a point with order 2) are considered equal.


This marks the completion of the first phase of our project proposal 🔥