Issues with PK key generation using Aeternity browser extension

Hi
I’m new to Aeternity blockchain.
I’m trying to interact with AE blockchain from Java sdk.
For creating AeternityServiceConfiguration object, we need to generate private key
of the wallet account.
I have generated private key from Aeternity browser extension using following steps.
Settings >>Security&privacy >> Reveal private key
and I got a string contains 128 character and used to connect from the java sdk.
That time I got an exception 'Account Not found".

After that I checked one example and found the private key used in that example is only 64 character long. Where I did make mistake ?

Thanks in adavance.
Regards
Ajesh cr

3 Likes

Hi,

I am not 100% sure what you are talking about. But you can ask @mitch_lbw and myself all the questions about the java sdk.

Unfortunately the timing is a bit problematic right now to talk about KeyPair handling within the java sdk. We are currently preparing a new release v3.0.0 that supports features like the PayingForTx that will be available after the Iris hardfork.

Additionally we are currently performing a refactoring in the area of KeyPair handling with breaking changes.

In regards to your problem:

  • The “reveal private key” function in Superhero isn’t 100% accurate as it will show you your seed that can be used to recover multiple keypairs (mostly known as HD Wallet). It displays you 12 words, right?
  • In the java sdk we also have the possibility to recover accounts from a mnemonic seed. Here we identified an issue which is already solved but will be fixed when we release v3.0.0 (see key derivation: wrong addresses · Issue #126 · kryptokrauts/aepp-sdk-java · GitHub). This means that when using MnemonicKeyPairs in the java sdk you currently won’t recover the same address(s) that you see in Superhero. When this pull request (Bugfix/126 key derivation by mitch-lbw · Pull Request #144 · kryptokrauts/aepp-sdk-java · GitHub) is merged (we are still refactoring the KeyPair handling here) you will be able to use v3.0.0-SNAPSHOT version to recover your address from Superhero using that 12 word seed

Now what can you do to still recover the Superhero address and private key to use it in the java sdk? You need to use the 12 word seed in the javascript sdk and call some functions that will reveal you the 128 char encoded private key for your KeyPair. This 128 char encoded private key can then be used in the java sdk calling keyPairService.generateBaseKeyPairFromSecret("<encoded_private_key>"); (will be another function in v3.0.0 after refactoring).

We hope to release v3.0.0 in the near future. At least a release candidate that includes the fixed and refactored KeyPair handling.

I hope this information helps you. And sorry for the circumstances! :smiley:

2 Likes

I might haven’t understood your question correctly. Did you use the AccountService to get the account info for your address?

This is a valid response from the node when the Account hasn’t been seen before.

Example:

If that account would receive some AE tokens the endpoint would deliver the Account object:

    "/accounts/{pubkey}": {
      "get": {
        "tags": [
          "external",
          "account"
        ],
        "operationId": "GetAccountByPubkey",
        "description": "Get an account by public key",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "pubkey",
            "description": "The public key of the account",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful operation",
            "schema": {
              "$ref": "#/definitions/Account"
            }
          },
          "400": {
            "description": "Invalid public key",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          },
          "404": {
            "description": "Account not found",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }

If you don’t need to reuse an existing private key you can also create a new BaseKeyPair using the KeyPairService:
BaseKeyPair baseKeyPair = keyPairService.generateBaseKeyPair();

If you are using testnet you can also fund your account using the official faucet: https://faucet.aepps.com/

Just a note on this specific thing: Contrary to other blockchains, aeternity doesn’t just give you the balance “0” for new accounts, it also tells you whether the account actually exists in the state tree or not. So you can technically have a valid private key to some account and still stumble over this API response from the node every here and there (I think the JavaScript SDK is wrapping that into a nicer response for you).

2 Likes

When we can expect the v3.0.0 release ?, thanks

1 Like

probably in the next few weeks. cannot provide you a concrete date. depending on the features you want to use it would already be possible to use a snapshot version of the current development version of v3.0.0

the thing is that we are already preparing v3.0.0 for the upcoming Iris hardfork. so some functionalities might not work with the current network (Lima) when using the snapshot version of the SDK.

what do you want to use the Java SDK for? we can also discuss this in private chat if you want. or on discord (Discord)

2 Likes