Last active
May 1, 2020 21:55
-
-
Save jwasinger/c03e2c30ed02ba6c1cc291cba6f1e27b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
function addmod384(x_offset, y_offset, mod_offset) { | |
/* stub for future evm opcode */ | |
} | |
function submod384(x_offset, y_offset, mod_offset) { | |
/* stub for future evm opcode */ | |
} | |
function mulmodmont384(x_offset, y_offset, mod_offset, inv_offset) { | |
/* stub for future evm opcode */ | |
} | |
function f6m_mul(x_offset, y_offset, mod_offset, inv_offset) { | |
// translate https://github.com/iden3/wasmsnark/blob/master/src/build_f3m.js#L125-L189 | |
let a = x_offset; | |
let b = x_offset + sizef1; | |
let c = x_offset + 2 * sizef1; | |
let A = y_offset; | |
let B = y_offset + sizef1; | |
let C = y_offset + 2 * sizef1; | |
let r_0 = ret_offset; | |
let r_1 = ret_offset + sizef1; | |
let r_2 = ret_offset + 2 * sizef1; | |
// TODO figure out allocation for local variables aA, bB, ... | |
/* | |
f6m_pseudocode: | |
aA = a * A | |
bB = b * B | |
cC = c * C | |
a_b = a + b | |
A_B = A + B | |
a_c = a + c | |
A_C = A + C | |
b_c = b + c | |
B_C = B + C | |
aA_bB = aA + bB | |
aA_cC = aA + cC | |
bB_cC = bB + cC | |
r_0 = b_c + B_C | |
r_0 = r_0 - bB_cC | |
r_0 = mulNonResidue(r_0) | |
r_0 = aA + r_0 | |
r_1 = a_b * A_B | |
r_1 = r_1 - aA_bB | |
AUX = mulNonResidue(cC) | |
r_1 = r_1 + AUX | |
r_2 = a_c + A_C | |
r_2 = r_2 - aA_cC | |
r_2 = r_2 + bB | |
*/ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment