/** * Clone a 2d byte array. * * @param in 2d byte array. * @return Copy of 2d byte array. */ public static byte[][] cloneArray(byte[][] in) { if (hasNullPointer(in)) { throw new NullPointerException("in has null pointers"); } byte[][] out = new byte[in.length][]; for (int i = 0; i < in.length; i++) { out[i] = new byte[in[i].length]; System.arraycopy(in[i], 0, out[i], 0, in[i].length); } return out; }
/** * Compares two 2d-byte arrays. * * @param a 2d-byte array 1. * @param b 2d-byte array 2. * @return true if all values in 2d-byte array are equal false else. */ public static boolean areEqual(byte[][] a, byte[][] b) { if (hasNullPointer(a) || hasNullPointer(b)) { throw new NullPointerException("a or b == null"); } for (int i = 0; i < a.length; i++) { if (!Arrays.areEqual(a[i], b[i])) { return false; } } return true; }
/** * Dump content of 2d byte array. * * @param x byte array. */ public static void dumpByteArray(byte[][] x) { if (hasNullPointer(x)) { throw new NullPointerException("x has null pointers"); } for (int i = 0; i < x.length; i++) { System.out.println(Hex.toHexString(x[i])); } }
protected WOTSPlusPrivateKeyParameters(WOTSPlusParameters params, byte[][] privateKey) { super(); if (params == null) { throw new NullPointerException("params == null"); } if (privateKey == null) { throw new NullPointerException("privateKey == null"); } if (XMSSUtil.hasNullPointer(privateKey)) { throw new NullPointerException("privateKey byte array == null"); } if (privateKey.length != params.getLen()) { throw new IllegalArgumentException("wrong privateKey format"); } for (int i = 0; i < privateKey.length; i++) { if (privateKey[i].length != params.getDigestSize()) { throw new IllegalArgumentException("wrong privateKey format"); } } this.privateKey = XMSSUtil.cloneArray(privateKey); }
protected WOTSPlusSignature(WOTSPlusParameters params, byte[][] signature) { super(); if (params == null) { throw new NullPointerException("params == null"); } if (signature == null) { throw new NullPointerException("signature == null"); } if (XMSSUtil.hasNullPointer(signature)) { throw new NullPointerException("signature byte array == null"); } if (signature.length != params.getLen()) { throw new IllegalArgumentException("wrong signature size"); } for (int i = 0; i < signature.length; i++) { if (signature[i].length != params.getDigestSize()) { throw new IllegalArgumentException("wrong signature format"); } } this.signature = XMSSUtil.cloneArray(signature); }
protected WOTSPlusPublicKeyParameters(WOTSPlusParameters params, byte[][] publicKey) { super(); if (params == null) { throw new NullPointerException("params == null"); } if (publicKey == null) { throw new NullPointerException("publicKey == null"); } if (XMSSUtil.hasNullPointer(publicKey)) { throw new NullPointerException("publicKey byte array == null"); } if (publicKey.length != params.getLen()) { throw new IllegalArgumentException("wrong publicKey size"); } for (int i = 0; i < publicKey.length; i++) { if (publicKey[i].length != params.getDigestSize()) { throw new IllegalArgumentException("wrong publicKey format"); } } this.publicKey = XMSSUtil.cloneArray(publicKey); }