@Test public void tvTest7() throws BipSss.NotEnoughSharesException, BipSss.InvalidContentTypeException, BipSss.IncompatibleSharesException { Collection<Share> shares = addShareWithId("SSS-2mghkBRhDnYVjuy9JkUN9SMWEQfFeizsE", "6b91", new ArrayList<Share>()); addShareWithId("SSS-2mghkFR2Fm7psBGPYC5EAUSG12QjgytWq", "6b91", shares); addShareWithId("SSS-2mghkHpD5x8D6t1CitLCgNxPzRxna7Dy3", "6b91", shares); addShareWithId("SSS-2mghkQUfD3xh51X8ZKWKG5kfD5UGtB3YW", "6b91", shares); addShareWithId("SSS-2mghkTDKSbL766zz4GDLHiK1LdQR5hQYo", "6b91", shares); addShareWithId("SSS-2mghkUTqvgNqEPVMnVP7eNT5UfJ39GVv2", "6b91", shares); addShareWithId("SSS-2mghkZgCcPUhDY9wagDry9kF32fEkYDdN", "6b91", shares); addShareWithId("SSS-2mghkbtcpPWx6Y2g4k7t8feZ2UX71AAUN", "6b91", shares); addShareWithId("SSS-2mghkhWxkj6oBWvQwXpXQVaDEZzCefrn7", "6b91", shares); addShareWithId("SSS-2mghkmwiADHSYZwokYBMEtkJRm53xUPcH", "6b91", shares); addShareWithId("SSS-2mghkqSiSaiPMp9R81A7yCeojoQnhbkuK", "6b91", shares); addShareWithId("SSS-2mghktFpVoXVKVLLrDVNRryYQwxJEzMKX", "6b91", shares); addShareWithId("SSS-2mghkuYfqfAheZu6ywXfGoFmwxnqw64yw", "6b91", shares); addShareWithId("SSS-2mghkzvNoX6AupKpt9n9PVRMgZ6FPUSLe", "6b91", shares); addShareWithId("SSS-2mghm2UGDwYuVYTSx9YYiYDCzeCmS2XGH", "6b91", shares); addShareWithId("SSS-2mghm6ePLVPJQhsryzUfst9RWochCXK5j", "6b91", shares); String result1 = BipSss.combine(shares); assertResult(result1, HexUtils.toBytes("7f34fc0d96fe07c01e28b183a5711805")); }
public static String combine(Collection<Share> shares) throws IncompatibleSharesException, NotEnoughSharesException, InvalidContentTypeException { if (shares.size() == 0) { throw new NotEnoughSharesException(1); } Iterator<Share> it = shares.iterator(); Share firstShare = it.next(); while (it.hasNext()) { Share share = it.next(); if (!share.isCompatible(firstShare)) { throw new IncompatibleSharesException(); } } if (firstShare.contentType != TYPE_BASE_58_STRING) { throw new InvalidContentTypeException(); } Collection<Share> unique = Share.removeDuplicateIndexes(shares); int threshold = unique.iterator().next().threshold; if (threshold > unique.size()) { throw new NotEnoughSharesException(threshold - unique.size()); } List<Share> selection = new ArrayList<Share>(); it = unique.iterator(); while (it.hasNext()) { selection.add(it.next()); if (selection.size() == threshold) { break; } } Gf256 gf = new Gf256(); List<Gf256.Share> gfShares = new ArrayList<Gf256.Share>(); for (Share s : selection) { gfShares.add(new Gf256.Share((byte) s.shareNumber, s.shareData)); } byte[] content = gf.combineShares(gfShares); return Base58.encodeWithChecksum(content); }
BipSss { public static String combine(Collection<Share> shares) throws IncompatibleSharesException, NotEnoughSharesException, InvalidContentTypeException { if (shares.size() == 0) { throw new NotEnoughSharesException(1); } Iterator<Share> it = shares.iterator(); Share firstShare = it.next(); while (it.hasNext()) { Share share = it.next(); if (!share.isCompatible(firstShare)) { throw new IncompatibleSharesException(); } } if (firstShare.contentType != TYPE_BASE_58_STRING) { throw new InvalidContentTypeException(); } Collection<Share> unique = Share.removeDuplicateIndexes(shares); int threshold = unique.iterator().next().threshold; if (threshold > unique.size()) { throw new NotEnoughSharesException(threshold - unique.size()); } List<Share> selection = new ArrayList<Share>(); it = unique.iterator(); while (it.hasNext()) { selection.add(it.next()); if (selection.size() == threshold) { break; } } Gf256 gf = new Gf256(); List<Gf256.Share> gfShares = new ArrayList<Gf256.Share>(); for (Share s : selection) { gfShares.add(new Gf256.Share((byte) s.shareNumber, s.shareData)); } byte[] content = gf.combineShares(gfShares); return Base58.encodeWithChecksum(content); } }
BipSss { public static String combine(Collection<Share> shares) throws IncompatibleSharesException, NotEnoughSharesException, InvalidContentTypeException { if (shares.size() == 0) { throw new NotEnoughSharesException(1); } Iterator<Share> it = shares.iterator(); Share firstShare = it.next(); while (it.hasNext()) { Share share = it.next(); if (!share.isCompatible(firstShare)) { throw new IncompatibleSharesException(); } } if (firstShare.contentType != TYPE_BASE_58_STRING) { throw new InvalidContentTypeException(); } Collection<Share> unique = Share.removeDuplicateIndexes(shares); int threshold = unique.iterator().next().threshold; if (threshold > unique.size()) { throw new NotEnoughSharesException(threshold - unique.size()); } List<Share> selection = new ArrayList<Share>(); it = unique.iterator(); while (it.hasNext()) { selection.add(it.next()); if (selection.size() == threshold) { break; } } Gf256 gf = new Gf256(); List<Gf256.Share> gfShares = new ArrayList<Gf256.Share>(); for (Share s : selection) { gfShares.add(new Gf256.Share((byte) s.shareNumber, s.shareData)); } byte[] content = gf.combineShares(gfShares); return Base58.encodeWithChecksum(content); }  }
BipSss { public static String combine(Collection<Share> shares) throws IncompatibleSharesException, NotEnoughSharesException, InvalidContentTypeException { if (shares.size() == 0) { throw new NotEnoughSharesException(1); } Iterator<Share> it = shares.iterator(); Share firstShare = it.next(); while (it.hasNext()) { Share share = it.next(); if (!share.isCompatible(firstShare)) { throw new IncompatibleSharesException(); } } if (firstShare.contentType != TYPE_BASE_58_STRING) { throw new InvalidContentTypeException(); } Collection<Share> unique = Share.removeDuplicateIndexes(shares); int threshold = unique.iterator().next().threshold; if (threshold > unique.size()) { throw new NotEnoughSharesException(threshold - unique.size()); } List<Share> selection = new ArrayList<Share>(); it = unique.iterator(); while (it.hasNext()) { selection.add(it.next()); if (selection.size() == threshold) { break; } } Gf256 gf = new Gf256(); List<Gf256.Share> gfShares = new ArrayList<Gf256.Share>(); for (Share s : selection) { gfShares.add(new Gf256.Share((byte) s.shareNumber, s.shareData)); } byte[] content = gf.combineShares(gfShares); return Base58.encodeWithChecksum(content); }  static String combine(Collection<Share> shares); }
BipSss { public static String combine(Collection<Share> shares) throws IncompatibleSharesException, NotEnoughSharesException, InvalidContentTypeException { if (shares.size() == 0) { throw new NotEnoughSharesException(1); } Iterator<Share> it = shares.iterator(); Share firstShare = it.next(); while (it.hasNext()) { Share share = it.next(); if (!share.isCompatible(firstShare)) { throw new IncompatibleSharesException(); } } if (firstShare.contentType != TYPE_BASE_58_STRING) { throw new InvalidContentTypeException(); } Collection<Share> unique = Share.removeDuplicateIndexes(shares); int threshold = unique.iterator().next().threshold; if (threshold > unique.size()) { throw new NotEnoughSharesException(threshold - unique.size()); } List<Share> selection = new ArrayList<Share>(); it = unique.iterator(); while (it.hasNext()) { selection.add(it.next()); if (selection.size() == threshold) { break; } } Gf256 gf = new Gf256(); List<Gf256.Share> gfShares = new ArrayList<Gf256.Share>(); for (Share s : selection) { gfShares.add(new Gf256.Share((byte) s.shareNumber, s.shareData)); } byte[] content = gf.combineShares(gfShares); return Base58.encodeWithChecksum(content); }  static String combine(Collection<Share> shares);  }