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

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

Open
wangshijun opened this issue Mar 13, 2019 · 2 comments

Comments

@wangshijun
Copy link
Contributor

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);
  }
})();

@wangshijun
Copy link
Contributor Author

I tested with fromSecretKey and fromRandom to generate wallet, they all behave the same, some random keys cannot produce elixir verifiable signatures.

@NateRobinson
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants