Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary doubling condition #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ashWhiteHat
Copy link

Hi there
I found unnecessary condition branch.

Projective identity is $(x, y, z) = (0, 1, 0)$ and doubling is as follows.

let t0 = self.y.square();
let z3 = t0 + t0;
let z3 = z3 + z3;
let z3 = z3 + z3;
let t1 = self.y * self.z;
let t2 = self.z.square();
let t2 = mul_by_3b(t2);
let x3 = t2 * z3;
let y3 = t0 + t2;
let z3 = t1 * z3;
let t1 = t2 + t2;
let t2 = t1 + t2;
let t0 = t0 - t2;
let y3 = t0 * y3;
let y3 = x3 + y3;
let t1 = self.x * self.y;
let x3 = t0 * t1;
let x3 = x3 + x3;

let tmp = G1Projective {
    x: x3,
    y: y3,
    z: z3,
};

G1Projective::conditional_select(&tmp, &G1Projective::identity(), self.is_identity())
  • Arithmetic Trace

$(x, y, z) = (0, 1, 0)$

t0 = 1 (y^2)
z3 = 2 (t0 + t0)
z3 = 4 (z3 + z3)
t1 = 0 (y * z)
t2 = 0 (z^2)
t2 = 0 (t2 * 12)
x3 = 0 (t2 * z3)
y3 = 1 (t0 + t2)
z3 = 0 (t1 * z3)
t1 = 0 (t2 + t2)
t2 = 0 (t1 + t2)
t0 = 1 (t0 - t2)
y3 = 1 (t0 * y3)
y3 = 1 (x3 + y3)
t1 = 0 (x * y)
x3 = 0 (t0 * t1)
x3 = 0 (x3 + x3)

$(x3, y3, z3) = (0, 1, 0)$

double arithmetic covers the identity case.

  • Other Concerns

Field double is faster than add
add_mixed identity condition may not necessary

I would appreciate it if you could confirm.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant