Skip to content

Commit

Permalink
revert changes to TezosMessageUtil.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
keefertaylor committed Jul 12, 2020
1 parent 682a2fc commit 13feb82
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/chain/tezos/TezosMessageUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ export namespace TezosMessageUtils {
export function writeKeyWithHint(key: string, hint: string): Buffer {
if (hint === 'edsk' || hint === 'edpk') { // ed25519
return base58check.decode(key).slice(4);
//} else if (hint === 'sppk') { // secp256k1
//} else if (hint === 'p2pk') { // secp256r1
//} else if (hint === 'sppk') { // secp256k1
//} else if (hint === 'p2pk') { // secp256r1
} else {
throw new Error(`Unrecognized key hint, '${hint}'`);
}
Expand All @@ -310,6 +310,7 @@ export namespace TezosMessageUtils {
*/
export function readSignatureWithHint(b: Buffer | Uint8Array, hint: string): string {
const sig = !(b instanceof Buffer) ? Buffer.from(b) : b;

if (hint === 'edsig') {
return base58check.encode(Buffer.from('09f5cd8612' + sig.toString('hex'), 'hex'));
} else {
Expand Down Expand Up @@ -397,7 +398,7 @@ export namespace TezosMessageUtils {
* @param format value format, this argument is used to encode complex values, Michelson and Micheline encoding is supported with the internal parser.
*/
export function writePackedData(value: string | number | Buffer, type: string, format: TezosParameterFormat = TezosParameterFormat.Micheline): string {
switch (type) {
switch(type) {
case 'int': {
return '0500' + writeSignedInt(value as number);
}
Expand Down Expand Up @@ -441,8 +442,8 @@ export namespace TezosMessageUtils {
* @param hex
* @param type
*/
export function readPackedData(hex: string, type: string): string | number {
switch (type) {
export function readPackedData(hex: string, type: string) : string | number {
switch(type) {
case 'int': {
return readSignedInt(hex.slice(4));
}
Expand Down Expand Up @@ -480,15 +481,15 @@ export namespace TezosMessageUtils {
* @param {Buffer} payload Buffer to hash
* @param {number} length Length of hash to produce
*/
export function simpleHash(payload: Buffer, length: number): Buffer {
export function simpleHash(payload: Buffer, length: number) : Buffer {
return Buffer.from(blakejs.blake2b(payload, null, length)); // Same as libsodium.crypto_generichash
}

/**
* Encodes the provided number as base128.
* @param n
*/
function twoByteHex(n: number): string {
function twoByteHex(n: number) : string {
if (n < 128) { return ('0' + n.toString(16)).slice(-2); }

let h = '';
Expand All @@ -513,7 +514,7 @@ export namespace TezosMessageUtils {
* Decodes the provided base128 string into a number
* @param s
*/
function fromByteHex(s: string): number {
function fromByteHex(s: string) : number {
if (s.length === 2) { return parseInt(s, 16); }

if (s.length <= 8) {
Expand Down

0 comments on commit 13feb82

Please sign in to comment.