From 258b232518a7fc91f6c60c20e282b61c8087fd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Iv=C3=A1n=20Vieitez=20Parra?= <3857362+corrideat@users.noreply.github.com> Date: Fri, 9 Feb 2024 21:05:32 +0100 Subject: [PATCH] Implemented manifest signatures (#27) * Implemented manifest signatures * Vendor tweetnacl * Various changes * New verifySignature command * Tests for validating signatures * keygen command now outputs to two files * manifest command now uses public key files instead of strings * Update CI deno version * Optional external key for verification, flow control using exit instead of throw * Verify that hashes match --- .github/workflows/ci.yml | 2 +- deno.json | 3 +- deno.lock | 24 +- src/commands.ts | 2 + src/deps.ts | 1 + src/help.ts | 5 +- src/keygen.ts | 29 ++ src/lib/crypto.ts | 379 ++++++++++++++++++ src/manifest.ts | 43 +- src/utils.ts | 11 +- src/verifySignature.ts | 80 ++++ test/assets/bundle-tampered.bundle.example | 1 + .../bundle-tampered.bundle.x.manifest.json | 1 + test/assets/bundle-tampered.slim.example | 0 .../edwards25519sha512batch-g6kUyhtL5bPd.json | 1 + ...ards25519sha512batch-g6kUyhtL5bPd.pub.json | 1 + .../edwards25519sha512batch-jy3R1NPmA17o.json | 1 + ...ards25519sha512batch-jy3R1NPmA17o.pub.json | 1 + ...d-signature-missing-pubkey.x.manifest.json | 1 + test/assets/slim-tampered.bundle.example | 0 .../slim-tampered.bundle.x.manifest.json | 1 + test/assets/slim-tampered.slim.example | 1 + ...valid-signature-missing-id.x.manifest.json | 1 + .../valid-signature-tampered.x.manifest.json | 1 + .../valid-signature-wrong-id.x.manifest.json | 1 + test/assets/valid-signature.example | 0 test/assets/valid-signature.x.manifest.json | 1 + test/signature.test.ts | 68 ++++ vendor/esm.sh/@multiformats/blake2@1.0.13.js | 6 +- vendor/esm.sh/multiformats@11.0.2.proxied.js | 7 +- .../bases/base58.proxied.js | 4 +- vendor/esm.sh/tweetnacl@1.0.3.js | 3 + vendor/esm.sh/tweetnacl@1.0.3.proxied.js | 3 + .../blake2@1.0.13/denonext/blake2.mjs | 3 + .../blake2@1.0.13/denonext/blake2b.js | 3 + .../blake2@1.0.13/denonext/blake2s.js | 3 + .../v120/blakejs@1.2.1/denonext/blakejs.mjs | 5 + .../denonext/hashes/hasher.js | 3 + .../multiformats@11.0.2/denonext/interface.js | 3 + .../denonext/multiformats.mjs | 3 + .../denonext/bases/base32.js | 3 + .../denonext/bases/base58.js | 3 + .../v120/multiformats@9.9.0/denonext/cid.js | 17 + .../denonext/hashes/digest.js | 3 + .../denonext/hashes/hasher.js | 3 + .../denonext/multiformats.mjs | 3 + .../tweetnacl@1.0.3/denonext/tweetnacl.mjs | 5 + vendor/esm.sh/v120/tweetnacl@1.0.3/nacl.d.ts | 98 +++++ vendor/import_map.json | 24 +- 49 files changed, 838 insertions(+), 27 deletions(-) create mode 100644 src/keygen.ts create mode 100644 src/lib/crypto.ts create mode 100644 src/verifySignature.ts create mode 100644 test/assets/bundle-tampered.bundle.example create mode 100644 test/assets/bundle-tampered.bundle.x.manifest.json create mode 100644 test/assets/bundle-tampered.slim.example create mode 100644 test/assets/edwards25519sha512batch-g6kUyhtL5bPd.json create mode 100644 test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json create mode 100644 test/assets/edwards25519sha512batch-jy3R1NPmA17o.json create mode 100644 test/assets/edwards25519sha512batch-jy3R1NPmA17o.pub.json create mode 100644 test/assets/invalid-signature-missing-pubkey.x.manifest.json create mode 100644 test/assets/slim-tampered.bundle.example create mode 100644 test/assets/slim-tampered.bundle.x.manifest.json create mode 100644 test/assets/slim-tampered.slim.example create mode 100644 test/assets/valid-signature-missing-id.x.manifest.json create mode 100644 test/assets/valid-signature-tampered.x.manifest.json create mode 100644 test/assets/valid-signature-wrong-id.x.manifest.json create mode 100644 test/assets/valid-signature.example create mode 100644 test/assets/valid-signature.x.manifest.json create mode 100644 test/signature.test.ts create mode 100644 vendor/esm.sh/tweetnacl@1.0.3.js create mode 100644 vendor/esm.sh/tweetnacl@1.0.3.proxied.js create mode 100644 vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs create mode 100644 vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js create mode 100644 vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js create mode 100644 vendor/esm.sh/v120/blakejs@1.2.1/denonext/blakejs.mjs create mode 100644 vendor/esm.sh/v120/multiformats@11.0.2/denonext/hashes/hasher.js create mode 100644 vendor/esm.sh/v120/multiformats@11.0.2/denonext/interface.js create mode 100644 vendor/esm.sh/v120/multiformats@11.0.2/denonext/multiformats.mjs create mode 100644 vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base32.js create mode 100644 vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base58.js create mode 100644 vendor/esm.sh/v120/multiformats@9.9.0/denonext/cid.js create mode 100644 vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/digest.js create mode 100644 vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/hasher.js create mode 100644 vendor/esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs create mode 100644 vendor/esm.sh/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs create mode 100644 vendor/esm.sh/v120/tweetnacl@1.0.3/nacl.d.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52381d7..60123c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,5 +14,5 @@ jobs: - uses: actions/checkout@v3 - uses: denoland/setup-deno@v1 with: - deno-version: v1.38.2 + deno-version: v1.40.4 - run: deno task test --no-check \ No newline at end of file diff --git a/deno.json b/deno.json index 713328d..1b05e60 100644 --- a/deno.json +++ b/deno.json @@ -24,5 +24,6 @@ "files": { "exclude": ["node_modules/", "test/", "vendor/", "dist/", "build/"] } - } + }, + "importMap": "./vendor/import_map.json" } diff --git a/deno.lock b/deno.lock index f96f2cd..d0b4abb 100644 --- a/deno.lock +++ b/deno.lock @@ -1,5 +1,16 @@ { "version": "3", + "packages": { + "specifiers": { + "npm:@types/node": "npm:@types/node@18.16.19" + }, + "npm": { + "@types/node@18.16.19": { + "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", + "dependencies": {} + } + } + }, "remote": { "https://deno.land/std@0.141.0/_deno_unstable.ts": "be3276fd42cffb49f51b705c4b0aa8656aaf2a34be22d769455c8e50ea38e51a", "https://deno.land/std@0.141.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", @@ -73,6 +84,7 @@ "https://esm.sh/multiformats@11.0.2/bases/base58?pin=v120": "56b47cfb7575c0f28044b5340f14a38e1775be6ab2c2fe5f81a882c19260f78a", "https://esm.sh/multiformats@11.0.2/cid?pin=v120": "56f33147af16cdb712f1d51858d1d483353ed09d54acde4fa86b379e83e058f9", "https://esm.sh/multiformats@11.0.2?pin=v120": "61b319b9f022bc676137ccd138d2f4abffc45c0887063c697a00068577910f82", + "https://esm.sh/tweetnacl@1.0.3?pin=v120": "7fd2e067403532babb7e801d6c3746135710d6e053200225fa146dc9782db4fa", "https://esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs": "06b7a0e19c9829682b687896238cee5af51914a6c4e36189962495c5fab6ca39", "https://esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js": "941975606700293e37053d2447cbc9f69a1c8dab5dcfb83e3e601bfb04e8a89a", "https://esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js": "501b9234b3c12c9126998ed31d7b7749f747ae672aceb25048d0769faa2542e1", @@ -91,6 +103,16 @@ "https://esm.sh/v120/multiformats@9.9.0/denonext/cid.js": "48cf6a7ce1549d22c4c1c52f7bdc86764e8b0b554e63479c225dfee55e5e2680", "https://esm.sh/v120/multiformats@9.9.0/denonext/hashes/digest.js": "48b56d71af6b63bbcc2ba2e950c4cad2ae39d1d1ffdac0bfa66b0158884870d7", "https://esm.sh/v120/multiformats@9.9.0/denonext/hashes/hasher.js": "0c14237ee590ff3bf5ef2d5dd2a9cac4bea36b9b0b58b66cb1dd8e6cfac505cc", - "https://esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs": "39aa6f06f0810d8e179e2cabbc0e5d56ce80c4167994ccb24d1730648d958ef9" + "https://esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs": "39aa6f06f0810d8e179e2cabbc0e5d56ce80c4167994ccb24d1730648d958ef9", + "https://esm.sh/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs": "b4b0ea92630faa255eef33b2ac85734313cd8930834375bb2527392f1823775e" + }, + "workspace": { + "packageJson": { + "dependencies": [ + "npm:axios@0.27.2", + "npm:rimraf@3.0.2", + "npm:tar@6.1.11" + ] + } } } diff --git a/src/commands.ts b/src/commands.ts index c74bb0e..5214bb1 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -5,7 +5,9 @@ export { eventsAfter } from './eventsAfter.ts' export { get } from './get.ts' export { hash } from './hash.ts' export { help } from './help.ts' +export { keygen } from './keygen.ts' export { manifest } from './manifest.ts' export { migrate } from './migrate.ts' export { upload } from './upload.ts' +export { verifySignature } from './verifySignature.ts' export { version } from './version.ts' diff --git a/src/deps.ts b/src/deps.ts index f3c039c..1f919d3 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -5,6 +5,7 @@ export * as colors from "https://deno.land/std@0.141.0/fmt/colors.ts" export * as fs from 'https://deno.land/std@0.141.0/fs/mod.ts' export * as path from 'https://deno.land/std@0.141.0/path/mod.ts' export * as streams from "https://deno.land/std@0.141.0/streams/mod.ts" +export { default as tweetnacl } from 'https://esm.sh/tweetnacl@1.0.3?pin=v120' export { base58btc } from 'https://esm.sh/multiformats@11.0.2/bases/base58?pin=v120' export { type Multibase } from 'https://esm.sh/multiformats@11.0.2?pin=v120' export { default as blake } from 'https://esm.sh/@multiformats/blake2@1.0.13?pin=v120' diff --git a/src/help.ts b/src/help.ts index 9511b1d..52d86ca 100644 --- a/src/help.ts +++ b/src/help.ts @@ -6,8 +6,9 @@ export function help (args?: string[]) { chel chel help [command] chel version - chel keygen [--out ] - chel manifest [-k|--key [-k|--key ...]] [--out=] [-s|--slim ] [-v|--version ] + chel keygen [--out ] [--pubout ] + chel verifySignature [-k ] + chel manifest [-k|--key [-k|--key ...]] [--out=] [-s|--slim ] [-v|--version ] chel deploy [ [ ...]] chel upload [ [ ...]] chel latestState diff --git a/src/keygen.ts b/src/keygen.ts new file mode 100644 index 0000000..c1634ff --- /dev/null +++ b/src/keygen.ts @@ -0,0 +1,29 @@ +import { colors, flags } from './deps.ts' +import { revokeNet } from './utils.ts' +import { EDWARDS25519SHA512BATCH, keygen as cryptoKeygen, keyId, serializeKey } from './lib/crypto.ts' + +export const keygen = async (args: string[]) => { + await revokeNet() + const parsedArgs = flags.parse(args) + const key = cryptoKeygen(EDWARDS25519SHA512BATCH) + const pubKeyData = { + version: '1.0.0', + pubkey: serializeKey(key, false) + } + const keyData = { + ...pubKeyData, + privkey: serializeKey(key, true) + } + const result = JSON.stringify(keyData) + const pubResult = JSON.stringify(pubKeyData) + + const idx = keyId(key).slice(-12) + const outFile = parsedArgs['out'] || `${EDWARDS25519SHA512BATCH}-${idx}.json` + const pubOutFile = parsedArgs['pubout'] || `${EDWARDS25519SHA512BATCH}-${idx}.pub.json` + + await Deno.writeTextFile(outFile, result) + console.log(colors.green('wrote:'), outFile, colors.blue('(secret)')) + + await Deno.writeTextFile(pubOutFile, pubResult) + console.log(colors.green('wrote:'), pubOutFile, colors.blue('(public)')) +} \ No newline at end of file diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts new file mode 100644 index 0000000..43e584f --- /dev/null +++ b/src/lib/crypto.ts @@ -0,0 +1,379 @@ +'use strict' + +import { base58btc, blake, tweetnacl as nacl } from '../deps.ts' + +export const EDWARDS25519SHA512BATCH = 'edwards25519sha512batch' +export const CURVE25519XSALSA20POLY1305 = 'curve25519xsalsa20poly1305' +export const XSALSA20POLY1305 = 'xsalsa20poly1305' + +const blake32Hash = (data: string | Uint8Array): string => { + const uint8array = typeof data === 'string' ? new TextEncoder().encode(data) : data + const digest = blake.blake2b.blake2b256.digest(uint8array) + // While `digest.digest` is only 32 bytes long in this case, + // `digest.bytes` is 36 bytes because it includes a multiformat prefix. + return base58btc.encode(digest.bytes) +} + +const bufToStr = (ary: Uint8Array) => { + return String.fromCharCode(...Array.from(ary)) +} + +const bytesToB64 = (ary: Uint8Array) => { + return btoa(bufToStr(ary)) +} + +const strToBuf = (str: string) => { + return new Uint8Array(str.split('').map(c => c.charCodeAt(0))) +} + +const b64ToBuf = (str: string) => { + return strToBuf(atob(str)) +} + +const bytesOrObjectToB64 = (ary: Uint8Array) => { + if (!(ary instanceof Uint8Array)) { + throw Error('Unsupported type') + } + return bytesToB64(ary) +} + +export type Key = { + type: string; + secretKey?: Uint8Array; + publicKey?: Uint8Array; +} + +export const keygen = (type: string): Key => { + if (type === EDWARDS25519SHA512BATCH) { + const key = nacl.sign.keyPair() + + const res: Key = { + type: type, + publicKey: key.publicKey + } + // prevents 'secretKey' from being enumerated or appearing in JSON + Object.defineProperty(res, 'secretKey', { value: key.secretKey }) + + return res + } else if (type === CURVE25519XSALSA20POLY1305) { + const key = nacl.box.keyPair() + + const res: Key = { + type: type, + publicKey: key.publicKey + } + + Object.defineProperty(res, 'secretKey', { value: key.secretKey }) + + return res + } else if (type === XSALSA20POLY1305) { + const res: Key = { + type: type + } + + Object.defineProperty(res, 'secretKey', { value: nacl.randomBytes(nacl.secretbox.keyLength) }) + + return res + } + + throw new Error('Unsupported key type') +} +export const generateSalt = (): string => { + return bytesOrObjectToB64(nacl.randomBytes(18)) +} + +// Format: [type, publicKey, secretKey]: [string, string, null] | [string, null, string] +// Using an array instead of an object ensures that the object is serialized in order since the JSON specification does not define the order for object keys +// and therefore different it could vary across implementations +export const serializeKey = (key: Key, saveSecretKey: boolean): string => { + if (key.type === EDWARDS25519SHA512BATCH || key.type === CURVE25519XSALSA20POLY1305) { + if (!saveSecretKey) { + if (!key.publicKey) { + throw new Error('Unsupported operation: no public key to export') + } + + return JSON.stringify([ + key.type, + bytesOrObjectToB64(key.publicKey), + null + ], undefined, 0) + } + + if (!key.secretKey) { + throw new Error('Unsupported operation: no secret key to export') + } + + return JSON.stringify([ + key.type, + null, + bytesOrObjectToB64(key.secretKey) + ], undefined, 0) + } else if (key.type === XSALSA20POLY1305) { + if (!saveSecretKey) { + throw new Error('Unsupported operation: no public key to export') + } + + if (!key.secretKey) { + throw new Error('Unsupported operation: no secret key to export') + } + + return JSON.stringify([ + key.type, + null, + bytesOrObjectToB64(key.secretKey) + ], undefined, 0) + } + + throw new Error('Unsupported key type') +} +export const deserializeKey = (data: string): Key => { + const keyData = JSON.parse(data) + + if (!keyData || keyData.length !== 3) { + throw new Error('Invalid key object') + } + + if (keyData[0] === EDWARDS25519SHA512BATCH) { + if (keyData[2]) { + const key = nacl.sign.keyPair.fromSecretKey(b64ToBuf(keyData[2])) + + const res: Key = { + type: keyData[0], + publicKey: key.publicKey + } + + Object.defineProperty(res, 'secretKey', { value: key.secretKey }) + + return res + } else if (keyData[1]) { + return { + type: keyData[0], + publicKey: new Uint8Array(b64ToBuf(keyData[1])) + } + } + + throw new Error('Missing secret or public key') + } else if (keyData[0] === CURVE25519XSALSA20POLY1305) { + if (keyData[2]) { + const key = nacl.box.keyPair.fromSecretKey(b64ToBuf(keyData[2])) + + const res: Key = { + type: keyData[0], + publicKey: key.publicKey + } + + Object.defineProperty(res, 'secretKey', { value: key.secretKey }) + + return res + } else if (keyData[1]) { + return { + type: keyData[0], + publicKey: new Uint8Array(b64ToBuf(keyData[1])) + } + } + + throw new Error('Missing secret or public key') + } else if (keyData[0] === XSALSA20POLY1305) { + if (!keyData[2]) { + throw new Error('Secret key missing') + } + + const res: Key = { + type: keyData[0] + } + + Object.defineProperty(res, 'secretKey', { value: new Uint8Array(b64ToBuf(keyData[2])) }) + + return res + } + + throw new Error('Unsupported key type') +} +export const keygenOfSameType = (inKey: Key | string): Key => { + const key = typeof inKey === 'string' ? deserializeKey(inKey) : inKey + + return keygen(key.type) +} +export const keyId = (inKey: Key | string): string => { + const key = typeof inKey === 'string' ? deserializeKey(inKey) : inKey + + const serializedKey = serializeKey(key, !key.publicKey) + return blake32Hash(serializedKey) +} +export const sign = (inKey: Key | string, data: string): string => { + const key = typeof inKey === 'string' ? deserializeKey(inKey) : inKey + + if (key.type !== EDWARDS25519SHA512BATCH) { + throw new Error('Unsupported algorithm') + } + + if (!key.secretKey) { + throw new Error('Secret key missing') + } + + const messageUint8 = strToBuf(data) + const signature = nacl.sign.detached(messageUint8, key.secretKey) + const base64Signature = bytesOrObjectToB64(signature) + + return base64Signature +} +export const verifySignature = (inKey: Key | string, data: string, signature: string): void => { + const key = typeof inKey === 'string' ? deserializeKey(inKey) : inKey + + if (key.type !== EDWARDS25519SHA512BATCH) { + throw new Error('Unsupported algorithm') + } + + if (!key.publicKey) { + throw new Error('Public key missing') + } + + const decodedSignature = b64ToBuf(signature) + const messageUint8 = strToBuf(data) + + const result = nacl.sign.detached.verify(messageUint8, decodedSignature, key.publicKey) + + if (!result) { + throw new Error('Invalid signature') + } +} + +/** + * @param inKey - Encryption key to use + * @param data - Data to encrypt + * @param ad - Additional data (the AD in AEAD), used for validation + */ +export const encrypt = (inKey: Key | string, data: string, ad?: string): string => { + const key = typeof inKey === 'string' ? deserializeKey(inKey) : inKey + + if (key.type === XSALSA20POLY1305) { + if (!key.secretKey) { + throw new Error('Secret key missing') + } + + const nonce = nacl.randomBytes(nacl.secretbox.nonceLength) + let encryptionNonce: typeof nonce + + if (ad) { + encryptionNonce = new Uint8Array(nonce) + const adHash = nacl.hash(strToBuf(ad)) + const len = Math.min(adHash.length, nonce.length) + for (let i = 0; i < len; i++) { + encryptionNonce[i] ^= adHash[i] + } + } else { + encryptionNonce = nonce + } + + const messageUint8 = strToBuf(data) + const box = nacl.secretbox(messageUint8, encryptionNonce, key.secretKey) + + const fullMessage = new Uint8Array(nonce.length + box.length) + + fullMessage.set(nonce) + fullMessage.set(box, nonce.length) + + const base64FullMessage = bytesOrObjectToB64(fullMessage) + + return base64FullMessage + } else if (key.type === CURVE25519XSALSA20POLY1305) { + if (!key.publicKey) { + throw new Error('Public key missing') + } + + const nonce = nacl.randomBytes(nacl.box.nonceLength) + let encryptionNonce: typeof nonce + + if (ad) { + encryptionNonce = new Uint8Array(nonce) + const adHash = nacl.hash(strToBuf(ad)) + const len = Math.min(adHash.length, nonce.length) + for (let i = 0; i < len; i++) { + encryptionNonce[i] ^= adHash[i] + } + } else { + encryptionNonce = nonce + } + + const messageUint8 = strToBuf(data) + const ephemeralKey = nacl.box.keyPair() + const box = nacl.box(messageUint8, encryptionNonce, key.publicKey, ephemeralKey.secretKey) + // Attempt to discard the data in memory for ephemeralKey.secretKey + ephemeralKey.secretKey.fill(0) + + const fullMessage = new Uint8Array(nacl.box.publicKeyLength + nonce.length + box.length) + + fullMessage.set(ephemeralKey.publicKey) + fullMessage.set(nonce, nacl.box.publicKeyLength) + fullMessage.set(box, nacl.box.publicKeyLength + nonce.length) + + const base64FullMessage = bytesOrObjectToB64(fullMessage) + + return base64FullMessage + } + + throw new Error('Unsupported algorithm') +} +export const decrypt = (inKey: Key | string, data: string, ad?: string): string => { + const key = typeof inKey === 'string' ? deserializeKey(inKey) : inKey + + if (key.type === XSALSA20POLY1305) { + if (!key.secretKey) { + throw new Error('Secret key missing') + } + + const messageWithNonceAsUint8Array = b64ToBuf(data) + + const nonce = messageWithNonceAsUint8Array.slice(0, nacl.secretbox.nonceLength) + const message = messageWithNonceAsUint8Array.slice( + nacl.secretbox.nonceLength, + messageWithNonceAsUint8Array.length + ) + + if (ad) { + const adHash = nacl.hash(strToBuf(ad)) + const len = Math.min(adHash.length, nonce.length) + for (let i = 0; i < len; i++) { + nonce[i] ^= adHash[i] + } + } + + const decrypted = nacl.secretbox.open(message, nonce, key.secretKey) + + if (!decrypted) { + throw new Error('Could not decrypt message') + } + + return bufToStr(decrypted) + } else if (key.type === CURVE25519XSALSA20POLY1305) { + if (!key.secretKey) { + throw new Error('Secret key missing') + } + + const messageWithNonceAsUint8Array = b64ToBuf(data) + + const ephemeralPublicKey = messageWithNonceAsUint8Array.slice(0, nacl.box.publicKeyLength) + const nonce = messageWithNonceAsUint8Array.slice(nacl.box.publicKeyLength, nacl.box.publicKeyLength + nacl.box.nonceLength) + const message = messageWithNonceAsUint8Array.slice( + nacl.box.publicKeyLength + nacl.box.nonceLength + ) + + if (ad) { + const adHash = nacl.hash(strToBuf(ad)) + const len = Math.min(adHash.length, nonce.length) + for (let i = 0; i < len; i++) { + nonce[i] ^= adHash[i] + } + } + + const decrypted = nacl.box.open(message, nonce, ephemeralPublicKey, key.secretKey) + + if (!decrypted) { + throw new Error('Could not decrypt message') + } + + return bufToStr(decrypted) + } + + throw new Error('Unsupported algorithm') +} diff --git a/src/manifest.ts b/src/manifest.ts index 65dd01f..93a5c10 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -7,29 +7,47 @@ import { flags, path, colors } from './deps.ts' import { hash } from './hash.ts' -import { revokeNet } from './utils.ts' +import { exit, importJsonFile, revokeNet } from './utils.ts' +import { EDWARDS25519SHA512BATCH, deserializeKey, keyId, serializeKey, sign } from './lib/crypto.ts' // import { writeAllSync } from "https://deno.land/std@0.141.0/streams/mod.ts" export async function manifest (args: string[]) { await revokeNet() - const parsedArgs = flags.parse(args) - const [_keyFile, contractFile] = parsedArgs._ + const parsedArgs = flags.parse(args, { collect: ['key'], alias: { 'key': 'k' } }) + console.log(parsedArgs) + const [keyFile, contractFile] = parsedArgs._ const parsedFilepath = path.parse(contractFile as string) const { name: contractName, base: contractBasename, dir: contractDir } = parsedFilepath const version = parsedArgs.version || parsedArgs.v || 'x' const slim = parsedArgs.slim || parsedArgs.s const outFilepath = path.join(contractDir, `${contractName}.${version}.manifest.json`) + if (!keyFile) exit('Missing signing key file') + + const signingKeyDescriptor = await importJsonFile(keyFile) + const signingKey = deserializeKey(signingKeyDescriptor.privkey) + + // Add all additional public keys in addition to the signing key + const publicKeys = Array.from(new Set( + [serializeKey(signingKey, false)] + .concat(...await Promise.all(parsedArgs.key?.map( + async (kf: number | string) => { + const descriptor = await importJsonFile(kf) + const key = deserializeKey(descriptor.pubkey) + if (key.type !== EDWARDS25519SHA512BATCH) { + exit(`Invalid key type ${key.type}; only ${EDWARDS25519SHA512BATCH} keys are supported.`) + } + return serializeKey(key, false) + } + ) || [])) + )) const body: {[key: string]: unknown} = { version, contract: { hash: await hash([contractFile as string], true), file: contractBasename }, - authors: [ - {cipher: "algo", key: ""}, - {cipher: "algo", key: ""} - ] + signingKeys: publicKeys } if (slim) { body.contractSlim = { @@ -37,12 +55,15 @@ export async function manifest (args: string[]) { hash: await hash([slim], true) } } + const serializedBody = JSON.stringify(body) + const head = { manifestVersion: "1.0.0" } + const serializedHead = JSON.stringify(head) const manifest = JSON.stringify({ - head: { manifestVersion: "1.0.0" }, - body: JSON.stringify(body), + head: serializedHead, + body: serializedBody, signature: { - key: "", - signature: "" + keyId: keyId(signingKey), + value: sign(signingKey, serializedBody + serializedHead) } }) if (parsedArgs.out === '-') { diff --git a/src/utils.ts b/src/utils.ts index aa1581e..00a06bc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -36,7 +36,8 @@ export function createCID (data: string | Uint8Array, multicode = multicodes.RAW return CID.create(1, multicode, digest).toString(multibase.encoder) } -export function exit (message: string): never { +export function exit (message: string, internal = false): never { + if (internal) throw new Error(message) console.error('[chel]', colors.red('Error:'), message) Deno.exit(1) } @@ -125,3 +126,11 @@ export async function readRemoteData (src: string, key: string): Promise { + const data = await import( + path.toFileUrl(path.resolve(String(file))).toString(), + { with: { type: 'json' }} + ) + return data.default +} \ No newline at end of file diff --git a/src/verifySignature.ts b/src/verifySignature.ts new file mode 100644 index 0000000..2b4fdf8 --- /dev/null +++ b/src/verifySignature.ts @@ -0,0 +1,80 @@ +import { hash } from './commands.ts' +import { colors, flags, path } from './deps.ts' +import { verifySignature as cryptoVerifySignature, deserializeKey, keyId } from './lib/crypto.ts' +import { exit, importJsonFile, revokeNet } from './utils.ts' + +export const verifySignature = async (args: string[], internal = false) => { + await revokeNet() + const parsedArgs = flags.parse(args) + const [manifestFile] = parsedArgs._ + const keyFile = parsedArgs.k + const [externalKeyDescriptor, manifest] = await Promise.all([ + keyFile ? importJsonFile(keyFile) : null, + importJsonFile(manifestFile) + ]) + if (keyFile && !externalKeyDescriptor.pubkey) { + exit('Public key missing from key file', internal) + } + if (!manifest.head) { + exit('Invalid manifest: missing head', internal) + } + if (!manifest.body) { + exit('Invalid manifest: missing body', internal) + } + if (!manifest.signature) { + exit('Invalid manifest: missing signature', internal) + } + if (!manifest.signature.keyId) { + exit('Invalid manifest: missing signature key ID', internal) + } + if (!manifest.signature.value) { + exit('Invalid manifest: missing signature value', internal) + } + const body = JSON.parse(manifest.body) + const signingKey = body.signingKeys?.find((k: string) => { + return keyId(k) === manifest.signature.keyId + }) + + if (externalKeyDescriptor) { + const id = keyId(externalKeyDescriptor.pubkey) + if (manifest.signature.keyId !== id) { + exit(`Invalid manifest signature: key ID doesn\'t match the provided key file. Expected ${id} but got ${manifest.signature.keyId}.`, internal) + } + } + + // If an external public key is provided, we use that one for verification, + // even if it is missing in body.signingKeys + const serializedPubKey = signingKey || externalKeyDescriptor?.pubkey + if (!serializedPubKey) { + exit('The manifest appears to be signed but verification can\'t proceed because the key used is unknown.', internal); + } + + const pubKey = deserializeKey(serializedPubKey) + try { + cryptoVerifySignature(pubKey, manifest.body + manifest.head, manifest.signature.value) + } catch(e) { + exit('Error validating signature: ' + (e?.message || String(e)), internal) + } + + if (!signingKey) { + exit('The signature is valid but the signing key is not listed in signingKeys', internal) + } + + const parsedFilepath = path.parse(manifestFile as string) + if (!body.contract?.file) { + exit('Invalid manifest: no contract file', internal) + } + const computedHash = await hash([path.join(parsedFilepath.dir, body.contract.file)], true) + if (computedHash !== body.contract.hash) { + exit(`Invalid contract file hash. Expected ${body.contract.hash} but got ${computedHash}`, internal) + } + + if (body.contractSlim) { + const computedHash = await hash([path.join(parsedFilepath.dir, body.contractSlim.file)], true) + if (computedHash !== body.contractSlim.hash) { + exit(`Invalid slim contract file hash. Expected ${body.contractSlim.hash} but got ${computedHash}`, internal) + } + } + + if (!internal) console.log(colors.green('ok'), 'all checks passed') +} \ No newline at end of file diff --git a/test/assets/bundle-tampered.bundle.example b/test/assets/bundle-tampered.bundle.example new file mode 100644 index 0000000..708bf77 --- /dev/null +++ b/test/assets/bundle-tampered.bundle.example @@ -0,0 +1 @@ +Tampered file \ No newline at end of file diff --git a/test/assets/bundle-tampered.bundle.x.manifest.json b/test/assets/bundle-tampered.bundle.x.manifest.json new file mode 100644 index 0000000..61bd884 --- /dev/null +++ b/test/assets/bundle-tampered.bundle.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"bundle-tampered.bundle.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\\\",null]\",\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"],\"contractSlim\":{\"file\":\"bundle-tampered.slim.example\",\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\"}}","signature":{"keyId":"z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"0kzsDs1sT2A9y8hVKlf7FQBOhnIxaOa1CHWf4+bVE3xBXFt+TyjKpdHKEZ3cc/Qn6i3l3nTKYACElsDv3oEoDw=="}} \ No newline at end of file diff --git a/test/assets/bundle-tampered.slim.example b/test/assets/bundle-tampered.slim.example new file mode 100644 index 0000000..e69de29 diff --git a/test/assets/edwards25519sha512batch-g6kUyhtL5bPd.json b/test/assets/edwards25519sha512batch-g6kUyhtL5bPd.json new file mode 100644 index 0000000..614bc2b --- /dev/null +++ b/test/assets/edwards25519sha512batch-g6kUyhtL5bPd.json @@ -0,0 +1 @@ +{"version":"1.0.0","pubkey":"[\"edwards25519sha512batch\",\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\",null]","privkey":"[\"edwards25519sha512batch\",null,\"WmU1qYz1iuywL+S3Dens1qYIIVQAQPwQmv3c+0TiyVE9bqe3fY5i5alsd9STke1xJOA/6TbxS7vnYGQu6fhTVg==\"]"} \ No newline at end of file diff --git a/test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json b/test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json new file mode 100644 index 0000000..614bc2b --- /dev/null +++ b/test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json @@ -0,0 +1 @@ +{"version":"1.0.0","pubkey":"[\"edwards25519sha512batch\",\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\",null]","privkey":"[\"edwards25519sha512batch\",null,\"WmU1qYz1iuywL+S3Dens1qYIIVQAQPwQmv3c+0TiyVE9bqe3fY5i5alsd9STke1xJOA/6TbxS7vnYGQu6fhTVg==\"]"} \ No newline at end of file diff --git a/test/assets/edwards25519sha512batch-jy3R1NPmA17o.json b/test/assets/edwards25519sha512batch-jy3R1NPmA17o.json new file mode 100644 index 0000000..76a5559 --- /dev/null +++ b/test/assets/edwards25519sha512batch-jy3R1NPmA17o.json @@ -0,0 +1 @@ +{"version":"1.0.0","pubkey":"[\"edwards25519sha512batch\",\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\",null]","privkey":"[\"edwards25519sha512batch\",null,\"i3oAd8oRHMg4BcbVACa0rEU/INHc9D5jwhQD0uaw2gc990TyN1YJ7Fzi8Ouvp0fCitK0CE7gm3yt/pxt2gvFPw==\"]"} \ No newline at end of file diff --git a/test/assets/edwards25519sha512batch-jy3R1NPmA17o.pub.json b/test/assets/edwards25519sha512batch-jy3R1NPmA17o.pub.json new file mode 100644 index 0000000..76a5559 --- /dev/null +++ b/test/assets/edwards25519sha512batch-jy3R1NPmA17o.pub.json @@ -0,0 +1 @@ +{"version":"1.0.0","pubkey":"[\"edwards25519sha512batch\",\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\",null]","privkey":"[\"edwards25519sha512batch\",null,\"i3oAd8oRHMg4BcbVACa0rEU/INHc9D5jwhQD0uaw2gc990TyN1YJ7Fzi8Ouvp0fCitK0CE7gm3yt/pxt2gvFPw==\"]"} \ No newline at end of file diff --git a/test/assets/invalid-signature-missing-pubkey.x.manifest.json b/test/assets/invalid-signature-missing-pubkey.x.manifest.json new file mode 100644 index 0000000..4950c7c --- /dev/null +++ b/test/assets/invalid-signature-missing-pubkey.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"invalid-signature-missing-pubkey.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"]}","signature":{"keyId":"z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"x9/kiEfw11AJXGBi9FXnlKXfCDvfJcpLr7B8PhGnP7O0TKz97lo5ml+McHfu2BBJkCKONUEAfCX31S0yzE8yCA=="}} \ No newline at end of file diff --git a/test/assets/slim-tampered.bundle.example b/test/assets/slim-tampered.bundle.example new file mode 100644 index 0000000..e69de29 diff --git a/test/assets/slim-tampered.bundle.x.manifest.json b/test/assets/slim-tampered.bundle.x.manifest.json new file mode 100644 index 0000000..681fc66 --- /dev/null +++ b/test/assets/slim-tampered.bundle.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"slim-tampered.bundle.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\\\",null]\",\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"],\"contractSlim\":{\"file\":\"slim-tampered.slim.example\",\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\"}}","signature":{"keyId":"z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"W1bLtxCz11OgGhH9ttBS5d8wybkH6tilhdFNWy6U7UbCHQ5s9dYOwnU28G7ZoyWcwOFGjO7OY8fnea3u8H8qDQ=="}} \ No newline at end of file diff --git a/test/assets/slim-tampered.slim.example b/test/assets/slim-tampered.slim.example new file mode 100644 index 0000000..708bf77 --- /dev/null +++ b/test/assets/slim-tampered.slim.example @@ -0,0 +1 @@ +Tampered file \ No newline at end of file diff --git a/test/assets/valid-signature-missing-id.x.manifest.json b/test/assets/valid-signature-missing-id.x.manifest.json new file mode 100644 index 0000000..48e9971 --- /dev/null +++ b/test/assets/valid-signature-missing-id.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"valid-signature.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\\\",null]\",\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"]}","signature":{"removed-keyId":"z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"Ly1GhzGGwTArCzfGiZQutp+ev9Bxi1THYDa6+RevIfrAeWw3yedWuZltMjY791JXR9DI/YjJNwj2W9XayImUBg=="}} \ No newline at end of file diff --git a/test/assets/valid-signature-tampered.x.manifest.json b/test/assets/valid-signature-tampered.x.manifest.json new file mode 100644 index 0000000..8ef0f31 --- /dev/null +++ b/test/assets/valid-signature-tampered.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"INSERTION\":\"x\",\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"valid-signature.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\\\",null]\",\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"]}","signature":{"keyId":"z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"Ly1GhzGGwTArCzfGiZQutp+ev9Bxi1THYDa6+RevIfrAeWw3yedWuZltMjY791JXR9DI/YjJNwj2W9XayImUBg=="}} \ No newline at end of file diff --git a/test/assets/valid-signature-wrong-id.x.manifest.json b/test/assets/valid-signature-wrong-id.x.manifest.json new file mode 100644 index 0000000..9345f6e --- /dev/null +++ b/test/assets/valid-signature-wrong-id.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"INSERTION\":\"x\",\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"valid-signature.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\\\",null]\",\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"]}","signature":{"keyId":"-z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"Ly1GhzGGwTArCzfGiZQutp+ev9Bxi1THYDa6+RevIfrAeWw3yedWuZltMjY791JXR9DI/YjJNwj2W9XayImUBg=="}} \ No newline at end of file diff --git a/test/assets/valid-signature.example b/test/assets/valid-signature.example new file mode 100644 index 0000000..e69de29 diff --git a/test/assets/valid-signature.x.manifest.json b/test/assets/valid-signature.x.manifest.json new file mode 100644 index 0000000..e2ecc06 --- /dev/null +++ b/test/assets/valid-signature.x.manifest.json @@ -0,0 +1 @@ +{"head":"{\"manifestVersion\":\"1.0.0\"}","body":"{\"version\":\"x\",\"contract\":{\"hash\":\"z9brRu3VFNnnn1BgyRBaQfs7Jyrx18K2ASgDKAiLyWx3KMVQGL8X\",\"file\":\"valid-signature.example\"},\"signingKeys\":[\"[\\\"edwards25519sha512batch\\\",\\\"PW6nt32OYuWpbHfUk5HtcSTgP+k28Uu752BkLun4U1Y=\\\",null]\",\"[\\\"edwards25519sha512batch\\\",\\\"PfdE8jdWCexc4vDrr6dHworStAhO4Jt8rf6cbdoLxT8=\\\",null]\"]}","signature":{"keyId":"z2Drjgb5QQTKooY4YntALeT1uEQtpo9bP7J9gt5g6kUyhtL5bPd","value":"Ly1GhzGGwTArCzfGiZQutp+ev9Bxi1THYDa6+RevIfrAeWw3yedWuZltMjY791JXR9DI/YjJNwj2W9XayImUBg=="}} \ No newline at end of file diff --git a/test/signature.test.ts b/test/signature.test.ts new file mode 100644 index 0000000..f427387 --- /dev/null +++ b/test/signature.test.ts @@ -0,0 +1,68 @@ +'use strict' + +import { assertRejects } from '../src/deps.ts' +import { verifySignature } from '../src/verifySignature.ts' +// import { CID, assertEquals, base58btc } from '../src/deps.ts' + +Deno.test({ + name: "Verify signature tests", + async fn (t) { + await t.step('it should validate a valid signature', async () => { + const manifestFile = './test/assets/valid-signature.x.manifest.json' + await verifySignature([manifestFile], true) + }) + + await t.step('it should validate a valid signature (using a matching external key descriptor file)', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/valid-signature.x.manifest.json' + await verifySignature(['-k', signingKeyFile, manifestFile], true) + }) + + await t.step('it should not validate a valid signature when using the wrong key file', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-jy3R1NPmA17o.pub.json' + const manifestFile = './test/assets/valid-signature.x.manifest.json' + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'key ID doesn\'t match the provided key file') + }) + + await t.step('it should not validate a valid signature if the public key isn\'t enumerated', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/invalid-signature-missing-pubkey.x.manifest.json' + await assertRejects(() => verifySignature([manifestFile], true), Error, 'The manifest appears to be signed') + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'signing key is not listed') + }) + + await t.step('it should not validate a valid signature missing its key ID', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/valid-signature-missing-id.x.manifest.json' + await assertRejects(() => verifySignature([manifestFile], true), Error, 'missing signature key ID') + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'missing signature key ID') + }) + + await t.step('it should not validate a valid signature with a wrong key ID', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/valid-signature-wrong-id.x.manifest.json' + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'key ID doesn\'t match the provided key file') + }) + + await t.step('it should not validate a manifest file that\'s been tampered with', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/valid-signature-tampered.x.manifest.json' + await assertRejects(() => verifySignature([manifestFile], true), Error, 'Invalid signature') + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'Invalid signature') + }) + + await t.step('it should not validate a tampered with bundle contract', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/bundle-tampered.bundle.x.manifest.json' + await assertRejects(() => verifySignature([manifestFile], true), Error, 'Invalid contract file hash') + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'Invalid contract file hash') + }) + + await t.step('it should not validate a tampered with slim contract', async () => { + const signingKeyFile = './test/assets/edwards25519sha512batch-g6kUyhtL5bPd.pub.json' + const manifestFile = './test/assets/slim-tampered.bundle.x.manifest.json' + await assertRejects(() => verifySignature([manifestFile], true), Error, 'Invalid slim contract file hash') + await assertRejects(() => verifySignature(['-k', signingKeyFile, manifestFile], true), Error, 'Invalid slim contract file hash') + }) + } +}) \ No newline at end of file diff --git a/vendor/esm.sh/@multiformats/blake2@1.0.13.js b/vendor/esm.sh/@multiformats/blake2@1.0.13.js index e9e2472..34c62f4 100644 --- a/vendor/esm.sh/@multiformats/blake2@1.0.13.js +++ b/vendor/esm.sh/@multiformats/blake2@1.0.13.js @@ -1,3 +1,5 @@ /* esm.sh - @multiformats/blake2@1.0.13 */ -export * from "https://esm.sh/v120/@multiformats/blake2@1.0.13/deno/blake2.mjs"; -export { default } from "https://esm.sh/v120/@multiformats/blake2@1.0.13/deno/blake2.mjs"; +import "/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js"; +import "/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js"; +export * from "/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs"; +export { default } from "/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs"; diff --git a/vendor/esm.sh/multiformats@11.0.2.proxied.js b/vendor/esm.sh/multiformats@11.0.2.proxied.js index a4743df..ba2483a 100644 --- a/vendor/esm.sh/multiformats@11.0.2.proxied.js +++ b/vendor/esm.sh/multiformats@11.0.2.proxied.js @@ -1,2 +1,7 @@ /* esm.sh - multiformats@11.0.2 */ -export * from "https://esm.sh/v120/multiformats@11.0.2/deno/multiformats.mjs"; +import "/v120/multiformats@11.0.2/denonext/cid.js"; +import "/v120/multiformats@11.0.2/denonext/bytes.js"; +import "/v120/multiformats@11.0.2/denonext/hashes/hasher.js"; +import "/v120/multiformats@11.0.2/denonext/hashes/digest.js"; +import "/v120/multiformats@11.0.2/denonext/interface.js"; +export * from "/v120/multiformats@11.0.2/denonext/multiformats.mjs"; diff --git a/vendor/esm.sh/multiformats@11.0.2/bases/base58.proxied.js b/vendor/esm.sh/multiformats@11.0.2/bases/base58.proxied.js index 9a87d7e..830d77b 100644 --- a/vendor/esm.sh/multiformats@11.0.2/bases/base58.proxied.js +++ b/vendor/esm.sh/multiformats@11.0.2/bases/base58.proxied.js @@ -1,2 +1,4 @@ /* esm.sh - multiformats@11.0.2/bases/base58 */ -export * from "https://esm.sh/v120/multiformats@11.0.2/deno/bases/base58.js"; +import "/v120/multiformats@11.0.2/denonext/bytes.js"; +import "/v120/multiformats@11.0.2/denonext/bases/interface.js"; +export * from "/v120/multiformats@11.0.2/denonext/bases/base58.js"; diff --git a/vendor/esm.sh/tweetnacl@1.0.3.js b/vendor/esm.sh/tweetnacl@1.0.3.js new file mode 100644 index 0000000..8987acc --- /dev/null +++ b/vendor/esm.sh/tweetnacl@1.0.3.js @@ -0,0 +1,3 @@ +// @deno-types="https://esm.sh/v120/tweetnacl@1.0.3/nacl.d.ts" +export * from "./tweetnacl@1.0.3.proxied.js"; +export { default } from "./tweetnacl@1.0.3.proxied.js"; diff --git a/vendor/esm.sh/tweetnacl@1.0.3.proxied.js b/vendor/esm.sh/tweetnacl@1.0.3.proxied.js new file mode 100644 index 0000000..89e8117 --- /dev/null +++ b/vendor/esm.sh/tweetnacl@1.0.3.proxied.js @@ -0,0 +1,3 @@ +/* esm.sh - tweetnacl@1.0.3 */ +export * from "/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs"; +export { default } from "/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs"; diff --git a/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs b/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs new file mode 100644 index 0000000..4152263 --- /dev/null +++ b/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(@multiformats/blake2@1.0.13) denonext production */ +import*as a from"/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js";import*as o from"/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js";var r={blake2b:a,blake2s:o};export{r as default}; +//# sourceMappingURL=blake2.mjs.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js b/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js new file mode 100644 index 0000000..834b71d --- /dev/null +++ b/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(@multiformats/blake2@1.0.13/blake2b) denonext production */ +import b from"/v120/blakejs@1.2.1/denonext/blakejs.mjs";import{from as o}from"/v120/multiformats@9.9.0/denonext/hashes/hasher.js";import{bytes as c}from"/v120/multiformats@9.9.0/denonext/multiformats.mjs";var{blake2b:n}=b,t=o({name:"blake2b-8",code:45569,encode:e=>c.coerce(n(e,void 0,1))}),k=o({name:"blake2b-16",code:45570,encode:e=>c.coerce(n(e,void 0,2))}),l=o({name:"blake2b-24",code:45571,encode:e=>c.coerce(n(e,void 0,3))}),m=o({name:"blake2b-32",code:45572,encode:e=>c.coerce(n(e,void 0,4))}),f=o({name:"blake2b-40",code:45573,encode:e=>c.coerce(n(e,void 0,5))}),i=o({name:"blake2b-48",code:45574,encode:e=>c.coerce(n(e,void 0,6))}),p=o({name:"blake2b-56",code:45575,encode:e=>c.coerce(n(e,void 0,7))}),s=o({name:"blake2b-64",code:45576,encode:e=>c.coerce(n(e,void 0,8))}),u=o({name:"blake2b-72",code:45577,encode:e=>c.coerce(n(e,void 0,9))}),x=o({name:"blake2b-80",code:45578,encode:e=>c.coerce(n(e,void 0,10))}),j=o({name:"blake2b-88",code:45579,encode:e=>c.coerce(n(e,void 0,11))}),y=o({name:"blake2b-96",code:45580,encode:e=>c.coerce(n(e,void 0,12))}),g=o({name:"blake2b-104",code:45581,encode:e=>c.coerce(n(e,void 0,13))}),h=o({name:"blake2b-112",code:45582,encode:e=>c.coerce(n(e,void 0,14))}),q=o({name:"blake2b-120",code:45583,encode:e=>c.coerce(n(e,void 0,15))}),v=o({name:"blake2b-128",code:45584,encode:e=>c.coerce(n(e,void 0,16))}),w=o({name:"blake2b-136",code:45585,encode:e=>c.coerce(n(e,void 0,17))}),z=o({name:"blake2b-144",code:45586,encode:e=>c.coerce(n(e,void 0,18))}),A=o({name:"blake2b-152",code:45587,encode:e=>c.coerce(n(e,void 0,19))}),B=o({name:"blake2b-160",code:45588,encode:e=>c.coerce(n(e,void 0,20))}),C=o({name:"blake2b-168",code:45589,encode:e=>c.coerce(n(e,void 0,21))}),D=o({name:"blake2b-176",code:45590,encode:e=>c.coerce(n(e,void 0,22))}),E=o({name:"blake2b-184",code:45591,encode:e=>c.coerce(n(e,void 0,23))}),F=o({name:"blake2b-192",code:45592,encode:e=>c.coerce(n(e,void 0,24))}),G=o({name:"blake2b-200",code:45593,encode:e=>c.coerce(n(e,void 0,25))}),H=o({name:"blake2b-208",code:45594,encode:e=>c.coerce(n(e,void 0,26))}),I=o({name:"blake2b-216",code:45595,encode:e=>c.coerce(n(e,void 0,27))}),J=o({name:"blake2b-224",code:45596,encode:e=>c.coerce(n(e,void 0,28))}),K=o({name:"blake2b-232",code:45597,encode:e=>c.coerce(n(e,void 0,29))}),L=o({name:"blake2b-240",code:45598,encode:e=>c.coerce(n(e,void 0,30))}),M=o({name:"blake2b-248",code:45599,encode:e=>c.coerce(n(e,void 0,31))}),N=o({name:"blake2b-256",code:45600,encode:e=>c.coerce(n(e,void 0,32))}),O=o({name:"blake2b-264",code:45601,encode:e=>c.coerce(n(e,void 0,33))}),P=o({name:"blake2b-272",code:45602,encode:e=>c.coerce(n(e,void 0,34))}),Q=o({name:"blake2b-280",code:45603,encode:e=>c.coerce(n(e,void 0,35))}),R=o({name:"blake2b-288",code:45604,encode:e=>c.coerce(n(e,void 0,36))}),S=o({name:"blake2b-296",code:45605,encode:e=>c.coerce(n(e,void 0,37))}),T=o({name:"blake2b-304",code:45606,encode:e=>c.coerce(n(e,void 0,38))}),U=o({name:"blake2b-312",code:45607,encode:e=>c.coerce(n(e,void 0,39))}),V=o({name:"blake2b-320",code:45608,encode:e=>c.coerce(n(e,void 0,40))}),W=o({name:"blake2b-328",code:45609,encode:e=>c.coerce(n(e,void 0,41))}),X=o({name:"blake2b-336",code:45610,encode:e=>c.coerce(n(e,void 0,42))}),Y=o({name:"blake2b-344",code:45611,encode:e=>c.coerce(n(e,void 0,43))}),Z=o({name:"blake2b-352",code:45612,encode:e=>c.coerce(n(e,void 0,44))}),_=o({name:"blake2b-360",code:45613,encode:e=>c.coerce(n(e,void 0,45))}),$=o({name:"blake2b-368",code:45614,encode:e=>c.coerce(n(e,void 0,46))}),ee=o({name:"blake2b-376",code:45615,encode:e=>c.coerce(n(e,void 0,47))}),oe=o({name:"blake2b-384",code:45616,encode:e=>c.coerce(n(e,void 0,48))}),ce=o({name:"blake2b-392",code:45617,encode:e=>c.coerce(n(e,void 0,49))}),ne=o({name:"blake2b-400",code:45618,encode:e=>c.coerce(n(e,void 0,50))}),be=o({name:"blake2b-408",code:45619,encode:e=>c.coerce(n(e,void 0,51))}),de=o({name:"blake2b-416",code:45620,encode:e=>c.coerce(n(e,void 0,52))}),ae=o({name:"blake2b-424",code:45621,encode:e=>c.coerce(n(e,void 0,53))}),re=o({name:"blake2b-432",code:45622,encode:e=>c.coerce(n(e,void 0,54))}),te=o({name:"blake2b-440",code:45623,encode:e=>c.coerce(n(e,void 0,55))}),ke=o({name:"blake2b-448",code:45624,encode:e=>c.coerce(n(e,void 0,56))}),le=o({name:"blake2b-456",code:45625,encode:e=>c.coerce(n(e,void 0,57))}),me=o({name:"blake2b-464",code:45626,encode:e=>c.coerce(n(e,void 0,58))}),fe=o({name:"blake2b-472",code:45627,encode:e=>c.coerce(n(e,void 0,59))}),ie=o({name:"blake2b-480",code:45628,encode:e=>c.coerce(n(e,void 0,60))}),pe=o({name:"blake2b-488",code:45629,encode:e=>c.coerce(n(e,void 0,61))}),se=o({name:"blake2b-496",code:45630,encode:e=>c.coerce(n(e,void 0,62))}),ue=o({name:"blake2b-504",code:45631,encode:e=>c.coerce(n(e,void 0,63))}),xe=o({name:"blake2b-512",code:45632,encode:e=>c.coerce(n(e,void 0,64))});export{g as blake2b104,h as blake2b112,q as blake2b120,v as blake2b128,w as blake2b136,z as blake2b144,A as blake2b152,k as blake2b16,B as blake2b160,C as blake2b168,D as blake2b176,E as blake2b184,F as blake2b192,G as blake2b200,H as blake2b208,I as blake2b216,J as blake2b224,K as blake2b232,l as blake2b24,L as blake2b240,M as blake2b248,N as blake2b256,O as blake2b264,P as blake2b272,Q as blake2b280,R as blake2b288,S as blake2b296,T as blake2b304,U as blake2b312,m as blake2b32,V as blake2b320,W as blake2b328,X as blake2b336,Y as blake2b344,Z as blake2b352,_ as blake2b360,$ as blake2b368,ee as blake2b376,oe as blake2b384,ce as blake2b392,f as blake2b40,ne as blake2b400,be as blake2b408,de as blake2b416,ae as blake2b424,re as blake2b432,te as blake2b440,ke as blake2b448,le as blake2b456,me as blake2b464,fe as blake2b472,i as blake2b48,ie as blake2b480,pe as blake2b488,se as blake2b496,ue as blake2b504,xe as blake2b512,p as blake2b56,s as blake2b64,u as blake2b72,t as blake2b8,x as blake2b80,j as blake2b88,y as blake2b96}; +//# sourceMappingURL=blake2b.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js b/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js new file mode 100644 index 0000000..23cd0a5 --- /dev/null +++ b/vendor/esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(@multiformats/blake2@1.0.13/blake2s) denonext production */ +import d from"/v120/blakejs@1.2.1/denonext/blakejs.mjs";import{from as o}from"/v120/multiformats@9.9.0/denonext/hashes/hasher.js";import{bytes as c}from"/v120/multiformats@9.9.0/denonext/multiformats.mjs";var{blake2s:n}=d,t=o({name:"blake2s-8",code:45633,encode:e=>c.coerce(n(e,void 0,1))}),b=o({name:"blake2s-16",code:45634,encode:e=>c.coerce(n(e,void 0,2))}),k=o({name:"blake2s-24",code:45635,encode:e=>c.coerce(n(e,void 0,3))}),l=o({name:"blake2s-32",code:45636,encode:e=>c.coerce(n(e,void 0,4))}),m=o({name:"blake2s-40",code:45637,encode:e=>c.coerce(n(e,void 0,5))}),f=o({name:"blake2s-48",code:45638,encode:e=>c.coerce(n(e,void 0,6))}),i=o({name:"blake2s-56",code:45639,encode:e=>c.coerce(n(e,void 0,7))}),p=o({name:"blake2s-64",code:45640,encode:e=>c.coerce(n(e,void 0,8))}),u=o({name:"blake2s-72",code:45641,encode:e=>c.coerce(n(e,void 0,9))}),x=o({name:"blake2s-80",code:45642,encode:e=>c.coerce(n(e,void 0,10))}),j=o({name:"blake2s-88",code:45643,encode:e=>c.coerce(n(e,void 0,11))}),y=o({name:"blake2s-96",code:45644,encode:e=>c.coerce(n(e,void 0,12))}),g=o({name:"blake2s-104",code:45645,encode:e=>c.coerce(n(e,void 0,13))}),h=o({name:"blake2s-112",code:45646,encode:e=>c.coerce(n(e,void 0,14))}),q=o({name:"blake2s-120",code:45647,encode:e=>c.coerce(n(e,void 0,15))}),v=o({name:"blake2s-128",code:45648,encode:e=>c.coerce(n(e,void 0,16))}),w=o({name:"blake2s-136",code:45649,encode:e=>c.coerce(n(e,void 0,17))}),z=o({name:"blake2s-144",code:45650,encode:e=>c.coerce(n(e,void 0,18))}),A=o({name:"blake2s-152",code:45651,encode:e=>c.coerce(n(e,void 0,19))}),B=o({name:"blake2s-160",code:45652,encode:e=>c.coerce(n(e,void 0,20))}),C=o({name:"blake2s-168",code:45653,encode:e=>c.coerce(n(e,void 0,21))}),D=o({name:"blake2s-176",code:45654,encode:e=>c.coerce(n(e,void 0,22))}),E=o({name:"blake2s-184",code:45655,encode:e=>c.coerce(n(e,void 0,23))}),F=o({name:"blake2s-192",code:45656,encode:e=>c.coerce(n(e,void 0,24))}),G=o({name:"blake2s-200",code:45657,encode:e=>c.coerce(n(e,void 0,25))}),H=o({name:"blake2s-208",code:45658,encode:e=>c.coerce(n(e,void 0,26))}),I=o({name:"blake2s-216",code:45659,encode:e=>c.coerce(n(e,void 0,27))}),J=o({name:"blake2s-224",code:45660,encode:e=>c.coerce(n(e,void 0,28))}),K=o({name:"blake2s-232",code:45661,encode:e=>c.coerce(n(e,void 0,29))}),L=o({name:"blake2s-240",code:45662,encode:e=>c.coerce(n(e,void 0,30))}),M=o({name:"blake2s-248",code:45663,encode:e=>c.coerce(n(e,void 0,31))}),N=o({name:"blake2s-256",code:45664,encode:e=>c.coerce(n(e,void 0,32))});export{g as blake2s104,h as blake2s112,q as blake2s120,v as blake2s128,w as blake2s136,z as blake2s144,A as blake2s152,b as blake2s16,B as blake2s160,C as blake2s168,D as blake2s176,E as blake2s184,F as blake2s192,G as blake2s200,H as blake2s208,I as blake2s216,J as blake2s224,K as blake2s232,k as blake2s24,L as blake2s240,M as blake2s248,N as blake2s256,l as blake2s32,m as blake2s40,f as blake2s48,i as blake2s56,p as blake2s64,u as blake2s72,t as blake2s8,x as blake2s80,j as blake2s88,y as blake2s96}; +//# sourceMappingURL=blake2s.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/blakejs@1.2.1/denonext/blakejs.mjs b/vendor/esm.sh/v120/blakejs@1.2.1/denonext/blakejs.mjs new file mode 100644 index 0000000..064c420 --- /dev/null +++ b/vendor/esm.sh/v120/blakejs@1.2.1/denonext/blakejs.mjs @@ -0,0 +1,5 @@ +/* esm.sh - esbuild bundle(blakejs@1.2.1) denonext production */ +var o1=Object.create;var G=Object.defineProperty;var l1=Object.getOwnPropertyDescriptor;var i1=Object.getOwnPropertyNames;var a1=Object.getPrototypeOf,s1=Object.prototype.hasOwnProperty;var y=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),f1=(n,t)=>{for(var e in t)G(n,e,{get:t[e],enumerable:!0})},F=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of i1(t))!s1.call(n,l)&&l!==e&&G(n,l,{get:()=>t[l],enumerable:!(r=l1(t,l))||r.enumerable});return n},U=(n,t,e)=>(F(n,t,"default"),e&&F(e,t,"default")),R=(n,t,e)=>(e=n!=null?o1(a1(n)):{},F(t||!n||!n.__esModule?G(e,"default",{value:n,enumerable:!0}):e,n));var M=y((M1,z)=>{var b1="Input must be an string, Buffer or Uint8Array";function u1(n){let t;if(n instanceof Uint8Array)t=n;else if(typeof n=="string")t=new TextEncoder().encode(n);else throw new Error(b1);return t}function c1(n){return Array.prototype.map.call(n,function(t){return(t<16?"0":"")+t.toString(16)}).join("")}function H(n){return(4294967296+n).toString(16).substring(1)}function h1(n,t,e){let r=` +`+n+" = ";for(let l=0;l{var _=M();function E(n,t,e){let r=n[t]+n[e],l=n[t+1]+n[e+1];r>=4294967296&&l++,n[t]=r,n[t+1]=l}function q(n,t,e,r){let l=n[t]+e;e<0&&(l+=4294967296);let a=n[t+1]+r;l>=4294967296&&a++,n[t]=l,n[t+1]=a}function P(n,t){return n[t]^n[t+1]<<8^n[t+2]<<16^n[t+3]<<24}function k(n,t,e,r,l,a){let h=A[l],S=A[l+1],x=A[a],m=A[a+1];E(o,n,t),q(o,n,h,S);let u=o[r]^o[n],c=o[r+1]^o[n+1];o[r]=c,o[r+1]=u,E(o,e,r),u=o[t]^o[e],c=o[t+1]^o[e+1],o[t]=u>>>24^c<<8,o[t+1]=c>>>24^u<<8,E(o,n,t),q(o,n,x,m),u=o[r]^o[n],c=o[r+1]^o[n+1],o[r]=u>>>16^c<<16,o[r+1]=c>>>16^u<<16,E(o,e,r),u=o[t]^o[e],c=o[t+1]^o[e+1],o[t]=c>>>31^u<<1,o[t+1]=u>>>31^c<<1}var O=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),w1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],f=new Uint8Array(w1.map(function(n){return n*2})),o=new Uint32Array(32),A=new Uint32Array(32);function j(n,t){let e=0;for(e=0;e<16;e++)o[e]=n.h[e],o[e+16]=O[e];for(o[24]=o[24]^n.t,o[25]=o[25]^n.t/4294967296,t&&(o[28]=~o[28],o[29]=~o[29]),e=0;e<32;e++)A[e]=P(n.b,4*e);for(e=0;e<12;e++)k(0,8,16,24,f[e*16+0],f[e*16+1]),k(2,10,18,26,f[e*16+2],f[e*16+3]),k(4,12,20,28,f[e*16+4],f[e*16+5]),k(6,14,22,30,f[e*16+6],f[e*16+7]),k(0,10,20,30,f[e*16+8],f[e*16+9]),k(2,12,22,24,f[e*16+10],f[e*16+11]),k(4,14,16,26,f[e*16+12],f[e*16+13]),k(6,8,18,28,f[e*16+14],f[e*16+15]);for(e=0;e<16;e++)n.h[e]=n.h[e]^o[e]^o[e+16]}var w=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function K(n,t,e,r){if(n===0||n>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(e&&e.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(r&&r.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");let l={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:n};w.fill(0),w[0]=n,t&&(w[1]=t.length),w[2]=1,w[3]=1,e&&w.set(e,32),r&&w.set(r,48);for(let a=0;a<16;a++)l.h[a]=O[a]^P(w,a*4);return t&&(T(l,t),l.c=128),l}function T(n,t){for(let e=0;e>2]>>8*(e&3);return t}function V(n,t,e,r,l){e=e||64,n=_.normalizeInput(n),r&&(r=_.normalizeInput(r)),l&&(l=_.normalizeInput(l));let a=K(e,t,r,l);return T(a,n),L(a)}function p1(n,t,e,r,l){let a=V(n,t,e,r,l);return _.toHex(a)}J.exports={blake2b:V,blake2bHex:p1,blake2bInit:K,blake2bUpdate:T,blake2bFinal:L}});var e1=y((C1,v)=>{var Q=M();function g1(n,t){return n[t]^n[t+1]<<8^n[t+2]<<16^n[t+3]<<24}function p(n,t,e,r,l,a){i[n]=i[n]+i[t]+l,i[r]=B(i[r]^i[n],16),i[e]=i[e]+i[r],i[t]=B(i[t]^i[e],12),i[n]=i[n]+i[t]+a,i[r]=B(i[r]^i[n],8),i[e]=i[e]+i[r],i[t]=B(i[t]^i[e],7)}function B(n,t){return n>>>t^n<<32-t}var W=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),i=new Uint32Array(16),s=new Uint32Array(16);function X(n,t){let e=0;for(e=0;e<8;e++)i[e]=n.h[e],i[e+8]=W[e];for(i[12]^=n.t,i[13]^=n.t/4294967296,t&&(i[14]=~i[14]),e=0;e<16;e++)s[e]=g1(n.b,4*e);for(e=0;e<10;e++)p(0,4,8,12,s[b[e*16+0]],s[b[e*16+1]]),p(1,5,9,13,s[b[e*16+2]],s[b[e*16+3]]),p(2,6,10,14,s[b[e*16+4]],s[b[e*16+5]]),p(3,7,11,15,s[b[e*16+6]],s[b[e*16+7]]),p(0,5,10,15,s[b[e*16+8]],s[b[e*16+9]]),p(1,6,11,12,s[b[e*16+10]],s[b[e*16+11]]),p(2,7,8,13,s[b[e*16+12]],s[b[e*16+13]]),p(3,4,9,14,s[b[e*16+14]],s[b[e*16+15]]);for(e=0;e<8;e++)n.h[e]^=i[e]^i[e+8]}function Y(n,t){if(!(n>0&&n<=32))throw new Error("Incorrect output length, should be in [1, 32]");let e=t?t.length:0;if(t&&!(e>0&&e<=32))throw new Error("Incorrect key length, should be in [1, 32]");let r={h:new Uint32Array(W),b:new Uint8Array(64),c:0,t:0,outlen:n};return r.h[0]^=16842752^e<<8^n,e>0&&(C(r,t),r.c=64),r}function C(n,t){for(let e=0;e>2]>>8*(e&3)&255;return t}function $(n,t,e){e=e||32,n=Q.normalizeInput(n);let r=Y(e,t);return C(r,n),Z(r)}function U1(n,t,e){let r=$(n,t,e);return Q.toHex(r)}v.exports={blake2s:$,blake2sHex:U1,blake2sInit:Y,blake2sUpdate:C,blake2sFinal:Z}});var D=y((D1,n1)=>{var I=N(),d=e1();n1.exports={blake2b:I.blake2b,blake2bHex:I.blake2bHex,blake2bInit:I.blake2bInit,blake2bUpdate:I.blake2bUpdate,blake2bFinal:I.blake2bFinal,blake2s:d.blake2s,blake2sHex:d.blake2sHex,blake2sInit:d.blake2sInit,blake2sUpdate:d.blake2sUpdate,blake2sFinal:d.blake2sFinal}});var g={};f1(g,{blake2b:()=>A1,blake2bFinal:()=>m1,blake2bHex:()=>I1,blake2bInit:()=>d1,blake2bUpdate:()=>x1,blake2s:()=>y1,blake2sFinal:()=>B1,blake2sHex:()=>H1,blake2sInit:()=>E1,blake2sUpdate:()=>_1,default:()=>F1});var r1=R(D());U(g,R(D()));var{blake2b:A1,blake2bHex:I1,blake2bInit:d1,blake2bUpdate:x1,blake2bFinal:m1,blake2s:y1,blake2sHex:H1,blake2sInit:E1,blake2sUpdate:_1,blake2sFinal:B1}=r1,{default:t1,...S1}=r1,F1=t1!==void 0?t1:S1;export{A1 as blake2b,m1 as blake2bFinal,I1 as blake2bHex,d1 as blake2bInit,x1 as blake2bUpdate,y1 as blake2s,B1 as blake2sFinal,H1 as blake2sHex,E1 as blake2sInit,_1 as blake2sUpdate,F1 as default}; +//# sourceMappingURL=blakejs.mjs.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@11.0.2/denonext/hashes/hasher.js b/vendor/esm.sh/v120/multiformats@11.0.2/denonext/hashes/hasher.js new file mode 100644 index 0000000..9a57b16 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@11.0.2/denonext/hashes/hasher.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@11.0.2/hashes/hasher) denonext production */ +import*as s from"/v120/multiformats@11.0.2/denonext/hashes/digest.js";var i=({name:n,code:e,encode:t})=>new o(n,e,t),o=class{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?s.create(this.code,t):t.then(r=>s.create(this.code,r))}else throw Error("Unknown type, must be binary type")}};export{o as Hasher,i as from}; +//# sourceMappingURL=hasher.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@11.0.2/denonext/interface.js b/vendor/esm.sh/v120/multiformats@11.0.2/denonext/interface.js new file mode 100644 index 0000000..0eddbc8 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@11.0.2/denonext/interface.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@11.0.2/interface) denonext production */ +var e={};var{default:t,...o}=e,d=t!==void 0?t:o;export{d as default}; +//# sourceMappingURL=interface.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@11.0.2/denonext/multiformats.mjs b/vendor/esm.sh/v120/multiformats@11.0.2/denonext/multiformats.mjs new file mode 100644 index 0000000..3bf5152 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@11.0.2/denonext/multiformats.mjs @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@11.0.2) denonext production */ +var M=Object.defineProperty;var x=(r,e)=>{for(var o in e)M(r,o,{get:e[o],enumerable:!0})};import{CID as G}from"/v120/multiformats@11.0.2/denonext/cid.js";var v={};x(v,{decode:()=>A,encodeTo:()=>D,encodingLength:()=>O});var N=w,h=128,g=127,m=~g,b=Math.pow(2,31);function w(r,e,o){e=e||[],o=o||0;for(var t=o;r>=b;)e[o++]=r&255|h,r/=128;for(;r&m;)e[o++]=r&255|h,r>>>=7;return e[o]=r|0,w.bytes=o-t+1,e}var f=p,F=128,i=127;function p(r,t){var o=0,t=t||0,a=0,c=t,d,s=r.length;do{if(c>=s)throw p.bytes=0,new RangeError("Could not decode varint");d=r[c++],o+=a<28?(d&i)<=F);return p.bytes=c-t,o}var y=Math.pow(2,7),L=Math.pow(2,14),S=Math.pow(2,21),T=Math.pow(2,28),B=Math.pow(2,35),E=Math.pow(2,42),R=Math.pow(2,49),_=Math.pow(2,56),C=Math.pow(2,63),I=function(r){return r[n.decode(r,e),n.decode.bytes],D=(r,e,o=0)=>(n.encode(r,e,o),e),O=r=>n.encodingLength(r);import*as H from"/v120/multiformats@11.0.2/denonext/bytes.js";import*as J from"/v120/multiformats@11.0.2/denonext/hashes/hasher.js";import*as K from"/v120/multiformats@11.0.2/denonext/hashes/digest.js";export*from"/v120/multiformats@11.0.2/denonext/interface.js";export{G as CID,H as bytes,K as digest,J as hasher,v as varint}; +//# sourceMappingURL=multiformats.mjs.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base32.js b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base32.js new file mode 100644 index 0000000..add7517 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base32.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@9.9.0/bases/base32) denonext production */ +var A=new Uint8Array(0);var c=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},p=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return u(this,e)}},l=class{constructor(e){this.decoders=e}or(e){return u(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},u=(t,e)=>new l({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),w=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new c(e,r,n),this.decoder=new p(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},y=({name:t,prefix:e,encode:r,decode:n})=>new w(t,e,r,n);var g=(t,e,r,n)=>{let o={};for(let d=0;d=8&&(i-=8,f[x++]=255&h>>i)}if(i>=r||255&h<<8-i)throw new SyntaxError("Unexpected end of data");return f},v=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<r;)f-=r,a+=e[o&i>>f];if(f&&(a+=e[o&i<y({prefix:e,name:t,encode(o){return v(o,n,r)},decode(o){return g(o,n,r,t)}});var k=s({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),M=s({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$=s({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),B=s({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),R=s({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),T=s({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),V=s({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),q=s({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),D=s({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});export{k as base32,R as base32hex,V as base32hexpad,q as base32hexpadupper,T as base32hexupper,$ as base32pad,B as base32padupper,M as base32upper,D as base32z}; +//# sourceMappingURL=base32.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base58.js b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base58.js new file mode 100644 index 0000000..7127f74 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/bases/base58.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@9.9.0/bases/base58) denonext production */ +function B(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o>>0,s=new Uint8Array(d);f!==c;){for(var h=t[f],p=0,a=d-1;(h!==0||p>>0,s[a]=h%y>>>0,h=h/y>>>0;if(h!==0)throw new Error("Non-zero carry");u=p,f++}for(var w=d-u;w!==d&&s[w]===0;)w++;for(var v=S.repeat(i);w>>0,d=new Uint8Array(c);t[i];){var s=n[t.charCodeAt(i)];if(s===255)return;for(var h=0,p=c-1;(s!==0||h>>0,d[p]=s%256>>>0,s=s/256>>>0;if(s!==0)throw new Error("Non-zero carry");f=h,i++}if(t[i]!==" "){for(var a=c-f;a!==c&&d[a]===0;)a++;for(var w=new Uint8Array(u+(c-a)),v=u;a!==c;)w[v++]=d[a++];return w}}}function _(t){var i=z(t);if(i)return i;throw new Error(`Non-${e} character`)}return{encode:R,decodeUnsafe:z,decode:_}}var T=B,V=T,$=V;var F=new Uint8Array(0);var k=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var A=class{constructor(e,n,o){this.name=e,this.prefix=n,this.baseEncode=o}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},b=class{constructor(e,n,o){if(this.name=e,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=o}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return N(this,e)}},x=class{constructor(e){this.decoders=e}or(e){return N(this,e)}decode(e){let n=e[0],o=this.decoders[n];if(o)return o.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},N=(r,e)=>new x({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),U=class{constructor(e,n,o,l){this.name=e,this.prefix=n,this.baseEncode=o,this.baseDecode=l,this.encoder=new A(e,n,o),this.decoder=new b(e,n,l)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},X=({name:r,prefix:e,encode:n,decode:o})=>new U(r,e,n,o),m=({prefix:r,name:e,alphabet:n})=>{let{encode:o,decode:l}=$(n,e);return X({prefix:r,name:e,encode:o,decode:g=>k(l(g))})};var G=m({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),I=m({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});export{G as base58btc,I as base58flickr}; +//# sourceMappingURL=base58.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@9.9.0/denonext/cid.js b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/cid.js new file mode 100644 index 0000000..1cb5480 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/cid.js @@ -0,0 +1,17 @@ +/* esm.sh - esbuild bundle(multiformats@9.9.0/cid) denonext production */ +var N=v,C=128,V=127,z=~V,O=Math.pow(2,31);function v(r,e,t){e=e||[],t=t||0;for(var n=t;r>=O;)e[t++]=r&255|C,r/=128;for(;r&z;)e[t++]=r&255|C,r>>>=7;return e[t]=r|0,v.bytes=t-n+1,e}var T=w,U=128,D=127;function w(r,n){var t=0,n=n||0,o=0,s=n,i,f=r.length;do{if(s>=f)throw w.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&D)<=U);return w.bytes=s-n,t}var $=Math.pow(2,7),R=Math.pow(2,14),j=Math.pow(2,21),k=Math.pow(2,28),q=Math.pow(2,35),F=Math.pow(2,42),H=Math.pow(2,49),P=Math.pow(2,56),W=Math.pow(2,63),G=function(r){return r<$?1:r[d.decode(r,e),d.decode.bytes],g=(r,e,t=0)=>(d.encode(r,e,t),e),y=r=>d.encodingLength(r);import*as a from"/v120/multiformats@9.9.0/denonext/hashes/digest.js";import{base58btc as c}from"/v120/multiformats@9.9.0/denonext/bases/base58.js";import{base32 as p}from"/v120/multiformats@9.9.0/denonext/bases/base32.js";var se=new Uint8Array(0);var S=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var x=class r{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this.byteOffset=o.byteOffset,this.byteLength=o.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:l,byteLength:l,code:u,version:u,multihash:u,bytes:u,_baseCache:l,asCID:l})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==h)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==_)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=a.create(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&a.equals(this.multihash,e.multihash)}toString(e){let{bytes:t,version:n,_baseCache:o}=this;switch(n){case 0:return Y(t,o,e||c.encoder);default:return Z(t,o,e||p.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return te(/^0\.0/,re),!!(e&&(e[A]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:n,multihash:o,bytes:s}=e;return new r(t,n,o,s||E(t,n,o.bytes))}else if(e!=null&&e[A]===!0){let{version:t,multihash:n,code:o}=e,s=a.decode(n);return r.create(t,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==h)throw new Error(`Version 0 CID must use dag-pb (code: ${h}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=E(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,h,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=S(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new a.Digest(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[M,B]=I(e.subarray(t));return t+=B,M},o=n(),s=h;if(o===18?(o=0,t=0):o===1&&(s=n()),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,f=n(),b=n(),m=t+b,L=m-i;return{version:o,codec:s,multihashCode:f,digestSize:b,multihashSize:L,size:m}}static parse(e,t){let[n,o]=X(e,t),s=r.decode(o);return s._baseCache.set(n,e),s}},X=(r,e)=>{switch(r[0]){case"Q":{let t=e||c;return[c.prefix,t.decode(`${c.prefix}${r}`)]}case c.prefix:{let t=e||c;return[c.prefix,t.decode(r)]}case p.prefix:{let t=e||p;return[p.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Y=(r,e,t)=>{let{prefix:n}=t;if(n!==c.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Z=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},h=112,_=18,E=(r,e,t)=>{let n=y(r),o=n+y(e),s=new Uint8Array(o+t.byteLength);return g(r,s,0),g(e,s,n),s.set(t,o),s},A=Symbol.for("@ipld/js-cid/CID"),u={writable:!1,configurable:!1,enumerable:!0},l={writable:!1,enumerable:!1,configurable:!1},ee="0.0.0-dev",te=(r,e)=>{if(r.test(ee))console.warn(e);else throw new Error(e)},re=`CID.isCID(v) is deprecated and will be removed in the next major release. +Following code pattern: + +if (CID.isCID(value)) { + doSomethingWithCID(value) +} + +Is replaced with: + +const cid = CID.asCID(value) +if (cid) { + // Make sure to use cid instead of value + doSomethingWithCID(cid) +} +`;export{x as CID}; +//# sourceMappingURL=cid.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/digest.js b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/digest.js new file mode 100644 index 0000000..231d176 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/digest.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@9.9.0/hashes/digest) denonext production */ +var V=new Uint8Array(0);var w=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var x=v,g=128,M=127,L=~M,A=Math.pow(2,31);function v(e,t,r){t=t||[],r=r||0;for(var n=r;e>=A;)t[r++]=e&255|g,e/=128;for(;e&L;)t[r++]=e&255|g,e>>>=7;return t[r]=e|0,v.bytes=r-n+1,t}var l=d,N=128,u=127;function d(e,n){var r=0,n=n||0,o=0,c=n,s,b=e.length;do{if(c>=b)throw d.bytes=0,new RangeError("Could not decode varint");s=e[c++],r+=o<28?(s&u)<=N);return d.bytes=c-n,r}var B=Math.pow(2,7),S=Math.pow(2,14),T=Math.pow(2,21),U=Math.pow(2,28),m=Math.pow(2,35),z=Math.pow(2,42),E=Math.pow(2,49),O=Math.pow(2,56),q=Math.pow(2,63),I=function(e){return e[i.decode(e,t),i.decode.bytes],h=(e,t,r=0)=>(i.encode(e,t,r),t),y=e=>i.encodingLength(e);var D=(e,t)=>{let r=t.byteLength,n=y(e),o=n+y(r),c=new Uint8Array(o+r);return h(e,c,0),h(r,c,n),c.set(t,o),new a(e,r,t,c)},F=e=>{let t=p(e),[r,n]=f(t),[o,c]=f(t.subarray(n)),s=t.subarray(n+c);if(s.byteLength!==o)throw new Error("Incorrect length");return new a(r,o,s,t)},G=(e,t)=>e===t?!0:e.code===t.code&&e.size===t.size&&w(e.bytes,t.bytes),a=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};export{a as Digest,D as create,F as decode,G as equals}; +//# sourceMappingURL=digest.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/hasher.js b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/hasher.js new file mode 100644 index 0000000..00af77b --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/hashes/hasher.js @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@9.9.0/hashes/hasher) denonext production */ +import*as s from"/v120/multiformats@9.9.0/denonext/hashes/digest.js";var i=({name:n,code:e,encode:t})=>new o(n,e,t),o=class{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?s.create(this.code,t):t.then(r=>s.create(this.code,r))}else throw Error("Unknown type, must be binary type")}};export{o as Hasher,i as from}; +//# sourceMappingURL=hasher.js.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs new file mode 100644 index 0000000..c274e69 --- /dev/null +++ b/vendor/esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs @@ -0,0 +1,3 @@ +/* esm.sh - esbuild bundle(multiformats@9.9.0) denonext production */ +var M=Object.defineProperty;var d=(r,t)=>{for(var e in t)M(r,e,{get:t[e],enumerable:!0})};import{CID as W}from"/v120/multiformats@9.9.0/denonext/cid.js";var w={};d(w,{decode:()=>H,encodeTo:()=>O,encodingLength:()=>V});var m=p,f=128,u=127,x=~u,A=Math.pow(2,31);function p(r,t,e){t=t||[],e=e||0;for(var n=e;r>=A;)t[e++]=r&255|f,r/=128;for(;r&x;)t[e++]=r&255|f,r>>>=7;return t[e]=r|0,p.bytes=e-n+1,t}var b=s,N=128,h=127;function s(r,n){var e=0,n=n||0,a=0,c=n,i,v=r.length;do{if(c>=v)throw s.bytes=0,new RangeError("Could not decode varint");i=r[c++],e+=a<28?(i&h)<=N);return s.bytes=c-n,e}var L=Math.pow(2,7),S=Math.pow(2,14),B=Math.pow(2,21),U=Math.pow(2,28),T=Math.pow(2,35),l=Math.pow(2,42),E=Math.pow(2,49),I=Math.pow(2,56),R=Math.pow(2,63),_=function(r){return r[o.decode(r,t),o.decode.bytes],O=(r,t,e=0)=>(o.encode(r,t,e),t),V=r=>o.encodingLength(r);var g={};d(g,{coerce:()=>j,empty:()=>y,equals:()=>q,fromHex:()=>k,fromString:()=>F,isBinary:()=>z,toHex:()=>$,toString:()=>G});var y=new Uint8Array(0),$=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),k=r=>{let t=r.match(/../g);return t?new Uint8Array(t.map(e=>parseInt(e,16))):y},q=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},z=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),F=r=>new TextEncoder().encode(r),G=r=>new TextDecoder().decode(r);import*as X from"/v120/multiformats@9.9.0/denonext/hashes/hasher.js";import*as Y from"/v120/multiformats@9.9.0/denonext/hashes/digest.js";export{W as CID,g as bytes,Y as digest,X as hasher,w as varint}; +//# sourceMappingURL=multiformats.mjs.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs b/vendor/esm.sh/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs new file mode 100644 index 0000000..4a069da --- /dev/null +++ b/vendor/esm.sh/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs @@ -0,0 +1,5 @@ +/* esm.sh - esbuild bundle(tweetnacl@1.0.3) denonext production */ +import * as __0$ from "node:crypto"; +var require=n=>{const e=m=>typeof m.default<"u"?m.default:m,c=m=>Object.assign({},m);switch(n){case"crypto":return e(__0$);default:throw new Error("module \""+n+"\" not found");}}; +var D0=Object.create;var t0=Object.defineProperty;var X0=Object.getOwnPropertyDescriptor;var G0=Object.getOwnPropertyNames;var V0=Object.getPrototypeOf,H0=Object.prototype.hasOwnProperty;var e0=(w=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(w,{get:(v,m)=>(typeof require<"u"?require:v)[m]}):w)(function(w){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+w+'" is not supported')});var J0=(w,v)=>()=>(v||w((v={exports:{}}).exports,v),v.exports),W0=(w,v)=>{for(var m in v)t0(w,m,{get:v[m],enumerable:!0})},x0=(w,v,m,pf)=>{if(v&&typeof v=="object"||typeof v=="function")for(let hf of G0(v))!H0.call(w,hf)&&hf!==m&&t0(w,hf,{get:()=>v[hf],enumerable:!(pf=X0(v,hf))||pf.enumerable});return w},lf=(w,v,m)=>(x0(w,v,"default"),m&&x0(m,v,"default")),M0=(w,v,m)=>(m=w!=null?D0(V0(w)):{},x0(v||!w||!w.__esModule?t0(m,"default",{value:w,enumerable:!0}):m,w));var a0=J0((k0,Nf)=>{(function(w){"use strict";var v=function(r){var t,x=new Float64Array(16);if(r)for(t=0;t>24&255,r[t+1]=x>>16&255,r[t+2]=x>>8&255,r[t+3]=x&255,r[t+4]=f>>24&255,r[t+5]=f>>16&255,r[t+6]=f>>8&255,r[t+7]=f&255}function Kf(r,t,x,f,e){var n,i=0;for(n=0;n>>8)-1}function c0(r,t,x,f){return Kf(r,t,x,f,16)}function Zf(r,t,x,f){return Kf(r,t,x,f,32)}function z0(r,t,x,f){for(var e=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,n=x[0]&255|(x[1]&255)<<8|(x[2]&255)<<16|(x[3]&255)<<24,i=x[4]&255|(x[5]&255)<<8|(x[6]&255)<<16|(x[7]&255)<<24,s=x[8]&255|(x[9]&255)<<8|(x[10]&255)<<16|(x[11]&255)<<24,_=x[12]&255|(x[13]&255)<<8|(x[14]&255)<<16|(x[15]&255)<<24,B=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,l=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,X=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,g=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,M=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,T=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,O=x[16]&255|(x[17]&255)<<8|(x[18]&255)<<16|(x[19]&255)<<24,z=x[20]&255|(x[21]&255)<<8|(x[22]&255)<<16|(x[23]&255)<<24,j=x[24]&255|(x[25]&255)<<8|(x[26]&255)<<16|(x[27]&255)<<24,R=x[28]&255|(x[29]&255)<<8|(x[30]&255)<<16|(x[31]&255)<<24,L=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,A=e,S=n,E=i,p=s,U=_,y=B,o=l,h=X,u=g,c=M,b=T,d=O,Y=z,C=j,P=R,N=L,a,Z=0;Z<20;Z+=2)a=A+Y|0,U^=a<<7|a>>>25,a=U+A|0,u^=a<<9|a>>>23,a=u+U|0,Y^=a<<13|a>>>19,a=Y+u|0,A^=a<<18|a>>>14,a=y+S|0,c^=a<<7|a>>>25,a=c+y|0,C^=a<<9|a>>>23,a=C+c|0,S^=a<<13|a>>>19,a=S+C|0,y^=a<<18|a>>>14,a=b+o|0,P^=a<<7|a>>>25,a=P+b|0,E^=a<<9|a>>>23,a=E+P|0,o^=a<<13|a>>>19,a=o+E|0,b^=a<<18|a>>>14,a=N+d|0,p^=a<<7|a>>>25,a=p+N|0,h^=a<<9|a>>>23,a=h+p|0,d^=a<<13|a>>>19,a=d+h|0,N^=a<<18|a>>>14,a=A+p|0,S^=a<<7|a>>>25,a=S+A|0,E^=a<<9|a>>>23,a=E+S|0,p^=a<<13|a>>>19,a=p+E|0,A^=a<<18|a>>>14,a=y+U|0,o^=a<<7|a>>>25,a=o+y|0,h^=a<<9|a>>>23,a=h+o|0,U^=a<<13|a>>>19,a=U+h|0,y^=a<<18|a>>>14,a=b+c|0,d^=a<<7|a>>>25,a=d+b|0,u^=a<<9|a>>>23,a=u+d|0,c^=a<<13|a>>>19,a=c+u|0,b^=a<<18|a>>>14,a=N+P|0,Y^=a<<7|a>>>25,a=Y+N|0,C^=a<<9|a>>>23,a=C+Y|0,P^=a<<13|a>>>19,a=P+C|0,N^=a<<18|a>>>14;A=A+e|0,S=S+n|0,E=E+i|0,p=p+s|0,U=U+_|0,y=y+B|0,o=o+l|0,h=h+X|0,u=u+g|0,c=c+M|0,b=b+T|0,d=d+O|0,Y=Y+z|0,C=C+j|0,P=P+R|0,N=N+L|0,r[0]=A>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=S>>>0&255,r[5]=S>>>8&255,r[6]=S>>>16&255,r[7]=S>>>24&255,r[8]=E>>>0&255,r[9]=E>>>8&255,r[10]=E>>>16&255,r[11]=E>>>24&255,r[12]=p>>>0&255,r[13]=p>>>8&255,r[14]=p>>>16&255,r[15]=p>>>24&255,r[16]=U>>>0&255,r[17]=U>>>8&255,r[18]=U>>>16&255,r[19]=U>>>24&255,r[20]=y>>>0&255,r[21]=y>>>8&255,r[22]=y>>>16&255,r[23]=y>>>24&255,r[24]=o>>>0&255,r[25]=o>>>8&255,r[26]=o>>>16&255,r[27]=o>>>24&255,r[28]=h>>>0&255,r[29]=h>>>8&255,r[30]=h>>>16&255,r[31]=h>>>24&255,r[32]=u>>>0&255,r[33]=u>>>8&255,r[34]=u>>>16&255,r[35]=u>>>24&255,r[36]=c>>>0&255,r[37]=c>>>8&255,r[38]=c>>>16&255,r[39]=c>>>24&255,r[40]=b>>>0&255,r[41]=b>>>8&255,r[42]=b>>>16&255,r[43]=b>>>24&255,r[44]=d>>>0&255,r[45]=d>>>8&255,r[46]=d>>>16&255,r[47]=d>>>24&255,r[48]=Y>>>0&255,r[49]=Y>>>8&255,r[50]=Y>>>16&255,r[51]=Y>>>24&255,r[52]=C>>>0&255,r[53]=C>>>8&255,r[54]=C>>>16&255,r[55]=C>>>24&255,r[56]=P>>>0&255,r[57]=P>>>8&255,r[58]=P>>>16&255,r[59]=P>>>24&255,r[60]=N>>>0&255,r[61]=N>>>8&255,r[62]=N>>>16&255,r[63]=N>>>24&255}function O0(r,t,x,f){for(var e=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,n=x[0]&255|(x[1]&255)<<8|(x[2]&255)<<16|(x[3]&255)<<24,i=x[4]&255|(x[5]&255)<<8|(x[6]&255)<<16|(x[7]&255)<<24,s=x[8]&255|(x[9]&255)<<8|(x[10]&255)<<16|(x[11]&255)<<24,_=x[12]&255|(x[13]&255)<<8|(x[14]&255)<<16|(x[15]&255)<<24,B=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,l=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,X=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,g=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,M=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,T=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,O=x[16]&255|(x[17]&255)<<8|(x[18]&255)<<16|(x[19]&255)<<24,z=x[20]&255|(x[21]&255)<<8|(x[22]&255)<<16|(x[23]&255)<<24,j=x[24]&255|(x[25]&255)<<8|(x[26]&255)<<16|(x[27]&255)<<24,R=x[28]&255|(x[29]&255)<<8|(x[30]&255)<<16|(x[31]&255)<<24,L=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,A=e,S=n,E=i,p=s,U=_,y=B,o=l,h=X,u=g,c=M,b=T,d=O,Y=z,C=j,P=R,N=L,a,Z=0;Z<20;Z+=2)a=A+Y|0,U^=a<<7|a>>>25,a=U+A|0,u^=a<<9|a>>>23,a=u+U|0,Y^=a<<13|a>>>19,a=Y+u|0,A^=a<<18|a>>>14,a=y+S|0,c^=a<<7|a>>>25,a=c+y|0,C^=a<<9|a>>>23,a=C+c|0,S^=a<<13|a>>>19,a=S+C|0,y^=a<<18|a>>>14,a=b+o|0,P^=a<<7|a>>>25,a=P+b|0,E^=a<<9|a>>>23,a=E+P|0,o^=a<<13|a>>>19,a=o+E|0,b^=a<<18|a>>>14,a=N+d|0,p^=a<<7|a>>>25,a=p+N|0,h^=a<<9|a>>>23,a=h+p|0,d^=a<<13|a>>>19,a=d+h|0,N^=a<<18|a>>>14,a=A+p|0,S^=a<<7|a>>>25,a=S+A|0,E^=a<<9|a>>>23,a=E+S|0,p^=a<<13|a>>>19,a=p+E|0,A^=a<<18|a>>>14,a=y+U|0,o^=a<<7|a>>>25,a=o+y|0,h^=a<<9|a>>>23,a=h+o|0,U^=a<<13|a>>>19,a=U+h|0,y^=a<<18|a>>>14,a=b+c|0,d^=a<<7|a>>>25,a=d+b|0,u^=a<<9|a>>>23,a=u+d|0,c^=a<<13|a>>>19,a=c+u|0,b^=a<<18|a>>>14,a=N+P|0,Y^=a<<7|a>>>25,a=Y+N|0,C^=a<<9|a>>>23,a=C+Y|0,P^=a<<13|a>>>19,a=P+C|0,N^=a<<18|a>>>14;r[0]=A>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=y>>>0&255,r[5]=y>>>8&255,r[6]=y>>>16&255,r[7]=y>>>24&255,r[8]=b>>>0&255,r[9]=b>>>8&255,r[10]=b>>>16&255,r[11]=b>>>24&255,r[12]=N>>>0&255,r[13]=N>>>8&255,r[14]=N>>>16&255,r[15]=N>>>24&255,r[16]=o>>>0&255,r[17]=o>>>8&255,r[18]=o>>>16&255,r[19]=o>>>24&255,r[20]=h>>>0&255,r[21]=h>>>8&255,r[22]=h>>>16&255,r[23]=h>>>24&255,r[24]=u>>>0&255,r[25]=u>>>8&255,r[26]=u>>>16&255,r[27]=u>>>24&255,r[28]=c>>>0&255,r[29]=c>>>8&255,r[30]=c>>>16&255,r[31]=c>>>24&255}function Bf(r,t,x,f){z0(r,t,x,f)}function Sf(r,t,x,f){O0(r,t,x,f)}var cf=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function s0(r,t,x,f,e,n,i){var s=new Uint8Array(16),_=new Uint8Array(64),B,l;for(l=0;l<16;l++)s[l]=0;for(l=0;l<8;l++)s[l]=n[l];for(;e>=64;){for(Bf(_,s,i,cf),l=0;l<64;l++)r[t+l]=x[f+l]^_[l];for(B=1,l=8;l<16;l++)B=B+(s[l]&255)|0,s[l]=B&255,B>>>=8;e-=64,t+=64,f+=64}if(e>0)for(Bf(_,s,i,cf),l=0;l=64;){for(Bf(i,n,e,cf),_=0;_<64;_++)r[t+_]=i[_];for(s=1,_=8;_<16;_++)s=s+(n[_]&255)|0,n[_]=s&255,s>>>=8;x-=64,t+=64}if(x>0)for(Bf(i,n,e,cf),_=0;_>>13|x<<3)&8191,f=r[4]&255|(r[5]&255)<<8,this.r[2]=(x>>>10|f<<6)&7939,e=r[6]&255|(r[7]&255)<<8,this.r[3]=(f>>>7|e<<9)&8191,n=r[8]&255|(r[9]&255)<<8,this.r[4]=(e>>>4|n<<12)&255,this.r[5]=n>>>1&8190,i=r[10]&255|(r[11]&255)<<8,this.r[6]=(n>>>14|i<<2)&8191,s=r[12]&255|(r[13]&255)<<8,this.r[7]=(i>>>11|s<<5)&8065,_=r[14]&255|(r[15]&255)<<8,this.r[8]=(s>>>8|_<<8)&8191,this.r[9]=_>>>5&127,this.pad[0]=r[16]&255|(r[17]&255)<<8,this.pad[1]=r[18]&255|(r[19]&255)<<8,this.pad[2]=r[20]&255|(r[21]&255)<<8,this.pad[3]=r[22]&255|(r[23]&255)<<8,this.pad[4]=r[24]&255|(r[25]&255)<<8,this.pad[5]=r[26]&255|(r[27]&255)<<8,this.pad[6]=r[28]&255|(r[29]&255)<<8,this.pad[7]=r[30]&255|(r[31]&255)<<8};Yf.prototype.blocks=function(r,t,x){for(var f=this.fin?0:2048,e,n,i,s,_,B,l,X,g,M,T,O,z,j,R,L,A,S,E,p=this.h[0],U=this.h[1],y=this.h[2],o=this.h[3],h=this.h[4],u=this.h[5],c=this.h[6],b=this.h[7],d=this.h[8],Y=this.h[9],C=this.r[0],P=this.r[1],N=this.r[2],a=this.r[3],Z=this.r[4],G=this.r[5],V=this.r[6],K=this.r[7],F=this.r[8],D=this.r[9];x>=16;)e=r[t+0]&255|(r[t+1]&255)<<8,p+=e&8191,n=r[t+2]&255|(r[t+3]&255)<<8,U+=(e>>>13|n<<3)&8191,i=r[t+4]&255|(r[t+5]&255)<<8,y+=(n>>>10|i<<6)&8191,s=r[t+6]&255|(r[t+7]&255)<<8,o+=(i>>>7|s<<9)&8191,_=r[t+8]&255|(r[t+9]&255)<<8,h+=(s>>>4|_<<12)&8191,u+=_>>>1&8191,B=r[t+10]&255|(r[t+11]&255)<<8,c+=(_>>>14|B<<2)&8191,l=r[t+12]&255|(r[t+13]&255)<<8,b+=(B>>>11|l<<5)&8191,X=r[t+14]&255|(r[t+15]&255)<<8,d+=(l>>>8|X<<8)&8191,Y+=X>>>5|f,g=0,M=g,M+=p*C,M+=U*(5*D),M+=y*(5*F),M+=o*(5*K),M+=h*(5*V),g=M>>>13,M&=8191,M+=u*(5*G),M+=c*(5*Z),M+=b*(5*a),M+=d*(5*N),M+=Y*(5*P),g+=M>>>13,M&=8191,T=g,T+=p*P,T+=U*C,T+=y*(5*D),T+=o*(5*F),T+=h*(5*K),g=T>>>13,T&=8191,T+=u*(5*V),T+=c*(5*G),T+=b*(5*Z),T+=d*(5*a),T+=Y*(5*N),g+=T>>>13,T&=8191,O=g,O+=p*N,O+=U*P,O+=y*C,O+=o*(5*D),O+=h*(5*F),g=O>>>13,O&=8191,O+=u*(5*K),O+=c*(5*V),O+=b*(5*G),O+=d*(5*Z),O+=Y*(5*a),g+=O>>>13,O&=8191,z=g,z+=p*a,z+=U*N,z+=y*P,z+=o*C,z+=h*(5*D),g=z>>>13,z&=8191,z+=u*(5*F),z+=c*(5*K),z+=b*(5*V),z+=d*(5*G),z+=Y*(5*Z),g+=z>>>13,z&=8191,j=g,j+=p*Z,j+=U*a,j+=y*N,j+=o*P,j+=h*C,g=j>>>13,j&=8191,j+=u*(5*D),j+=c*(5*F),j+=b*(5*K),j+=d*(5*V),j+=Y*(5*G),g+=j>>>13,j&=8191,R=g,R+=p*G,R+=U*Z,R+=y*a,R+=o*N,R+=h*P,g=R>>>13,R&=8191,R+=u*C,R+=c*(5*D),R+=b*(5*F),R+=d*(5*K),R+=Y*(5*V),g+=R>>>13,R&=8191,L=g,L+=p*V,L+=U*G,L+=y*Z,L+=o*a,L+=h*N,g=L>>>13,L&=8191,L+=u*P,L+=c*C,L+=b*(5*D),L+=d*(5*F),L+=Y*(5*K),g+=L>>>13,L&=8191,A=g,A+=p*K,A+=U*V,A+=y*G,A+=o*Z,A+=h*a,g=A>>>13,A&=8191,A+=u*N,A+=c*P,A+=b*C,A+=d*(5*D),A+=Y*(5*F),g+=A>>>13,A&=8191,S=g,S+=p*F,S+=U*K,S+=y*V,S+=o*G,S+=h*Z,g=S>>>13,S&=8191,S+=u*a,S+=c*N,S+=b*P,S+=d*C,S+=Y*(5*D),g+=S>>>13,S&=8191,E=g,E+=p*D,E+=U*F,E+=y*K,E+=o*V,E+=h*G,g=E>>>13,E&=8191,E+=u*Z,E+=c*a,E+=b*N,E+=d*P,E+=Y*C,g+=E>>>13,E&=8191,g=(g<<2)+g|0,g=g+M|0,M=g&8191,g=g>>>13,T+=g,p=M,U=T,y=O,o=z,h=j,u=R,c=L,b=A,d=S,Y=E,t+=16,x-=16;this.h[0]=p,this.h[1]=U,this.h[2]=y,this.h[3]=o,this.h[4]=h,this.h[5]=u,this.h[6]=c,this.h[7]=b,this.h[8]=d,this.h[9]=Y},Yf.prototype.finish=function(r,t){var x=new Uint16Array(10),f,e,n,i;if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(f=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=f,f=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=f*5,f=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=f,f=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=f,x[0]=this.h[0]+5,f=x[0]>>>13,x[0]&=8191,i=1;i<10;i++)x[i]=this.h[i]+f,f=x[i]>>>13,x[i]&=8191;for(x[9]-=8192,e=(f^1)-1,i=0;i<10;i++)x[i]&=e;for(e=~e,i=0;i<10;i++)this.h[i]=this.h[i]&e|x[i];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,n=this.h[0]+this.pad[0],this.h[0]=n&65535,i=1;i<8;i++)n=(this.h[i]+this.pad[i]|0)+(n>>>16)|0,this.h[i]=n&65535;r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255},Yf.prototype.update=function(r,t,x){var f,e;if(this.leftover){for(e=16-this.leftover,e>x&&(e=x),f=0;f=16&&(e=x-x%16,this.blocks(r,t,e),t+=e,x-=e),x){for(f=0;f>16&1),n[x-1]&=65535;n[15]=i[15]-32767-(n[14]>>16&1),e=n[15]>>16&1,n[14]&=65535,df(i,n,1-e)}for(x=0;x<16;x++)r[2*x]=i[x]&255,r[2*x+1]=i[x]>>8}function _0(r,t){var x=new Uint8Array(32),f=new Uint8Array(32);return _f(x,r),_f(f,t),Zf(x,0,f,0)}function v0(r){var t=new Uint8Array(32);return _f(t,r),t[0]&1}function Vf(r,t){var x;for(x=0;x<16;x++)r[x]=t[2*x]+(t[2*x+1]<<8);r[15]&=32767}function ef(r,t,x){for(var f=0;f<16;f++)r[f]=t[f]+x[f]}function af(r,t,x){for(var f=0;f<16;f++)r[f]=t[f]-x[f]}function I(r,t,x){var f,e,n=0,i=0,s=0,_=0,B=0,l=0,X=0,g=0,M=0,T=0,O=0,z=0,j=0,R=0,L=0,A=0,S=0,E=0,p=0,U=0,y=0,o=0,h=0,u=0,c=0,b=0,d=0,Y=0,C=0,P=0,N=0,a=x[0],Z=x[1],G=x[2],V=x[3],K=x[4],F=x[5],D=x[6],q=x[7],H=x[8],J=x[9],W=x[10],$=x[11],Q=x[12],k=x[13],ff=x[14],rf=x[15];f=t[0],n+=f*a,i+=f*Z,s+=f*G,_+=f*V,B+=f*K,l+=f*F,X+=f*D,g+=f*q,M+=f*H,T+=f*J,O+=f*W,z+=f*$,j+=f*Q,R+=f*k,L+=f*ff,A+=f*rf,f=t[1],i+=f*a,s+=f*Z,_+=f*G,B+=f*V,l+=f*K,X+=f*F,g+=f*D,M+=f*q,T+=f*H,O+=f*J,z+=f*W,j+=f*$,R+=f*Q,L+=f*k,A+=f*ff,S+=f*rf,f=t[2],s+=f*a,_+=f*Z,B+=f*G,l+=f*V,X+=f*K,g+=f*F,M+=f*D,T+=f*q,O+=f*H,z+=f*J,j+=f*W,R+=f*$,L+=f*Q,A+=f*k,S+=f*ff,E+=f*rf,f=t[3],_+=f*a,B+=f*Z,l+=f*G,X+=f*V,g+=f*K,M+=f*F,T+=f*D,O+=f*q,z+=f*H,j+=f*J,R+=f*W,L+=f*$,A+=f*Q,S+=f*k,E+=f*ff,p+=f*rf,f=t[4],B+=f*a,l+=f*Z,X+=f*G,g+=f*V,M+=f*K,T+=f*F,O+=f*D,z+=f*q,j+=f*H,R+=f*J,L+=f*W,A+=f*$,S+=f*Q,E+=f*k,p+=f*ff,U+=f*rf,f=t[5],l+=f*a,X+=f*Z,g+=f*G,M+=f*V,T+=f*K,O+=f*F,z+=f*D,j+=f*q,R+=f*H,L+=f*J,A+=f*W,S+=f*$,E+=f*Q,p+=f*k,U+=f*ff,y+=f*rf,f=t[6],X+=f*a,g+=f*Z,M+=f*G,T+=f*V,O+=f*K,z+=f*F,j+=f*D,R+=f*q,L+=f*H,A+=f*J,S+=f*W,E+=f*$,p+=f*Q,U+=f*k,y+=f*ff,o+=f*rf,f=t[7],g+=f*a,M+=f*Z,T+=f*G,O+=f*V,z+=f*K,j+=f*F,R+=f*D,L+=f*q,A+=f*H,S+=f*J,E+=f*W,p+=f*$,U+=f*Q,y+=f*k,o+=f*ff,h+=f*rf,f=t[8],M+=f*a,T+=f*Z,O+=f*G,z+=f*V,j+=f*K,R+=f*F,L+=f*D,A+=f*q,S+=f*H,E+=f*J,p+=f*W,U+=f*$,y+=f*Q,o+=f*k,h+=f*ff,u+=f*rf,f=t[9],T+=f*a,O+=f*Z,z+=f*G,j+=f*V,R+=f*K,L+=f*F,A+=f*D,S+=f*q,E+=f*H,p+=f*J,U+=f*W,y+=f*$,o+=f*Q,h+=f*k,u+=f*ff,c+=f*rf,f=t[10],O+=f*a,z+=f*Z,j+=f*G,R+=f*V,L+=f*K,A+=f*F,S+=f*D,E+=f*q,p+=f*H,U+=f*J,y+=f*W,o+=f*$,h+=f*Q,u+=f*k,c+=f*ff,b+=f*rf,f=t[11],z+=f*a,j+=f*Z,R+=f*G,L+=f*V,A+=f*K,S+=f*F,E+=f*D,p+=f*q,U+=f*H,y+=f*J,o+=f*W,h+=f*$,u+=f*Q,c+=f*k,b+=f*ff,d+=f*rf,f=t[12],j+=f*a,R+=f*Z,L+=f*G,A+=f*V,S+=f*K,E+=f*F,p+=f*D,U+=f*q,y+=f*H,o+=f*J,h+=f*W,u+=f*$,c+=f*Q,b+=f*k,d+=f*ff,Y+=f*rf,f=t[13],R+=f*a,L+=f*Z,A+=f*G,S+=f*V,E+=f*K,p+=f*F,U+=f*D,y+=f*q,o+=f*H,h+=f*J,u+=f*W,c+=f*$,b+=f*Q,d+=f*k,Y+=f*ff,C+=f*rf,f=t[14],L+=f*a,A+=f*Z,S+=f*G,E+=f*V,p+=f*K,U+=f*F,y+=f*D,o+=f*q,h+=f*H,u+=f*J,c+=f*W,b+=f*$,d+=f*Q,Y+=f*k,C+=f*ff,P+=f*rf,f=t[15],A+=f*a,S+=f*Z,E+=f*G,p+=f*V,U+=f*K,y+=f*F,o+=f*D,h+=f*q,u+=f*H,c+=f*J,b+=f*W,d+=f*$,Y+=f*Q,C+=f*k,P+=f*ff,N+=f*rf,n+=38*S,i+=38*E,s+=38*p,_+=38*U,B+=38*y,l+=38*o,X+=38*h,g+=38*u,M+=38*c,T+=38*b,O+=38*d,z+=38*Y,j+=38*C,R+=38*P,L+=38*N,e=1,f=n+e+65535,e=Math.floor(f/65536),n=f-e*65536,f=i+e+65535,e=Math.floor(f/65536),i=f-e*65536,f=s+e+65535,e=Math.floor(f/65536),s=f-e*65536,f=_+e+65535,e=Math.floor(f/65536),_=f-e*65536,f=B+e+65535,e=Math.floor(f/65536),B=f-e*65536,f=l+e+65535,e=Math.floor(f/65536),l=f-e*65536,f=X+e+65535,e=Math.floor(f/65536),X=f-e*65536,f=g+e+65535,e=Math.floor(f/65536),g=f-e*65536,f=M+e+65535,e=Math.floor(f/65536),M=f-e*65536,f=T+e+65535,e=Math.floor(f/65536),T=f-e*65536,f=O+e+65535,e=Math.floor(f/65536),O=f-e*65536,f=z+e+65535,e=Math.floor(f/65536),z=f-e*65536,f=j+e+65535,e=Math.floor(f/65536),j=f-e*65536,f=R+e+65535,e=Math.floor(f/65536),R=f-e*65536,f=L+e+65535,e=Math.floor(f/65536),L=f-e*65536,f=A+e+65535,e=Math.floor(f/65536),A=f-e*65536,n+=e-1+37*(e-1),e=1,f=n+e+65535,e=Math.floor(f/65536),n=f-e*65536,f=i+e+65535,e=Math.floor(f/65536),i=f-e*65536,f=s+e+65535,e=Math.floor(f/65536),s=f-e*65536,f=_+e+65535,e=Math.floor(f/65536),_=f-e*65536,f=B+e+65535,e=Math.floor(f/65536),B=f-e*65536,f=l+e+65535,e=Math.floor(f/65536),l=f-e*65536,f=X+e+65535,e=Math.floor(f/65536),X=f-e*65536,f=g+e+65535,e=Math.floor(f/65536),g=f-e*65536,f=M+e+65535,e=Math.floor(f/65536),M=f-e*65536,f=T+e+65535,e=Math.floor(f/65536),T=f-e*65536,f=O+e+65535,e=Math.floor(f/65536),O=f-e*65536,f=z+e+65535,e=Math.floor(f/65536),z=f-e*65536,f=j+e+65535,e=Math.floor(f/65536),j=f-e*65536,f=R+e+65535,e=Math.floor(f/65536),R=f-e*65536,f=L+e+65535,e=Math.floor(f/65536),L=f-e*65536,f=A+e+65535,e=Math.floor(f/65536),A=f-e*65536,n+=e-1+37*(e-1),r[0]=n,r[1]=i,r[2]=s,r[3]=_,r[4]=B,r[5]=l,r[6]=X,r[7]=g,r[8]=M,r[9]=T,r[10]=O,r[11]=z,r[12]=j,r[13]=R,r[14]=L,r[15]=A}function tf(r,t){I(r,t,t)}function y0(r,t){var x=v(),f;for(f=0;f<16;f++)x[f]=t[f];for(f=253;f>=0;f--)tf(x,x),f!==2&&f!==4&&I(x,x,t);for(f=0;f<16;f++)r[f]=x[f]}function l0(r,t){var x=v(),f;for(f=0;f<16;f++)x[f]=t[f];for(f=250;f>=0;f--)tf(x,x),f!==1&&I(x,x,t);for(f=0;f<16;f++)r[f]=x[f]}function Mf(r,t,x){var f=new Uint8Array(32),e=new Float64Array(80),n,i,s=v(),_=v(),B=v(),l=v(),X=v(),g=v();for(i=0;i<31;i++)f[i]=t[i];for(f[31]=t[31]&127|64,f[0]&=248,Vf(e,x),i=0;i<16;i++)_[i]=e[i],l[i]=s[i]=B[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)n=f[i>>>3]>>>(i&7)&1,df(s,_,n),df(B,l,n),ef(X,s,B),af(s,s,B),ef(B,_,l),af(_,_,l),tf(l,X),tf(g,s),I(s,B,s),I(B,_,X),ef(X,s,B),af(s,s,B),tf(_,s),af(B,l,g),I(s,B,j0),ef(s,s,l),I(B,B,s),I(s,l,g),I(l,_,e),tf(_,X),df(s,_,n),df(B,l,n);for(i=0;i<16;i++)e[i+16]=s[i],e[i+32]=B[i],e[i+48]=_[i],e[i+64]=l[i];var M=e.subarray(32),T=e.subarray(16);return y0(M,M),I(T,T,M),_f(r,T),0}function Tf(r,t){return Mf(r,t,hf)}function w0(r,t){return m(t,32),Tf(r,t)}function jf(r,t,x){var f=new Uint8Array(32);return Mf(f,x,t),Sf(r,pf,f,cf)}var E0=Df,C0=Xf;function N0(r,t,x,f,e,n){var i=new Uint8Array(32);return jf(i,e,n),E0(r,t,x,f,i)}function P0(r,t,x,f,e,n){var i=new Uint8Array(32);return jf(i,e,n),C0(r,t,x,f,i)}var g0=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function A0(r,t,x,f){for(var e=new Int32Array(16),n=new Int32Array(16),i,s,_,B,l,X,g,M,T,O,z,j,R,L,A,S,E,p,U,y,o,h,u,c,b,d,Y=r[0],C=r[1],P=r[2],N=r[3],a=r[4],Z=r[5],G=r[6],V=r[7],K=t[0],F=t[1],D=t[2],q=t[3],H=t[4],J=t[5],W=t[6],$=t[7],Q=0;f>=128;){for(U=0;U<16;U++)y=8*U+Q,e[U]=x[y+0]<<24|x[y+1]<<16|x[y+2]<<8|x[y+3],n[U]=x[y+4]<<24|x[y+5]<<16|x[y+6]<<8|x[y+7];for(U=0;U<80;U++)if(i=Y,s=C,_=P,B=N,l=a,X=Z,g=G,M=V,T=K,O=F,z=D,j=q,R=H,L=J,A=W,S=$,o=V,h=$,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=(a>>>14|H<<18)^(a>>>18|H<<14)^(H>>>9|a<<23),h=(H>>>14|a<<18)^(H>>>18|a<<14)^(a>>>9|H<<23),u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,o=a&Z^~a&G,h=H&J^~H&W,u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,o=g0[U*2],h=g0[U*2+1],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,o=e[U%16],h=n[U%16],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,E=b&65535|d<<16,p=u&65535|c<<16,o=E,h=p,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=(Y>>>28|K<<4)^(K>>>2|Y<<30)^(K>>>7|Y<<25),h=(K>>>28|Y<<4)^(Y>>>2|K<<30)^(Y>>>7|K<<25),u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,o=Y&C^Y&P^C&P,h=K&F^K&D^F&D,u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,M=b&65535|d<<16,S=u&65535|c<<16,o=B,h=j,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=E,h=p,u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,B=b&65535|d<<16,j=u&65535|c<<16,C=i,P=s,N=_,a=B,Z=l,G=X,V=g,Y=M,F=T,D=O,q=z,H=j,J=R,W=L,$=A,K=S,U%16===15)for(y=0;y<16;y++)o=e[y],h=n[y],u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=e[(y+9)%16],h=n[(y+9)%16],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,E=e[(y+1)%16],p=n[(y+1)%16],o=(E>>>1|p<<31)^(E>>>8|p<<24)^E>>>7,h=(p>>>1|E<<31)^(p>>>8|E<<24)^(p>>>7|E<<25),u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,E=e[(y+14)%16],p=n[(y+14)%16],o=(E>>>19|p<<13)^(p>>>29|E<<3)^E>>>6,h=(p>>>19|E<<13)^(E>>>29|p<<3)^(p>>>6|E<<26),u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,e[y]=b&65535|d<<16,n[y]=u&65535|c<<16;o=Y,h=K,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[0],h=t[0],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[0]=Y=b&65535|d<<16,t[0]=K=u&65535|c<<16,o=C,h=F,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[1],h=t[1],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[1]=C=b&65535|d<<16,t[1]=F=u&65535|c<<16,o=P,h=D,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[2],h=t[2],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[2]=P=b&65535|d<<16,t[2]=D=u&65535|c<<16,o=N,h=q,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[3],h=t[3],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[3]=N=b&65535|d<<16,t[3]=q=u&65535|c<<16,o=a,h=H,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[4],h=t[4],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[4]=a=b&65535|d<<16,t[4]=H=u&65535|c<<16,o=Z,h=J,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[5],h=t[5],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[5]=Z=b&65535|d<<16,t[5]=J=u&65535|c<<16,o=G,h=W,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[6],h=t[6],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[6]=G=b&65535|d<<16,t[6]=W=u&65535|c<<16,o=V,h=$,u=h&65535,c=h>>>16,b=o&65535,d=o>>>16,o=r[7],h=t[7],u+=h&65535,c+=h>>>16,b+=o&65535,d+=o>>>16,c+=u>>>16,b+=c>>>16,d+=b>>>16,r[7]=V=b&65535|d<<16,t[7]=$=u&65535|c<<16,Q+=128,f-=128}return f}function sf(r,t,x){var f=new Int32Array(8),e=new Int32Array(8),n=new Uint8Array(256),i,s=x;for(f[0]=1779033703,f[1]=3144134277,f[2]=1013904242,f[3]=2773480762,f[4]=1359893119,f[5]=2600822924,f[6]=528734635,f[7]=1541459225,e[0]=4089235720,e[1]=2227873595,e[2]=4271175723,e[3]=1595750129,e[4]=2917565137,e[5]=725511199,e[6]=4215389547,e[7]=327033209,A0(f,e,t,x),x%=128,i=0;i=0;--e)f=x[e/8|0]>>(e&7)&1,p0(r,t,f),Lf(t,r),Lf(r,r),p0(r,t,f)}function Rf(r,t){var x=[v(),v(),v(),v()];nf(x[0],i0),nf(x[1],o0),nf(x[2],Uf),I(x[3],i0,o0),Jf(r,x,t)}function Wf(r,t,x){var f=new Uint8Array(64),e=[v(),v(),v(),v()],n;for(x||m(t,32),sf(f,t,32),f[0]&=248,f[31]&=127,f[31]|=64,Rf(e,f),Hf(r,e),n=0;n<32;n++)t[n+32]=r[n];return 0}var zf=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function $f(r,t){var x,f,e,n;for(f=63;f>=32;--f){for(x=0,e=f-32,n=f-12;e>4)*zf[e],x=t[e]>>8,t[e]&=255;for(e=0;e<32;e++)t[e]-=x*zf[e];for(f=0;f<32;f++)t[f+1]+=t[f]>>8,r[f]=t[f]&255}function qf(r){var t=new Float64Array(64),x;for(x=0;x<64;x++)t[x]=r[x];for(x=0;x<64;x++)r[x]=0;$f(r,t)}function U0(r,t,x,f){var e=new Uint8Array(64),n=new Uint8Array(64),i=new Uint8Array(64),s,_,B=new Float64Array(64),l=[v(),v(),v(),v()];sf(e,f,32),e[0]&=248,e[31]&=127,e[31]|=64;var X=x+64;for(s=0;s>7&&af(r[0],Pf,r[0]),I(r[3],r[0],r[1]),0)}function Qf(r,t,x,f){var e,n=new Uint8Array(32),i=new Uint8Array(64),s=[v(),v(),v(),v()],_=[v(),v(),v(),v()];if(x<64||K0(_,f))return-1;for(e=0;e=0},w.sign.keyPair=function(){var r=new Uint8Array(bf),t=new Uint8Array(yf);return Wf(r,t),{publicKey:r,secretKey:t}},w.sign.keyPair.fromSecretKey=function(r){if(xf(r),r.length!==yf)throw new Error("bad secret key size");for(var t=new Uint8Array(bf),x=0;xQ0});var $0=M0(a0());lf(uf,M0(a0()));var{default:T0,...q0}=$0,Q0=T0!==void 0?T0:q0;export{Q0 as default}; +//# sourceMappingURL=tweetnacl.mjs.map \ No newline at end of file diff --git a/vendor/esm.sh/v120/tweetnacl@1.0.3/nacl.d.ts b/vendor/esm.sh/v120/tweetnacl@1.0.3/nacl.d.ts new file mode 100644 index 0000000..78c4f78 --- /dev/null +++ b/vendor/esm.sh/v120/tweetnacl@1.0.3/nacl.d.ts @@ -0,0 +1,98 @@ +// Type definitions for TweetNaCl.js + +export as namespace nacl; + +declare var nacl: nacl; +export = nacl; + +declare namespace nacl { + export interface BoxKeyPair { + publicKey: Uint8Array; + secretKey: Uint8Array; + } + + export interface SignKeyPair { + publicKey: Uint8Array; + secretKey: Uint8Array; + } + + export interface secretbox { + (msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; + open(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; + readonly keyLength: number; + readonly nonceLength: number; + readonly overheadLength: number; + } + + export interface scalarMult { + (n: Uint8Array, p: Uint8Array): Uint8Array; + base(n: Uint8Array): Uint8Array; + readonly scalarLength: number; + readonly groupElementLength: number; + } + + namespace boxProps { + export interface open { + (msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null; + after(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; + } + + export interface keyPair { + (): BoxKeyPair; + fromSecretKey(secretKey: Uint8Array): BoxKeyPair; + } + } + + export interface box { + (msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; + before(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; + after(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; + open: boxProps.open; + keyPair: boxProps.keyPair; + readonly publicKeyLength: number; + readonly secretKeyLength: number; + readonly sharedKeyLength: number; + readonly nonceLength: number; + readonly overheadLength: number; + } + + namespace signProps { + export interface detached { + (msg: Uint8Array, secretKey: Uint8Array): Uint8Array; + verify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean; + } + + export interface keyPair { + (): SignKeyPair; + fromSecretKey(secretKey: Uint8Array): SignKeyPair; + fromSeed(secretKey: Uint8Array): SignKeyPair; + } + } + + export interface sign { + (msg: Uint8Array, secretKey: Uint8Array): Uint8Array; + open(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null; + detached: signProps.detached; + keyPair: signProps.keyPair; + readonly publicKeyLength: number; + readonly secretKeyLength: number; + readonly seedLength: number; + readonly signatureLength: number; + } + + export interface hash { + (msg: Uint8Array): Uint8Array; + readonly hashLength: number; + } +} + +declare interface nacl { + randomBytes(n: number): Uint8Array; + secretbox: nacl.secretbox; + scalarMult: nacl.scalarMult; + box: nacl.box; + sign: nacl.sign; + hash: nacl.hash; + verify(x: Uint8Array, y: Uint8Array): boolean; + setPRNG(fn: (x: Uint8Array, n: number) => void): void; +} diff --git a/vendor/import_map.json b/vendor/import_map.json index 7785b0d..883ab65 100644 --- a/vendor/import_map.json +++ b/vendor/import_map.json @@ -1,5 +1,6 @@ { "imports": { + "https://esm.sh/tweetnacl@1.0.3?pin=v120": "./esm.sh/tweetnacl@1.0.3.js", "https://esm.sh/multiformats@11.0.2/bases/base58?pin=v120": "./esm.sh/multiformats@11.0.2/bases/base58.js", "https://esm.sh/multiformats@11.0.2?pin=v120": "./esm.sh/multiformats@11.0.2.js", "https://esm.sh/@multiformats/blake2@1.0.13?pin=v120": "./esm.sh/@multiformats/blake2@1.0.13.js", @@ -10,15 +11,26 @@ }, "scopes": { "./esm.sh/": { - "/v120/multiformats@11.0.2/denonext/hashes/digest.js": "./esm.sh/v120/multiformats@11.0.2/denonext/hashes/digest.js", + "/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js": "./esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2b.js", + "/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js": "./esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2s.js", + "/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs": "./esm.sh/v120/@multiformats/blake2@1.0.13/denonext/blake2.mjs", + "/v120/multiformats@11.0.2/denonext/bytes.js": "./esm.sh/v120/multiformats@11.0.2/denonext/bytes.js", + "/v120/multiformats@11.0.2/denonext/bases/interface.js": "./esm.sh/v120/multiformats@11.0.2/denonext/bases/interface.js", "/v120/multiformats@11.0.2/denonext/bases/base58.js": "./esm.sh/v120/multiformats@11.0.2/denonext/bases/base58.js", + "/v120/multiformats@11.0.2/denonext/hashes/digest.js": "./esm.sh/v120/multiformats@11.0.2/denonext/hashes/digest.js", "/v120/multiformats@11.0.2/denonext/bases/base32.js": "./esm.sh/v120/multiformats@11.0.2/denonext/bases/base32.js", - "/v120/multiformats@11.0.2/denonext/bytes.js": "./esm.sh/v120/multiformats@11.0.2/denonext/bytes.js", "/v120/multiformats@11.0.2/denonext/cid.js": "./esm.sh/v120/multiformats@11.0.2/denonext/cid.js", - "/v120/blakejs@1.2.1/deno/blakejs.mjs": "./esm.sh/v120/blakejs@1.2.1/deno/blakejs.mjs", - "/v120/multiformats@9.9.0/deno/hashes/hasher.js": "./esm.sh/v120/multiformats@9.9.0/deno/hashes/hasher.js", - "/v120/multiformats@9.9.0/deno/multiformats.mjs": "./esm.sh/v120/multiformats@9.9.0/deno/multiformats.mjs", - "/v120/multiformats@11.0.2/denonext/bases/interface.js": "./esm.sh/v120/multiformats@11.0.2/denonext/bases/interface.js" + "/v120/multiformats@11.0.2/denonext/hashes/hasher.js": "./esm.sh/v120/multiformats@11.0.2/denonext/hashes/hasher.js", + "/v120/multiformats@11.0.2/denonext/interface.js": "./esm.sh/v120/multiformats@11.0.2/denonext/interface.js", + "/v120/multiformats@11.0.2/denonext/multiformats.mjs": "./esm.sh/v120/multiformats@11.0.2/denonext/multiformats.mjs", + "/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs": "./esm.sh/v120/tweetnacl@1.0.3/denonext/tweetnacl.mjs", + "/v120/blakejs@1.2.1/denonext/blakejs.mjs": "./esm.sh/v120/blakejs@1.2.1/denonext/blakejs.mjs", + "/v120/multiformats@9.9.0/denonext/hashes/hasher.js": "./esm.sh/v120/multiformats@9.9.0/denonext/hashes/hasher.js", + "/v120/multiformats@9.9.0/denonext/multiformats.mjs": "./esm.sh/v120/multiformats@9.9.0/denonext/multiformats.mjs", + "/v120/multiformats@9.9.0/denonext/hashes/digest.js": "./esm.sh/v120/multiformats@9.9.0/denonext/hashes/digest.js", + "/v120/multiformats@9.9.0/denonext/bases/base58.js": "./esm.sh/v120/multiformats@9.9.0/denonext/bases/base58.js", + "/v120/multiformats@9.9.0/denonext/bases/base32.js": "./esm.sh/v120/multiformats@9.9.0/denonext/bases/base32.js", + "/v120/multiformats@9.9.0/denonext/cid.js": "./esm.sh/v120/multiformats@9.9.0/denonext/cid.js" } } }