Created
March 20, 2017 20:25
-
-
Save kushti/f0d54abee9ee863bb04987fd13bd13ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lookupTest() { | |
val kl = 4 | |
val vl = 7 | |
val p = new BatchAVLProver(keyLength = kl, valueLength = vl) | |
val key1 = Sha256("1").take(kl) | |
val key2 = Sha256("2").take(kl) | |
val key3 = Sha256("3").take(kl) | |
val key4 = Sha256("4").take(kl) | |
val key5 = Sha256("5").take(kl) | |
val key6 = Sha256("6").take(kl) | |
val key7 = Sha256("7").take(kl) | |
println("k1: " + arrayToString(key1)) | |
println("k2: " + arrayToString(key2)) | |
println("k3: " + arrayToString(key3)) | |
val v1 = Sha256("1").take(vl) | |
val v2 = Sha256("2").take(vl) | |
val i1 = Insert(key1, v1) | |
val i2 = Insert(key2, v2) | |
p.performOneModification(i1) | |
p.performOneModification(i2) | |
p.generateProof() | |
val l1 = Lookup(key1) | |
val l2 = Lookup(key2) | |
val l3 = Lookup(key3) | |
val pr = p.performLookups(l1, l2, l3).get | |
val vr = new BatchAVLVerifier(p.digest, pr, keyLength = kl, valueLength = vl) | |
assert(vr.performOneLookup(l1).get.isDefined) | |
assert(vr.performOneLookup(l2).get.isDefined) | |
assert(vr.performOneLookup(l3).get.isEmpty) | |
val i4 = Insert(key4, v1) | |
val i5 = Insert(key5, v2) | |
p.performOneModification(i4) | |
p.performOneModification(i5) | |
p.generateProof() | |
val l4 = Lookup(key4) | |
val l5 = Lookup(key5) | |
val l6 = Lookup(key6) | |
val l7 = Lookup(key7) | |
val pr2 = p.performLookups(l1, l2, l3, l4, l5, l6).get | |
val vr2 = new BatchAVLVerifier(p.digest, pr2, keyLength = kl, valueLength = vl) | |
val pl2 = vr2.performLookups(Seq(l1, l2, l3, l4, l5, l6)).get | |
println(pl2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment