Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public signedHashing(data: string, signerPrivateKey: string, networkType: NetworkType): string {
const dataHash = CryptoJS.SHA3(data, { outputLength: 256 }).toString();
if (networkType === NetworkType.MAIN_NET || networkType === NetworkType.TEST_NET) {
const keyPair = nem.crypto.keyPair.create(signerPrivateKey);
return this.checksum + keyPair.sign(dataHash).toString();
} else {
// sha-3 signing
const signer = Account.createFromPrivateKey(signerPrivateKey, networkType);
return this.checksum + signer.signData(dataHash);
}
}
}
it('should return true after creation', async () => {
const privateApostille = Apostille.initFromSeed('new random seed', generator);
const creator = Account.createFromPrivateKey(sk, NetworkType.MIJIN_TEST);
const Icreator = new Initiator(creator);
expect.assertions(1);
const creationTransaction = privateApostille.update('raw');
const signedTransaction = Icreator.sign(creationTransaction, generationHash);
await apostilleHttp.announce(signedTransaction);
return apostilleHttp.isCreated(privateApostille.publicAccount).then((result) => {
expect(result).toBeTruthy();
});
});
private getAccount(): Account
{
return Account.createFromPrivateKey(this.privateKey, NetworkType.MIJIN_TEST);
}
public signedHashing(data: string, signerPrivateKey: string, networkType: NetworkType): string {
const dataHash = sha3_256(data);
if (networkType === NetworkType.MAIN_NET || networkType === NetworkType.TEST_NET) {
throw Errors[Errors.NETWORK_TYPE_NOT_SUPPORTED];
} else {
const signer = Account.createFromPrivateKey(signerPrivateKey, networkType);
return this.checksum + signer.signData(dataHash);
}
}
}