@@ -165,37 +165,51 @@ func IDFromPublicKey(pk ic.PubKey) (ID, error) {
165
165
if AdvancedEnableInlining && len (b ) <= maxInlineKeyLength {
166
166
alg = mh .ID
167
167
}
168
- hash , _ := mh .Sum (b , alg , - 1 )
168
+ // OpenBazaar: handle the Sum error
169
+ hash , err := mh .Sum (b , alg , - 1 )
170
+ if err != nil {
171
+ return "" , err
172
+ }
169
173
return ID (hash ), nil
170
174
}
171
175
172
176
// HashedIDFromPublicKey will always return the SHA256 hash of
173
- // the pubkey bytes. OpenBazaar: temporary helper to isolate the
177
+ // the pubkey bytes.
178
+ // OpenBazaar: temporary helper to isolate the
174
179
// hash-producing ID behavior.
175
180
func HashedIDFromPublicKey (pk ic.PubKey ) (ID , error ) {
176
181
b , err := pk .Bytes ()
177
182
if err != nil {
178
183
return "" , err
179
184
}
180
- hash , _ := mh .Sum (b , mh .SHA2_256 , - 1 )
185
+ hash , err := mh .Sum (b , mh .SHA2_256 , - 1 )
186
+ if err != nil {
187
+ return "" , err
188
+ }
181
189
return ID (hash ), nil
182
190
}
183
191
184
192
// InlineIDFromPublicKey will always return the new inline ID format
185
- // of the pubkey bytes. OpenBazaar: temporary helper function to
193
+ // of the pubkey bytes.
194
+ // OpenBazaar: temporary helper function to
186
195
// remain forward compatible with inline keys
187
196
func InlineIDFromPublicKey (pk ic.PubKey ) (ID , error ) {
188
197
b , err := pk .Bytes ()
189
198
if err != nil {
190
199
return "" , err
191
200
}
192
- hash , _ := mh .Sum (b , mh .ID , - 1 )
201
+ hash , err := mh .Sum (b , mh .SHA2_256 , - 1 )
202
+ if err != nil {
203
+ return "" , err
204
+ }
193
205
return ID (hash ), nil
194
206
}
195
207
196
208
// AlternativeIDFromPublicKey returns SHA256 hash ID when AdvancedEnableInlining
197
- // is true, and returns new InlineID otherwise. This allows legacy IDs to be compared
198
- // after they are no longer available by the default IDFromPublicKey function.
209
+ // is true, and returns new InlineID otherwise.
210
+ // OpenBazaar: This allows legacy IDs
211
+ // to be compared after they are no longer available by the default IDFromPublicKey
212
+ // function.
199
213
func AlternativeIDFromPublicKey (pubkey ic.PubKey ) (ID , error ) {
200
214
if AdvancedEnableInlining {
201
215
return HashedIDFromPublicKey (pubkey )
0 commit comments