mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-04 23:03:08 +00:00
Fp12
This commit is contained in:
parent
fc2ea6281d
commit
adc8c33b0d
@ -5,8 +5,15 @@
|
||||
///
|
||||
/// h = fg + sh(f'g')
|
||||
/// h' = (f+f')(g+g') - fg - f'g'
|
||||
///
|
||||
/// Note: each symbol in the stack comments takes up six words
|
||||
|
||||
mul_Fp12:
|
||||
global mul_Fp12:
|
||||
|
||||
pre_mul:
|
||||
|
||||
|
||||
calc:
|
||||
%load_fp6(6)
|
||||
%load_fp6(18)
|
||||
%dup2_fp6
|
||||
@ -56,4 +63,5 @@ mul_Fp12:
|
||||
%add_fp6
|
||||
// stack: sh(f'g') + fg
|
||||
%store_fp6(24)
|
||||
JUMP
|
||||
|
||||
%jump(0xdeadbeef)
|
||||
|
||||
@ -1,4 +1,28 @@
|
||||
global mul_Fp6:
|
||||
macro mul_Fp6
|
||||
// stack: c0, c0_, c1, c1_, c2, c2_, d0, d0_, d1, d1_, d2, d2_
|
||||
SWAP3
|
||||
// stack: c1_, c0_, c1, c0, c2, c2_, d0, d0_, d1, d1_, d2, d2_
|
||||
SWAP11
|
||||
// stack: d2_, c0_, c1, c0, c2, c2_, d0, d0_, d1, d1_, d2, c1_
|
||||
SWAP4
|
||||
// stack: c2, c0_, c1, c0, d2_, c2_, d0, d0_, d1, d1_, d2, c1_
|
||||
SWAP9
|
||||
// stack: d1_, c0_, c1, c0, d2_, c2_, d0, d0_, d1, c2, d2, c1_
|
||||
SWAP7
|
||||
// stack: d0_, c0_, c1, c0, d2_, c2_, d0, d1_, d1, c2, d2, c1_
|
||||
SWAP10
|
||||
// stack: d2, c0_, c1, c0, d2_, c2_, d0, d1_, d1, c2, d0_, c1_
|
||||
SWAP6
|
||||
// stack: d0, c0_, c1, c0, d2_, c2_, d2, d1_, d1, c2, d0_, c1_
|
||||
SWAP2
|
||||
// stack: c1, c0_, d0, c0, d2_, c2_, d2, d1_, d1, c2, d0_, c1_
|
||||
SWAP8
|
||||
// stack: d1, c0_, d0, c0, d2_, c2_, d2, d1_, c1, c2, d0_, c1_
|
||||
SWAP1
|
||||
// stack: c0_, d1, d0, c0, d2_, c2_, d2, d1_, c1, c2, d0_, c1_
|
||||
SWAP5
|
||||
// stack: c2_, d1, d0, c0, d2_, c0_, d2, d1_, c1, c2, d0_, c1_
|
||||
SWAP1
|
||||
// stack: d1, c2_, d0, c0, d2_, c0_, d2, d1_, c1, c2, d0_, c1_
|
||||
DUP6
|
||||
// stack: c0_, d1, c2_, d0, c0, d2_, c0_, d2, d1_, c1, c2, d0_, c1_
|
||||
@ -316,4 +340,4 @@ global mul_Fp6:
|
||||
// stack: d2c0_ + d2_c0 + d0c2_ + d1c1_ + d1_c1 + d0_c2, 9d1c2_ + d1_c2 + d2c1_ + d2_c1 + d1c2 + d2c1 - d2_c1_ + d1_c2_ + d0c0 - d0_c0_, c0d1 + c1d0 + 9c2d2_ + c2_d2 - c2d2 - c2_d2_ - c0_d1_ + c1_d0_, c0d1_ + c0_d1 + c1d0_ + c1_d0 + 9c2d2 - c2_d2_ + c2d2_ + c2_d2, c0d2 + c1d1 + c2d0 - c0_d2_ + c1_d1_ + c2_d0_, 9d1c2 + d2c1 - d2_c1_ + d1_c2_ - d1c2_ + d1_c2 + d2c1_ + d2_c1 + c0d0_ + c0_d0
|
||||
SWAP5
|
||||
// stack: 9d1c2 + d2c1 - d2_c1_ + d1_c2_ - d1c2_ + d1_c2 + d2c1_ + d2_c1 + c0d0_ + c0_d0, 9d1c2_ + d1_c2 + d2c1_ + d2_c1 + d1c2 + d2c1 - d2_c1_ + d1_c2_ + d0c0 - d0_c0_, c0d1 + c1d0 + 9c2d2_ + c2_d2 - c2d2 - c2_d2_ - c0_d1_ + c1_d0_, c0d1_ + c0_d1 + c1d0_ + c1_d0 + 9c2d2 - c2_d2_ + c2d2_ + c2_d2, c0d2 + c1d1 + c2d0 - c0_d2_ + c1_d1_ + c2_d0_, d2c0_ + d2_c0 + d0c2_ + d1c1_ + d1_c1 + d0_c2
|
||||
%jump(0xdeadbeef)
|
||||
%endmacro
|
||||
|
||||
@ -9,8 +9,8 @@ use crate::cpu::kernel::interpreter::run_with_kernel;
|
||||
fn test_field() -> Result<()> {
|
||||
|
||||
let kernel = combined_kernel();
|
||||
let initial_offset = kernel.global_labels["mul_Fp6"];
|
||||
let initial_stack: Vec<U256> = vec![0, 0, 3, 1, 0, 1, 0, 1, 0, 1, 0, 0].iter().map(|&x| U256::from(x as u32)).rev().collect();
|
||||
let initial_offset = kernel.global_labels["mul_Fp12"];
|
||||
let initial_stack: Vec<U256> = vec![1, 1, 0, 0, 1, 0, 3, 0, 0, 1, 0, 0].iter().map(|&x| U256::from(x as u32)).rev().collect();
|
||||
let final_stack: Vec<U256> = run_with_kernel(&kernel, initial_offset, initial_stack)?
|
||||
.stack()
|
||||
.to_vec();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user