Skip to content

mcrypto.secp256k1 may generate keypair that produce different signature than elixir #173

@wangshijun

Description

@wangshijun

Since this is not a stable/critical issue, create a backlog here:

/* eslint no-console:"off" */
const { fromRandom, WalletType } = require('@arcblock/forge-wallet');
const Mcrypto = require('@arcblock/mcrypto');
const { hexToBytes } = require('@arcblock/forge-util');
const GraphqlClient = require('@arcblock/forge-graphql-client');

const client = new GraphqlClient('http://localhost:8210/api'); // local

const type = WalletType({
  role: Mcrypto.types.RoleType.ROLE_ACCOUNT,
  // pk: Mcrypto.types.KeyType.ED25519,
  pk: Mcrypto.types.KeyType.SECP256K1,
  hash: Mcrypto.types.HashType.SHA3,
});

(async () => {
  try {
    const wallet = fromRandom(type);
    console.log(wallet.toJSON().type);
    const res = await client.sendDeclareTx({
      data: {
        moniker: `wangshijun_${Math.round(Math.random() * 1000)}`,
        pk: Buffer.from(hexToBytes(wallet.publicKey)),
        type,
        issuer: '',
        data: null,
      },
      wallet,
    });

    console.log(res);
  } catch (err) {
    console.error(err);
  }
})();

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions