Search in sources :

Example 11 with MerkleProof

use of com.jd.blockchain.ledger.MerkleProof in project jdchain-core by blockchain-jd-com.

the class KvDataset method getDataProof.

public MerkleDataProof getDataProof(Bytes key, long version) {
    DataEntry<Bytes, byte[]> dataEntry = getDataEntry(key, version);
    if (dataEntry == null) {
        return null;
    }
    MerkleProof proof = getProof(key);
    return new MerkleDataEntryWrapper(dataEntry, proof);
}
Also used : Bytes(utils.Bytes) MerkleProof(com.jd.blockchain.ledger.MerkleProof)

Example 12 with MerkleProof

use of com.jd.blockchain.ledger.MerkleProof in project jdchain-core by blockchain-jd-com.

the class MerkleSequenceDataset method getDataProof.

public MerkleDataProof getDataProof(Bytes key, long version) {
    DataEntry<Bytes, byte[]> dataEntry = getDataEntry(key, version);
    if (dataEntry == null) {
        return null;
    }
    MerkleProof proof = getProof(key);
    return new MerkleDataEntryWrapper(dataEntry, proof);
}
Also used : Bytes(utils.Bytes) MerkleProof(com.jd.blockchain.ledger.MerkleProof)

Example 13 with MerkleProof

use of com.jd.blockchain.ledger.MerkleProof in project jdchain-core by blockchain-jd-com.

the class KvDataset method getDataProof.

public MerkleDataProof getDataProof(Bytes key) {
    DataEntry<Bytes, byte[]> dataEntry = getDataEntry(key);
    if (dataEntry == null) {
        return null;
    }
    MerkleProof proof = getProof(key);
    return new MerkleDataEntryWrapper(dataEntry, proof);
}
Also used : Bytes(utils.Bytes) MerkleProof(com.jd.blockchain.ledger.MerkleProof)

Example 14 with MerkleProof

use of com.jd.blockchain.ledger.MerkleProof in project jdchain-core by blockchain-jd-com.

the class MerkleHashDataset method getDataProof.

public MerkleDataProof getDataProof(Bytes key) {
    DataEntry<Bytes, byte[]> dataEntry = getDataEntry(key);
    if (dataEntry == null) {
        return null;
    }
    MerkleProof proof = getProof(key);
    return new MerkleDataEntryWrapper(dataEntry, proof);
}
Also used : Bytes(utils.Bytes) MerkleProof(com.jd.blockchain.ledger.MerkleProof)

Example 15 with MerkleProof

use of com.jd.blockchain.ledger.MerkleProof in project jdchain-core by blockchain-jd-com.

the class MerkleHashSortTreeTest method assertMerkleProof.

private MerkleProof assertMerkleProof(VersioningKVData<String, byte[]> data, MerkleTree merkleTree) {
    MerkleProof proof_nx = merkleTree.getProof(BytesUtils.toBytes("KEY_NOT_EXIST"));
    assertNull(proof_nx);
    MerkleProof proof = merkleTree.getProof(BytesUtils.toBytes(data.getKey()), data.getVersion());
    assertNotNull(proof);
    HashDigest dataHash = SHA256_HASH_FUNC.hash(data.getValue());
    assertEquals(dataHash, proof.getDataHash());
    HashDigest rootHash = merkleTree.getRootHash();
    assertEquals(rootHash, proof.getRootHash());
    assertTrue(MerkleProofVerifier.verify(proof));
    return proof;
}
Also used : HashDigest(com.jd.blockchain.crypto.HashDigest) MerkleProof(com.jd.blockchain.ledger.MerkleProof)

Aggregations

MerkleProof (com.jd.blockchain.ledger.MerkleProof)16 HashDigest (com.jd.blockchain.crypto.HashDigest)8 Bytes (utils.Bytes)6 Test (org.junit.Test)4 VersioningKVData (com.jd.blockchain.storage.service.utils.VersioningKVData)3 Random (java.util.Random)3 CryptoSetting (com.jd.blockchain.ledger.CryptoSetting)2 MerkleHashDataset (com.jd.blockchain.ledger.core.MerkleHashDataset)2 MerkleHashTrie (com.jd.blockchain.ledger.proof.MerkleHashTrie)2 MemoryKVStorage (com.jd.blockchain.storage.service.utils.MemoryKVStorage)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DataEntry (utils.DataEntry)2 Dataset (utils.Dataset)2 CryptoProvider (com.jd.blockchain.crypto.CryptoProvider)1 MerkleDataNode (com.jd.blockchain.ledger.MerkleDataNode)1 MerkleNode (com.jd.blockchain.ledger.MerkleNode)1 CryptoConfig (com.jd.blockchain.ledger.core.CryptoConfig)1 MerkleHashSortTree (com.jd.blockchain.ledger.merkletree.MerkleHashSortTree)1