test_class.file: tx-signer/src/test/java/io/bytom/offline/common/NonHardenedChildTest.java
test_class.identifier: NonHardenedChildTest
test_case.body: @Test
      public void testNHChild() throws NoSuchAlgorithmException, SignatureException, InvalidKeyException {
          String hxprv = "10fdbc41a4d3b8e5a0f50dd3905c1660e7476d4db3dbd9454fa4347500a633531c487e8174ffc0cfa76c3be6833111a9b8cd94446e37a76ee18bb21a7d6ea66b";
          byte[] xprv = Hex.decode(hxprv);
          //expected: d9c7b41f030a398dada343096040c675be48278046623849977cb0fd01d395a51c487e8174ffc0cfa76c3be6833111a9b8cd94446e37a76ee18bb21a7d6ea66b
          String[] hpaths = {"010400000000000000", "0100000000000000"};
          byte[][] paths = new byte[][]{
                  Hex.decode(hpaths[0]),
                  Hex.decode(hpaths[1])
          };
          byte[] res = xprv;
          for (int i = 0; i < hpaths.length; i++) {
              byte[] xpub = DeriveXpub.deriveXpub(res);
  //            System.out.println("xpub: "+Hex.toHexString(xpub));
              res = NonHardenedChild.nhChild(paths[i], res, xpub);
          }
          //expected: e8c0965af60563c4cabcf2e947b1cd955c4f501eb946ffc8c3447e5ec8a6335398a3720b3f96077fa187fdde48fe7dc293984b196f5e292ef8ed78fdbd8ed954
          //          e8c0965af60563c4cabcf2e947b1cd955c4f501eb946ffc8c3447e5ec8a6335398a3720b3f96077fa187fdde48fe7dc293984b196f5e292ef8ed78fdbd8ed954
      }
test_case.class_method_signature: NonHardenedChildTest.testNHChild()
test_case.full_signature: @Test public void testNHChild()
test_case.identifier: testNHChild
test_case.invocations: decode decode decode deriveXpub nhChild
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testNHChild()
focal_class.file: tx-signer/src/main/java/io/bytom/offline/common/NonHardenedChild.java
focal_class.identifier: NonHardenedChild
focal_class.class_method_signature: NonHardenedChild.hmacSha512(byte[] data, byte[] key)
focal_class.full_signature: private static byte[] hmacSha512(byte[] data, byte[] key)
focal_class.identifier: hmacSha512
focal_class.modifiers: private static
focal_class.parameters: (byte[] data, byte[] key)
focal_class.return: byte[]
focal_class.signature: byte[] hmacSha512(byte[] data, byte[] key)
focal_class.class_method_signature: NonHardenedChild.nhChild(byte[] path, byte[] xprv, byte[] xpub)
focal_class.full_signature: public static byte[] nhChild(byte[] path, byte[] xprv, byte[] xpub)
focal_class.identifier: nhChild
focal_class.modifiers: public static
focal_class.parameters: (byte[] path, byte[] xprv, byte[] xpub)
focal_class.return: byte[]
focal_class.signature: byte[] nhChild(byte[] path, byte[] xprv, byte[] xpub)
focal_class.class_method_signature: NonHardenedChild.pruneIntermediateScalar(byte[] f)
focal_class.full_signature: private static byte[] pruneIntermediateScalar(byte[] f)
focal_class.identifier: pruneIntermediateScalar
focal_class.modifiers: private static
focal_class.parameters: (byte[] f)
focal_class.return: byte[]
focal_class.signature: byte[] pruneIntermediateScalar(byte[] f)
focal_class.class_method_signature: NonHardenedChild.child(byte[] xprv, String[] hpaths)
focal_class.full_signature: public static byte[] child(byte[] xprv, String[] hpaths)
focal_class.identifier: child
focal_class.modifiers: public static
focal_class.parameters: (byte[] xprv, String[] hpaths)
focal_class.return: byte[]
focal_class.signature: byte[] child(byte[] xprv, String[] hpaths)
focal_method.body: public static byte[] nhChild(byte[] path, byte[] xprv, byte[] xpub) throws NoSuchAlgorithmException, InvalidKeyException {
          // begin build data
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          out.write('N');
          out.write(xpub, 0, xpub.length / 2);
          out.write(path, 0, path.length);
          byte[] data = out.toByteArray();
          // end build data
  
          // begin build key
          byte[] key = new byte[xpub.length / 2];
          System.arraycopy(xpub, xpub.length / 2, key, 0, xpub.length / 2);
          // end build key
  
          // doFinal()
          byte[] res = hmacSha512(data, key);
  
          //begin operate res[:32]
          byte[] f = new byte[res.length / 2];
          System.arraycopy(res, 0, f, 0, res.length / 2);
          f = pruneIntermediateScalar(f);
          System.arraycopy(f, 0, res, 0, res.length / 2);
          //end operate res[:32]
  
          //begin operate res[:32] again
          int carry = 0;
          int sum = 0;
          for (int i = 0; i < 32; i++) {
              int xprvInt = xprv[i] & 0xFF;
              int resInt = res[i] & 0xFF;
              sum = xprvInt + resInt + carry;
              res[i] = (byte) sum;
              carry = sum >> 8;
          }
          if ((sum >> 8) != 0) {
              System.err.println("sum does not fit in 256-bit int");
          }
          //end operate res[:32] again
          return res;
      }
focal_method.class_method_signature: NonHardenedChild.nhChild(byte[] path, byte[] xprv, byte[] xpub)
focal_method.full_signature: public static byte[] nhChild(byte[] path, byte[] xprv, byte[] xpub)
focal_method.identifier: nhChild
focal_method.invocations: write write write toByteArray arraycopy hmacSha512 arraycopy pruneIntermediateScalar arraycopy println
focal_method.modifiers: public static
focal_method.parameters: (byte[] path, byte[] xprv, byte[] xpub)
focal_method.return: byte[]
focal_method.signature: byte[] nhChild(byte[] path, byte[] xprv, byte[] xpub)