Package net.i2p.crypto.eddsa
Class Utils
java.lang.Object
net.i2p.crypto.eddsa.Utils
Basic utilities for EdDSA.
Not for external use, not maintained as a public API.
- Since:
- 0.9.15
- Author:
- str4d
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intbit(byte[] h, int i) Get 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()
-
-
Method Details
-
equal
public static int equal(int b, int c) Constant-time byte comparison.- Parameters:
b- a bytec- a byte- 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) Get 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.
-