@@ -24,11 +24,14 @@ use ecdsa_fun::{
24
24
fun:: { Point , Scalar } ,
25
25
nonce, ECDSA ,
26
26
} ;
27
+ // FIXME: when secp256kfun as new crates.io release
27
28
#[ cfg( feature = "experimental" ) ]
28
29
use rand:: rngs:: ThreadRng ;
29
30
#[ cfg( feature = "experimental" ) ]
30
31
use rand_chacha:: ChaCha20Rng ;
31
32
#[ cfg( feature = "experimental" ) ]
33
+ use secp256kfun:: marker:: * ;
34
+ #[ cfg( feature = "experimental" ) ]
32
35
use sha2:: Sha256 ;
33
36
34
37
#[ cfg( feature = "experimental" ) ]
@@ -306,7 +309,12 @@ impl Sign<PublicKey, Sha256dHash, Signature> for KeyManager {
306
309
) -> Result < Signature , crypto:: Error > {
307
310
let secret_key = self . get_or_derive_bitcoin_key ( key) ?;
308
311
309
- let secret_key = Scalar :: from ( secret_key) ;
312
+ // FIXME: when new version is released on crates.io
313
+ // let secret_key = Scalar::from(secret_key);
314
+ let secret_key = Scalar :: from_slice ( & secret_key[ ..] )
315
+ . unwrap ( )
316
+ . mark :: < NonZero > ( )
317
+ . expect ( "SecretKey is never zero" ) ;
310
318
let message_hash: & [ u8 ; 32 ] = {
311
319
use bitcoin:: hashes:: Hash ;
312
320
msg. as_inner ( )
@@ -315,7 +323,12 @@ impl Sign<PublicKey, Sha256dHash, Signature> for KeyManager {
315
323
let nonce_gen = nonce:: Synthetic :: < Sha256 , nonce:: GlobalRng < ThreadRng > > :: default ( ) ;
316
324
let ecdsa = ECDSA :: new ( nonce_gen) ;
317
325
318
- Ok ( ecdsa. sign ( & secret_key, message_hash) . into ( ) )
326
+ // FIXME
327
+ // Ok(ecdsa.sign(&secret_key, message_hash).into())
328
+ Ok (
329
+ Signature :: from_compact ( ecdsa. sign ( & secret_key, message_hash) . to_bytes ( ) . as_ref ( ) )
330
+ . unwrap ( ) ,
331
+ )
319
332
}
320
333
321
334
fn verify_signature (
@@ -343,8 +356,15 @@ impl EncSign<PublicKey, Sha256dHash, Signature, EncryptedSignature> for KeyManag
343
356
let secret_key = self . get_or_derive_bitcoin_key ( signing_key) ?;
344
357
345
358
let engine = Adaptor :: < Transcript , NonceGen > :: default ( ) ;
346
- let secret_signing_key = Scalar :: from ( secret_key) ;
347
- let encryption_key = Point :: from ( * encryption_key) ;
359
+ // FIXME
360
+ // let secret_signing_key = Scalar::from(secret_key);
361
+ let secret_signing_key = Scalar :: from_slice ( & secret_key[ ..] )
362
+ . unwrap ( )
363
+ . mark :: < NonZero > ( )
364
+ . expect ( "SecretKey is never zero" ) ;
365
+ // FIXME
366
+ // let encryption_key = Point::from(*encryption_key);
367
+ let encryption_key = Point :: from_bytes ( encryption_key. serialize ( ) ) . unwrap ( ) ;
348
368
let message_hash: & [ u8 ; 32 ] = {
349
369
use bitcoin:: hashes:: Hash ;
350
370
msg. as_inner ( )
@@ -361,8 +381,11 @@ impl EncSign<PublicKey, Sha256dHash, Signature, EncryptedSignature> for KeyManag
361
381
sig : & EncryptedSignature ,
362
382
) -> Result < ( ) , crypto:: Error > {
363
383
let engine = Adaptor :: < Transcript , NonceGen > :: default ( ) ;
364
- let verification_key = Point :: from ( * signing_key) ;
365
- let encryption_key = Point :: from ( * encryption_key) ;
384
+ // FIXME
385
+ // let verification_key = Point::from(*signing_key);
386
+ // let encryption_key = Point::from(*encryption_key);
387
+ let verification_key = Point :: from_bytes ( signing_key. serialize ( ) ) . unwrap ( ) ;
388
+ let encryption_key = Point :: from_bytes ( encryption_key. serialize ( ) ) . unwrap ( ) ;
366
389
let message_hash: & [ u8 ; 32 ] = {
367
390
use bitcoin:: hashes:: Hash ;
368
391
msg. as_inner ( )
@@ -394,9 +417,22 @@ impl EncSign<PublicKey, Sha256dHash, Signature, EncryptedSignature> for KeyManag
394
417
. map_err ( crypto:: Error :: new) ?;
395
418
396
419
let adaptor = Adaptor :: < Transcript , NonceGen > :: default ( ) ;
397
- let decryption_key = Scalar :: from ( secret_key) ;
398
-
399
- Ok ( adaptor. decrypt_signature ( & decryption_key, sig) . into ( ) )
420
+ // FIXME
421
+ // let decryption_key = Scalar::from(secret_key);
422
+ let decryption_key = Scalar :: from_slice ( & secret_key[ ..] )
423
+ . unwrap ( )
424
+ . mark :: < NonZero > ( )
425
+ . expect ( "SecretKey is never zero" ) ;
426
+
427
+ // FIXME
428
+ // Ok(adaptor.decrypt_signature(&decryption_key, sig).into())
429
+ Ok ( Signature :: from_compact (
430
+ adaptor
431
+ . decrypt_signature ( & decryption_key, sig)
432
+ . to_bytes ( )
433
+ . as_ref ( ) ,
434
+ )
435
+ . unwrap ( ) )
400
436
}
401
437
}
402
438
@@ -410,11 +446,18 @@ impl RecoverSecret<PublicKey, SecretKey, Signature, EncryptedSignature> for KeyM
410
446
sig : Signature ,
411
447
) -> SecretKey {
412
448
let adaptor = Adaptor :: < Transcript , NonceGen > :: default ( ) ;
413
- let encryption_key = Point :: from ( * encryption_key) ;
414
- let signature = ecdsa_fun:: Signature :: from ( sig) ;
449
+ // FIXME
450
+ // let encryption_key = Point::from(*encryption_key);
451
+ //let signature = ecdsa_fun::Signature::from(sig);
452
+ let encryption_key = Point :: from_bytes ( encryption_key. serialize ( ) ) . unwrap ( ) ;
453
+ let signature = ecdsa_fun:: Signature :: from_bytes ( sig. serialize_compact ( ) ) . unwrap ( ) ;
415
454
416
455
match adaptor. recover_decryption_key ( & encryption_key, & signature, & encrypted_sig) {
417
- Some ( decryption_key) => decryption_key. into ( ) ,
456
+ // FIXME
457
+ // Some(decryption_key) => decryption_key.into(),
458
+ Some ( decryption_key) => {
459
+ SecretKey :: from_slice ( decryption_key. to_bytes ( ) . as_ref ( ) ) . unwrap ( )
460
+ }
418
461
None => panic ! ( "signature is not the decryption of our original encrypted signature" ) ,
419
462
}
420
463
}
@@ -456,7 +499,9 @@ impl ProveCrossGroupDleq<PublicKey, monero::PublicKey, DLEQProof> for KeyManager
456
499
. point
457
500
. decompress ( )
458
501
. expect ( "Valid point to decompress" ) ,
459
- ecdsa_fun:: fun:: Point :: from ( * encryption_key) ,
502
+ // FIXME
503
+ //ecdsa_fun::fun::Point::from(*encryption_key),
504
+ Point :: from_bytes ( encryption_key. serialize ( ) ) . unwrap ( ) ,
460
505
)
461
506
}
462
507
}
0 commit comments