Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为以太坊地址两种生成方式增加测试用例 #94

Open
NateRobinson opened this issue Feb 7, 2022 · 0 comments
Open

为以太坊地址两种生成方式增加测试用例 #94

NateRobinson opened this issue Feb 7, 2022 · 0 comments
Assignees

Comments

@NateRobinson
Copy link

下面是 Android 的测试 case,需要在 iOS 上面能得到一样的结果。

  @Test
  fun genETHAddressByMnemonicCode() {
    val codes =
      "virus million sister elite junior comfort since grain train artefact lunch fever".split(" ")
    val seed = Bip44Utils.genSeedByInsertMnemonics(codes)
    println("seed:${seed.seedBytes?.encodeB64Url()}")

    // DID 派生规则生成的以太坊地址
    val keyPair = IdGenerator.genAppKeyPair("", 0, seed.seedBytes!!, KeyType.ETHEREUM)
    val addressFromIdGen1 = IdGenerator.pk2Address(
      keyPair.publicKey, DidType.DID_TYPE_ETHEREUM
    )
    println("addressFromIdGen1:${addressFromIdGen1}")
    Assert.assertEquals(addressFromIdGen1, "0xBA6f19e811A21a18F31D1320C18842b77f6D3afD")

    // 以太坊钱包默认派生规则生成的以太坊地址
    val keyPair2 = Bip44Utils.genKeyPair(seed.seedBytes)
    val addressFromIdGen2 = IdGenerator.pk2Address(
      keyPair2.publicKey.toByteArray(), DidType.DID_TYPE_ETHEREUM
    )
    println("addressFromIdGen2:${addressFromIdGen2}")
    Assert.assertEquals(addressFromIdGen2, "0xd89972DC4247fdf76570116A1CF643135a062916")
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants