Closed scottexton closed 4 months ago
The seed with indy sdk was actually the private key. I think askar has a fromPrivateKey/fromSecretKey method and that should work with the seed
Unfortunately the 'fromSecretKey' method does not work when using the secret. If I change the above-mentioned code to use the following:
const key = askar.Key.fromSecretBytes({
algorithm: askar.KeyAlgs.Ed25519,
secretKey: Buffer.from("0000000000000000000ISVAGENCYROOT"),
});
I get the following error:
AriesAskarError: Invalid key data
at NodeJSAriesAskar.getAriesAskarError (/home/agency/node_modules/@hyperledger/aries-askar-nodejs/src/NodeJSAriesAskar.ts:219:12)
at NodeJSAriesAskar.handleError (/home/agency/node_modules/@hyperledger/aries-askar-nodejs/src/NodeJSAriesAskar.ts:225:16)
at NodeJSAriesAskar.keyFromSecretBytes (/home/agency/node_modules/@hyperledger/aries-askar-nodejs/src/NodeJSAriesAskar.ts:601:10)
at Function.fromSecretBytes (/home/agency/node_modules/@hyperledger/aries-askar-shared/src/crypto/Key.ts:35:31)
at /home/agency/indy-vdr/main.ts:73:27
at Generator.next (<anonymous>)
at fulfilled (/home/agency/indy-vdr/main.ts:28:58) {
code: 5
}
I think it may have to do with a bug fixed in main, but not yet released. Could you wrap the Buffer.from in a new Uint8Array
?
So:
const key = askar.Key.fromSecretBytes({
algorithm: askar.KeyAlgs.Ed25519,
secretKey: new Uint8Array(Buffer.from("0000000000000000000ISVAGENCYROOT")),
});
Unfortunately I get the same error when I wrap the buffer in a new Uint8Array
. Any other ideas? Thanks.
@TimoGlastra I've managed to resolve the problem based on your latest advice. I had to wrap the Buffer.from in a new Uint8Array
, along with the call to signMessage
. The working code is:
const newverkey = await createKey();
const request = new vdr.NymRequest({
dest: newverkey.did,
submitterDid: endorserDid,
verkey: newverkey.verkey,
})
const key = askar.Key.fromSecretBytes({
secretKey: new Uint8Array(Buffer.from('00000000000000000000MYAGENCYROOT')),
algorithm: askar.KeyAlgs.Ed25519,
});
request.setSignature({
signature: key.signMessage({
message: new Uint8Array(Buffer.from(request.signatureInput)),
}),
})
await pool.submitRequest(request);
I'm not sure if this is the correct place to get some assistance, but I am currently looking to convert from the indy-sdk to the indy-vdr/aries-askar. I have an indy-ledger already set up, and I am trying to create a key from a secret which can then be used when creating a new Nym. My code is as follows:
I know that the seed and endorserDid is correct as I can use this successfully with my indy-sdk program. However, the above code appears to generate a different key from the seed and I get the following error when submitting the request:
Any ideas as to what I could be doing wrong?