@Beta public class VisibilityUtils extends Object
Constructor and Description |
---|
VisibilityUtils() |
Modifier and Type | Method and Description |
---|---|
static MerkleTree |
buildMerkleTree(LinkedHashMap<String,String> keyValues)
Default MessageDigest is set as SHA-256
|
static MerkleTree |
buildMerkleTree(LinkedHashMap<String,String> keyValues,
MessageDigest messageDigest)
Returns a special MerkleTree serving visibility purpose and efficient in term of storage.
First leaf in the result tree is list of all keys in a JSNO format: ["key1","key2"] Rest of the leaves are the values corresponding to the keys in the same order |
static MerkleProof |
getMerkleProof(MerkleTree tree,
Set<Integer> leavesIndexesToShare)
Generates and returns necessary information to proof given information are part of the same MerkleTree
|
static MerkleProof |
mergeMerkleProofs(Set<MerkleProof> merkleProofs)
Merges a set of MerkleProofs to one MerkleProof.
|
static boolean |
validateMerkleProof(MerkleProof proof,
String merkleRootHash)
Validates a MerkleProof.
|
@Nonnull public static MerkleTree buildMerkleTree(LinkedHashMap<String,String> keyValues) throws NoSuchAlgorithmException
keyValues
- LinkedHashMap<String, String>
keys can not contain "," characterMerkleTree
NoSuchAlgorithmException
- if the used hashing algorithm is not available@Nonnull public static MerkleTree buildMerkleTree(@Nonnull LinkedHashMap<String,String> keyValues, @Nonnull MessageDigest messageDigest)
keyValues
- LinkedHashMap<String, String>
keys can not contain "," charactermessageDigest
- message digest to calculate hashing functionMerkleTree
@Nonnull public static MerkleProof getMerkleProof(@Nonnull MerkleTree tree, @Nonnull Set<Integer> leavesIndexesToShare)
tree
- MerkleTree
original Merkle treeleavesIndexesToShare
- List<Integer>
list of all leaves indexes we would like to share from the whole tree. Must only
contain indexes that exist in the tree.MerkleProof
minimum information required to proof shared leaves are part of the same given treeIllegalArgumentException
- If leavesIndexesToShare is empty or contains any index that does not exist in the tree.public static boolean validateMerkleProof(@Nonnull MerkleProof proof, @Nonnull String merkleRootHash) throws NoSuchAlgorithmException
proof
- MerkleProof
to validatemerkleRootHash
- root hash, which should match the given proofNoSuchAlgorithmException
- If the proof's hashing algorithm is not supported on this systemIllegalArgumentException
- If the proof is invalid (does not have a hashing algorithm or has a root hash set)@Nonnull public static MerkleProof mergeMerkleProofs(@Nonnull Set<MerkleProof> merkleProofs) throws IllegalArgumentException
merkleProofs
- set of MerkleProofsMerkleProof
IllegalArgumentException
- If the Set of Proof are not mergeable.Copyright © 2021 SAP SE. All rights reserved.