@@ -954,7 +954,7 @@ func (n *LeafNode) getOldCn(index byte) (*Point, *Fr) {
954
954
return c , & oldc
955
955
}
956
956
957
- func (n * LeafNode ) updateC (stem [] byte , index byte , c * Point , oldc * Fr ) {
957
+ func (n * LeafNode ) updateC (index byte , c * Point , oldc * Fr ) {
958
958
var (
959
959
newc Fr
960
960
poly [256 ]Fr
@@ -963,13 +963,6 @@ func (n *LeafNode) updateC(stem []byte, index byte, c *Point, oldc *Fr) {
963
963
toFr (& newc , c )
964
964
newc .Sub (& newc , oldc )
965
965
poly [2 + (index / 128 )] = newc
966
-
967
- if n .commitment == nil {
968
- poly [0 ].SetUint64 (1 )
969
- StemFromBytes (& poly [1 ], stem )
970
- n .commitment = cfg .CommitToPoly (poly [:], 0 )
971
- return
972
- }
973
966
n .commitment .Add (n .commitment , cfg .CommitToPoly (poly [:], 0 ))
974
967
}
975
968
@@ -1026,22 +1019,6 @@ func (n *LeafNode) updateLeaf(index byte, value []byte) {
1026
1019
n .values [index ] = value
1027
1020
}
1028
1021
1029
- /*
1030
- func (n *LeafNode) updateLeaf(index byte, value []byte) {
1031
- if n.commitment == nil {
1032
- panic("nil commitment")
1033
- }
1034
-
1035
- c, oldc := n.getOldCn(index)
1036
-
1037
- n.updateCn(index, value, c)
1038
-
1039
- n.updateC(index, c, oldc)
1040
-
1041
- n.values[index] = value
1042
- }
1043
- */
1044
-
1045
1022
func (n * LeafNode ) updateMultipleLeaves (values [][]byte ) {
1046
1023
for i := range values {
1047
1024
if values [i ] != nil {
@@ -1050,41 +1027,6 @@ func (n *LeafNode) updateMultipleLeaves(values [][]byte) {
1050
1027
}
1051
1028
}
1052
1029
1053
- /*
1054
- func (n *LeafNode) updateMultipleLeaves(values [][]byte) {
1055
- if n.commitment == nil {
1056
- panic("nil commitment")
1057
- }
1058
-
1059
- var c1, c2 *Point
1060
- var old1, old2 *Fr
1061
- for i, v := range values {
1062
- if len(v) != 0 && !bytes.Equal(v, n.values[i]) {
1063
- if i < 128 {
1064
- if c1 == nil {
1065
- c1, old1 = n.getOldCn(byte(i))
1066
- }
1067
- n.updateCn(byte(i), v, c1)
1068
- } else {
1069
- if c2 == nil {
1070
- c2, old2 = n.getOldCn(byte(i))
1071
- }
1072
- n.updateCn(byte(i), v, c2)
1073
- }
1074
-
1075
- n.values[i] = v
1076
- }
1077
- }
1078
-
1079
- if c1 != nil {
1080
- n.updateC(0, c1, old1)
1081
- }
1082
- if c2 != nil {
1083
- n.updateC(128, c2, old2)
1084
- }
1085
- }
1086
- */
1087
-
1088
1030
func (n * LeafNode ) InsertOrdered (key []byte , value []byte , _ NodeFlushFn ) error {
1089
1031
// In the previous version, this value used to be flushed on insert.
1090
1032
// This is no longer the case, as all values at the last level get
@@ -1154,14 +1096,14 @@ func (leaf *LeafNode) Commit() *Point {
1154
1096
frPool .Put (c1polyp )
1155
1097
}()
1156
1098
1157
- count = fillSuffixTreePoly (c1poly [:] , leaf .values [:128 ])
1158
- leaf .c1 = cfg .CommitToPoly (c1poly [:] , 256 - count )
1099
+ count = fillSuffixTreePoly (c1poly , leaf .values [:128 ])
1100
+ leaf .c1 = cfg .CommitToPoly (c1poly , 256 - count )
1159
1101
1160
1102
for i := 0 ; i < 256 ; i ++ {
1161
1103
c1poly [i ] = Fr {}
1162
1104
}
1163
- count = fillSuffixTreePoly (c1poly [:] , leaf .values [128 :])
1164
- leaf .c2 = cfg .CommitToPoly (c1poly [:] , 256 - count )
1105
+ count = fillSuffixTreePoly (c1poly , leaf .values [128 :])
1106
+ leaf .c2 = cfg .CommitToPoly (c1poly , 256 - count )
1165
1107
1166
1108
for i := 0 ; i < 256 ; i ++ {
1167
1109
c1poly [i ] = Fr {}
@@ -1170,7 +1112,7 @@ func (leaf *LeafNode) Commit() *Point {
1170
1112
StemFromBytes (& c1poly [1 ], leaf .stem )
1171
1113
1172
1114
toFrMultiple ([]* Fr {& c1poly [2 ], & c1poly [3 ]}, []* Point {leaf .c1 , leaf .c2 })
1173
- leaf .commitment = cfg .CommitToPoly (c1poly [:] , 252 )
1115
+ leaf .commitment = cfg .CommitToPoly (c1poly , 252 )
1174
1116
1175
1117
} else if len (leaf .cow ) != 0 {
1176
1118
// If we've already have a calculated commitment, and there're touched leaf values, we do a diff update.
@@ -1180,23 +1122,23 @@ func (leaf *LeafNode) Commit() *Point {
1180
1122
if ! bytes .Equal (oldValue , leaf .values [i ]) {
1181
1123
if i < 128 {
1182
1124
if c1 == nil {
1183
- c1 , old1 = leaf .getOldCn (byte ( i ) )
1125
+ c1 , old1 = leaf .getOldCn (i )
1184
1126
}
1185
- leaf .updateCn (byte ( i ) , oldValue , c1 )
1127
+ leaf .updateCn (i , oldValue , c1 )
1186
1128
} else {
1187
1129
if c2 == nil {
1188
- c2 , old2 = leaf .getOldCn (byte ( i ) )
1130
+ c2 , old2 = leaf .getOldCn (i )
1189
1131
}
1190
- leaf .updateCn (byte ( i ) , oldValue , c2 )
1132
+ leaf .updateCn (i , oldValue , c2 )
1191
1133
}
1192
1134
}
1193
1135
}
1194
1136
1195
1137
if c1 != nil {
1196
- leaf .updateC (leaf . stem , 0 , c1 , old1 )
1138
+ leaf .updateC (0 , c1 , old1 )
1197
1139
}
1198
1140
if c2 != nil {
1199
- leaf .updateC (leaf . stem , 128 , c2 , old2 )
1141
+ leaf .updateC (128 , c2 , old2 )
1200
1142
}
1201
1143
leaf .cow = nil
1202
1144
}
0 commit comments