Skip to content

Commit

Permalink
Optimizze commitment script filters
Browse files Browse the repository at this point in the history
  • Loading branch information
fatemeh-ra committed Feb 17, 2024
1 parent a6e44dd commit 31eacec
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/scala/rosen/bridge/scripts/Commitment.es
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@
}
.slice(0, trigger.R7[Int].get)
.map{(box:Box) => box.R4[Coll[Byte]].get}
val commitmentWIDs = INPUTS.filter{(box:Box) =>
val commitmentsWithMyWid = INPUTS.filter{(box:Box) =>
box.tokens.size > 0 &&
box.tokens(0)._1 == SELF.tokens(0)._1 &&
box.propositionBytes == SELF.propositionBytes
box.propositionBytes == SELF.propositionBytes &&
box.R4[Coll[Byte]].get == myWID
}
.map{(box:Box) => box.R4[Coll[Byte]].get}
val permitBox = OUTPUTS.filter {(box:Box) =>
box.R4[Coll[Byte]].isDefined &&
box.R4[Coll[Byte]].get == myWID
}(0)
val WIDExists = WIDs.exists {(WID: Coll[Byte]) => myWID == WID}
val commitmentWithWid = commitmentWIDs.filter{(WID: Coll[Byte]) => myWID == WID}
sigmaProp(
allOf(
Coll(
Expand All @@ -41,7 +40,7 @@
permitBox.tokens(0)._2 == SELF.tokens(0)._2,
// check for duplicates
WIDExists == false,
commitmentWithWid.size == 1,
commitmentsWithMyWid.size == 1,
// validate commitment
blake2b256(eventData ++ myWID) == SELF.R6[Coll[Byte]].get
)
Expand Down

0 comments on commit 31eacec

Please sign in to comment.