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

ITEM 2 - Implement all of FieldElement and Scalar operations for non-reference values #47

Closed
CPerezz opened this issue Jul 5, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request invalid This doesn't seem right

Comments

@CPerezz
Copy link
Contributor

CPerezz commented Jul 5, 2019

This issue lives under the item: https://gitlab.dusk.network/dusk-org/tech/issues/2

Some implementations have the issue called Eye of Sauron by Dalek guys team on it's Curve25519 RustConf talk, which consists of something that looks like:

let A = &(&(&(&(&self.X + &self.Y) * &(&other.X + &other.Y)) - &C) - &D);

As can be seen, it turns out much more complex and uncomfortable to write these kinds of operatios.

This problem comes from the implementation of the Add and other Traits, which are always implemented for &'a TRAIT. So in order to avoid this, we should implement all of the FieldElement, Scalar, EdwardsPoint and ProjectivePoint for non-reference items.

@CPerezz CPerezz added enhancement New feature or request invalid This doesn't seem right labels Jul 5, 2019
@CPerezz CPerezz self-assigned this Jul 5, 2019
CPerezz added a commit that referenced this issue Jul 5, 2019
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 added a commit that referenced this issue Jul 5, 2019
The implementation intends to make the point
implementations easier, avoiding the &(&(&()))
problem mentioned on #47.
CPerezz added a commit that referenced this issue Jul 5, 2019
The implementation intends to make the point
implementations easier, avoiding the &(&(&()))
problem mentioned on #47 .
CPerezz added a commit that referenced this issue Jul 5, 2019
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 added a commit that referenced this issue Jul 5, 2019
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
Copy link
Contributor Author

CPerezz commented Jul 6, 2019

With the last commit, this issue can be closed, now we should refactor the Point operations to enable an easy to read version of them.

@CPerezz CPerezz closed this as completed Jul 6, 2019
CPerezz added a commit that referenced this issue Jul 6, 2019
Following guidelines of #47 we've implemented
addition for reference, and non-reference
ProjectivePoints.
CPerezz added a commit that referenced this issue Jul 6, 2019
Note that the sub implementation is just
the addition but negating the second point.

The trait has been implemented following #47
suggestions.
CPerezz added a commit that referenced this issue Jul 7, 2019
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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant