| 770 | // ---------------------------------------------------------------------------- |
| 771 | |
| 772 | bool VanitySearch::checkPrivKey(string addr, Int &key, int32_t incr, int endomorphism, bool mode) { |
| 773 | |
| 774 | Int k(&key); |
| 775 | Point sp = startPubKey; |
| 776 | |
| 777 | if (incr < 0) { |
| 778 | k.Add((uint64_t)(-incr)); |
| 779 | k.Neg(); |
| 780 | k.Add(&secp->order); |
| 781 | if (startPubKeySpecified) sp.y.ModNeg(); |
| 782 | } else { |
| 783 | k.Add((uint64_t)incr); |
| 784 | } |
| 785 | |
| 786 | // Endomorphisms |
| 787 | switch (endomorphism) { |
| 788 | case 1: |
| 789 | k.ModMulK1order(&lambda); |
| 790 | if(startPubKeySpecified) sp.x.ModMulK1(&beta); |
| 791 | break; |
| 792 | case 2: |
| 793 | k.ModMulK1order(&lambda2); |
| 794 | if (startPubKeySpecified) sp.x.ModMulK1(&beta2); |
| 795 | break; |
| 796 | } |
| 797 | |
| 798 | // Check addresses |
| 799 | Point p = secp->ComputePublicKey(&k); |
| 800 | if (startPubKeySpecified) p = secp->AddDirect(p, sp); |
| 801 | |
| 802 | string chkAddr = secp->GetAddress(searchType, mode, p); |
| 803 | if (chkAddr != addr) { |
| 804 | |
| 805 | //Key may be the opposite one (negative zero or compressed key) |
| 806 | k.Neg(); |
| 807 | k.Add(&secp->order); |
| 808 | p = secp->ComputePublicKey(&k); |
| 809 | if (startPubKeySpecified) { |
| 810 | sp.y.ModNeg(); |
| 811 | p = secp->AddDirect(p, sp); |
| 812 | } |
| 813 | string chkAddr = secp->GetAddress(searchType, mode, p); |
| 814 | if (chkAddr != addr) { |
| 815 | printf("\nWarning, wrong private key generated !\n"); |
| 816 | printf(" Addr :%s\n", addr.c_str()); |
| 817 | printf(" Check:%s\n", chkAddr.c_str()); |
| 818 | printf(" Endo:%d incr:%d comp:%d\n", endomorphism, incr, mode); |
| 819 | return false; |
| 820 | } |
| 821 | |
| 822 | } |
| 823 | |
| 824 | output(addr, secp->GetPrivAddress(mode ,k), k.GetBase16()); |
| 825 | |
| 826 | return true; |
| 827 | |
| 828 | } |
| 829 |
nothing calls this directly
no test coverage detected