File tree 4 files changed +20
-11
lines changed
4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -212,6 +212,18 @@ Returns `null` if result is equal to `0`.
212
212
- `Expected Private ` if `! isPrivate(d)`
213
213
- `Expected Tweak ` if `tweak` is not in `[0 ... order - 1 ]`
214
214
215
+ ### privateNegate (d)
216
+
217
+ ```haskell
218
+ privateNegate :: Buffer -> Buffer
219
+ ```
220
+
221
+ Returns the negation of d on the order n (`n - d`)
222
+
223
+ ##### Throws:
224
+
225
+ - `Expected Private ` if `! isPrivate(d)`
226
+
215
227
### xOnlyPointAddTweak (p, tweak)
216
228
217
229
```haskell
Original file line number Diff line number Diff line change @@ -421,14 +421,12 @@ pub extern "C" fn private_sub() -> i32 {
421
421
#[ allow( clippy:: missing_panics_doc) ]
422
422
#[ no_mangle]
423
423
#[ export_name = "privateNegate" ]
424
- pub extern "C" fn private_key_negate ( ) -> i32 {
424
+ pub extern "C" fn private_negate ( ) {
425
425
unsafe {
426
- if secp256k1_ec_seckey_negate ( secp256k1_context_no_precomp , PRIVATE_INPUT . as_mut_ptr ( ) ) == 1
427
- {
426
+ assert_eq ! (
427
+ secp256k1_ec_seckey_negate ( secp256k1_context_no_precomp , PRIVATE_INPUT . as_mut_ptr ( ) ) ,
428
428
1
429
- } else {
430
- 0
431
- }
429
+ ) ;
432
430
}
433
431
}
434
432
Original file line number Diff line number Diff line change @@ -244,14 +244,13 @@ export function privateSub(
244
244
}
245
245
}
246
246
247
- export function privateNegate ( d : Uint8Array ) : Uint8Array | null {
247
+ export function privateNegate ( d : Uint8Array ) : Uint8Array {
248
248
validate . validatePrivate ( d ) ;
249
249
250
250
try {
251
251
PRIVATE_KEY_INPUT . set ( d ) ;
252
- return wasm . privateNegate ( ) === 1
253
- ? PRIVATE_KEY_INPUT . slice ( 0 , validate . PRIVATE_KEY_SIZE )
254
- : null ;
252
+ wasm . privateNegate ( ) ;
253
+ return PRIVATE_KEY_INPUT . slice ( 0 , validate . PRIVATE_KEY_SIZE ) ;
255
254
} finally {
256
255
PRIVATE_KEY_INPUT . fill ( 0 ) ;
257
256
}
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ interface Secp256k1WASM {
48
48
pointMultiply : ( p : number , outputlen : number ) => number ;
49
49
privateAdd : ( ) => number ;
50
50
privateSub : ( ) => number ;
51
- privateNegate : ( ) => number ;
51
+ privateNegate : ( ) => void ;
52
52
sign : ( e : number ) => void ;
53
53
signRecoverable : ( e : number ) => 0 | 1 | 2 | 3 ;
54
54
signSchnorr : ( e : number ) => void ;
You can’t perform that action at this time.
0 commit comments