@@ -80,7 +80,7 @@ func (p *Pollard) Prove(hashes []Hash) (Proof, error) {
80
80
sort .Slice (sortedTargets , func (a , b int ) bool { return sortedTargets [a ] < sortedTargets [b ] })
81
81
82
82
// Get the positions of all the hashes that are needed to prove the targets
83
- proofPositions , _ := proofPositions (sortedTargets , p .NumLeaves , treeRows (p .NumLeaves ))
83
+ proofPositions , _ := ProofPositions (sortedTargets , p .NumLeaves , treeRows (p .NumLeaves ))
84
84
85
85
// Fetch all the proofs from the accumulator.
86
86
proof .Proof = make ([]Hash , len (proofPositions ))
@@ -760,12 +760,12 @@ func GetMissingPositions(numLeaves uint64, proofTargets, desiredTargets []uint64
760
760
}
761
761
762
762
// desiredPositions are all the positions that are needed to proof the desiredTargets.
763
- desiredPositions , _ := proofPositions (desiredTargets , numLeaves , forestRows )
763
+ desiredPositions , _ := ProofPositions (desiredTargets , numLeaves , forestRows )
764
764
765
765
// havePositions represent all the positions in the tree we already have access to.
766
766
// Since targets and computablePositions are something we already have, append
767
767
// those to the havePositions.
768
- havePositions , computablePos := proofPositions (targets , numLeaves , forestRows )
768
+ havePositions , computablePos := ProofPositions (targets , numLeaves , forestRows )
769
769
havePositions = append (havePositions , targets ... )
770
770
havePositions = append (havePositions , computablePos ... )
771
771
sort .Slice (havePositions , func (a , b int ) bool { return havePositions [a ] < havePositions [b ] })
@@ -783,12 +783,12 @@ func AddProof(proofA, proofB Proof, targetHashesA, targetHashesB []Hash, numLeav
783
783
784
784
// Calculate proof hashes for proof A and add positions to the proof hashes.
785
785
targetsA := copySortedFunc (proofA .Targets , uint64Less )
786
- proofPosA , calculateableA := proofPositions (targetsA , numLeaves , totalRows )
786
+ proofPosA , calculateableA := ProofPositions (targetsA , numLeaves , totalRows )
787
787
proofAndPosA := hashAndPos {proofPosA , proofA .Proof }
788
788
789
789
// Calculate proof hashes for proof B and add positions to the proof hashes.
790
790
targetsB := copySortedFunc (proofB .Targets , uint64Less )
791
- proofPosB , calculateableB := proofPositions (targetsB , numLeaves , totalRows )
791
+ proofPosB , calculateableB := ProofPositions (targetsB , numLeaves , totalRows )
792
792
proofAndPosB := hashAndPos {proofPosB , proofB .Proof }
793
793
794
794
// Add the proof hashes of proofA and proofB.
@@ -896,12 +896,12 @@ func (p *Proof) updateProofRemove(blockTargets []uint64, cachedHashes []Hash, up
896
896
897
897
// Attach positions to the proofs.
898
898
sortedCachedTargets := copySortedFunc (p .Targets , uint64Less )
899
- proofPos , _ := proofPositions (sortedCachedTargets , numLeaves , totalRows )
899
+ proofPos , _ := ProofPositions (sortedCachedTargets , numLeaves , totalRows )
900
900
oldProofs := toHashAndPos (proofPos , p .Proof )
901
901
newProofs := hashAndPos {make ([]uint64 , 0 , len (p .Proof )), make ([]Hash , 0 , len (p .Proof ))}
902
902
903
903
// Grab all the positions of the needed proof hashes.
904
- neededPos , _ := proofPositions (targetsWithHash .positions , numLeaves , totalRows )
904
+ neededPos , _ := ProofPositions (targetsWithHash .positions , numLeaves , totalRows )
905
905
906
906
// Grab the un-needed positions. These are un-needed as they were proofs
907
907
// for the now deleted targets.
@@ -1026,7 +1026,7 @@ func pruneEdges(hnp hashAndPos, numAdds, numLeaves uint64, forestRows, prevFores
1026
1026
// proof hashes that could not have existed before the add.
1027
1027
func (p * Proof ) undoAdd (numAdds , numLeaves uint64 , cachedHashes []Hash , toDestroy []uint64 ) ([]Hash , error ) {
1028
1028
targetsWithHash := toHashAndPos (p .Targets , cachedHashes )
1029
- proofPos , _ := proofPositions (targetsWithHash .positions , numLeaves , treeRows (numLeaves ))
1029
+ proofPos , _ := ProofPositions (targetsWithHash .positions , numLeaves , treeRows (numLeaves ))
1030
1030
proofWithPos := toHashAndPos (proofPos , p .Proof )
1031
1031
1032
1032
forestRows := treeRows (numLeaves )
@@ -1129,7 +1129,7 @@ func (p *Proof) undoAdd(numAdds, numLeaves uint64, cachedHashes []Hash, toDestro
1129
1129
1130
1130
// There may be extra proof hashes that we don't need anymore. Calculate the
1131
1131
// needed positions and remove the rest.
1132
- neededProofPos , _ := proofPositions (targetsWithHash .positions , numLeaves - numAdds , prevForestRows )
1132
+ neededProofPos , _ := ProofPositions (targetsWithHash .positions , numLeaves - numAdds , prevForestRows )
1133
1133
proofWithPos = getHashAndPosSubset (proofWithPos , neededProofPos )
1134
1134
1135
1135
// Set the proof.
@@ -1150,7 +1150,7 @@ func (p *Proof) undoDel(blockTargets []uint64, blockHashes, cachedHashes []Hash,
1150
1150
}
1151
1151
1152
1152
targetsWithHashes := toHashAndPos (p .Targets , cachedHashes )
1153
- proofPos , _ := proofPositions (targetsWithHashes .positions , numLeaves , totalRows )
1153
+ proofPos , _ := ProofPositions (targetsWithHashes .positions , numLeaves , totalRows )
1154
1154
proofWithPos := toHashAndPos (proofPos , p .Proof )
1155
1155
1156
1156
// Detwin the block targets.
@@ -1247,7 +1247,7 @@ func (p *Proof) undoDel(blockTargets []uint64, blockHashes, cachedHashes []Hash,
1247
1247
1248
1248
// Only extract the proof hashes that are needed for the targets after
1249
1249
// the remap.
1250
- neededProofPos , _ := proofPositions (targetsWithHashes .positions , numLeaves , totalRows )
1250
+ neededProofPos , _ := ProofPositions (targetsWithHashes .positions , numLeaves , totalRows )
1251
1251
proofWithPos = getHashAndPosSubset (proofWithPos , neededProofPos )
1252
1252
1253
1253
p .Proof = proofWithPos .hashes
@@ -1286,7 +1286,7 @@ func GetProofSubset(proof Proof, hashes []Hash, wants []uint64, numLeaves uint64
1286
1286
sort .Sort (posAndHashes )
1287
1287
1288
1288
// Put positions onto the proof hashes.
1289
- positions , _ := proofPositions (proofTargetsCopy , numLeaves , treeRows (numLeaves ))
1289
+ positions , _ := ProofPositions (proofTargetsCopy , numLeaves , treeRows (numLeaves ))
1290
1290
proofPos := toHashAndPos (positions , proof .Proof )
1291
1291
1292
1292
// Merge the proof positions and its hashes along with the calculated intermediate nodes
@@ -1298,7 +1298,7 @@ func GetProofSubset(proof Proof, hashes []Hash, wants []uint64, numLeaves uint64
1298
1298
targetHashesWithPos = getHashAndPosSubset (targetHashesWithPos , sortedWants )
1299
1299
1300
1300
// Grab the positions that we need to prove the wants.
1301
- wantProofPos , _ := proofPositions (targetHashesWithPos .positions , numLeaves , treeRows (numLeaves ))
1301
+ wantProofPos , _ := ProofPositions (targetHashesWithPos .positions , numLeaves , treeRows (numLeaves ))
1302
1302
1303
1303
// Extract the proof positions we want and then sanity check to see that we have everything.
1304
1304
posAndHashes = getHashAndPosSubset (posAndHashes , wantProofPos )
@@ -1350,7 +1350,7 @@ func (p *Proof) updateProofAdd(adds, cachedDelHashes []Hash, remembers []uint32,
1350
1350
origTargetsWithHash := toHashAndPos (p .Targets , cachedDelHashes )
1351
1351
1352
1352
// Attach positions to the proof.
1353
- proofPos , _ := proofPositions (origTargetsWithHash .positions , beforeNumLeaves , treeRows (beforeNumLeaves ))
1353
+ proofPos , _ := ProofPositions (origTargetsWithHash .positions , beforeNumLeaves , treeRows (beforeNumLeaves ))
1354
1354
proofWithPos := toHashAndPos (proofPos , p .Proof )
1355
1355
1356
1356
// Remap the positions if we moved up a after the addition row.
@@ -1391,7 +1391,7 @@ func (p *Proof) updateProofAdd(adds, cachedDelHashes []Hash, remembers []uint32,
1391
1391
origTargetsWithHash = mergeSortedHashAndPos (remembersWithHash , origTargetsWithHash )
1392
1392
1393
1393
// Grab all the new nodes after this add.
1394
- neededProofPositions , _ := proofPositions (origTargetsWithHash .positions , beforeNumLeaves + uint64 (len (adds )), treeRows (beforeNumLeaves + uint64 (len (adds ))))
1394
+ neededProofPositions , _ := ProofPositions (origTargetsWithHash .positions , beforeNumLeaves + uint64 (len (adds )), treeRows (beforeNumLeaves + uint64 (len (adds ))))
1395
1395
1396
1396
// Add all the new proof hashes to the proof.
1397
1397
newProofWithPos := hashAndPos {}
0 commit comments