net.i2p.crypto.eddsa

## Class Utils

- java.lang.Object
- - net.i2p.crypto.eddsa.Utils

-     public class Utils
      extends Object

  Basic utilities for EdDSA. Not for external use, not maintained as a public API.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Utils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `bit(byte[] h, int i)` Get the i'th bit of a byte array.
    `static String` | `bytesToHex(byte[] raw)` Converts bytes to a hex string.
    `static int` | `equal(byte[] b, byte[] c)` Constant-time byte[] comparison.
    `static int` | `equal(int b, int c)` Constant-time byte comparison.
    `static byte[]` | `hexToBytes(String s)` Converts a hex string to bytes.
    `static int` | `negative(int b)` Constant-time determine if byte is negative.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Utils

          public Utils()

  - ### Method Detail

    - #### 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

    - #### bytesToHex

          public static String bytesToHex(byte[] raw)

      Converts bytes to a hex string.
      Parameters:
        `raw` - the byte[] to be converted.
      Returns:
        the hex representation as a string.

    - #### 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.

    - #### equal

          public static int equal(int b,
                                  int c)

      Constant-time byte comparison.
      Parameters:
        `b` - a byte
        `c` - a byte
      Returns:
        1 if b and c are equal, 0 otherwise.

    - #### hexToBytes

          public static byte[] hexToBytes(String s)

      Converts a hex string to bytes.
      Parameters:
        `s` - the hex string to be converted.
      Returns:
        the byte[]

    - #### 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.