
org.whispersystems.curve25519.java.sc_cmov Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of curve25519-java Show documentation
Show all versions of curve25519-java Show documentation
Curve25519 library for Java
The newest version!
package org.whispersystems.curve25519.java;
public class sc_cmov {
/*
Replace (f,g) with (g,g) if b == 1;
replace (f,g) with (f,g) if b == 0.
Preconditions: b in {0,1}.
*/
public static void sc_cmov(byte[] f, byte[] g, byte b) {
int count;
byte[] x = new byte[32];
for (count = 0; count < 32; count++)
x[count] = (byte) (f[count] ^ g[count]);
b = (byte) -b;
for (count = 0; count < 32; count++)
x[count] &= b;
for (count = 0; count < 32; count++)
f[count] = (byte) (f[count] ^ x[count]);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy