-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
mod.ts
27 lines (24 loc) · 938 Bytes
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// prettier-ignore
import {
CURVE, ProjectivePoint, Signature,
getPublicKey, sign, signAsync, verify, getSharedSecret,
utils, etc,
} from './index.ts';
import { hmac } from 'npm:@noble/[email protected]/hmac';
import { sha256 } from 'npm:@noble/[email protected]/sha256';
import { crypto } from 'https://deno.land/[email protected]/crypto/mod.ts';
utils.sha256 = async (...msgs: Uint8Array[]): Promise<Uint8Array> => {
return new Uint8Array(await crypto.subtle.digest('SHA-256', utils.concatBytes(...msgs)));
};
utils.sha256Sync = (...msgs: Uint8Array[]): Uint8Array => {
return new Uint8Array(crypto.subtle.digestSync('SHA-256', utils.concatBytes(...msgs)));
};
utils.hmacSha256Sync = function hmac(key: Uint8Array, ...messages: Uint8Array[]): Uint8Array {
return hmac(sha256, key, ...messages);
}
// prettier-ignore
export {
CURVE, ProjectivePoint, Signature,
getPublicKey, sign, signAsync, verify, getSharedSecret,
utils, etc,
};