Remove PrehashType

This commit is contained in:
Simon Warta
2020-09-24 13:54:13 +02:00
parent bc890bee73
commit 5f2cf289eb
7 changed files with 7 additions and 34 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ export {
} from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
export { AccountData, Algo, PrehashType, OfflineSigner } from "./signer";
export { AccountData, Algo, OfflineSigner } from "./signer";
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
export { makeCosmoshubPath, executeKdf, KdfConfiguration } from "./wallet";
+1 -7
View File
@@ -1,8 +1,6 @@
import { StdSignDoc } from "./encoding";
import { StdSignature } from "./types";
export type PrehashType = "sha256" | "sha512" | null;
export type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
@@ -24,9 +22,5 @@ export interface OfflineSigner {
* @param signerAddress The address of the account that should sign the transaction
* @param signDoc The content that should be signed
*/
readonly sign: (
signerAddress: string,
signDoc: StdSignDoc,
prehashType?: PrehashType,
) => Promise<StdSignature>;
readonly sign: (signerAddress: string, signDoc: StdSignDoc) => Promise<StdSignature>;
}
-17
View File
@@ -3,29 +3,12 @@ import {
HdPath,
isArgon2idOptions,
Random,
Sha256,
Sha512,
Slip10RawIndex,
xchacha20NonceLength,
Xchacha20poly1305Ietf,
} from "@cosmjs/crypto";
import { toAscii } from "@cosmjs/encoding";
import { PrehashType } from "./signer";
export function prehash(bytes: Uint8Array, type: PrehashType): Uint8Array {
switch (type) {
case null:
return new Uint8Array([...bytes]);
case "sha256":
return new Sha256(bytes).digest();
case "sha512":
return new Sha512(bytes).digest();
default:
throw new Error("Unknown prehash type");
}
}
/**
* The Cosmoshub derivation path in the form `m/44'/118'/0'/0/a`
* with 0-based account index `a`.