@@ -387,3 +387,51 @@ def test_is_entropy_wrong_input():
387
387
def test_is_entropy_value_error ():
388
388
is_entropy = HDWallet .is_entropy ("*(#_" )
389
389
assert is_entropy is False
390
+
391
+
392
+ def test_non_harden_public_derivation ():
393
+ public_key = bytes .fromhex (
394
+ "601c86a2310f438079fff07454f4df4ce416bd181d972cd4c4615f15a733ba15"
395
+ )
396
+ chain_code = bytes .fromhex (
397
+ "8a34b66a32c9d2d61d1d7a0e8fcf167efae3fb556af74808cd1ba8a22251c031"
398
+ )
399
+ hdwallet = HDWallet (chain_code = chain_code , public_key = public_key )
400
+ hdwallet = hdwallet .derive (0 , private = False , hardened = False )
401
+ child1 = hdwallet .derive (0 , private = False , hardened = False )
402
+ child2 = hdwallet .derive (1 , private = False , hardened = False )
403
+ child3 = hdwallet .derive (2 , private = False , hardened = False )
404
+
405
+ assert (
406
+ child1 .public_key .hex ()
407
+ == "b3f354cbdc2837f823c5e0585995d3bd2d6edf1dc9fc8a1a90d01840c519408d"
408
+ )
409
+ assert (
410
+ child2 .public_key .hex ()
411
+ == "363aa29a3c93085859310ccddb182abcca18db6f6897a4f936ae82ba0a15af90"
412
+ )
413
+ assert (
414
+ child3 .public_key .hex ()
415
+ == "db58a4102f555ccb64a0db45259799cbd42fac14f7f6fd1059557fef3961e2c0"
416
+ )
417
+
418
+
419
+ def test_non_harden_public_derivation_without_pubkey ():
420
+ chain_code = bytes .fromhex (
421
+ "8a34b66a32c9d2d61d1d7a0e8fcf167efae3fb556af74808cd1ba8a22251c031"
422
+ )
423
+ hdwallet = HDWallet (chain_code = chain_code )
424
+ with pytest .raises (ValueError ):
425
+ hdwallet .derive (0 , private = False , hardened = False )
426
+
427
+
428
+ def test_non_harden_private_derivation_without_privkey ():
429
+ public_key = bytes .fromhex (
430
+ "601c86a2310f438079fff07454f4df4ce416bd181d972cd4c4615f15a733ba15"
431
+ )
432
+ chain_code = bytes .fromhex (
433
+ "8a34b66a32c9d2d61d1d7a0e8fcf167efae3fb556af74808cd1ba8a22251c031"
434
+ )
435
+ hdwallet = HDWallet (chain_code = chain_code , public_key = public_key )
436
+ with pytest .raises (ValueError ):
437
+ hdwallet .derive (0 , private = True , hardened = False )
0 commit comments