mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 08:13:11 +00:00
clean
This commit is contained in:
parent
f225ea495d
commit
d928a70b6f
@ -1,4 +1,4 @@
|
||||
use std::ops::Add;
|
||||
use std::ops::{Add, Mul, Neg};
|
||||
|
||||
use ethereum_types::U256;
|
||||
use rand::Rng;
|
||||
@ -42,6 +42,38 @@ impl Add for Curve {
|
||||
}
|
||||
}
|
||||
|
||||
impl Neg for Curve {
|
||||
type Output = Curve;
|
||||
|
||||
fn neg(self) -> Self {
|
||||
Curve {
|
||||
x: self.x,
|
||||
y: -self.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<i32> for Curve {
|
||||
type Output = Curve;
|
||||
|
||||
fn mul(self, other: i32) -> Self {
|
||||
let mut result: Curve = self;
|
||||
if other.is_negative() {
|
||||
result = -result;
|
||||
}
|
||||
let mut multiplier = result;
|
||||
let mut exp = other.abs() as usize;
|
||||
while exp > 0 {
|
||||
if exp % 2 == 1 {
|
||||
result = result + multiplier;
|
||||
}
|
||||
exp >>= 1;
|
||||
multiplier = multiplier + multiplier;
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
// The twisted curve consists of pairs (x, y): (Fp2, Fp2) | y^2 = x^3 + 3/(9 + i)
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub struct TwistedCurve {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user