diff --git a/src/eosjs-jssig.ts b/src/eosjs-jssig.ts index 610261372..51b47a9dc 100644 --- a/src/eosjs-jssig.ts +++ b/src/eosjs-jssig.ts @@ -48,7 +48,7 @@ class JsSignatureProvider implements SignatureProvider { /** @param privateKeys private keys to sign with */ constructor(privateKeys: string[]) { for (const k of privateKeys) { - const priv = PrivateKey.fromString(k).toElliptic(); + const priv = PrivateKey.fromString(k).toElliptic(defaultEc); const pubStr = PublicKey.fromElliptic(priv, KeyType.k1).toString(); this.keys.set(pubStr, priv); this.availableKeys.push(pubStr); diff --git a/src/eosjs-numeric.ts b/src/eosjs-numeric.ts index cbb40e65d..ad8ba5df0 100644 --- a/src/eosjs-numeric.ts +++ b/src/eosjs-numeric.ts @@ -266,24 +266,6 @@ export interface Key { data: Uint8Array; } -/** Construct the digest from transaction details */ -export function digestFromSerializedData( - chainId: string, - serializedTransaction: Uint8Array, - serializedContextFreeData?: Uint8Array, - e = new ec('secp256k1')) { - const signBuf = Buffer.concat([ - new Buffer(chainId, 'hex'), - new Buffer(serializedTransaction), - new Buffer( - serializedContextFreeData ? - new Uint8Array(e.hash(serializedContextFreeData).update(serializedContextFreeData).digest()) : - new Uint8Array(32) - ), - ]); - return e.hash().update(signBuf).digest(); -} - function digestSuffixRipemd160(data: Uint8Array, suffix: string) { const d = new Uint8Array(data.length + suffix.length); for (let i = 0; i < data.length; ++i) { diff --git a/src/tests/eosjs-jssig.test.ts b/src/tests/eosjs-jssig.test.ts index 807fbc1eb..5080d7f6e 100644 --- a/src/tests/eosjs-jssig.test.ts +++ b/src/tests/eosjs-jssig.test.ts @@ -1,7 +1,10 @@ -import { JsSignatureProvider } from '../eosjs-jssig'; import { ec } from 'elliptic'; + import { Signature, PrivateKey, PublicKey } from '../eosjs-key-conversions'; -import { digestFromSerializedData } from '../eosjs-numeric'; +import { + JsSignatureProvider, + digestFromSerializedData +} from '../eosjs-jssig'; import { SignatureProviderArgs } from '../eosjs-api-interfaces'; describe('JsSignatureProvider', () => {