Skip to content

Commit

Permalink
crypto: update interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tammo committed Jan 13, 2021
1 parent a9de095 commit 0724373
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/Crypto.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { Buffer } from 'buffer';

/**
* Cross platform interface to implement crypto related functions.
*
* TODO: Maybe replace 'any' with generics as Crypto<T> so that
* nodejs implementations can use Crypto<Buffer> and browser-utils
* can use Crypto<UInt8Array>.
*/
export interface Crypto {
randomBytes: (length: number) => any;
base64: {
toBytes: (payload: string | String) => any;
toString: (payload: any) => string;
randomBytes(length: number): Buffer;
sha256(message: string): string;
base58: {
toBytes(payload: string): Buffer;
toString(payload: Buffer): string;
};
secp256k1: {
verify(message: Buffer, signature: Buffer, publicKey: Buffer): boolean;
sign(message: Buffer, privateKey: Buffer): Buffer;
verifyPrivateKey(privateKey: Buffer): boolean;
createPublicKey(privateKey: Buffer): Buffer;
};
}
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
# yarn lockfile v1


base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==

[email protected]:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"

ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==

[email protected]:
version "3.1.4"
resolved "https://registry.yarnpkg.com/jsbi/-/jsbi-3.1.4.tgz#9654dd02207a66a4911b4e4bb74265bc2cbc9dd0"
Expand Down

0 comments on commit 0724373

Please sign in to comment.