Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
further optimizing ec object passing around; removing function from i…
Browse files Browse the repository at this point in the history
…ts original location, I already moved
  • Loading branch information
Mike Manfredi committed Oct 15, 2019
1 parent 7be6cef commit dc5bd5f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/eosjs-jssig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 0 additions & 18 deletions src/eosjs-numeric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions src/tests/eosjs-jssig.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down

0 comments on commit dc5bd5f

Please sign in to comment.