mol_crypto_lib 0.0.744 → 0.0.746
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node.d.ts +3 -2
- package/node.deps.json +1 -1
- package/node.js +22 -0
- package/node.js.map +1 -1
- package/node.mjs +22 -0
- package/node.test.js +29 -0
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.d.ts +3 -2
- package/web.deps.json +1 -1
- package/web.js +22 -0
- package/web.js.map +1 -1
- package/web.mjs +22 -0
- package/web.test.js +49 -42
- package/web.test.js.map +1 -1
package/package.json
CHANGED
package/web.d.ts
CHANGED
|
@@ -26,15 +26,16 @@ declare namespace $ {
|
|
|
26
26
|
declare namespace $ {
|
|
27
27
|
class $mol_crypto_secret extends Object {
|
|
28
28
|
readonly native: CryptoKey & {
|
|
29
|
-
type: '
|
|
29
|
+
type: 'secret';
|
|
30
30
|
};
|
|
31
31
|
static size: number;
|
|
32
32
|
static extra: number;
|
|
33
33
|
constructor(native: CryptoKey & {
|
|
34
|
-
type: '
|
|
34
|
+
type: 'secret';
|
|
35
35
|
});
|
|
36
36
|
static generate(): Promise<$mol_crypto_secret>;
|
|
37
37
|
static from(serial: BufferSource | string): Promise<$mol_crypto_secret>;
|
|
38
|
+
static derive(private_serial: string, public_serial: string): Promise<$mol_crypto_secret>;
|
|
38
39
|
serial(): Promise<ArrayBuffer>;
|
|
39
40
|
encrypt(open: BufferSource, salt: BufferSource): Promise<ArrayBuffer>;
|
|
40
41
|
decrypt(closed: BufferSource, salt: BufferSource): Promise<ArrayBuffer>;
|
package/web.deps.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"files":["mam.ts","LICENSE","README.md","yarn.lock","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/index.html","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/crypto/README.md","mol/crypto/native/native.web.ts","node/node.ts","node/node.web.ts","mol/charset/encode/encode.ts","mol/crypto/secret/secret.ts","mol/crypto/cipher/cipher.ts","mol/crypto/auditor/auditor.ts","mol/crypto/hash/hash.ts","mol/crypto/salt/salt.ts","mol/crypto/lib/lib.meta.tree"],"mods":{},"deps_in":{"mol/crypto":{"mol/crypto/lib":-9007199254740991,"mol/crypto/secret":-9007199254740991,"mol/crypto/native":-9007199254740991,"mol/crypto/cipher":-9007199254740991,"mol/crypto/auditor":-9007199254740991,"mol/crypto/hash":-9007199254740991,"mol/crypto/salt":-9007199254740991},"mol":{"mol/crypto":-9007199254740991,"mol/charset":-9007199254740991},"":{"mol":-9007199254740991,"node":-9007199254740991},"mol/crypto/secret":{"mol/crypto/lib":-9000},"mol/crypto/native":{"mol/crypto/secret":-3,"mol/crypto/cipher":-2,"mol/crypto/auditor":-2,"mol/crypto/salt":-2},"mol/charset/encode":{"mol/crypto/secret":-4},"mol/charset":{"mol/charset/encode":-9007199254740991},"node":{"mol/charset/encode":-1},"node/node.ts":{"node":0},"mol/crypto/cipher":{"mol/crypto/lib":-9000},"mol/crypto/auditor":{"mol/crypto/lib":-9000},"mol/crypto/hash":{"mol/crypto/lib":-9000},"mol/crypto/salt":{"mol/crypto/lib":-9000}},"deps_out":{"mol/crypto/lib":{"mol/crypto":-9007199254740991,"mol/crypto/secret":-9000,"mol/crypto/cipher":-9000,"mol/crypto/auditor":-9000,"mol/crypto/hash":-9000,"mol/crypto/salt":-9000},"mol/crypto":{"mol":-9007199254740991},"mol":{"":-9007199254740991},"mol/crypto/secret":{"mol/crypto":-9007199254740991,"mol/crypto/native":-3,"mol/charset/encode":-4},"mol/crypto/native":{"mol/crypto":-9007199254740991},"mol/charset/encode":{"mol/charset":-9007199254740991,"node":-1},"mol/charset":{"mol":-9007199254740991},"node":{"":-9007199254740991,"node/node.ts":0},"mol/crypto/cipher":{"mol/crypto":-9007199254740991,"mol/crypto/native":-2},"mol/crypto/auditor":{"mol/crypto":-9007199254740991,"mol/crypto/native":-2},"mol/crypto/hash":{"mol/crypto":-9007199254740991},"mol/crypto/salt":{"mol/crypto":-9007199254740991,"mol/crypto/native":-2}},"sloc":{"ts":
|
|
1
|
+
{"files":["mam.ts","LICENSE","README.md","yarn.lock","mam.jam.js","tsfmt.json","package.json","tsconfig.json","lang.lang.tree","meta.lang.tree","sandbox.config.json","mol/CNAME","mol/LICENSE","mol/readme.md","mol/index.html","mol/mol.meta.tree","mol/CONTRIBUTING.md","mol/CODE_OF_CONDUCT.md","mol/crypto/README.md","mol/crypto/native/native.web.ts","node/node.ts","node/node.web.ts","mol/charset/encode/encode.ts","mol/crypto/secret/secret.ts","mol/crypto/cipher/cipher.ts","mol/crypto/auditor/auditor.ts","mol/crypto/hash/hash.ts","mol/crypto/salt/salt.ts","mol/crypto/lib/lib.meta.tree"],"mods":{},"deps_in":{"mol/crypto":{"mol/crypto/lib":-9007199254740991,"mol/crypto/secret":-9007199254740991,"mol/crypto/native":-9007199254740991,"mol/crypto/cipher":-9007199254740991,"mol/crypto/auditor":-9007199254740991,"mol/crypto/hash":-9007199254740991,"mol/crypto/salt":-9007199254740991},"mol":{"mol/crypto":-9007199254740991,"mol/charset":-9007199254740991},"":{"mol":-9007199254740991,"node":-9007199254740991},"mol/crypto/secret":{"mol/crypto/lib":-9000},"mol/crypto/native":{"mol/crypto/secret":-3,"mol/crypto/cipher":-2,"mol/crypto/auditor":-2,"mol/crypto/salt":-2},"mol/charset/encode":{"mol/crypto/secret":-4},"mol/charset":{"mol/charset/encode":-9007199254740991},"node":{"mol/charset/encode":-1},"node/node.ts":{"node":0},"mol/crypto/cipher":{"mol/crypto/lib":-9000},"mol/crypto/auditor":{"mol/crypto/lib":-9000},"mol/crypto/hash":{"mol/crypto/lib":-9000},"mol/crypto/salt":{"mol/crypto/lib":-9000}},"deps_out":{"mol/crypto/lib":{"mol/crypto":-9007199254740991,"mol/crypto/secret":-9000,"mol/crypto/cipher":-9000,"mol/crypto/auditor":-9000,"mol/crypto/hash":-9000,"mol/crypto/salt":-9000},"mol/crypto":{"mol":-9007199254740991},"mol":{"":-9007199254740991},"mol/crypto/secret":{"mol/crypto":-9007199254740991,"mol/crypto/native":-3,"mol/charset/encode":-4},"mol/crypto/native":{"mol/crypto":-9007199254740991},"mol/charset/encode":{"mol/charset":-9007199254740991,"node":-1},"mol/charset":{"mol":-9007199254740991},"node":{"":-9007199254740991,"node/node.ts":0},"mol/crypto/cipher":{"mol/crypto":-9007199254740991,"mol/crypto/native":-2},"mol/crypto/auditor":{"mol/crypto":-9007199254740991,"mol/crypto/native":-2},"mol/crypto/hash":{"mol/crypto":-9007199254740991},"mol/crypto/salt":{"mol/crypto":-9007199254740991,"mol/crypto/native":-2}},"sloc":{"ts":430,"LICENSE":113,"md":533,"lock":913,"js":9,"json":93,"tree":46,"CNAME":1,"html":1},"deps":{"mol/crypto/lib":{"..":-9007199254740991,"/mol/crypto/secret":-9000,"/mol/crypto/cipher":-9000,"/mol/crypto/auditor":-9000,"/mol/crypto/hash":-9000,"/mol/crypto/salt":-9000},"mol/crypto":{"..":-9007199254740991},"mol":{"..":-9007199254740991},"":{},"mol/crypto/secret":{"..":-9007199254740991,"/mol/crypto/secret":-1,"/mol/crypto/native/subtle/generate/key":-4,"/mol/charset/encode":-4,"/mol/crypto/native/subtle/digest":-4,"/mol/crypto/native/subtle/import/key":-3,"/mol/crypto/native/subtle/derive/key":-3,"/mol/crypto/native/subtle/export/key":-3,"/mol/crypto/native/subtle/encrypt":-3,"/mol/crypto/native/subtle/decrypt":-3},"mol/crypto/native":{"..":-9007199254740991,"./native.ts":0,"/mol/crypto/native":-1},"mol/charset/encode":{"..":-9007199254740991,"/node/util":-1,"/mol/charset/encode":-1},"mol/charset":{"..":-9007199254740991},"node":{"..":-9007199254740991,"./node.ts":0,"/node":0},"node/node.ts":{},"mol/crypto/cipher":{"..":-9007199254740991,"/mol/crypto/cipher/pair":-1,"/mol/crypto/native/subtle/generate/key":-2,"/mol/crypto/cipher/public":-1,"/mol/crypto/cipher/private":-1,"/mol/crypto/native/subtle/import/key":-4,"/mol/crypto/native/subtle/export/key":-3,"/mol/crypto/native/subtle/encrypt":-3,"/mol/crypto/native/subtle/decrypt":-3,"/mol/crypto/cipher/ecrypted/size":-1},"mol/crypto/auditor":{"..":-9007199254740991,"/mol/crypto/auditor/pair":-1,"/mol/crypto/native/subtle/generate/key":-2,"/mol/crypto/auditor/public":-1,"/mol/crypto/auditor/private":-1,"/mol/crypto/native/subtle/import/key":-4,"/mol/crypto/native/subtle/export/key":-3,"/mol/crypto/native/subtle/verify":-3,"/mol/crypto/native/subtle/sign":-3,"/mol/crypto/auditor/public/from":-3,"/mol/crypto/auditor/private/to/public":-1,"/mol/crypto/auditor/sign/size":-1},"mol/crypto/hash":{"..":-9007199254740991,"/mol/crypto/hash":-1},"mol/crypto/salt":{"..":-9007199254740991,"/mol/crypto/salt":-1,"/mol/crypto/native/get/random/values":-2}}}
|
package/web.js
CHANGED
|
@@ -80,6 +80,28 @@ var $;
|
|
|
80
80
|
}
|
|
81
81
|
return new this(await $mol_crypto_native.subtle.importKey('raw', serial, algorithm, true, ['encrypt', 'decrypt']));
|
|
82
82
|
}
|
|
83
|
+
static async derive(private_serial, public_serial) {
|
|
84
|
+
const ecdh = { name: "ECDH", namedCurve: "P-256" };
|
|
85
|
+
const jwk = { crv: 'P-256', ext: true, kty: 'EC' };
|
|
86
|
+
const private_key = await $mol_crypto_native.subtle.importKey('jwk', {
|
|
87
|
+
...jwk,
|
|
88
|
+
key_ops: ['deriveKey'],
|
|
89
|
+
x: private_serial.slice(0, 43),
|
|
90
|
+
y: private_serial.slice(43, 86),
|
|
91
|
+
d: private_serial.slice(86, 129),
|
|
92
|
+
}, ecdh, true, ['deriveKey']);
|
|
93
|
+
const public_key = await $mol_crypto_native.subtle.importKey('jwk', {
|
|
94
|
+
...jwk,
|
|
95
|
+
key_ops: [],
|
|
96
|
+
x: public_serial.slice(0, 43),
|
|
97
|
+
y: public_serial.slice(43, 86),
|
|
98
|
+
}, ecdh, true, []);
|
|
99
|
+
const secret = await $mol_crypto_native.subtle.deriveKey({
|
|
100
|
+
name: "ECDH",
|
|
101
|
+
public: public_key,
|
|
102
|
+
}, private_key, algorithm, true, ["encrypt", "decrypt"]);
|
|
103
|
+
return new this(secret);
|
|
104
|
+
}
|
|
83
105
|
async serial() {
|
|
84
106
|
return await $mol_crypto_native.subtle.exportKey('raw', this.native);
|
|
85
107
|
}
|
package/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["-","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../../../mam.ts","../../../../mam.jam.js","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../native/mol/crypto/native/native.web.ts","../../../../node/node.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../../../node/node/node.web.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../../charset/encode/mol/charset/encode/encode.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../secret/mol/crypto/secret/secret.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../cipher/mol/crypto/cipher/cipher.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../auditor/mol/crypto/auditor/auditor.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../hash/mol/crypto/hash/hash.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../salt/mol/crypto/salt/salt.ts"],"names":[],"sourceRoot":"/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/","mappings":";;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;AEFA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,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,QAAQ,GAAG,IAAI,KAAK,CAAC,GAAG,MAAM,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,CAAA;SACtF;QAED,OAAO,IAAI,UAAU,CAAE,IAAI,CAAC,MAAM,CAAE,CAAA;IACrC,CAAC;IA3Fe,kBAAgB,mBA2F/B,CAAA;AAEF,CAAC,EAlGS,CAAC,KAAD,CAAC,QAkGV;;;;AClGD,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IAGV,SAAgB,gBAAgB;QAC/B,OAAO,kBAAkB,CAAC,eAAe,CACxC,IAAI,UAAU,CAAE,EAAE,CAAE,CACpB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n",null,"namespace $ {\n\texport var $mol_crypto_native = crypto\n}\n",null,"// @ts-ignore\nvar $node = $node || {}\n","namespace $ {\n\tconst TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder\n\n\tconst encoder = new TextEncoder()\n\n\texport function $mol_charset_encode(value: string) {\n\t\treturn encoder.encode(value)\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: BufferSource | string ) {\n\t\t\t\n\t\t\tif( typeof serial === 'string' ) {\n\t\t\t\tserial = $mol_charset_encode( serial )\n\t\t\t\tserial = await $mol_crypto_native.subtle.digest( 'SHA-256', serial )\n\t\t\t}\n\t\t\t\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: BufferSource, salt: BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: BufferSource, salt : BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-256',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $mol_crypto_native.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: BufferSource ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: BufferSource ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\n\t/** @FIXME Need polyfill for Safari and Node (https://github.com/microsoft/MSR-JavaScript-Crypto/) */\n\tconst algorithm = {\n\t\tname: 'ECDSA',\n\t\thash: 'SHA-256',\n\t\tnamedCurve: \"P-256\",\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $mol_crypto_native.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 86\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: string ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'jwk',\n\t\t\t\t\t{\n\t\t\t\t\t\tcrv: \"P-256\",\n\t\t\t\t\t\text: true,\n\t\t\t\t\t\tkey_ops: ['verify'],\n\t\t\t\t\t\tkty: \"EC\",\n\t\t\t\t\t\tx: serial.slice( 0, 43 ),\n\t\t\t\t\t\ty: serial.slice( 43, 86 ),\n\t\t\t\t\t},\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial(): Promise< string > {\n\t\t\tconst { x, y } = await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'jwk',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t\treturn x! + y!\n\t\t}\n\t\t\n\t\tasync verify( data: BufferSource, sign: BufferSource ) {\n\t\t\treturn await $mol_crypto_native.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 129\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: string ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'jwk',\n\t\t\t\t\t{\n\t\t\t\t\t\tcrv: \"P-256\",\n\t\t\t\t\t\text: true,\n\t\t\t\t\t\tkey_ops: ['sign'],\n\t\t\t\t\t\tkty: \"EC\",\n\t\t\t\t\t\tx: serial.slice( 0, 43 ),\n\t\t\t\t\t\ty: serial.slice( 43, 86 ),\n\t\t\t\t\t\td: serial.slice( 86, 129 ),\n\t\t\t\t\t},\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 129 bytes */\n\t\tasync serial(): Promise< string > {\n\t\t\tconst { x, y, d } = await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'jwk',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t\treturn x! + y! + d!\n\t\t}\n\t\t\n\t\t/** 64 bytes */\n\t\tasync sign( data: BufferSource ) {\n\t\t\t\n\t\t\treturn await $mol_crypto_native.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t\t/** Makes public key from private */\n\t\tasync public() {\n\t\t\treturn await $mol_crypto_auditor_public.from(\n\t\t\t\t$mol_crypto_auditor_private_to_public( await this.serial() )\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 64\n\t\n\texport function $mol_crypto_auditor_private_to_public( serial: string ) {\n\t\treturn serial.slice( 0, 86 )\n\t}\n\t\n}\n","namespace $ {\n\t\n\tlet sponge = new Uint32Array(80)\n\t\n\t/** Fast small sync SHA-1 */\n\texport function $mol_crypto_hash( data: Uint8Array ) {\n\t\t\n\t\tconst bits = data.byteLength << 3\n\t\tconst kbits = bits >> 5\n\t\tconst kword = 0x80 << ( 24 - bits & 0b11111 )\n\t\t\n\t\tconst bytes = 16 + ( bits + 64 >>> 9 << 4 )\n\t\tconst klens = bytes - 1\n\t\tconst words = new Int32Array( data.buffer, data.byteOffset, data.byteLength >> 2 )\n\t\t\n\t\tlet tail = 0\n\t\tfor( let i = words.length * 4; i < data.length; ++i ) {\n\t\t\ttail |= data[i] << ( i << 3 & 0b11000 )\n\t\t}\n\t\t\n\t\t// Initial\n\t\tconst hash = new Int32Array([ 1732584193, -271733879, -1732584194, 271733878, -1009589776 ])\n\t\t\n\t\t// Digest\n\t\tfor( let i = 0; i < bytes; i += 16 ) {\n\t\t\t\n\t\t\tlet h0 = hash[0]\n\t\t\tlet h1 = hash[1]\n\t\t\tlet h2 = hash[2]\n\t\t\tlet h3 = hash[3]\n\t\t\tlet h4 = hash[4]\n\n\t\t\tfor( let j = 0; j < 80; ++j ) {\n\t\t\t\t\n\t\t\t\tlet turn\n\t\t\t\t\n\t\t\t\tif( j < 16 ) {\n\t\t\t\t\t\n\t\t\t\t\tconst k = i + j\n\t\t\t\t\tif( k === klens ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tsponge[j] = bits\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet word =\n\t\t\t\t\t\t\tk === words.length ? tail :\n\t\t\t\t\t\t\tk > words.length ? 0 :\n\t\t\t\t\t\t\twords[k]\n\t\t\t\t\t\t\n\t\t\t\t\t\tword = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF // LE -> BE\n\t\t\t\t\t\tif( k === kbits ) word |= kword\n\t\t\t\t\t\t\n\t\t\t\t\t\tsponge[j] = word\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tturn = ( h1 & h2 | ~h1 & h3 ) + 1518500249\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tconst shuffle = sponge[j-3] ^ sponge[j-8] ^ sponge[j-14] ^ sponge[j-16]\n\t\t\t\t\tsponge[j] = shuffle << 1 | shuffle >>> 31\n\t\t\t\t\t\n\t\t\t\t\tturn =\n\t\t\t\t\t\tj < 20 ? ( h1 & h2 | ~h1 & h3 ) + 1518500249 :\n\t\t\t\t\t\tj < 40 ? ( h1 ^ h2 ^ h3 ) + 1859775393 :\n\t\t\t\t\t\tj < 60 ? ( h1 & h2 | h1 & h3 | h2 & h3 ) - 1894007588 :\n\t\t\t\t\t\t( h1 ^ h2 ^ h3 ) - 899497514\n\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst next = turn + h4 + ( sponge[j] >>> 0 ) + (( h0 << 5 )|( h0 >>> 27 ))\n\n\t\t\t\th4 = h3\n\t\t\t\th3 = h2\n\t\t\t\th2 = ( h1 << 30 )|( h1 >>> 2 )\n\t\t\t\th1 = h0\n\t\t\t\th0 = next\n\t\t\t\t\n\t\t\t}\n\n\t\t\thash[0] += h0\n\t\t\thash[1] += h1\n\t\t\thash[2] += h2\n\t\t\thash[3] += h3\n\t\t\thash[4] += h4\n\t\t\t\n\t\t}\n\t\t\n\t\tfor( let i = 0; i < 20; ++i ) {\n\t\t\tconst word = hash[i]\n\t\t\thash[i] = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF // BE -> LE\n\t\t}\n\n\t\treturn new Uint8Array( hash.buffer )\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn $mol_crypto_native.getRandomValues(\n\t\t\tnew Uint8Array( 12 )\n\t\t)\n\t}\n\t\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["-","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../../../mam.ts","../../../../mam.jam.js","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../native/mol/crypto/native/native.web.ts","../../../../node/node.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../../../node/node/node.web.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../../charset/encode/mol/charset/encode/encode.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../secret/mol/crypto/secret/secret.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../cipher/mol/crypto/cipher/cipher.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../auditor/mol/crypto/auditor/auditor.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../hash/mol/crypto/hash/hash.ts","/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/../../salt/mol/crypto/salt/salt.ts"],"names":[],"sourceRoot":"/home/runner/work/mam_mol/mam_mol/mol/crypto/lib/-/","mappings":";;AAAA;AACA;AACA;AACA;;ACHA,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;AAK3B,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;AAMX,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;AAED,MAAM,CAAC,OAAO,GAAG,CAAC,CAAA;;;ADblB;AACA;AACA;AEFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACZA,IAAU,CAAC,CAEV;AAFD,WAAU,CAAC;IACC,oBAAkB,GAAG,MAAM,CAAA;AACvC,CAAC,EAFS,CAAC,KAAD,CAAC,QAEV;;;ACFD;AACA;AACA;;ACDA,IAAI,KAAK,GAAG,KAAK,IAAI,EAAE,CAAA;;;;ACDvB,IAAU,CAAC,CASV;AATD,WAAU,CAAC;IACV,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC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B,gBAAgB;QAC/B,OAAO,kBAAkB,CAAC,eAAe,CACxC,IAAI,UAAU,CAAE,EAAE,CAAE,CACpB,CAAA;IACF,CAAC;IAJe,kBAAgB,mBAI/B,CAAA;AAEF,CAAC,EATS,CAAC,KAAD,CAAC,QASV;;","sourcesContent":[null,"Error.stackTraceLimit = 50;\n\ndeclare let _$_: { new(): {} } & typeof globalThis\ndeclare class $ extends _$_ {}\n\nnamespace $ {\n\texport type $ = typeof $$\n\texport declare class $$ extends $ {}\n\tnamespace $$ {\n\t\texport type $$ = $\n\t}\n}\n\nmodule.exports = $\n",null,"namespace $ {\n\texport var $mol_crypto_native = crypto\n}\n",null,"// @ts-ignore\nvar $node = $node || {}\n","namespace $ {\n\tconst TextEncoder = globalThis.TextEncoder ?? $node.util.TextEncoder\n\n\tconst encoder = new TextEncoder()\n\n\texport function $mol_charset_encode(value: string) {\n\t\treturn encoder.encode(value)\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'AES-GCM',\n\t\tlength: 128,\n\t\ttagLength: 32,\n\t}\n\t\n\t/** Symmetric cipher with shortest payload */\n\texport class $mol_crypto_secret extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 16\n\t\t\n\t\t/** Extra size in bytes to encrypted data. */\n\t\tstatic extra = 4\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'secret' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async generate() {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.generateKey(\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t\t\t) as CryptoKey & { type: 'secret' }\n\t\t\t)\n\t\t}\n\t\t\n\t\tstatic async from( serial: BufferSource | string ) {\n\t\t\t\n\t\t\tif( typeof serial === 'string' ) {\n\t\t\t\tserial = $mol_charset_encode( serial )\n\t\t\t\tserial = await $mol_crypto_native.subtle.digest( 'SHA-256', serial )\n\t\t\t}\n\t\t\t\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'raw',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt', 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'secret' }\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t\tstatic async derive( private_serial: string, public_serial: string ) {\n\t\t\t\n\t\t\tconst ecdh = { name: \"ECDH\", namedCurve: \"P-256\" }\n\t\t\tconst jwk = { crv: 'P-256', ext: true, kty: 'EC' }\n\t\t\t\n\t\t\tconst private_key = await $mol_crypto_native.subtle.importKey(\n\t\t\t\t'jwk',\n\t\t\t\t{\n\t\t\t\t\t... jwk,\n\t\t\t\t\tkey_ops: [ 'deriveKey' ],\n\t\t\t\t\tx: private_serial.slice( 0, 43 ),\n\t\t\t\t\ty: private_serial.slice( 43, 86 ),\n\t\t\t\t\td: private_serial.slice( 86, 129 ),\n\t\t\t\t},\n\t\t\t\tecdh,\n\t\t\t\ttrue,\n\t\t\t\t[ 'deriveKey' ],\n\t\t\t)\n\t\t\n\t\t\tconst public_key = await $mol_crypto_native.subtle.importKey(\n\t\t\t\t'jwk',\n\t\t\t\t{\n\t\t\t\t\t... jwk,\n\t\t\t\t\tkey_ops: [],\n\t\t\t\t\tx: public_serial.slice( 0, 43 ),\n\t\t\t\t\ty: public_serial.slice( 43, 86 ),\n\t\t\t\t},\n\t\t\t\tecdh,\n\t\t\t\ttrue,\n\t\t\t\t[],\n\t\t\t)\n\t\t\t\n\t\t\tconst secret = await $mol_crypto_native.subtle.deriveKey(\n\t\t\t\t{\n\t\t\t\t name: \"ECDH\",\n\t\t\t\t public: public_key,\n\t\t\t\t},\n\t\t\t\tprivate_key,\n\t\t\t\talgorithm,\n\t\t\t\ttrue,\n\t\t\t\t[ \"encrypt\", \"decrypt\" ],\n\t\t\t)\n\t\t\n\t\t\treturn new this( secret as CryptoKey & { type: 'secret' } )\n\t\t}\n\t\t\n\t\t/** 16 bytes */\n\t\tasync serial() {\n\t\t\treturn await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'raw',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\n\t\t/** 4 bytes + data length */\n\t\tasync encrypt( open: BufferSource, salt: BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.encrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\topen\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( closed: BufferSource, salt : BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.decrypt(\n\t\t\t\t{\n\t\t\t\t\t... algorithm,\n\t\t\t\t\tiv: salt,\n\t\t\t\t},\n\t\t\t\tthis.native,\n\t\t\t\tclosed\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n}\n","namespace $ {\n\t\n\tconst algorithm = {\n\t\tname: 'RSA-OAEP',\n\t\tmodulusLength: 1024,\n\t\tpublicExponent: new Uint8Array([ 1, 0, 1 ]),\n\t\thash: 'SHA-256',\n\t}\n\t\n\t/** Asymmetric cipher pair with shortest payload */\n\texport async function $mol_crypto_cipher_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $mol_crypto_native.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'encrypt', 'decrypt' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_cipher_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_cipher_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher public key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_public extends Object {\n\t\t\n\t\t/** Public key size in bytes. */\n\t\tstatic size = 162\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: BufferSource ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'spki',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'encrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 162 bytes */\n\t\tasync serial() {\n\t\t\treturn await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'spki',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** max 86 bytes input, 128 bytes output */\n\t\tasync encrypt( data: BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.encrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\n\t/** Asymmetric cipher private key wrapper with shortest payload */\n\texport class $mol_crypto_cipher_private extends Object {\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: BufferSource ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'pkcs8',\n\t\t\t\t\tserial,\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'decrypt' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** ~640 bytes */\n\t\tasync serial() {\n\t\t\treturn await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'pkcs8',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t}\n\t\t\n\t\tasync decrypt( data: BufferSource ): Promise< ArrayBuffer > {\n\t\t\treturn await $mol_crypto_native.subtle.decrypt(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Encrypted size in bytes. */\n\texport const $mol_crypto_cipher_ecrypted_size = 128\n\n}\n","namespace $ {\n\n\t/** @FIXME Need polyfill for Safari and Node (https://github.com/microsoft/MSR-JavaScript-Crypto/) */\n\tconst algorithm = {\n\t\tname: 'ECDSA',\n\t\thash: 'SHA-256',\n\t\tnamedCurve: \"P-256\",\n\t}\n\t\n\t/** Asymmetric signing pair with shortest payload */\n\texport async function $mol_crypto_auditor_pair( this: $ ) {\n\t\t\n\t\tconst pair = await $mol_crypto_native.subtle.generateKey(\n\t\t\talgorithm,\n\t\t\ttrue,\n\t\t\t[ 'sign', 'verify' ]\n\t\t)\n\t\t\n\t\treturn {\n\t\t\t\n\t\t\tpublic: new $mol_crypto_auditor_public(\n\t\t\t\tpair.publicKey as CryptoKey & { type: 'public' }\n\t\t\t),\n\t\t\t\n\t\t\tprivate: new $mol_crypto_auditor_private(\n\t\t\t\tpair.privateKey as CryptoKey & { type: 'private' }\n\t\t\t),\n\t\t\t\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing public key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_public extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 86\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'public' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\t\n\t\tstatic async from( serial: string ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'jwk',\n\t\t\t\t\t{\n\t\t\t\t\t\tcrv: \"P-256\",\n\t\t\t\t\t\text: true,\n\t\t\t\t\t\tkey_ops: ['verify'],\n\t\t\t\t\t\tkty: \"EC\",\n\t\t\t\t\t\tx: serial.slice( 0, 43 ),\n\t\t\t\t\t\ty: serial.slice( 43, 86 ),\n\t\t\t\t\t},\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'verify' ],\n\t\t\t\t) as CryptoKey & { type: 'public' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 62 bytes */\n\t\tasync serial(): Promise< string > {\n\t\t\tconst { x, y } = await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'jwk',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t\treturn x! + y!\n\t\t}\n\t\t\n\t\tasync verify( data: BufferSource, sign: BufferSource ) {\n\t\t\treturn await $mol_crypto_native.subtle.verify(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tsign,\n\t\t\t\tdata,\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Asymmetric signing private key wrapper with shortest payload */\n\texport class $mol_crypto_auditor_private extends Object {\n\t\t\n\t\t/** Key size in bytes. */\n\t\tstatic size = 129\n\t\t\n\t\tconstructor(\n\t\t\treadonly native: CryptoKey & { type: 'private' }\n\t\t) {\n\t\t\tsuper()\n\t\t}\n\t\n\t\tstatic async from( serial: string ) {\n\t\t\treturn new this(\n\t\t\t\tawait $mol_crypto_native.subtle.importKey(\n\t\t\t\t\t'jwk',\n\t\t\t\t\t{\n\t\t\t\t\t\tcrv: \"P-256\",\n\t\t\t\t\t\text: true,\n\t\t\t\t\t\tkey_ops: ['sign'],\n\t\t\t\t\t\tkty: \"EC\",\n\t\t\t\t\t\tx: serial.slice( 0, 43 ),\n\t\t\t\t\t\ty: serial.slice( 43, 86 ),\n\t\t\t\t\t\td: serial.slice( 86, 129 ),\n\t\t\t\t\t},\n\t\t\t\t\talgorithm,\n\t\t\t\t\ttrue,\n\t\t\t\t\t[ 'sign' ],\n\t\t\t\t) as CryptoKey & { type: 'private' }\n\t\t\t)\n\t\t}\n\t\t\n\t\t/** 129 bytes */\n\t\tasync serial(): Promise< string > {\n\t\t\tconst { x, y, d } = await $mol_crypto_native.subtle.exportKey(\n\t\t\t\t'jwk',\n\t\t\t\tthis.native,\n\t\t\t)\n\t\t\treturn x! + y! + d!\n\t\t}\n\t\t\n\t\t/** 64 bytes */\n\t\tasync sign( data: BufferSource ) {\n\t\t\t\n\t\t\treturn await $mol_crypto_native.subtle.sign(\n\t\t\t\talgorithm,\n\t\t\t\tthis.native,\n\t\t\t\tdata\n\t\t\t)\n\t\t\t\n\t\t}\n\t\t\n\t\t/** Makes public key from private */\n\t\tasync public() {\n\t\t\treturn await $mol_crypto_auditor_public.from(\n\t\t\t\t$mol_crypto_auditor_private_to_public( await this.serial() )\n\t\t\t)\n\t\t}\n\t\t\n\t}\n\t\n\t/** Sign size in bytes. */\n\texport const $mol_crypto_auditor_sign_size = 64\n\t\n\texport function $mol_crypto_auditor_private_to_public( serial: string ) {\n\t\treturn serial.slice( 0, 86 )\n\t}\n\t\n}\n","namespace $ {\n\t\n\tlet sponge = new Uint32Array(80)\n\t\n\t/** Fast small sync SHA-1 */\n\texport function $mol_crypto_hash( data: Uint8Array ) {\n\t\t\n\t\tconst bits = data.byteLength << 3\n\t\tconst kbits = bits >> 5\n\t\tconst kword = 0x80 << ( 24 - bits & 0b11111 )\n\t\t\n\t\tconst bytes = 16 + ( bits + 64 >>> 9 << 4 )\n\t\tconst klens = bytes - 1\n\t\tconst words = new Int32Array( data.buffer, data.byteOffset, data.byteLength >> 2 )\n\t\t\n\t\tlet tail = 0\n\t\tfor( let i = words.length * 4; i < data.length; ++i ) {\n\t\t\ttail |= data[i] << ( i << 3 & 0b11000 )\n\t\t}\n\t\t\n\t\t// Initial\n\t\tconst hash = new Int32Array([ 1732584193, -271733879, -1732584194, 271733878, -1009589776 ])\n\t\t\n\t\t// Digest\n\t\tfor( let i = 0; i < bytes; i += 16 ) {\n\t\t\t\n\t\t\tlet h0 = hash[0]\n\t\t\tlet h1 = hash[1]\n\t\t\tlet h2 = hash[2]\n\t\t\tlet h3 = hash[3]\n\t\t\tlet h4 = hash[4]\n\n\t\t\tfor( let j = 0; j < 80; ++j ) {\n\t\t\t\t\n\t\t\t\tlet turn\n\t\t\t\t\n\t\t\t\tif( j < 16 ) {\n\t\t\t\t\t\n\t\t\t\t\tconst k = i + j\n\t\t\t\t\tif( k === klens ) {\n\t\t\t\t\t\t\n\t\t\t\t\t\tsponge[j] = bits\n\t\t\t\t\t\t\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet word =\n\t\t\t\t\t\t\tk === words.length ? tail :\n\t\t\t\t\t\t\tk > words.length ? 0 :\n\t\t\t\t\t\t\twords[k]\n\t\t\t\t\t\t\n\t\t\t\t\t\tword = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF // LE -> BE\n\t\t\t\t\t\tif( k === kbits ) word |= kword\n\t\t\t\t\t\t\n\t\t\t\t\t\tsponge[j] = word\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tturn = ( h1 & h2 | ~h1 & h3 ) + 1518500249\n\t\t\t\t\t\n\t\t\t\t} else {\n\t\t\t\t\t\n\t\t\t\t\tconst shuffle = sponge[j-3] ^ sponge[j-8] ^ sponge[j-14] ^ sponge[j-16]\n\t\t\t\t\tsponge[j] = shuffle << 1 | shuffle >>> 31\n\t\t\t\t\t\n\t\t\t\t\tturn =\n\t\t\t\t\t\tj < 20 ? ( h1 & h2 | ~h1 & h3 ) + 1518500249 :\n\t\t\t\t\t\tj < 40 ? ( h1 ^ h2 ^ h3 ) + 1859775393 :\n\t\t\t\t\t\tj < 60 ? ( h1 & h2 | h1 & h3 | h2 & h3 ) - 1894007588 :\n\t\t\t\t\t\t( h1 ^ h2 ^ h3 ) - 899497514\n\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst next = turn + h4 + ( sponge[j] >>> 0 ) + (( h0 << 5 )|( h0 >>> 27 ))\n\n\t\t\t\th4 = h3\n\t\t\t\th3 = h2\n\t\t\t\th2 = ( h1 << 30 )|( h1 >>> 2 )\n\t\t\t\th1 = h0\n\t\t\t\th0 = next\n\t\t\t\t\n\t\t\t}\n\n\t\t\thash[0] += h0\n\t\t\thash[1] += h1\n\t\t\thash[2] += h2\n\t\t\thash[3] += h3\n\t\t\thash[4] += h4\n\t\t\t\n\t\t}\n\t\t\n\t\tfor( let i = 0; i < 20; ++i ) {\n\t\t\tconst word = hash[i]\n\t\t\thash[i] = word << 24 | word << 8 & 0xFF0000 | word >>> 8 & 0xFF00 | word >>> 24 & 0xFF // BE -> LE\n\t\t}\n\n\t\treturn new Uint8Array( hash.buffer )\n\t}\n\t\n}\n","namespace $ {\n\t\n\t/** 8 byte */\n\texport function $mol_crypto_salt() {\n\t\treturn $mol_crypto_native.getRandomValues(\n\t\t\tnew Uint8Array( 12 )\n\t\t)\n\t}\n\t\n}\n"]}
|
package/web.mjs
CHANGED
|
@@ -80,6 +80,28 @@ var $;
|
|
|
80
80
|
}
|
|
81
81
|
return new this(await $mol_crypto_native.subtle.importKey('raw', serial, algorithm, true, ['encrypt', 'decrypt']));
|
|
82
82
|
}
|
|
83
|
+
static async derive(private_serial, public_serial) {
|
|
84
|
+
const ecdh = { name: "ECDH", namedCurve: "P-256" };
|
|
85
|
+
const jwk = { crv: 'P-256', ext: true, kty: 'EC' };
|
|
86
|
+
const private_key = await $mol_crypto_native.subtle.importKey('jwk', {
|
|
87
|
+
...jwk,
|
|
88
|
+
key_ops: ['deriveKey'],
|
|
89
|
+
x: private_serial.slice(0, 43),
|
|
90
|
+
y: private_serial.slice(43, 86),
|
|
91
|
+
d: private_serial.slice(86, 129),
|
|
92
|
+
}, ecdh, true, ['deriveKey']);
|
|
93
|
+
const public_key = await $mol_crypto_native.subtle.importKey('jwk', {
|
|
94
|
+
...jwk,
|
|
95
|
+
key_ops: [],
|
|
96
|
+
x: public_serial.slice(0, 43),
|
|
97
|
+
y: public_serial.slice(43, 86),
|
|
98
|
+
}, ecdh, true, []);
|
|
99
|
+
const secret = await $mol_crypto_native.subtle.deriveKey({
|
|
100
|
+
name: "ECDH",
|
|
101
|
+
public: public_key,
|
|
102
|
+
}, private_key, algorithm, true, ["encrypt", "decrypt"]);
|
|
103
|
+
return new this(secret);
|
|
104
|
+
}
|
|
83
105
|
async serial() {
|
|
84
106
|
return await $mol_crypto_native.subtle.exportKey('raw', this.native);
|
|
85
107
|
}
|
package/web.test.js
CHANGED
|
@@ -941,6 +941,48 @@ var $;
|
|
|
941
941
|
;
|
|
942
942
|
"use strict";
|
|
943
943
|
var $;
|
|
944
|
+
(function ($) {
|
|
945
|
+
$mol_test({
|
|
946
|
+
async 'sizes'() {
|
|
947
|
+
const pair = await $$.$mol_crypto_auditor_pair();
|
|
948
|
+
const key_public = await pair.public.serial();
|
|
949
|
+
$mol_assert_equal(key_public.length, $mol_crypto_auditor_public.size);
|
|
950
|
+
const key_private = await pair.private.serial();
|
|
951
|
+
$mol_assert_equal(key_private.length, $mol_crypto_auditor_private.size);
|
|
952
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
953
|
+
const sign = await pair.private.sign(data);
|
|
954
|
+
$mol_assert_equal(sign.byteLength, $mol_crypto_auditor_sign_size);
|
|
955
|
+
},
|
|
956
|
+
async 'verify self signed with auto generated key'() {
|
|
957
|
+
const auditor = await $$.$mol_crypto_auditor_pair();
|
|
958
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
959
|
+
const sign = await auditor.private.sign(data);
|
|
960
|
+
$mol_assert_ok(await auditor.public.verify(data, sign));
|
|
961
|
+
},
|
|
962
|
+
async 'verify signed with exported auto generated key'() {
|
|
963
|
+
const pair = await $$.$mol_crypto_auditor_pair();
|
|
964
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
965
|
+
const Alice = await $mol_crypto_auditor_private.from(await pair.private.serial());
|
|
966
|
+
const sign = await Alice.sign(data);
|
|
967
|
+
const Bob = await $mol_crypto_auditor_public.from(await pair.public.serial());
|
|
968
|
+
$mol_assert_ok(await Bob.verify(data, sign));
|
|
969
|
+
},
|
|
970
|
+
async 'take public key from private'() {
|
|
971
|
+
const pair = await $$.$mol_crypto_auditor_pair();
|
|
972
|
+
const data = new Uint8Array([1, 2, 3]);
|
|
973
|
+
const Alice = pair.private;
|
|
974
|
+
const sign = await Alice.sign(data);
|
|
975
|
+
const Bob = await pair.private.public();
|
|
976
|
+
const Carol = await $mol_crypto_auditor_public.from(await pair.private.serial());
|
|
977
|
+
$mol_assert_ok(await Bob.verify(data, sign));
|
|
978
|
+
$mol_assert_ok(await Carol.verify(data, sign));
|
|
979
|
+
},
|
|
980
|
+
});
|
|
981
|
+
})($ || ($ = {}));
|
|
982
|
+
//mol/crypto/auditor/auditor.web.test.ts
|
|
983
|
+
;
|
|
984
|
+
"use strict";
|
|
985
|
+
var $;
|
|
944
986
|
(function ($) {
|
|
945
987
|
$mol_test({
|
|
946
988
|
async 'sizes'() {
|
|
@@ -969,6 +1011,13 @@ var $;
|
|
|
969
1011
|
const opened = await Bob.decrypt(closed, salt);
|
|
970
1012
|
$mol_assert_like(data, new Uint8Array(opened));
|
|
971
1013
|
},
|
|
1014
|
+
async 'derivation from public & private keys'() {
|
|
1015
|
+
const A = await $$.$mol_crypto_auditor_pair();
|
|
1016
|
+
const B = await $$.$mol_crypto_auditor_pair();
|
|
1017
|
+
const AK = await $mol_crypto_secret.derive(await A.private.serial(), await B.public.serial());
|
|
1018
|
+
const BK = await $mol_crypto_secret.derive(await B.private.serial(), await A.public.serial());
|
|
1019
|
+
$mol_assert_like(new Uint8Array(await AK.serial()), new Uint8Array(await BK.serial()));
|
|
1020
|
+
},
|
|
972
1021
|
});
|
|
973
1022
|
})($ || ($ = {}));
|
|
974
1023
|
//mol/crypto/secret/secret.test.ts
|
|
@@ -1010,48 +1059,6 @@ var $;
|
|
|
1010
1059
|
;
|
|
1011
1060
|
"use strict";
|
|
1012
1061
|
var $;
|
|
1013
|
-
(function ($) {
|
|
1014
|
-
$mol_test({
|
|
1015
|
-
async 'sizes'() {
|
|
1016
|
-
const pair = await $$.$mol_crypto_auditor_pair();
|
|
1017
|
-
const key_public = await pair.public.serial();
|
|
1018
|
-
$mol_assert_equal(key_public.length, $mol_crypto_auditor_public.size);
|
|
1019
|
-
const key_private = await pair.private.serial();
|
|
1020
|
-
$mol_assert_equal(key_private.length, $mol_crypto_auditor_private.size);
|
|
1021
|
-
const data = new Uint8Array([1, 2, 3]);
|
|
1022
|
-
const sign = await pair.private.sign(data);
|
|
1023
|
-
$mol_assert_equal(sign.byteLength, $mol_crypto_auditor_sign_size);
|
|
1024
|
-
},
|
|
1025
|
-
async 'verify self signed with auto generated key'() {
|
|
1026
|
-
const auditor = await $$.$mol_crypto_auditor_pair();
|
|
1027
|
-
const data = new Uint8Array([1, 2, 3]);
|
|
1028
|
-
const sign = await auditor.private.sign(data);
|
|
1029
|
-
$mol_assert_ok(await auditor.public.verify(data, sign));
|
|
1030
|
-
},
|
|
1031
|
-
async 'verify signed with exported auto generated key'() {
|
|
1032
|
-
const pair = await $$.$mol_crypto_auditor_pair();
|
|
1033
|
-
const data = new Uint8Array([1, 2, 3]);
|
|
1034
|
-
const Alice = await $mol_crypto_auditor_private.from(await pair.private.serial());
|
|
1035
|
-
const sign = await Alice.sign(data);
|
|
1036
|
-
const Bob = await $mol_crypto_auditor_public.from(await pair.public.serial());
|
|
1037
|
-
$mol_assert_ok(await Bob.verify(data, sign));
|
|
1038
|
-
},
|
|
1039
|
-
async 'take public key from private'() {
|
|
1040
|
-
const pair = await $$.$mol_crypto_auditor_pair();
|
|
1041
|
-
const data = new Uint8Array([1, 2, 3]);
|
|
1042
|
-
const Alice = pair.private;
|
|
1043
|
-
const sign = await Alice.sign(data);
|
|
1044
|
-
const Bob = await pair.private.public();
|
|
1045
|
-
const Carol = await $mol_crypto_auditor_public.from(await pair.private.serial());
|
|
1046
|
-
$mol_assert_ok(await Bob.verify(data, sign));
|
|
1047
|
-
$mol_assert_ok(await Carol.verify(data, sign));
|
|
1048
|
-
},
|
|
1049
|
-
});
|
|
1050
|
-
})($ || ($ = {}));
|
|
1051
|
-
//mol/crypto/auditor/auditor.web.test.ts
|
|
1052
|
-
;
|
|
1053
|
-
"use strict";
|
|
1054
|
-
var $;
|
|
1055
1062
|
(function ($) {
|
|
1056
1063
|
$mol_test({
|
|
1057
1064
|
'empty hash'() {
|