-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multisig: collecting PositionedLeafs
- Loading branch information
1 parent
5206ff1
commit 42f8297
Showing
5 changed files
with
77 additions
and
62 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
interpreter/shared/src/main/scala/sigmastate/NodePosition.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package sigmastate | ||
|
||
/** | ||
* Data type which encodes position of a node in a tree. | ||
* | ||
* Position is encoded like following (the example provided is for CTHRESHOLD(2, Seq(pk1, pk2, pk3 && pk4)) : | ||
* | ||
* 0 | ||
* / | \ | ||
* / | \ | ||
* 0-0 0-1 0-2 | ||
* /| | ||
* / | | ||
* / | | ||
* / | | ||
* 0-2-0 0-2-1 | ||
* | ||
* So a hint associated with pk1 has a position "0-0", pk4 - "0-2-1" . | ||
* | ||
* Please note that "0" prefix is for a crypto tree. There are several kinds of trees during evaluation. | ||
* Initial mixed tree (ergoTree) would have another prefix. | ||
* | ||
* @param positions - positions from root (inclusive) in top-down order | ||
*/ | ||
case class NodePosition(positions: Seq[Int]) { | ||
def child(childIdx: Int): NodePosition = NodePosition(positions :+ childIdx) | ||
def ++(path: Seq[Int]): NodePosition = NodePosition(positions ++ path) | ||
override def toString: String = positions.mkString("-") | ||
} | ||
|
||
object NodePosition { | ||
/** | ||
* Prefix to encode node positions in a crypto tree. | ||
*/ | ||
val CryptoTreePrefix = NodePosition(Seq(0)) | ||
|
||
/** | ||
* Prefix to encode node positions in an ErgoTree instance. | ||
*/ | ||
val ErgoTreePrefix = NodePosition(Seq(1)) | ||
} |
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
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
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
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