mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-02 22:03:07 +00:00
merge successful
This commit is contained in:
parent
59ae7103a8
commit
d3986e6b50
@ -20,7 +20,7 @@ fn extract_stack(interpreter: Interpreter<'static>) -> Vec<U256> {
|
||||
.collect::<Vec<U256>>()
|
||||
}
|
||||
|
||||
fn run_bn_mul_fp6(f: Fp6<BN254>, g: Fp6<BN254>, label: &str) -> Vec<U256> {
|
||||
fn run_bn_mul_fp6(f: Fp6<BN254>, g: Fp6<BN254>, label: &str) -> Fp6<BN254> {
|
||||
let mut stack = f.to_stack();
|
||||
if label == "mul_fp254_6" {
|
||||
stack.extend(g.to_stack().to_vec());
|
||||
@ -52,7 +52,7 @@ fn test_bn_mul_fp6() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_bn_mul_fp12(f: Fp12<BN254>, g: Fp12<BN254>, label: &str) -> Vec<U256> {
|
||||
fn run_bn_mul_fp12(f: Fp12<BN254>, g: Fp12<BN254>, label: &str) -> Fp12<BN254> {
|
||||
let in0: usize = 100;
|
||||
let in1: usize = 112;
|
||||
let out: usize = 124;
|
||||
@ -118,7 +118,7 @@ fn test_bn_frob_fp6() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_bn_frob_fp12(f: Fp12<BN254>, n: usize) -> Vec<U256> {
|
||||
fn run_bn_frob_fp12(f: Fp12<BN254>, n: usize) -> Fp12<BN254> {
|
||||
let ptr: usize = 100;
|
||||
let setup = InterpreterMemoryInitialization {
|
||||
label: format!("test_frob_fp254_12_{}", n),
|
||||
|
||||
@ -25,12 +25,21 @@ impl<T: FieldExt> Curve<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: FieldExt + Stack> Curve<T> {
|
||||
pub fn on_stack(self) -> Vec<U256> {
|
||||
let mut stack = self.x.on_stack();
|
||||
stack.extend(self.y.on_stack());
|
||||
impl<T: FieldExt + Stack> Stack for Curve<T> {
|
||||
const SIZE: usize = 2 * T::SIZE;
|
||||
|
||||
fn to_stack(&self) -> Vec<U256> {
|
||||
let mut stack = self.x.to_stack();
|
||||
stack.extend(self.y.to_stack());
|
||||
stack
|
||||
}
|
||||
|
||||
fn from_stack(stack: &[U256]) -> Self {
|
||||
Curve {
|
||||
x: T::from_stack(&stack[0..T::SIZE]),
|
||||
y: T::from_stack(&stack[T::SIZE..2 * T::SIZE]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Curve<T>
|
||||
|
||||
@ -1225,7 +1225,7 @@ where
|
||||
pub trait Stack {
|
||||
const SIZE: usize;
|
||||
|
||||
fn to_stack(&self) -> &[U256];
|
||||
fn to_stack(&self) -> Vec<U256>;
|
||||
|
||||
fn from_stack(stack: &[U256]) -> Self;
|
||||
}
|
||||
@ -1233,9 +1233,8 @@ pub trait Stack {
|
||||
impl Stack for BN254 {
|
||||
const SIZE: usize = 1;
|
||||
|
||||
fn to_stack(&self) -> &[U256] {
|
||||
let boxed: Box<[U256]> = Box::new([self.val]);
|
||||
Box::leak(boxed)
|
||||
fn to_stack(&self) -> Vec<U256> {
|
||||
vec![self.val]
|
||||
}
|
||||
|
||||
fn from_stack(stack: &[U256]) -> BN254 {
|
||||
@ -1243,18 +1242,11 @@ impl Stack for BN254 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Stack for BN254 {
|
||||
fn on_stack(self) -> Vec<U256> {
|
||||
vec![self.val]
|
||||
}
|
||||
}
|
||||
|
||||
impl Stack for BLS381 {
|
||||
const SIZE: usize = 2;
|
||||
|
||||
fn to_stack(&self) -> &[U256] {
|
||||
let boxed: Box<[U256]> = Box::new([self.lo(), self.hi()]);
|
||||
Box::leak(boxed)
|
||||
fn to_stack(&self) -> Vec<U256> {
|
||||
vec![self.lo(), self.hi()]
|
||||
}
|
||||
|
||||
fn from_stack(stack: &[U256]) -> BLS381 {
|
||||
@ -1268,13 +1260,10 @@ impl Stack for BLS381 {
|
||||
impl<T: FieldExt + Stack> Stack for Fp2<T> {
|
||||
const SIZE: usize = 2 * T::SIZE;
|
||||
|
||||
fn to_stack(&self) -> &[U256] {
|
||||
let re = self.re.to_stack();
|
||||
let im = self.im.to_stack();
|
||||
let mut combined: Vec<U256> = Vec::new();
|
||||
combined.extend_from_slice(re);
|
||||
combined.extend_from_slice(im);
|
||||
Box::leak(combined.into_boxed_slice())
|
||||
fn to_stack(&self) -> Vec<U256> {
|
||||
let mut stack = self.re.to_stack();
|
||||
stack.extend(self.im.to_stack());
|
||||
stack
|
||||
}
|
||||
|
||||
fn from_stack(stack: &[U256]) -> Fp2<T> {
|
||||
@ -1293,16 +1282,11 @@ where
|
||||
{
|
||||
const SIZE: usize = 3 * Fp2::<T>::SIZE;
|
||||
|
||||
fn to_stack(&self) -> &[U256] {
|
||||
let t0 = self.t0.to_stack();
|
||||
let t1 = self.t1.to_stack();
|
||||
let t2 = self.t2.to_stack();
|
||||
|
||||
let mut combined: Vec<U256> = Vec::new();
|
||||
combined.extend_from_slice(t0);
|
||||
combined.extend_from_slice(t1);
|
||||
combined.extend_from_slice(t2);
|
||||
Box::leak(combined.into_boxed_slice())
|
||||
fn to_stack(&self) -> Vec<U256> {
|
||||
let mut stack = self.t0.to_stack();
|
||||
stack.extend(self.t1.to_stack());
|
||||
stack.extend(self.t2.to_stack());
|
||||
stack
|
||||
}
|
||||
|
||||
fn from_stack(stack: &[U256]) -> Self {
|
||||
@ -1322,14 +1306,10 @@ where
|
||||
{
|
||||
const SIZE: usize = 2 * Fp6::<T>::SIZE;
|
||||
|
||||
fn to_stack(&self) -> &[U256] {
|
||||
let z0 = self.z0.to_stack();
|
||||
let z1 = self.z1.to_stack();
|
||||
|
||||
let mut combined: Vec<U256> = Vec::new();
|
||||
combined.extend_from_slice(z0);
|
||||
combined.extend_from_slice(z1);
|
||||
Box::leak(combined.into_boxed_slice())
|
||||
fn to_stack(&self) -> Vec<U256> {
|
||||
let mut stack = self.z0.to_stack();
|
||||
stack.extend(self.z1.to_stack());
|
||||
stack
|
||||
}
|
||||
|
||||
fn from_stack(stack: &[U256]) -> Self {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user