java.lang.Object
net.i2p.crypto.eddsa.Utils
Basic utilities for EdDSA. Not for external use, not maintained as a public API.
Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic intbit(byte[] h, int i) The i'th bit of a byte array.static StringbytesToHex(byte[] raw) Converts bytes to a hex string.static intequal(byte[] b, byte[] c) Constant-time byte[] comparison.static intequal(int b, int c) Constant-time byte comparison.static byte[]hexToBytes(String s) Converts a hex string to bytes.static intnegative(int b) Constant-time determine if byte is negative.
Constructor Details
Utils
public Utils()Every helper below is static, so an instance carries nothing.
Method Details
equal
public static int equal(int b, int c) Constant-time byte comparison.- Parameters:
b- the first value; only its low 8 bits, which carry the byte, are comparedc- the second value; only its low 8 bits, which carry the byte, are compared- Returns:
- 1 if b and c are equal, 0 otherwise.
equal
public static int equal(byte[] b, byte[] c) Constant-time byte[] comparison.- Parameters:
b- a byte[]c- a byte[]- Returns:
- 1 if b and c are equal, 0 otherwise.
negative
public static int negative(int b) Constant-time determine if byte is negative.- Parameters:
b- the byte to check.- Returns:
- 1 if the byte is negative, 0 otherwise.
bit
public static int bit(byte[] h, int i) The i'th bit of a byte array.- Parameters:
h- The byte array.i- The bit index.- Returns:
- 0 or 1, the value of the i'th bit in h.
hexToBytes
Converts a hex string to bytes.- Parameters:
s- the hex string to be converted.- Returns:
- the byte[]
bytesToHex
Converts bytes to a hex string.- Parameters:
raw- the byte[] to be converted.- Returns:
- the hex representation as a string.