Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Implement ProjectivePoint and improved docs. #56

Merged
merged 71 commits into from
Jul 10, 2019
Merged

Commits on Jul 4, 2019

  1. Define ProjectivePoint struct and implement Debug for it

    A `ProjectivePoint` represents a point on the Doppio Curve expressed
    over the Twisted Edwards Projective Coordinates eg. (X, Y, Z).
    CPerezz committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    c86ecb7 View commit details
    Browse the repository at this point in the history
  2. Implement Default and Identity traits for ProjectivePoint

    `Default` returns the `Identity` impl for `ProjectivePoint`
    which gives back: (0,1,1)
    CPerezz committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    08a23d9 View commit details
    Browse the repository at this point in the history
  3. Implement Into trait for ProjectivePoint

    This performs the conversion from a ProjectivePoint
    into an `EdwardsPoint` one.
    CPerezz committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    a683322 View commit details
    Browse the repository at this point in the history
  4. Implement From trait for ProjectivePoint

    - Allows us to perform the conversion from an
    `EdwardsPoint` to a `ProjectivePoint`.
    
    Given (X:Y:T:Z) in εε, passing to ε is cost-free by
    simply ignoring `T`.
    
    Twisted Edwards Curves Revisited -
    Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter,
    and Ed Dawson, Section 3.
    CPerezz committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    f784267 View commit details
    Browse the repository at this point in the history
  5. Implement Point Doubling for ProjectivePoint

    Source: 2008 Hisil–Wong–Carter–Dawson,
    http://eprint.iacr.org/2008/522, Section 3.1.
    Cost: 3M+ 4S+ +7a + 1D
    CPerezz committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    cec2468 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d56cb5a View commit details
    Browse the repository at this point in the history
  7. Add tests for conversions between Projective and Extended

    These conevrsions are implemented on the `From`
    trait implementations.
    CPerezz committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    bdb0117 View commit details
    Browse the repository at this point in the history

Commits on Jul 5, 2019

  1. Configuration menu
    Copy the full SHA
    dc3f4ff View commit details
    Browse the repository at this point in the history
  2. Implement Neg for ProjectivePoint

    The neg operation perfoms the Negation over
    Twisted Edwards Projective Coordinates, giving
    back (-X, Y, Z) as a result.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    0db4294 View commit details
    Browse the repository at this point in the history
  3. Implement Add for ProjectivePoint

    This implementation executes the point
    addition operation over the Doppio
    Curve between two points expressed
    on Porjective Twisted Edwards Coordinates.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    33666d0 View commit details
    Browse the repository at this point in the history
  4. Add Tests comment separator.

    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    f9fcc41 View commit details
    Browse the repository at this point in the history
  5. Implement tests for ProjectivePoint negation

    Tested:
    - Random point negation.
    - Identity negation.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    809d7d1 View commit details
    Browse the repository at this point in the history
  6. Define testing Point values in Projective Coordinates

    On this way, we don't need to use Point conversions
    on every test (which are already being tested on
    other tests).
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    3a4aabf View commit details
    Browse the repository at this point in the history
  7. [WIP] Implement tests for Projective Point addition

    Tests are failing, so we will review the paper again
    to see what we are missing.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    529fadd View commit details
    Browse the repository at this point in the history
  8. Implement Add for FieldElement by value

    This implementation calls to the
    `Add<&'a FieldElement> for &'b FieldElement`.
    
    The implementation intends to make the point
    implementations easier, avoiding the &(&(&()))
    problem.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    ea7dc37 View commit details
    Browse the repository at this point in the history
  9. Implement Traits for FieldElement without references

    The implementation intends to make the point
    implementations easier, avoiding the &(&(&()))
    problem.
    
    Traits implemented:
    - Add
    - Sub
    - Mul
    - Neg
    
    This closes #47 on the field part.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    ba752d3 View commit details
    Browse the repository at this point in the history
  10. Improve docs for Mul implementation

    Added a short description about how the mul
    function works. And which usage makes
    of the Montgomery Reduction.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    121b903 View commit details
    Browse the repository at this point in the history
  11. Implement Add for Scalar for non-reference values

    The implementation intends to make the point
    implementations easier, avoiding the &(&(&()))
    problem mentioned on #47.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    adddfeb View commit details
    Browse the repository at this point in the history
  12. Implement Mul for Scalar

    The implementation intends to make the point
    implementations easier, avoiding the &(&(&()))
    problem mentioned on #47 .
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    1a131a1 View commit details
    Browse the repository at this point in the history
  13. Implement Neg for Scalar and &Scalar

    Following the guidelines specified on #47 ,
    negate trait is implemented for Scalar and
    a reference of it.
    
    Performs the negation operation over the
    modular field formed by the prime of the
    sub-group.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    cd2eb27 View commit details
    Browse the repository at this point in the history
  14. Implement Identity for Scalar

    The identity function implemented for
    `Scalar` returns the identity element
    of the field = `1 (mod l)`.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    3aab967 View commit details
    Browse the repository at this point in the history
  15. Implement Square for &Scalar

    Square performs the operation `a^2` for
    whatever element of the field generated
    by the prime of the sub-group.
    
    NOTE: Here we don't implement it fo `Scalar`
    also (as said in #47) because it only has one
    operator, se we are not winning anything.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    286dfa2 View commit details
    Browse the repository at this point in the history
  16. Refactor Mul tests for Scalar implementation

    Refactored some of the tests of the `Scalar`
    tests mod. According to the new `ops` trait
    implementations.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    bf8f861 View commit details
    Browse the repository at this point in the history
  17. Implement tests for squaring impl for Scalar

    - Squaring a random Scalar.
    - Square the identity element.
    - Square the null element.
    
    All passed.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    aaf23ae View commit details
    Browse the repository at this point in the history
  18. Improve Identity trait def and create Square trait.

    Created `Square` trait since it's an operation
    that has to be performed a lot of times for
    different elements of the lib such as:
    - FieldElement
    - Scalar
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    fbf52c4 View commit details
    Browse the repository at this point in the history
  19. Implement square_internal() for FieldElement

    This operation returns a double_precision result
    expressed on: `[u128; 9]` with the result of the
    squaring.
    CPerezz committed Jul 5, 2019
    Configuration menu
    Copy the full SHA
    7c16654 View commit details
    Browse the repository at this point in the history

Commits on Jul 6, 2019

  1. Implement tests for Square impl for &FieldElement

    Implemented tests for
    - Random FieldElement squaring.
    - Identity element squaring.
    - Null element squaring.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    f718b6e View commit details
    Browse the repository at this point in the history
  2. Fix doc-comments & Change internal fn visibility for Scalar

    Since there's not any need for the final user for
    using the internal functions (even it can be a
    problem if hasn't the knowledge of what they do),
    the visibility of them has been hidden/reduced to
    it's module only using `(self)`.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    454471c View commit details
    Browse the repository at this point in the history
  3. Fix doc-comments & Change internal fn visibility for Scalar & FieldEl…

    …ement
    
    Since there's not any need for the final user for
    using the internal functions (even it can be a
    problem if hasn't the knowledge of what they do),
    the visibility of them has been hidden/reduced to
    it's module only using `(self)`.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    789690a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3996fe6 View commit details
    Browse the repository at this point in the history
  5. Add #[cfg(test)] for edwards.rs tests module

    This makes that edwards tests will only be run
    if `cargo test` is executed, but will never be
    executed when `cargo build` is executed.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    7fde279 View commit details
    Browse the repository at this point in the history
  6. Benchmark all FieldElement and Scalar basic ops.

    Refactored and re-ordered all of the Criterion tests
    in oder to improve them.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    646dc10 View commit details
    Browse the repository at this point in the history
  7. Implement Benchmarks for Twisted Edwards Extended Coordinates Point ops

    Refactored and re-ordered all of the Criterion tests
    in oder to improve them.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    eb66db5 View commit details
    Browse the repository at this point in the history
  8. Implement Point Addition for ProjectivePoint.

    Following guidelines of #47 we've implemented
    addition for reference, and non-reference
    ProjectivePoints.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    9aceeab View commit details
    Browse the repository at this point in the history
  9. Add debug_assert macro on half() function for FieldElement

    This is intended to prevent users to try
    to use numbers greater than 260 as exp.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    f2b3ac6 View commit details
    Browse the repository at this point in the history
  10. Implement Sub for ProjectivePoint

    Note that the sub implementation is just
    the addition but negating the second point.
    
    The trait has been implemented following #47
    suggestions.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    a842a00 View commit details
    Browse the repository at this point in the history
  11. Declare DoubleAndAdd trait on edwards.rs

    This trait intends to be the generical one
    for the double_and_add algorithm for the
    different types of points on the Doppio
    curve.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    3e6dfff View commit details
    Browse the repository at this point in the history
  12. Create Double op trait and impl for EdwardsPoint

    Created `Double` trait since it will be used by
    all of the different Point Coordinates
    declared on this library.
    CPerezz committed Jul 6, 2019
    Configuration menu
    Copy the full SHA
    b0d9bd6 View commit details
    Browse the repository at this point in the history

Commits on Jul 7, 2019

  1. Impl double_and_add for T

    Implemented `double_and_add()` as a generic
    fn for types that implement `Add`, `Double`,
    `Identity` and `Clone`.
    CPerezz committed Jul 7, 2019
    Configuration menu
    Copy the full SHA
    d258b66 View commit details
    Browse the repository at this point in the history
  2. Move traits and impl Double on traits.rs

    Added a math module inside of tratis.rs file.
    CPerezz committed Jul 7, 2019
    Configuration menu
    Copy the full SHA
    282ea8a View commit details
    Browse the repository at this point in the history
  3. Define Half trait on traits.rs.

    Since various types implement it, it's better
    to implement half operation as a trait and impl
    it for the types that need it.
    CPerezz committed Jul 7, 2019
    Configuration menu
    Copy the full SHA
    fe6e5b4 View commit details
    Browse the repository at this point in the history
  4. Implement Half trait for FieldElement

    Made the implementation for `&FieldElement`.
    CPerezz committed Jul 7, 2019
    Configuration menu
    Copy the full SHA
    f112b0b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    8144f5a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1ad497a View commit details
    Browse the repository at this point in the history
  7. Impl Div trait for &FieldElement

    Performs the op: `x / y (mod l)`.
    Since on modular fields we don't divide, the equivanelnt op
    is: `x * (y^-1 (mod l))`, which is equivalent to the naive
    division but for Finite Fields.
    CPerezz committed Jul 7, 2019
    Configuration menu
    Copy the full SHA
    6fbbbb8 View commit details
    Browse the repository at this point in the history
  8. Implement Div for non reference FieldElement

    This follows #47 guidelines.
    
    Performs the op: `x / y (mod l)`.
    Since on modular fields we don't divide, the equivanelnt op
    is: `x * (y^-1 (mod l))`, which is equivalent to the naive
    division but for Finite Fields.
    CPerezz committed Jul 7, 2019
    Configuration menu
    Copy the full SHA
    e7104d7 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    991b605 View commit details
    Browse the repository at this point in the history

Commits on Jul 8, 2019

  1. Configuration menu
    Copy the full SHA
    51b6eec View commit details
    Browse the repository at this point in the history
  2. Implement test for Div impl for FieldElement

    Implemented a test where we compute the EDWARDS_D
    constant value which equals: `(-86649/86650) mod l`.
    
    This completely verifies that the trait impl is working
    when performing `x*inverse_mod(y, l) mod l`.
    CPerezz committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    d7caad3 View commit details
    Browse the repository at this point in the history
  3. Add assert! check in two_pow_k()

    In order to avoid errors on end-users site,
    change the debug_assert! by assert! to make
    the lib panic.
    CPerezz committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    d700910 View commit details
    Browse the repository at this point in the history
  4. Implement FieldElement security checks not only for debug builds.

    In order to avoid end-user implementation errors,
    add `assert!` for `debug_assert!` statements.
    
    This has been done on:
    
    - Div impl when dividing by zero.
    - Half if the input is not even.
    CPerezz committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    17b3cc4 View commit details
    Browse the repository at this point in the history
  5. Impl assert! instead of debug_assert! for Scalars

    This is done to avoid errors on final user
    implementations.
    CPerezz committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    d10c467 View commit details
    Browse the repository at this point in the history
  6. Fix doc err on empty line

    CPerezz committed Jul 8, 2019
    Configuration menu
    Copy the full SHA
    999d46e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    8450e4f View commit details
    Browse the repository at this point in the history

Commits on Jul 9, 2019

  1. Configuration menu
    Copy the full SHA
    38bf29a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a20ed03 View commit details
    Browse the repository at this point in the history
  3. Implement two_pow_k() for &Scalar

    This function provides support to some
    `edwards.rs` functions as well as it is
    also a way of constructing an Scalar.
    
    The function is inlined and documented.
    CPerezz committed Jul 9, 2019
    Configuration menu
    Copy the full SHA
    9ba89d0 View commit details
    Browse the repository at this point in the history
  4. Impl mul_by_pow_2() for &EdwardsPoint

    The function multiplies an `EdwardsPoint`
    for an Scalar in the form: `2^x`.
    CPerezz committed Jul 9, 2019
    Configuration menu
    Copy the full SHA
    a08f203 View commit details
    Browse the repository at this point in the history
  5. Impl mul_by_cofactor() for &EdwardsPoint

    This function returns the given `EdwardsPoint`
    multiplied by the cofactor `h = 8`.
    CPerezz committed Jul 9, 2019
    Configuration menu
    Copy the full SHA
    dafd791 View commit details
    Browse the repository at this point in the history
  6. Inline two_pok_k() function

    CPerezz committed Jul 9, 2019
    Configuration menu
    Copy the full SHA
    afd5db0 View commit details
    Browse the repository at this point in the history

Commits on Jul 10, 2019

  1. Define generic Edwards functions on edwards.rs

    As did in d258b66, we have implemented functions
    that are generic for all of the Edwards Points
    for generic traits.
    
    In this case, we've done it for:
    - `mul_by_cofactor()`
    - `mul_by_pow_2()`
    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    e407f46 View commit details
    Browse the repository at this point in the history
  2. WIP repo.

    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    812f397 View commit details
    Browse the repository at this point in the history
  3. Implement Double trait for &ProjectivePoint.

    Refactored all of the test and ignored the ones non-
    working until we find the errors.
    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    0e8f659 View commit details
    Browse the repository at this point in the history
  4. Implement Mul trait for &ProjectiveEdwards.

    This closes the development part of #32.
    
    Scalar multiplication: compute `Scalar * self`.
    This implementation uses the algorithm:
    `add_and_doubling` which is the standard one for
    this operations and also adds less constraints on
    R1CS.
    
    Hankerson, Darrel; Vanstone, Scott; Menezes, Alfred (2004).
    Guide to Elliptic Curve Cryptography.
    Springer Professional Computing. New York: Springer-Verlag.
    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    d698aaa View commit details
    Browse the repository at this point in the history
  5. Merge branch 'docs' into provective_edws

    Accepted incoming changes to `field.rs` file.
    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    463d85d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ca65356 View commit details
    Browse the repository at this point in the history
  7. Add algorithm references

    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    526b858 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    c93ec53 View commit details
    Browse the repository at this point in the history
  9. Impl assert! statement on inverse

    In order to avoid end-user errors, we check that
    the divisor != 0.
    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    45effe9 View commit details
    Browse the repository at this point in the history
  10. Impl Benchmarks for ProjectivePoint vs EdwardsPoint

    This closes #49.
    
    Benchmarks are done for all of the ops traits
    implemented for each type.
    
    Operations have been performed with the same inputs.
    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    97aa478 View commit details
    Browse the repository at this point in the history
  11. Add latest compiled docs.

    CPerezz committed Jul 10, 2019
    Configuration menu
    Copy the full SHA
    6e3cb6b View commit details
    Browse the repository at this point in the history