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.
Since:
0.9.15
Author:
str4d
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    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[]
    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 Details

    • Utils

      public Utils()
  • Method Details

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

      public static byte[] hexToBytes(String s)
      Converts a hex string to bytes.
      Parameters:
      s - the hex string to be converted.
      Returns:
      the byte[]
    • 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.