Created
May 11, 2022 20:51
-
-
Save imeckler/9cd2ec6bb7a6e77eedc838cf4933b7c7 to your computer and use it in GitHub Desktop.
Information for combine ZPrize
This file contains 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
fn combine( | |
g1: &[ark_pallas::Affine], | |
g2: &[ark_pallas::Affine], | |
chal: &[bool]) -> Vec<ark_pallas::Affine> { | |
let c = endo_challenge_to_field(chal); | |
g1.iter().zip(g2.iter()).map(|(p1, p2)| p1 + &p2.mul(c)) | |
.collect() | |
} | |
fn endo_challenge_to_field(chal: &[bool]) -> ark_pallas::Affine::ScalarField { | |
let length_in_bits: u64 = 128; | |
let mut a: F = 2_u64.into(); | |
let mut b: F = 2_u64.into(); | |
let one = F::one(); | |
let neg_one = -one; | |
for i in (0..(length_in_bits / 2)).rev() { | |
a.double_in_place(); | |
b.double_in_place(); | |
let s = if chal[2 * i] == false { &neg_one } else { &one }; | |
if chal[2 * i + 1] == false { | |
b += s; | |
} else { | |
a += s; | |
} | |
} | |
// endo_coeff is 0x397E65A7D7C1AD71AEE24B27E308F0A61259527EC1D4752E619D1840AF55F1B1 | |
// or in decimal, 26005156700822196841419187675678338661165322343552424574062261873906994770353 | |
a * endo_coeff + b | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment