HD钱包可以只用主公钥生成子地址或者子公钥吗

web3大韭菜 web3大韭菜 提出于 2024-12-26 10:16 5310 浏览

** 这是从根地址助记词生成子地址私钥和子地址公钥,这种方式需要用到根地址的敏感信息,请教一下大佬们,可以只用根地址公钥派生出子地址的地址或者公钥么,用到私钥的时候再用这个方法还原回去 **

   // 2. 从助记词生成种子
    byte[] seed = generateSeedFromMnemonic(mnemonic);
    System.out.println("seed: " + seed);
    // 3. 从种子生成 BIP44 密钥链
    DeterministicKeyChain keyChain = DeterministicKeyChain.builder().seed(
            new DeterministicSeed(mnemonic.split(" ").toString(), seed, "", 0)).build();

    // 4. 获取私钥、公钥(使用 BIP-44 路径)
    String path = "44H/195H/0H/0/0";  // 修改为包含硬化路径的正确格式
    DeterministicKey key = keyChain.getKeyByPath(HDUtils.parsePath(path), true);
    
    byte[] privateKey = key.getPrivKeyBytes();
    byte[] publicKey = key.getPubKey();

2 个回答

Tiny熊 2024-12-26 19:13

擅长:智能合约,以太坊

写回答

你需要登录后才可以回答问题,登录