@twin.org/crypto 0.0.4-next.1 → 0.0.4-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/curves/ed25519.js +1 -1
- package/dist/es/curves/ed25519.js.map +1 -1
- package/dist/es/curves/secp256k1.js +1 -1
- package/dist/es/curves/secp256k1.js.map +1 -1
- package/dist/es/hashes/argon2id.js +1 -1
- package/dist/es/hashes/argon2id.js.map +1 -1
- package/dist/es/hashes/blake2b.js +1 -1
- package/dist/es/hashes/blake2b.js.map +1 -1
- package/dist/es/hashes/blake3.js +1 -1
- package/dist/es/hashes/blake3.js.map +1 -1
- package/dist/es/hashes/hmacSha1.js +1 -1
- package/dist/es/hashes/hmacSha1.js.map +1 -1
- package/dist/es/hashes/hmacSha256.js +1 -1
- package/dist/es/hashes/hmacSha256.js.map +1 -1
- package/dist/es/hashes/hmacSha512.js +1 -1
- package/dist/es/hashes/hmacSha512.js.map +1 -1
- package/dist/es/hashes/sha1.js +1 -1
- package/dist/es/hashes/sha1.js.map +1 -1
- package/dist/es/hashes/sha256.js +1 -1
- package/dist/es/hashes/sha256.js.map +1 -1
- package/dist/es/hashes/sha3.js +1 -1
- package/dist/es/hashes/sha3.js.map +1 -1
- package/dist/es/hashes/sha512.js +1 -1
- package/dist/es/hashes/sha512.js.map +1 -1
- package/dist/es/helpers/integrityHelper.js +1 -1
- package/dist/es/helpers/integrityHelper.js.map +1 -1
- package/dist/es/keys/slip0010.js +1 -1
- package/dist/es/keys/slip0010.js.map +1 -1
- package/dist/es/otp/totp.js +1 -1
- package/dist/es/otp/totp.js.map +1 -1
- package/dist/types/curves/ed25519.d.ts +1 -1
- package/dist/types/curves/secp256k1.d.ts +1 -1
- package/dist/types/hashes/argon2id.d.ts +1 -1
- package/dist/types/hashes/blake2b.d.ts +1 -1
- package/dist/types/hashes/blake3.d.ts +1 -1
- package/dist/types/hashes/hmacSha1.d.ts +1 -1
- package/dist/types/hashes/hmacSha256.d.ts +1 -1
- package/dist/types/hashes/hmacSha512.d.ts +1 -1
- package/dist/types/hashes/sha1.d.ts +1 -1
- package/dist/types/hashes/sha256.d.ts +1 -1
- package/dist/types/hashes/sha3.d.ts +1 -1
- package/dist/types/hashes/sha512.d.ts +1 -1
- package/dist/types/keys/slip0010.d.ts +1 -1
- package/dist/types/otp/totp.d.ts +1 -1
- package/docs/changelog.md +214 -0
- package/docs/reference/classes/Argon2id.md +1 -1
- package/docs/reference/classes/Blake2b.md +1 -1
- package/docs/reference/classes/Blake3.md +1 -1
- package/docs/reference/classes/Ed25519.md +1 -1
- package/docs/reference/classes/HmacSha1.md +1 -1
- package/docs/reference/classes/HmacSha256.md +1 -1
- package/docs/reference/classes/HmacSha512.md +1 -1
- package/docs/reference/classes/Secp256k1.md +1 -1
- package/docs/reference/classes/Sha1.md +1 -1
- package/docs/reference/classes/Sha256.md +1 -1
- package/docs/reference/classes/Sha3.md +1 -1
- package/docs/reference/classes/Sha512.md +1 -1
- package/docs/reference/classes/Slip0010.md +1 -1
- package/docs/reference/classes/Totp.md +1 -1
- package/package.json +5 -5
|
@@ -35,7 +35,7 @@ export class Ed25519 {
|
|
|
35
35
|
return ed25519.getPublicKey(privateKey);
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Signs the block with the private key and returns a signature.
|
|
39
39
|
* @param privateKey The private key.
|
|
40
40
|
* @param block The block to sign.
|
|
41
41
|
* @returns The signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../../src/curves/ed25519.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGxE;;GAEG;AACH,MAAM,OAAO,OAAO;IACnB;;OAEG;IACI,MAA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CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC/F,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;QACnE,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,SAAoB;QACzD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,eAAqB,SAAS,CAAC,CAAC;QAEjE,uEAAuE;QACvE,8DAA8D;QAC9D,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAErE,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { GeneralError, Guards, Uint8ArrayHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Implementation of Ed25519.\n */\nexport class Ed25519 {\n\t/**\n\t * Private Key Size is the size, in bytes, of private keys as used in this package.\n\t */\n\tpublic static PRIVATE_KEY_SIZE: number = 32;\n\n\t/**\n\t * Public Key Size is the size, in bytes, of public keys as used in this package.\n\t */\n\tpublic static PUBLIC_KEY_SIZE: number = 32;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Ed25519>();\n\n\t/**\n\t * Public returns the PublicKey corresponding to private.\n\t * @param privateKey The private key to get the corresponding public key.\n\t * @returns The public key.\n\t * @throws Error if the private key is not the correct length.\n\t */\n\tpublic static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(privateKey), privateKey);\n\n\t\tif (privateKey.length !== Ed25519.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Ed25519.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Ed25519.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey.length\n\t\t\t});\n\t\t}\n\n\t\treturn ed25519.getPublicKey(privateKey);\n\t}\n\n\t/**\n\t *
|
|
1
|
+
{"version":3,"file":"ed25519.js","sourceRoot":"","sources":["../../../src/curves/ed25519.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGxE;;GAEG;AACH,MAAM,OAAO,OAAO;IACnB;;OAEG;IACI,MAAM,CAAC,gBAAgB,GAAW,EAAE,CAAC;IAE5C;;OAEG;IACI,MAAM,CAAC,eAAe,GAAW,EAAE,CAAC;IAE3C;;OAEG;IACI,MAAM,CAAU,UAAU,aAA6B;IAE9D;;;;;OAKG;IACI,MAAM,CAAC,uBAAuB,CAAC,UAAsB;QAC3D,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAEtE,IAAI,UAAU,CAAC,MAAM,KAAK,OAAO,CAAC,gBAAgB,EAAE,CAAC;YACpD,MAAM,IAAI,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,kBAAkB,EAAE;gBAC9D,YAAY,EAAE,OAAO,CAAC,gBAAgB;gBACtC,UAAU,EAAE,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AC,iBAAiB,CAAC,SAAoB;QACzD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,eAAqB,SAAS,CAAC,CAAC;QAEjE,uEAAuE;QACvE,8DAA8D;QAC9D,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAErE,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { GeneralError, Guards, Uint8ArrayHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Implementation of Ed25519.\n */\nexport class Ed25519 {\n\t/**\n\t * Private Key Size is the size, in bytes, of private keys as used in this package.\n\t */\n\tpublic static PRIVATE_KEY_SIZE: number = 32;\n\n\t/**\n\t * Public Key Size is the size, in bytes, of public keys as used in this package.\n\t */\n\tpublic static PUBLIC_KEY_SIZE: number = 32;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Ed25519>();\n\n\t/**\n\t * Public returns the PublicKey corresponding to private.\n\t * @param privateKey The private key to get the corresponding public key.\n\t * @returns The public key.\n\t * @throws Error if the private key is not the correct length.\n\t */\n\tpublic static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(privateKey), privateKey);\n\n\t\tif (privateKey.length !== Ed25519.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Ed25519.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Ed25519.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey.length\n\t\t\t});\n\t\t}\n\n\t\treturn ed25519.getPublicKey(privateKey);\n\t}\n\n\t/**\n\t * Signs the block with the private key and returns a signature.\n\t * @param privateKey The private key.\n\t * @param block The block to sign.\n\t * @returns The signature.\n\t * @throws Error if the private key is not the correct length.\n\t */\n\tpublic static sign(privateKey: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(privateKey), privateKey);\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(block), block);\n\n\t\tif (privateKey.length !== Ed25519.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Ed25519.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Ed25519.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey ? privateKey.length : 0\n\t\t\t});\n\t\t}\n\n\t\treturn ed25519.sign(block, privateKey);\n\t}\n\n\t/**\n\t * Verify reports whether sig is a valid signature of block by publicKey.\n\t * @param publicKey The public key to verify the signature.\n\t * @param block The block for the signature.\n\t * @param signature The signature.\n\t * @returns True if the signature matches.\n\t * @throws Error if the public key is not the correct length.\n\t */\n\tpublic static verify(publicKey: Uint8Array, block: Uint8Array, signature: Uint8Array): boolean {\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(publicKey), publicKey);\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(block), block);\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(signature), signature);\n\n\t\tif (publicKey.length !== Ed25519.PUBLIC_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Ed25519.CLASS_NAME, \"publicKeyLength\", {\n\t\t\t\trequiredSize: Ed25519.PUBLIC_KEY_SIZE,\n\t\t\t\tactualSize: publicKey ? publicKey.length : 0\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\treturn ed25519.verify(signature, block, publicKey);\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Convert a private key in PKCS8 format.\n\t * @param privateKey The private key to convert.\n\t * @returns The private key in PKCS8 format.\n\t */\n\tpublic static async privateKeyToPkcs8(privateKey: Uint8Array): Promise<CryptoKey> {\n\t\tGuards.uint8Array(Ed25519.CLASS_NAME, nameof(privateKey), privateKey);\n\n\t\tif (privateKey.length !== Ed25519.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Ed25519.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Ed25519.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey.length\n\t\t\t});\n\t\t}\n\n\t\t// crypto.subtle.importKey does not support Ed25519 keys in raw format.\n\t\t// We need to convert the key to PKCS8 format before importing.\n\t\t// The PKCS8 format is the raw key prefixed with the ASN.1 sequence for an Ed25519 private key.\n\t\t// The ASN.1 sequence is 48 46 02 01 00 30 05 06 03 2b 65 70 04 20 04 20 (0x302e020100300506032b657004220420)\n\t\tconst pkcs8Prefix = new Uint8Array([48, 46, 2, 1, 0, 48, 5, 6, 3, 43, 101, 112, 4, 34, 4, 32]);\n\t\tconst fullKey = Uint8ArrayHelper.concat([pkcs8Prefix, privateKey]);\n\t\treturn crypto.subtle.importKey(\"pkcs8\", new Uint8Array(fullKey), \"Ed25519\", true, [\"sign\"]);\n\t}\n\n\t/**\n\t * Convert a crypto key to raw private key.\n\t * @param cryptoKey The crypto key to convert.\n\t * @returns The raw private key.\n\t */\n\tpublic static async pkcs8ToPrivateKey(cryptoKey: CryptoKey): Promise<Uint8Array> {\n\t\tGuards.defined(Ed25519.CLASS_NAME, nameof(cryptoKey), cryptoKey);\n\n\t\t// crypto.subtle.exportKey does not support Ed25519 keys in raw format.\n\t\t// so we export as PKCS8 and remove the ASN.1 sequence prefix.\n\t\tconst pkcs8Bytes = await crypto.subtle.exportKey(\"pkcs8\", cryptoKey);\n\n\t\treturn new Uint8Array(pkcs8Bytes.slice(16));\n\t}\n}\n"]}
|
|
@@ -35,7 +35,7 @@ export class Secp256k1 {
|
|
|
35
35
|
return secp256k1.getPublicKey(privateKey);
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Signs the block with the private key and returns a signature.
|
|
39
39
|
* @param privateKey The private key.
|
|
40
40
|
* @param block The block to sign.
|
|
41
41
|
* @returns The signature.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../src/curves/secp256k1.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,SAAS;IACrB;;OAEG;IACI,MAAM,CAAC,gBAAgB,GAAW,EAAE,CAAC;IAE5C;;OAEG;IACI,MAAM,CAAC,eAAe,GAAW,EAAE,CAAC;IAE3C;;OAEG;IACI,MAAM,CAAU,UAAU,eAA+B;IAEhE;;;;;OAKG;IACI,MAAM,CAAC,uBAAuB,CAAC,UAAsB;QAC3D,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QAExE,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,gBAAgB,EAAE,CAAC;YACtD,MAAM,IAAI,YAAY,CAAC,SAAS,CAAC,UAAU,EAAE,kBAAkB,EAAE;gBAChE,YAAY,EAAE,SAAS,CAAC,gBAAgB;gBACxC,UAAU,EAAE,UAAU,CAAC,MAAM;aAC7B,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,IAAI,CAAC,UAAsB,EAAE,KAAiB;QAC3D,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,gBAAsB,UAAU,CAAC,CAAC;QACxE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAE9D,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-Identifier: Apache-2.0.\nimport { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Implementation of secp256k1.\n */\nexport class Secp256k1 {\n\t/**\n\t * Private Key Size is the size, in bytes, of private keys as used in this package.\n\t */\n\tpublic static PRIVATE_KEY_SIZE: number = 32;\n\n\t/**\n\t * Public Key Size is the size, in bytes, of public keys as used in this package.\n\t */\n\tpublic static PUBLIC_KEY_SIZE: number = 33;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Secp256k1>();\n\n\t/**\n\t * Public returns the PublicKey corresponding to private.\n\t * @param privateKey The private key to get the corresponding public key.\n\t * @returns The public key.\n\t * @throws Error if the private key is not the correct length.\n\t */\n\tpublic static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(privateKey), privateKey);\n\n\t\tif (privateKey.length !== Secp256k1.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Secp256k1.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Secp256k1.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey.length\n\t\t\t});\n\t\t}\n\n\t\treturn secp256k1.getPublicKey(privateKey);\n\t}\n\n\t/**\n\t *
|
|
1
|
+
{"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../src/curves/secp256k1.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,SAAS;IACrB;;OAEG;IACI,MAAM,CAAC,gBAAgB,GAAW,EAAE,CAAC;IAE5C;;OAEG;IACI,MAAM,CAAC,eAAe,GAA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AAC,UAAU,eAAqB,SAAS,CAAC,CAAC;QACtE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC9D,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,eAAqB,SAAS,CAAC,CAAC;QAEtE,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,eAAe,EAAE,CAAC;YACpD,MAAM,IAAI,YAAY,CAAC,SAAS,CAAC,UAAU,EAAE,iBAAiB,EAAE;gBAC/D,YAAY,EAAE,SAAS,CAAC,eAAe;gBACvC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAC5C,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YACJ,OAAO,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1E,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { secp256k1 } from \"@noble/curves/secp256k1.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Implementation of secp256k1.\n */\nexport class Secp256k1 {\n\t/**\n\t * Private Key Size is the size, in bytes, of private keys as used in this package.\n\t */\n\tpublic static PRIVATE_KEY_SIZE: number = 32;\n\n\t/**\n\t * Public Key Size is the size, in bytes, of public keys as used in this package.\n\t */\n\tpublic static PUBLIC_KEY_SIZE: number = 33;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Secp256k1>();\n\n\t/**\n\t * Public returns the PublicKey corresponding to private.\n\t * @param privateKey The private key to get the corresponding public key.\n\t * @returns The public key.\n\t * @throws Error if the private key is not the correct length.\n\t */\n\tpublic static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(privateKey), privateKey);\n\n\t\tif (privateKey.length !== Secp256k1.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Secp256k1.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Secp256k1.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey.length\n\t\t\t});\n\t\t}\n\n\t\treturn secp256k1.getPublicKey(privateKey);\n\t}\n\n\t/**\n\t * Signs the block with the private key and returns a signature.\n\t * @param privateKey The private key.\n\t * @param block The block to sign.\n\t * @returns The signature.\n\t * @throws Error if the private key is not the correct length.\n\t */\n\tpublic static sign(privateKey: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(privateKey), privateKey);\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(block), block);\n\n\t\tif (privateKey.length !== Secp256k1.PRIVATE_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Secp256k1.CLASS_NAME, \"privateKeyLength\", {\n\t\t\t\trequiredSize: Secp256k1.PRIVATE_KEY_SIZE,\n\t\t\t\tactualSize: privateKey.length\n\t\t\t});\n\t\t}\n\n\t\tconst res = secp256k1.sign(block, privateKey, { prehash: false });\n\t\treturn res;\n\t}\n\n\t/**\n\t * Verify reports whether sig is a valid signature of block by publicKey.\n\t * @param publicKey The public key to verify the signature.\n\t * @param block The block for the signature.\n\t * @param signature The signature.\n\t * @returns True if the signature matches.\n\t * @throws Error if the public key is not the correct length.\n\t */\n\tpublic static verify(publicKey: Uint8Array, block: Uint8Array, signature: Uint8Array): boolean {\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(publicKey), publicKey);\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(block), block);\n\t\tGuards.uint8Array(Secp256k1.CLASS_NAME, nameof(signature), signature);\n\n\t\tif (publicKey.length !== Secp256k1.PUBLIC_KEY_SIZE) {\n\t\t\tthrow new GeneralError(Secp256k1.CLASS_NAME, \"publicKeyLength\", {\n\t\t\t\trequiredSize: Secp256k1.PUBLIC_KEY_SIZE,\n\t\t\t\tactualSize: publicKey ? publicKey.length : 0\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\treturn secp256k1.verify(signature, block, publicKey, { prehash: false });\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -20,7 +20,7 @@ export class Argon2id {
|
|
|
20
20
|
* @param options.p Number of parallel threads to use, default 1.
|
|
21
21
|
* @param options.dkLen The length of the derived key in bytes, default 32.
|
|
22
22
|
* @param options.maxmem The maximum amount of memory to use in bytes, default 2^30.
|
|
23
|
-
* @returns
|
|
23
|
+
* @returns A promise that resolves with the derived key bytes.
|
|
24
24
|
*/
|
|
25
25
|
static async hash(password, salt, options) {
|
|
26
26
|
Guards.uint8Array(Argon2id.CLASS_NAME, "password", password);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argon2id.js","sourceRoot":"","sources":["../../../src/hashes/argon2id.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,QAAQ;IACpB;;OAEG;IACI,MAAM,CAAU,UAAU,cAA8B;IAE/D;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CACvB,QAAoB,EACpB,IAAgB,EAChB,OAMC;QAED,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QACnE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,UAAgB,IAAI,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG;YACpB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;YAClB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;YAClB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;YAClB,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE;YAC3B,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE;SAClC,CAAC;QACF,OAAO,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { argon2idAsync } from \"@noble/hashes/argon2.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Implementation of the Argon2id password based key derivation function.\n */\nexport class Argon2id {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Argon2id>();\n\n\t/**\n\t * Derive a key from the parameters using Argon2id.\n\t * @param password The password to derive the key from.\n\t * @param salt The salt for the derivation.\n\t * @param options The options for the derivation.\n\t * @param options.t Number of iterations to perform, default 1.\n\t * @param options.m Amount of memory to use in kibibytes, default 8.\n\t * @param options.p Number of parallel threads to use, default 1.\n\t * @param options.dkLen The length of the derived key in bytes, default 32.\n\t * @param options.maxmem The maximum amount of memory to use in bytes, default 2^30.\n\t * @returns
|
|
1
|
+
{"version":3,"file":"argon2id.js","sourceRoot":"","sources":["../../../src/hashes/argon2id.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,QAAQ;IACpB;;OAEG;IACI,MAAM,CAAU,UAAU,cAA8B;IAE/D;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CACvB,QAAoB,EACpB,IAAgB,EAChB,OAMC;QAED,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,cAAoB,QAAQ,CAAC,CAAC;QACnE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,UAAgB,IAAI,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG;YACpB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;YAClB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;YAClB,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;YAClB,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,EAAE;YAC3B,MAAM,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,IAAI,EAAE;SAClC,CAAC;QACF,OAAO,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { argon2idAsync } from \"@noble/hashes/argon2.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Implementation of the Argon2id password based key derivation function.\n */\nexport class Argon2id {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Argon2id>();\n\n\t/**\n\t * Derive a key from the parameters using Argon2id.\n\t * @param password The password to derive the key from.\n\t * @param salt The salt for the derivation.\n\t * @param options The options for the derivation.\n\t * @param options.t Number of iterations to perform, default 1.\n\t * @param options.m Amount of memory to use in kibibytes, default 8.\n\t * @param options.p Number of parallel threads to use, default 1.\n\t * @param options.dkLen The length of the derived key in bytes, default 32.\n\t * @param options.maxmem The maximum amount of memory to use in bytes, default 2^30.\n\t * @returns A promise that resolves with the derived key bytes.\n\t */\n\tpublic static async hash(\n\t\tpassword: Uint8Array,\n\t\tsalt: Uint8Array,\n\t\toptions?: {\n\t\t\tt?: number;\n\t\t\tm?: number;\n\t\t\tp?: number;\n\t\t\tdkLen?: number;\n\t\t\tmaxmem?: number;\n\t\t}\n\t): Promise<Uint8Array> {\n\t\tGuards.uint8Array(Argon2id.CLASS_NAME, nameof(password), password);\n\t\tGuards.uint8Array(Argon2id.CLASS_NAME, nameof(salt), salt);\n\t\tconst localOptions = {\n\t\t\tt: options?.t ?? 1,\n\t\t\tm: options?.m ?? 8,\n\t\t\tp: options?.p ?? 1,\n\t\t\tdkLen: options?.dkLen ?? 32,\n\t\t\tmaxmem: options?.maxmem ?? 2 ** 30\n\t\t};\n\t\treturn argon2idAsync(password, salt, localOptions);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blake2b.js","sourceRoot":"","sources":["../../../src/hashes/blake2b.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,OAAO;IACnB;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAU,UAAU,aAA6B;IAE9D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;;OAIG;IACH,YAAY,YAAoB,EAAE,GAAgB;QACjD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;YAC/B,KAAK,EAAE,YAAY;YACnB,GAAG;SACH,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { blake2b } from \"@noble/hashes/blake2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with Blake2B Signature scheme.\n */\nexport class Blake2b {\n\t/**\n\t * Blake2b 160.\n\t */\n\tpublic static SIZE_160: number = 20;\n\n\t/**\n\t * Blake2b 256.\n\t */\n\tpublic static SIZE_256: number = 32;\n\n\t/**\n\t * Blake2b 512.\n\t */\n\tpublic static SIZE_512: number = 64;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Blake2b>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Blake2b.\n\t * @param outputLength The output length.\n\t * @param key Optional key for the hash.\n\t */\n\tconstructor(outputLength: number, key?: Uint8Array) {\n\t\tthis._instance = blake2b.create({\n\t\t\tdkLen: outputLength,\n\t\t\tkey\n\t\t});\n\t}\n\n\t/**\n\t * Perform Sum 160 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 160 of the block.\n\t */\n\tpublic static sum160(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake2b(Blake2b.SIZE_160, key).update(block).digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake2b(Blake2b.SIZE_256, key).update(block).digest();\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake2b(Blake2b.SIZE_512, key).update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Blake2b {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"blake2b.js","sourceRoot":"","sources":["../../../src/hashes/blake2b.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,OAAO;IACnB;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAU,UAAU,aAA6B;IAE9D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;;OAIG;IACH,YAAY,YAAoB,EAAE,GAAgB;QACjD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC;YAC/B,KAAK,EAAE,YAAY;YACnB,GAAG;SACH,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { blake2b } from \"@noble/hashes/blake2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with Blake2B Signature scheme.\n */\nexport class Blake2b {\n\t/**\n\t * Blake2b 160.\n\t */\n\tpublic static SIZE_160: number = 20;\n\n\t/**\n\t * Blake2b 256.\n\t */\n\tpublic static SIZE_256: number = 32;\n\n\t/**\n\t * Blake2b 512.\n\t */\n\tpublic static SIZE_512: number = 64;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Blake2b>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Blake2b.\n\t * @param outputLength The output length.\n\t * @param key Optional key for the hash.\n\t */\n\tconstructor(outputLength: number, key?: Uint8Array) {\n\t\tthis._instance = blake2b.create({\n\t\t\tdkLen: outputLength,\n\t\t\tkey\n\t\t});\n\t}\n\n\t/**\n\t * Perform Sum 160 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 160 of the block.\n\t */\n\tpublic static sum160(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake2b(Blake2b.SIZE_160, key).update(block).digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake2b(Blake2b.SIZE_256, key).update(block).digest();\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake2b(Blake2b.SIZE_512, key).update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Blake2b {\n\t\tGuards.uint8Array(Blake2b.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
package/dist/es/hashes/blake3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blake3.js","sourceRoot":"","sources":["../../../src/hashes/blake3.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,MAAM;IAClB;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAU,UAAU,YAA4B;IAE7D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;;OAIG;IACH,YAAY,YAAoB,EAAE,GAAgB;QACjD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;YAC9B,KAAK,EAAE,YAAY;YACnB,GAAG;SACH,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { blake3 } from \"@noble/hashes/blake3.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with Blake3 Signature scheme.\n */\nexport class Blake3 {\n\t/**\n\t * Blake3 256.\n\t */\n\tpublic static SIZE_256: number = 32;\n\n\t/**\n\t * Blake3 512.\n\t */\n\tpublic static SIZE_512: number = 64;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Blake3>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Blake3.\n\t * @param outputLength The output length.\n\t * @param key Optional key for the hash.\n\t */\n\tconstructor(outputLength: number, key?: Uint8Array) {\n\t\tthis._instance = blake3.create({\n\t\t\tdkLen: outputLength,\n\t\t\tkey\n\t\t});\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake3.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake3(Blake3.SIZE_256, key).update(block).digest();\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake3.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake3(Blake3.SIZE_512, key).update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Blake3 {\n\t\tGuards.uint8Array(Blake3.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"blake3.js","sourceRoot":"","sources":["../../../src/hashes/blake3.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,MAAM;IAClB;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,EAAE,CAAC;IAEpC;;OAEG;IACI,MAAM,CAAU,UAAU,YAA4B;IAE7D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;;OAIG;IACH,YAAY,YAAoB,EAAE,GAAgB;QACjD,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;YAC9B,KAAK,EAAE,YAAY;YACnB,GAAG;SACH,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB,EAAE,GAAgB;QACvD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAChE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { blake3 } from \"@noble/hashes/blake3.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with Blake3 Signature scheme.\n */\nexport class Blake3 {\n\t/**\n\t * Blake3 256.\n\t */\n\tpublic static SIZE_256: number = 32;\n\n\t/**\n\t * Blake3 512.\n\t */\n\tpublic static SIZE_512: number = 64;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Blake3>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Blake3.\n\t * @param outputLength The output length.\n\t * @param key Optional key for the hash.\n\t */\n\tconstructor(outputLength: number, key?: Uint8Array) {\n\t\tthis._instance = blake3.create({\n\t\t\tdkLen: outputLength,\n\t\t\tkey\n\t\t});\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake3.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake3(Blake3.SIZE_256, key).update(block).digest();\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @param key Optional key for the hash.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array, key?: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Blake3.CLASS_NAME, nameof(block), block);\n\t\treturn new Blake3(Blake3.SIZE_512, key).update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Blake3 {\n\t\tGuards.uint8Array(Blake3.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmacSha1.js","sourceRoot":"","sources":["../../../src/hashes/hmacSha1.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,QAAQ;IACpB;;OAEG;IACI,MAAM,CAAU,UAAU,cAA8B;IAE/D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;OAGG;IACH,YAAY,GAAe;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,GAAG,CAAC,GAAe,EAAE,KAAiB;QACnD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,SAAe,GAAG,CAAC,CAAC;QACzD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC7D,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha1 } from \"@noble/hashes/legacy.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with HmacSha1 scheme.\n */\nexport class HmacSha1 {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HmacSha1>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of HmacSha1.\n\t * @param key The key for the hmac.\n\t */\n\tconstructor(key: Uint8Array) {\n\t\tthis._instance = hmac.create(sha1, key);\n\t}\n\n\t/**\n\t * Perform Sum on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum of the block.\n\t */\n\tpublic static sum(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha1.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha1.CLASS_NAME, nameof(block), block);\n\t\treturn new HmacSha1(key).update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): HmacSha1 {\n\t\tGuards.uint8Array(HmacSha1.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"hmacSha1.js","sourceRoot":"","sources":["../../../src/hashes/hmacSha1.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,QAAQ;IACpB;;OAEG;IACI,MAAM,CAAU,UAAU,cAA8B;IAE/D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;OAGG;IACH,YAAY,GAAe;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,GAAG,CAAC,GAAe,EAAE,KAAiB;QACnD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,SAAe,GAAG,CAAC,CAAC;QACzD,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC7D,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC7D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha1 } from \"@noble/hashes/legacy.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with HmacSha1 scheme.\n */\nexport class HmacSha1 {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HmacSha1>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of HmacSha1.\n\t * @param key The key for the hmac.\n\t */\n\tconstructor(key: Uint8Array) {\n\t\tthis._instance = hmac.create(sha1, key);\n\t}\n\n\t/**\n\t * Perform Sum on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum of the block.\n\t */\n\tpublic static sum(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha1.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha1.CLASS_NAME, nameof(block), block);\n\t\treturn new HmacSha1(key).update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): HmacSha1 {\n\t\tGuards.uint8Array(HmacSha1.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmacSha256.js","sourceRoot":"","sources":["../../../src/hashes/hmacSha256.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,UAAU,gBAAgC;IAEjE;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;;OAIG;IACH,YAAY,GAAe,EAAE,OAAe,UAAU,CAAC,QAAQ;QAC9D,IAAI,IAAI,KAAK,UAAU,CAAC,QAAQ,IAAI,I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AAiB,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha224, sha256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with HmacSha256 scheme.\n */\nexport class HmacSha256 {\n\t/**\n\t * Sha256 256.\n\t */\n\tpublic static readonly SIZE_256: number = 256;\n\n\t/**\n\t * Sha256 224.\n\t */\n\tpublic static readonly SIZE_224: number = 224;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HmacSha256>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of HmacSha256.\n\t * @param key The key for the hmac.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(key: Uint8Array, bits: number = HmacSha256.SIZE_256) {\n\t\tif (bits !== HmacSha256.SIZE_224 && bits !== HmacSha256.SIZE_256) {\n\t\t\tthrow new GeneralError(HmacSha256.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tthis._instance = hmac.create(bits === HmacSha256.SIZE_256 ? sha256 : sha224, key);\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha256(key, HmacSha256.SIZE_224);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha256(key, HmacSha256.SIZE_256);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): HmacSha256 {\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"hmacSha256.js","sourceRoot":"","sources":["../../../src/hashes/hmacSha256.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,UAAU,gBAAgC;IAEjE;;;OAGG;IACH,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ACvB,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha224, sha256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with HmacSha256 scheme.\n */\nexport class HmacSha256 {\n\t/**\n\t * Sha256 256.\n\t */\n\tpublic static readonly SIZE_256: number = 256;\n\n\t/**\n\t * Sha256 224.\n\t */\n\tpublic static readonly SIZE_224: number = 224;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HmacSha256>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of HmacSha256.\n\t * @param key The key for the hmac.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(key: Uint8Array, bits: number = HmacSha256.SIZE_256) {\n\t\tif (bits !== HmacSha256.SIZE_224 && bits !== HmacSha256.SIZE_256) {\n\t\t\tthrow new GeneralError(HmacSha256.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tthis._instance = hmac.create(bits === HmacSha256.SIZE_256 ? sha256 : sha224, key);\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha256(key, HmacSha256.SIZE_224);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha256(key, HmacSha256.SIZE_256);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): HmacSha256 {\n\t\tGuards.uint8Array(HmacSha256.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmacSha512.js","sourceRoot":"","sources":["../../../src/hashes/hmacSha512.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,8BAA8B;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;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,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,GAAe,EAAE,KAAiB;QACtD,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,SAAe,GAAG,CAAC,CAAC;QAC3D,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1D,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/* eslint-disable camelcase */\n\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha384, sha512, sha512_224, sha512_256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with HmacSha512 scheme.\n */\nexport class HmacSha512 {\n\t/**\n\t * Sha512 224.\n\t */\n\tpublic static SIZE_224: number = 224;\n\n\t/**\n\t * Sha512 256.\n\t */\n\tpublic static SIZE_256: number = 256;\n\n\t/**\n\t * Sha512 384.\n\t */\n\tpublic static SIZE_384: number = 384;\n\n\t/**\n\t * Sha512 512.\n\t */\n\tpublic static SIZE_512: number = 512;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HmacSha512>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of HmacSha512.\n\t * @param key The key for the hmac.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(key: Uint8Array, bits: number = HmacSha512.SIZE_512) {\n\t\tif (\n\t\t\tbits !== HmacSha512.SIZE_224 &&\n\t\t\tbits !== HmacSha512.SIZE_256 &&\n\t\t\tbits !== HmacSha512.SIZE_384 &&\n\t\t\tbits !== HmacSha512.SIZE_512\n\t\t) {\n\t\t\tthrow new GeneralError(HmacSha512.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tif (bits === HmacSha512.SIZE_224) {\n\t\t\tthis._instance = hmac.create(sha512_224, key);\n\t\t} else if (bits === HmacSha512.SIZE_256) {\n\t\t\tthis._instance = hmac.create(sha512_256, key);\n\t\t} else if (bits === HmacSha512.SIZE_384) {\n\t\t\tthis._instance = hmac.create(sha384, key);\n\t\t} else {\n\t\t\tthis._instance = hmac.create(sha512, key);\n\t\t}\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_512);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 384 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 384 of the block.\n\t */\n\tpublic static sum384(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_384);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_256);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_224);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): HmacSha512 {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"hmacSha512.js","sourceRoot":"","sources":["../../../src/hashes/hmacSha512.ts"],"names":[],"mappings":"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G,CAAC,CAAC;QAC3D,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1D,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,GAAe,EAAE,KAAiB;QACtD,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,SAAe,GAAG,CAAC,CAAC;QAC3D,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1D,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC/D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/* eslint-disable camelcase */\n\nimport { hmac } from \"@noble/hashes/hmac.js\";\nimport { sha384, sha512, sha512_224, sha512_256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Class to help with HmacSha512 scheme.\n */\nexport class HmacSha512 {\n\t/**\n\t * Sha512 224.\n\t */\n\tpublic static SIZE_224: number = 224;\n\n\t/**\n\t * Sha512 256.\n\t */\n\tpublic static SIZE_256: number = 256;\n\n\t/**\n\t * Sha512 384.\n\t */\n\tpublic static SIZE_384: number = 384;\n\n\t/**\n\t * Sha512 512.\n\t */\n\tpublic static SIZE_512: number = 512;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HmacSha512>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of HmacSha512.\n\t * @param key The key for the hmac.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(key: Uint8Array, bits: number = HmacSha512.SIZE_512) {\n\t\tif (\n\t\t\tbits !== HmacSha512.SIZE_224 &&\n\t\t\tbits !== HmacSha512.SIZE_256 &&\n\t\t\tbits !== HmacSha512.SIZE_384 &&\n\t\t\tbits !== HmacSha512.SIZE_512\n\t\t) {\n\t\t\tthrow new GeneralError(HmacSha512.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tif (bits === HmacSha512.SIZE_224) {\n\t\t\tthis._instance = hmac.create(sha512_224, key);\n\t\t} else if (bits === HmacSha512.SIZE_256) {\n\t\t\tthis._instance = hmac.create(sha512_256, key);\n\t\t} else if (bits === HmacSha512.SIZE_384) {\n\t\t\tthis._instance = hmac.create(sha384, key);\n\t\t} else {\n\t\t\tthis._instance = hmac.create(sha512, key);\n\t\t}\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_512);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 384 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 384 of the block.\n\t */\n\tpublic static sum384(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_384);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_256);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param key The key for the hmac.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(key: Uint8Array, block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(key), key);\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tconst instance = new HmacSha512(key, HmacSha512.SIZE_224);\n\t\tinstance.update(block);\n\t\treturn instance.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): HmacSha512 {\n\t\tGuards.uint8Array(HmacSha512.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
package/dist/es/hashes/sha1.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha1.js","sourceRoot":"","sources":["../../../src/hashes/sha1.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,UAAU,UAA0B;IAE3D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;OAEG;IACH;QACC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,GAAG,CAAC,KAAiB;QAClC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QACzD,OAAO,IAAI,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { sha1 } from \"@noble/hashes/legacy.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-1 hash on the block.\n */\nexport class Sha1 {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha1>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha1.\n\t */\n\tconstructor() {\n\t\tthis._instance = sha1.create();\n\t}\n\n\t/**\n\t * Perform Sum on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum of the block.\n\t */\n\tpublic static sum(block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Sha1.CLASS_NAME, nameof(block), block);\n\t\treturn new Sha1().update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha1 {\n\t\tGuards.uint8Array(Sha1.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"sha1.js","sourceRoot":"","sources":["../../../src/hashes/sha1.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,UAAU,UAA0B;IAE3D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;OAEG;IACH;QACC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,GAAG,CAAC,KAAiB;QAClC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QACzD,OAAO,IAAI,IAAI,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { sha1 } from \"@noble/hashes/legacy.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-1 hash on the block.\n */\nexport class Sha1 {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha1>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha1.\n\t */\n\tconstructor() {\n\t\tthis._instance = sha1.create();\n\t}\n\n\t/**\n\t * Perform Sum on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum of the block.\n\t */\n\tpublic static sum(block: Uint8Array): Uint8Array {\n\t\tGuards.uint8Array(Sha1.CLASS_NAME, nameof(block), block);\n\t\treturn new Sha1().update(block).digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha1 {\n\t\tGuards.uint8Array(Sha1.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
package/dist/es/hashes/sha256.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/hashes/sha256.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,MAAM;IAClB;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,UAAU,YAA4B;IAE7D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;OAGG;IACH,YAAY,OAAe,MAAM,CAAC,QAAQ;QACzC,IAAI,IAAI,KAAK,MAAM,CAAC,QAAQ,IAAI,IAAI,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC1D,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAC/E,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { sha224, sha256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-256 hash on the block.\n */\nexport class Sha256 {\n\t/**\n\t * Sha256 256.\n\t */\n\tpublic static readonly SIZE_256: number = 256;\n\n\t/**\n\t * Sha256 224.\n\t */\n\tpublic static readonly SIZE_224: number = 224;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha256>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha256.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(bits: number = Sha256.SIZE_256) {\n\t\tif (bits !== Sha256.SIZE_224 && bits !== Sha256.SIZE_256) {\n\t\t\tthrow new GeneralError(Sha256.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tthis._instance = bits === Sha256.SIZE_256 ? sha256.create() : sha224.create();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha256(Sha256.SIZE_256);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha256(Sha256.SIZE_224);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha256 {\n\t\tGuards.uint8Array(Sha256.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../../src/hashes/sha256.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,MAAM;IAClB;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IAC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OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { sha224, sha256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-256 hash on the block.\n */\nexport class Sha256 {\n\t/**\n\t * Sha256 256.\n\t */\n\tpublic static readonly SIZE_256: number = 256;\n\n\t/**\n\t * Sha256 224.\n\t */\n\tpublic static readonly SIZE_224: number = 224;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha256>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha256.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(bits: number = Sha256.SIZE_256) {\n\t\tif (bits !== Sha256.SIZE_224 && bits !== Sha256.SIZE_256) {\n\t\t\tthrow new GeneralError(Sha256.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tthis._instance = bits === Sha256.SIZE_256 ? sha256.create() : sha224.create();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha256(Sha256.SIZE_256);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha256(Sha256.SIZE_224);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha256 {\n\t\tGuards.uint8Array(Sha256.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
package/dist/es/hashes/sha3.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha3.js","sourceRoot":"","sources":["../../../src/hashes/sha3.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,qCAAqC;AACrC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,UAAU,UAA0B;IAE3D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;OAGG;IACH,YAAY,OAAe,IAAI,CAAC,QAAQ;QACvC,IACC,IAAI,KAAK,IAAI,CAAC,QAAQ;YACtB,IAAI,KAAK,IAAI,CAAC,QAAQ;YACtB,IAAI,KAAK,IAAI,CAAC,QAAQ;YACtB,IAAI,KAAK,IAAI,CAAC,QAAQ,EACrB,CAAC;YACF,MAAM,IAAI,Y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C,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n// eslint-disable-next-line camelcase\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-3 hash on the block.\n */\nexport class Sha3 {\n\t/**\n\t * Sha3 224.\n\t */\n\tpublic static readonly SIZE_224: number = 224;\n\n\t/**\n\t * Sha3 256.\n\t */\n\tpublic static readonly SIZE_256: number = 256;\n\n\t/**\n\t * Sha3 384.\n\t */\n\tpublic static readonly SIZE_384: number = 384;\n\n\t/**\n\t * Sha3 512.\n\t */\n\tpublic static readonly SIZE_512: number = 512;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha3>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha3.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(bits: number = Sha3.SIZE_256) {\n\t\tif (\n\t\t\tbits !== Sha3.SIZE_224 &&\n\t\t\tbits !== Sha3.SIZE_256 &&\n\t\t\tbits !== Sha3.SIZE_384 &&\n\t\t\tbits !== Sha3.SIZE_512\n\t\t) {\n\t\t\tthrow new GeneralError(Sha3.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tif (bits === Sha3.SIZE_224) {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_224.create();\n\t\t} else if (bits === Sha3.SIZE_256) {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_256.create();\n\t\t} else if (bits === Sha3.SIZE_384) {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_384.create();\n\t\t} else {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_512.create();\n\t\t}\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_256);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_224);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 384 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 384 of the block.\n\t */\n\tpublic static sum384(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_384);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_512);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha3 {\n\t\tGuards.uint8Array(Sha3.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"sha3.js","sourceRoot":"","sources":["../../../src/hashes/sha3.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,qCAAqC;AACrC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,IAAI;IAChB;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,QAAQ,GAAW,GAAG,CAAC;IAE9C;;OAEG;IACI,MAAM,CAAU,UAAU,UAA0B;IAE3D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;OAGG;IACH,YAAY,OAAe,IAAI,CAAC,QAAQ;QACvC,IACC,IAAI,KAAK,IAAI,CAAC,QAAQ;YACtB,IAAI,KAAK,IAAI,CAAC,QAAQ;YACtB,IAAI,KAAK,IAAI,CAAC,QA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,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n// eslint-disable-next-line camelcase\nimport { sha3_224, sha3_256, sha3_384, sha3_512 } from \"@noble/hashes/sha3.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-3 hash on the block.\n */\nexport class Sha3 {\n\t/**\n\t * Sha3 224.\n\t */\n\tpublic static readonly SIZE_224: number = 224;\n\n\t/**\n\t * Sha3 256.\n\t */\n\tpublic static readonly SIZE_256: number = 256;\n\n\t/**\n\t * Sha3 384.\n\t */\n\tpublic static readonly SIZE_384: number = 384;\n\n\t/**\n\t * Sha3 512.\n\t */\n\tpublic static readonly SIZE_512: number = 512;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha3>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha3.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(bits: number = Sha3.SIZE_256) {\n\t\tif (\n\t\t\tbits !== Sha3.SIZE_224 &&\n\t\t\tbits !== Sha3.SIZE_256 &&\n\t\t\tbits !== Sha3.SIZE_384 &&\n\t\t\tbits !== Sha3.SIZE_512\n\t\t) {\n\t\t\tthrow new GeneralError(Sha3.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tif (bits === Sha3.SIZE_224) {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_224.create();\n\t\t} else if (bits === Sha3.SIZE_256) {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_256.create();\n\t\t} else if (bits === Sha3.SIZE_384) {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_384.create();\n\t\t} else {\n\t\t\t// eslint-disable-next-line camelcase\n\t\t\tthis._instance = sha3_512.create();\n\t\t}\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_256);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_224);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 384 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 384 of the block.\n\t */\n\tpublic static sum384(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_384);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha3(Sha3.SIZE_512);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha3 {\n\t\tGuards.uint8Array(Sha3.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
package/dist/es/hashes/sha512.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sha512.js","sourceRoot":"","sources":["../../../src/hashes/sha512.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,8BAA8B;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,MAAM;IAClB;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAU,UAAU,YAA4B;IAE7D;;;OAGG;IACH,8DAA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C;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/* eslint-disable camelcase */\nimport { sha384, sha512, sha512_224, sha512_256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-512 hash on the block.\n */\nexport class Sha512 {\n\t/**\n\t * Sha512 224.\n\t */\n\tpublic static SIZE_224: number = 224;\n\n\t/**\n\t * Sha512 256.\n\t */\n\tpublic static SIZE_256: number = 256;\n\n\t/**\n\t * Sha512 384.\n\t */\n\tpublic static SIZE_384: number = 384;\n\n\t/**\n\t * Sha512 512.\n\t */\n\tpublic static SIZE_512: number = 512;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha512>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha512.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(bits: number = Sha512.SIZE_512) {\n\t\tif (\n\t\t\tbits !== Sha512.SIZE_224 &&\n\t\t\tbits !== Sha512.SIZE_256 &&\n\t\t\tbits !== Sha512.SIZE_384 &&\n\t\t\tbits !== Sha512.SIZE_512\n\t\t) {\n\t\t\tthrow new GeneralError(Sha512.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tif (bits === Sha512.SIZE_224) {\n\t\t\tthis._instance = sha512_224.create();\n\t\t} else if (bits === Sha512.SIZE_256) {\n\t\t\tthis._instance = sha512_256.create();\n\t\t} else if (bits === Sha512.SIZE_384) {\n\t\t\tthis._instance = sha384.create();\n\t\t} else {\n\t\t\tthis._instance = sha512.create();\n\t\t}\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_512);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 384 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 384 of the block.\n\t */\n\tpublic static sum384(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_384);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_256);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_224);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha512 {\n\t\tGuards.uint8Array(Sha512.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"sha512.js","sourceRoot":"","sources":["../../../src/hashes/sha512.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,8BAA8B;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtD;;GAEG;AACH,MAAM,OAAO,MAAM;IAClB;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAC,QAAQ,GAAW,GAAG,CAAC;IAErC;;OAEG;IACI,MAAM,CAAU,UAAU,YAA4B;IAE7D;;;OAGG;IACH,8DAA8D;IAC7C,SAAS,CAAY;IAEtC;;;OAGG;IACH,YAAY,OAAe,MAAM,CAAC,QAAQ;QACzC,IACC,IAAI,KAAK,MAAM,CAAC,QAAQ;YACxB,IAAI,KAAK,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I,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,KAAiB;QACrC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAiB;QAC9B,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,WAAiB,KAAK,CAAC,CAAC;QAC3D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,MAAM;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/* eslint-disable camelcase */\nimport { sha384, sha512, sha512_224, sha512_256 } from \"@noble/hashes/sha2.js\";\nimport type { Hash } from \"@noble/hashes/utils.js\";\nimport { GeneralError, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Perform a SHA-512 hash on the block.\n */\nexport class Sha512 {\n\t/**\n\t * Sha512 224.\n\t */\n\tpublic static SIZE_224: number = 224;\n\n\t/**\n\t * Sha512 256.\n\t */\n\tpublic static SIZE_256: number = 256;\n\n\t/**\n\t * Sha512 384.\n\t */\n\tpublic static SIZE_384: number = 384;\n\n\t/**\n\t * Sha512 512.\n\t */\n\tpublic static SIZE_512: number = 512;\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Sha512>();\n\n\t/**\n\t * The instance of the hash.\n\t * @internal\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprivate readonly _instance: Hash<any>;\n\n\t/**\n\t * Create a new instance of Sha512.\n\t * @param bits The number of bits.\n\t */\n\tconstructor(bits: number = Sha512.SIZE_512) {\n\t\tif (\n\t\t\tbits !== Sha512.SIZE_224 &&\n\t\t\tbits !== Sha512.SIZE_256 &&\n\t\t\tbits !== Sha512.SIZE_384 &&\n\t\t\tbits !== Sha512.SIZE_512\n\t\t) {\n\t\t\tthrow new GeneralError(Sha512.CLASS_NAME, \"bitSize\", { bitSize: bits });\n\t\t}\n\n\t\tif (bits === Sha512.SIZE_224) {\n\t\t\tthis._instance = sha512_224.create();\n\t\t} else if (bits === Sha512.SIZE_256) {\n\t\t\tthis._instance = sha512_256.create();\n\t\t} else if (bits === Sha512.SIZE_384) {\n\t\t\tthis._instance = sha384.create();\n\t\t} else {\n\t\t\tthis._instance = sha512.create();\n\t\t}\n\t}\n\n\t/**\n\t * Perform Sum 512 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 512 of the block.\n\t */\n\tpublic static sum512(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_512);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 384 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 384 of the block.\n\t */\n\tpublic static sum384(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_384);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 256 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 256 of the block.\n\t */\n\tpublic static sum256(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_256);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Perform Sum 224 on the block.\n\t * @param block The block to operate on.\n\t * @returns The sum 224 of the block.\n\t */\n\tpublic static sum224(block: Uint8Array): Uint8Array {\n\t\tconst b2b = new Sha512(Sha512.SIZE_224);\n\t\tb2b.update(block);\n\t\treturn b2b.digest();\n\t}\n\n\t/**\n\t * Update the hash with the block.\n\t * @param block The block to update the hash with.\n\t * @returns The instance for chaining.\n\t */\n\tpublic update(block: Uint8Array): Sha512 {\n\t\tGuards.uint8Array(Sha512.CLASS_NAME, nameof(block), block);\n\t\tthis._instance.update(block);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Get the digest for the hash.\n\t * @returns The computed hash as bytes.\n\t */\n\tpublic digest(): Uint8Array {\n\t\treturn this._instance.digest();\n\t}\n}\n"]}
|
|
@@ -47,7 +47,7 @@ export class IntegrityHelper {
|
|
|
47
47
|
* Generate a hash for the given content using the specified type.
|
|
48
48
|
* @param type The hash algorithm to use, either "sha256", "sha384" or "sha512".
|
|
49
49
|
* @param content The content to hash as a Uint8Array.
|
|
50
|
-
* @returns The
|
|
50
|
+
* @returns The base64-encoded hash of the content.
|
|
51
51
|
* @internal
|
|
52
52
|
*/
|
|
53
53
|
static generateHash(type, content) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrityHelper.js","sourceRoot":"","sources":["../../../src/helpers/integrityHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAwB,EAAE,OAAmB;QACnE,MAAM,CAA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,kBAAkB,CAAC,MAAM,EAAE,CAAC;YAC/C,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACP,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Sha256 } from \"../hashes/sha256.js\";\nimport { Sha512 } from \"../hashes/sha512.js\";\nimport { IntegrityAlgorithm } from \"../models/integrityAlgorithm.js\";\n\n/**\n * Helper class for creating integrity signatures.\n * @see https://www.w3.org/TR/SRI/\n */\nexport class IntegrityHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IntegrityHelper>();\n\n\t/**\n\t * Generate an integrity signature for the given content using the specified hash algorithm.\n\t * @param type The hash algorithm to use, either \"sha256\", \"sha384\" or \"sha512\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns The integrity signature in the format \"type-base64hash\".\n\t */\n\tpublic static generate(type: IntegrityAlgorithm, content: Uint8Array): string {\n\t\tGuards.arrayOneOf(\n\t\t\tIntegrityHelper.CLASS_NAME,\n\t\t\tnameof(type),\n\t\t\ttype,\n\t\t\tObject.values(IntegrityAlgorithm)\n\t\t);\n\t\tGuards.uint8Array(IntegrityHelper.CLASS_NAME, nameof(content), content);\n\n\t\treturn `${type}-${IntegrityHelper.generateHash(type, content)}`;\n\t}\n\n\t/**\n\t * Verify an integrity signature for the given content.\n\t * @param integrity The integrity signature in the format \"type-base64hash\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns True if the integrity signature matches the content.\n\t * @throws If the integrity signature is invalid.\n\t */\n\tpublic static verify(integrity: string, content: Uint8Array): boolean {\n\t\tGuards.stringValue(IntegrityHelper.CLASS_NAME, nameof(integrity), integrity);\n\t\tGuards.uint8Array(IntegrityHelper.CLASS_NAME, nameof(content), content);\n\n\t\tconst parts = integrity.split(\"-\");\n\t\tif (parts.length !== 2) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [type, hash] = parts;\n\n\t\tGuards.arrayOneOf(\n\t\t\tIntegrityHelper.CLASS_NAME,\n\t\t\tnameof(type),\n\t\t\ttype,\n\t\t\tObject.values(IntegrityAlgorithm)\n\t\t);\n\t\tGuards.stringValue(IntegrityHelper.CLASS_NAME, nameof(hash), hash);\n\n\t\treturn IntegrityHelper.generateHash(type as IntegrityAlgorithm, content) === hash;\n\t}\n\n\t/**\n\t * Generate a hash for the given content using the specified type.\n\t * @param type The hash algorithm to use, either \"sha256\", \"sha384\" or \"sha512\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns The
|
|
1
|
+
{"version":3,"file":"integrityHelper.js","sourceRoot":"","sources":["../../../src/helpers/integrityHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC3B;;OAEG;IACI,MAAM,CAAU,UAAU,qBAAqC;IAEtE;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAwB,EAAE,OAAmB;QACnE,MAAM,CAAC,UAAU,CAChB,eAAe,CAAC,UAAU,UAE1B,IAAI,EACJ,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CACjC,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,UAAU,aAAmB,OAAO,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AAO,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { Sha256 } from \"../hashes/sha256.js\";\nimport { Sha512 } from \"../hashes/sha512.js\";\nimport { IntegrityAlgorithm } from \"../models/integrityAlgorithm.js\";\n\n/**\n * Helper class for creating integrity signatures.\n * @see https://www.w3.org/TR/SRI/\n */\nexport class IntegrityHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<IntegrityHelper>();\n\n\t/**\n\t * Generate an integrity signature for the given content using the specified hash algorithm.\n\t * @param type The hash algorithm to use, either \"sha256\", \"sha384\" or \"sha512\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns The integrity signature in the format \"type-base64hash\".\n\t */\n\tpublic static generate(type: IntegrityAlgorithm, content: Uint8Array): string {\n\t\tGuards.arrayOneOf(\n\t\t\tIntegrityHelper.CLASS_NAME,\n\t\t\tnameof(type),\n\t\t\ttype,\n\t\t\tObject.values(IntegrityAlgorithm)\n\t\t);\n\t\tGuards.uint8Array(IntegrityHelper.CLASS_NAME, nameof(content), content);\n\n\t\treturn `${type}-${IntegrityHelper.generateHash(type, content)}`;\n\t}\n\n\t/**\n\t * Verify an integrity signature for the given content.\n\t * @param integrity The integrity signature in the format \"type-base64hash\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns True if the integrity signature matches the content.\n\t * @throws If the integrity signature is invalid.\n\t */\n\tpublic static verify(integrity: string, content: Uint8Array): boolean {\n\t\tGuards.stringValue(IntegrityHelper.CLASS_NAME, nameof(integrity), integrity);\n\t\tGuards.uint8Array(IntegrityHelper.CLASS_NAME, nameof(content), content);\n\n\t\tconst parts = integrity.split(\"-\");\n\t\tif (parts.length !== 2) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst [type, hash] = parts;\n\n\t\tGuards.arrayOneOf(\n\t\t\tIntegrityHelper.CLASS_NAME,\n\t\t\tnameof(type),\n\t\t\ttype,\n\t\t\tObject.values(IntegrityAlgorithm)\n\t\t);\n\t\tGuards.stringValue(IntegrityHelper.CLASS_NAME, nameof(hash), hash);\n\n\t\treturn IntegrityHelper.generateHash(type as IntegrityAlgorithm, content) === hash;\n\t}\n\n\t/**\n\t * Generate a hash for the given content using the specified type.\n\t * @param type The hash algorithm to use, either \"sha256\", \"sha384\" or \"sha512\".\n\t * @param content The content to hash as a Uint8Array.\n\t * @returns The base64-encoded hash of the content.\n\t * @internal\n\t */\n\tprivate static generateHash(type: IntegrityAlgorithm, content: Uint8Array): string {\n\t\tlet hash;\n\t\tif (type === IntegrityAlgorithm.Sha384) {\n\t\t\thash = Sha512.sum384(content);\n\t\t} else if (type === IntegrityAlgorithm.Sha512) {\n\t\t\thash = Sha512.sum512(content);\n\t\t} else {\n\t\t\thash = Sha256.sum256(content);\n\t\t}\n\t\treturn Converter.bytesToBase64(hash);\n\t}\n}\n"]}
|
package/dist/es/keys/slip0010.js
CHANGED
|
@@ -64,7 +64,7 @@ export class Slip0010 {
|
|
|
64
64
|
* Get the public key from the private key.
|
|
65
65
|
* @param privateKey The private key.
|
|
66
66
|
* @param keyType The key type.
|
|
67
|
-
* @param withZeroByte Include a zero
|
|
67
|
+
* @param withZeroByte Include a zero byte prefix.
|
|
68
68
|
* @returns The public key.
|
|
69
69
|
*/
|
|
70
70
|
static getPublicKey(privateKey, keyType = KeyType.Ed25519, withZeroByte = true) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slip0010.js","sourceRoot":"","sources":["../../../src/keys/slip0010.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,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YAAY,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YACjD,OAAO;gBACN,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,SAAS,EAAE,UAAU,CAAC,SAAS;aAC/B,CAAC;QACH,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjD,OAAO;YACN,UAAU,EAAE,UAAU,CAAC,UAAU,IAAI,IAAI,UAAU,EAAE;YACrD,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,IAAI,UAAU,EAAE;SACnD,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,YAAY,CACzB,UAAsB,EACtB,UAAmB,OAAO,CAAC,OAAO,EAClC,eAAwB,IAAI;QAE5B,MAAM,MAAM,GACX,OAAO,KAAK,OAAO,CAAC,OAAO;YAC1B,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,UAAU,CAAC;YAC7C,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACX,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACnB,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { HDKey as HDKeySecp256k1 } from \"@scure/bip32\";\nimport { Converter, GeneralError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HDKey as HDKeyEd25519 } from \"micro-key-producer/slip10.js\";\nimport type { Bip32Path } from \"./bip32Path.js\";\nimport { Ed25519 } from \"../curves/ed25519.js\";\nimport { Secp256k1 } from \"../curves/secp256k1.js\";\nimport { KeyType } from \"../models/keyType.js\";\n\n/**\n * Class to help with slip0010 key derivation\n * https://github.com/satoshilabs/slips/blob/master/slip-0010.md.\n */\nexport class Slip0010 {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Slip0010>();\n\n\t/**\n\t * Get the master key from the seed.\n\t * @param seed The seed to generate the master key from.\n\t * @param keyType The key type.\n\t * @returns The key and chain code.\n\t * @throws If the seed is invalid.\n\t */\n\tpublic static getMasterKeyFromSeed(\n\t\tseed: Uint8Array,\n\t\tkeyType: KeyType = KeyType.Ed25519\n\t): {\n\t\tprivateKey: Uint8Array;\n\t\tchainCode: Uint8Array;\n\t} {\n\t\ttry {\n\t\t\tconst masterKey =\n\t\t\t\tkeyType === KeyType.Ed25519\n\t\t\t\t\t? HDKeyEd25519.fromMasterSeed(seed)\n\t\t\t\t\t: HDKeySecp256k1.fromMasterSeed(seed);\n\n\t\t\treturn {\n\t\t\t\tprivateKey: masterKey.privateKey ?? new Uint8Array(),\n\t\t\t\tchainCode: masterKey.chainCode ?? new Uint8Array()\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tSlip0010.CLASS_NAME,\n\t\t\t\t\"invalidSeed\",\n\t\t\t\t{ seed: Converter.bytesToUtf8(seed) },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Derive a key from the path.\n\t * @param seed The seed.\n\t * @param path The path.\n\t * @param keyType The key type.\n\t * @returns The key and chain code.\n\t */\n\tpublic static derivePath(\n\t\tseed: Uint8Array,\n\t\tpath: Bip32Path,\n\t\tkeyType: KeyType = KeyType.Ed25519\n\t): {\n\t\tprivateKey: Uint8Array;\n\t\tchainCode: Uint8Array;\n\t} {\n\t\tconst keyOpts = Slip0010.getMasterKeyFromSeed(seed, keyType);\n\n\t\tif (keyType === KeyType.Ed25519) {\n\t\t\tconst hdKey = new HDKeyEd25519(keyOpts);\n\t\t\tconst derivedKey = hdKey.derive(path.toString());\n\t\t\treturn {\n\t\t\t\tprivateKey: derivedKey.privateKey,\n\t\t\t\tchainCode: derivedKey.chainCode\n\t\t\t};\n\t\t}\n\t\tconst hdKey = new HDKeySecp256k1(keyOpts);\n\t\tconst derivedKey = hdKey.derive(path.toString());\n\t\treturn {\n\t\t\tprivateKey: derivedKey.privateKey ?? new Uint8Array(),\n\t\t\tchainCode: derivedKey.chainCode ?? new Uint8Array()\n\t\t};\n\t}\n\n\t/**\n\t * Get the public key from the private key.\n\t * @param privateKey The private key.\n\t * @param keyType The key type.\n\t * @param withZeroByte Include a zero
|
|
1
|
+
{"version":3,"file":"slip0010.js","sourceRoot":"","sources":["../../../src/keys/slip0010.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C;;;GAGG;AACH,MAAM,OAAO,QAAQ;IACpB;;OAEG;IACI,MAAM,CAAU,UAAU,cAA8B;IAE/D;;;;;;OAMG;IACI,MAAM,CAAC,oBAAoB,CACjC,IAAgB,EAChB,UAAmB,OAAO,CAAC,OAAO;QAKlC,IAAI,CAAC;YACJ,MAAM,SAAS,GACd,OAAO,KAAK,OAAO,CA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IAAI,UAAU,EAAE;SACnD,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,YAAY,CACzB,UAAsB,EACtB,UAAmB,OAAO,CAAC,OAAO,EAClC,eAAwB,IAAI;QAE5B,MAAM,MAAM,GACX,OAAO,KAAK,OAAO,CAAC,OAAO;YAC1B,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,UAAU,CAAC;YAC7C,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;QAClD,IAAI,YAAY,EAAE,CAAC;YAClB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;YAC9C,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACX,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACnB,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { HDKey as HDKeySecp256k1 } from \"@scure/bip32\";\nimport { Converter, GeneralError } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HDKey as HDKeyEd25519 } from \"micro-key-producer/slip10.js\";\nimport type { Bip32Path } from \"./bip32Path.js\";\nimport { Ed25519 } from \"../curves/ed25519.js\";\nimport { Secp256k1 } from \"../curves/secp256k1.js\";\nimport { KeyType } from \"../models/keyType.js\";\n\n/**\n * Class to help with slip0010 key derivation\n * https://github.com/satoshilabs/slips/blob/master/slip-0010.md.\n */\nexport class Slip0010 {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Slip0010>();\n\n\t/**\n\t * Get the master key from the seed.\n\t * @param seed The seed to generate the master key from.\n\t * @param keyType The key type.\n\t * @returns The key and chain code.\n\t * @throws If the seed is invalid.\n\t */\n\tpublic static getMasterKeyFromSeed(\n\t\tseed: Uint8Array,\n\t\tkeyType: KeyType = KeyType.Ed25519\n\t): {\n\t\tprivateKey: Uint8Array;\n\t\tchainCode: Uint8Array;\n\t} {\n\t\ttry {\n\t\t\tconst masterKey =\n\t\t\t\tkeyType === KeyType.Ed25519\n\t\t\t\t\t? HDKeyEd25519.fromMasterSeed(seed)\n\t\t\t\t\t: HDKeySecp256k1.fromMasterSeed(seed);\n\n\t\t\treturn {\n\t\t\t\tprivateKey: masterKey.privateKey ?? new Uint8Array(),\n\t\t\t\tchainCode: masterKey.chainCode ?? new Uint8Array()\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tthrow new GeneralError(\n\t\t\t\tSlip0010.CLASS_NAME,\n\t\t\t\t\"invalidSeed\",\n\t\t\t\t{ seed: Converter.bytesToUtf8(seed) },\n\t\t\t\terror\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Derive a key from the path.\n\t * @param seed The seed.\n\t * @param path The path.\n\t * @param keyType The key type.\n\t * @returns The key and chain code.\n\t */\n\tpublic static derivePath(\n\t\tseed: Uint8Array,\n\t\tpath: Bip32Path,\n\t\tkeyType: KeyType = KeyType.Ed25519\n\t): {\n\t\tprivateKey: Uint8Array;\n\t\tchainCode: Uint8Array;\n\t} {\n\t\tconst keyOpts = Slip0010.getMasterKeyFromSeed(seed, keyType);\n\n\t\tif (keyType === KeyType.Ed25519) {\n\t\t\tconst hdKey = new HDKeyEd25519(keyOpts);\n\t\t\tconst derivedKey = hdKey.derive(path.toString());\n\t\t\treturn {\n\t\t\t\tprivateKey: derivedKey.privateKey,\n\t\t\t\tchainCode: derivedKey.chainCode\n\t\t\t};\n\t\t}\n\t\tconst hdKey = new HDKeySecp256k1(keyOpts);\n\t\tconst derivedKey = hdKey.derive(path.toString());\n\t\treturn {\n\t\t\tprivateKey: derivedKey.privateKey ?? new Uint8Array(),\n\t\t\tchainCode: derivedKey.chainCode ?? new Uint8Array()\n\t\t};\n\t}\n\n\t/**\n\t * Get the public key from the private key.\n\t * @param privateKey The private key.\n\t * @param keyType The key type.\n\t * @param withZeroByte Include a zero byte prefix.\n\t * @returns The public key.\n\t */\n\tpublic static getPublicKey(\n\t\tprivateKey: Uint8Array,\n\t\tkeyType: KeyType = KeyType.Ed25519,\n\t\twithZeroByte: boolean = true\n\t): Uint8Array {\n\t\tconst signPk =\n\t\t\tkeyType === KeyType.Ed25519\n\t\t\t\t? Ed25519.publicKeyFromPrivateKey(privateKey)\n\t\t\t\t: Secp256k1.publicKeyFromPrivateKey(privateKey);\n\t\tif (withZeroByte) {\n\t\t\tconst arr = new Uint8Array(1 + signPk.length);\n\t\t\tarr[0] = 0;\n\t\t\tarr.set(signPk, 1);\n\t\t\treturn arr;\n\t\t}\n\t\treturn signPk;\n\t}\n}\n"]}
|
package/dist/es/otp/totp.js
CHANGED
|
@@ -25,7 +25,7 @@ export class Totp {
|
|
|
25
25
|
* @param window The allowable margin for the counter.
|
|
26
26
|
* @param interval The time step of the counter.
|
|
27
27
|
* @param timestamp The timestamp now.
|
|
28
|
-
* @returns
|
|
28
|
+
* @returns The counter delta on success, or undefined if no matching code is found within the window.
|
|
29
29
|
*/
|
|
30
30
|
static verify(token, key, window = 2, interval = 30, timestamp = Date.now()) {
|
|
31
31
|
for (let i = -window; i < window; i++) {
|
package/dist/es/otp/totp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"totp.js","sourceRoot":"","sources":["../../../src/otp/totp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAEjD;;;GAGG;AACH,MAAM,OAAO,IAAI;IAChB;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CACrB,GAAe,EACf,WAAmB,EAAE,EACrB,YAAoB,IAAI,CAAC,GAAG,EAAE;QAE9B,OAAO,GAAG,CAAC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BAAkB,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,kBAAkB,aAAa,MAAM,kBAAkB,CAC7D,KAAK,CACL,WAAW,YAAY,WAAW,aAAa,sCAAsC,CAAC;IACxF,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Base32, RandomHelper } from \"@twin.org/core\";\nimport * as otp from \"micro-key-producer/otp.js\";\n\n/**\n * Perform TOTP.\n * Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .\n */\nexport class Totp {\n\t/**\n\t * Generate a time based One Time Password.\n\t * @param key Key for the one time password.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp.\n\t * @returns The one time password.\n\t */\n\tpublic static generate(\n\t\tkey: Uint8Array,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): string {\n\t\treturn otp.totp({ secret: key, digits: 6, algorithm: \"sha1\", interval }, timestamp);\n\t}\n\n\t/**\n\t * Check a One Time Password based on a timer.\n\t * @param token Passcode to validate.\n\t * @param key Key for the one time password. This should be unique and secret for\n\t * every user as it is the seed used to calculate the HMAC.\n\t * @param window The allowable margin for the counter.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp now.\n\t * @returns
|
|
1
|
+
{"version":3,"file":"totp.js","sourceRoot":"","sources":["../../../src/otp/totp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AAEjD;;;GAGG;AACH,MAAM,OAAO,IAAI;IAChB;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CACrB,GAAe,EACf,WAAmB,EAAE,EACrB,YAAoB,IAAI,CAAC,GAAG,EAAE;QAE9B,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,E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,kBAAkB,CAC7D,KAAK,CACL,WAAW,YAAY,WAAW,aAAa,sCAAsC,CAAC;IACxF,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Base32, RandomHelper } from \"@twin.org/core\";\nimport * as otp from \"micro-key-producer/otp.js\";\n\n/**\n * Perform TOTP.\n * Implementation of https://datatracker.ietf.org/doc/html/rfc4226 .\n */\nexport class Totp {\n\t/**\n\t * Generate a time based One Time Password.\n\t * @param key Key for the one time password.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp.\n\t * @returns The one time password.\n\t */\n\tpublic static generate(\n\t\tkey: Uint8Array,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): string {\n\t\treturn otp.totp({ secret: key, digits: 6, algorithm: \"sha1\", interval }, timestamp);\n\t}\n\n\t/**\n\t * Check a One Time Password based on a timer.\n\t * @param token Passcode to validate.\n\t * @param key Key for the one time password. This should be unique and secret for\n\t * every user as it is the seed used to calculate the HMAC.\n\t * @param window The allowable margin for the counter.\n\t * @param interval The time step of the counter.\n\t * @param timestamp The timestamp now.\n\t * @returns The counter delta on success, or undefined if no matching code is found within the window.\n\t */\n\tpublic static verify(\n\t\ttoken: string,\n\t\tkey: Uint8Array,\n\t\twindow: number = 2,\n\t\tinterval: number = 30,\n\t\ttimestamp: number = Date.now()\n\t): number | undefined {\n\t\tfor (let i = -window; i < window; i++) {\n\t\t\tconst intervalWindow = i * interval * 1000;\n\t\t\tif (timestamp + intervalWindow > 0) {\n\t\t\t\tconst gen = Totp.generate(key, interval, timestamp + intervalWindow);\n\t\t\t\tif (gen === token) {\n\t\t\t\t\t// We have found a matching code\n\t\t\t\t\treturn i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If we get to here then no codes have matched, return undefined\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Generate a secret.\n\t * @param length The length of the secret to generate.\n\t * @returns The secret encoded as base32.\n\t */\n\tpublic static generateSecret(length: number): string {\n\t\tconst encodedBase32 = Base32.encode(RandomHelper.generate(length));\n\n\t\t// Strip the trailing = the authenticator apps don't need them\n\t\treturn encodedBase32.replace(/=/g, \"\");\n\t}\n\n\t/**\n\t * Convert the secret back to bytes.\n\t * @param secretBase32 The secret encoded as base32.\n\t * @returns The bytes of the secret.\n\t */\n\tpublic static secretToBytes(secretBase32: string): Uint8Array {\n\t\treturn Base32.decode(secretBase32);\n\t}\n\n\t/**\n\t * Generate a url for use with authenticator apps.\n\t * See https://github.com/google/google-authenticator/wiki/Key-Uri-Format .\n\t * @param issuer The issuer of the totp.\n\t * @param label The label that will show in auth apps.\n\t * @param secretBase32 The secret as base 32.\n\t * @returns The url.\n\t */\n\tpublic static generateAuthUrl(issuer: string, label: string, secretBase32: string): string {\n\t\tconst encodedIssuer = encodeURIComponent(issuer);\n\t\treturn `otpauth://totp/${encodedIssuer}%3A${encodeURIComponent(\n\t\t\tlabel\n\t\t)}?secret=${secretBase32}&issuer=${encodedIssuer}&digits=6&algorithm=SHA1&interval=30`;\n\t}\n}\n"]}
|
|
@@ -22,7 +22,7 @@ export declare class Ed25519 {
|
|
|
22
22
|
*/
|
|
23
23
|
static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Signs the block with the private key and returns a signature.
|
|
26
26
|
* @param privateKey The private key.
|
|
27
27
|
* @param block The block to sign.
|
|
28
28
|
* @returns The signature.
|
|
@@ -22,7 +22,7 @@ export declare class Secp256k1 {
|
|
|
22
22
|
*/
|
|
23
23
|
static publicKeyFromPrivateKey(privateKey: Uint8Array): Uint8Array;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Signs the block with the private key and returns a signature.
|
|
26
26
|
* @param privateKey The private key.
|
|
27
27
|
* @param block The block to sign.
|
|
28
28
|
* @returns The signature.
|
|
@@ -16,7 +16,7 @@ export declare class Argon2id {
|
|
|
16
16
|
* @param options.p Number of parallel threads to use, default 1.
|
|
17
17
|
* @param options.dkLen The length of the derived key in bytes, default 32.
|
|
18
18
|
* @param options.maxmem The maximum amount of memory to use in bytes, default 2^30.
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns A promise that resolves with the derived key bytes.
|
|
20
20
|
*/
|
|
21
21
|
static hash(password: Uint8Array, salt: Uint8Array, options?: {
|
|
22
22
|
t?: number;
|
|
@@ -35,7 +35,7 @@ export declare class Slip0010 {
|
|
|
35
35
|
* Get the public key from the private key.
|
|
36
36
|
* @param privateKey The private key.
|
|
37
37
|
* @param keyType The key type.
|
|
38
|
-
* @param withZeroByte Include a zero
|
|
38
|
+
* @param withZeroByte Include a zero byte prefix.
|
|
39
39
|
* @returns The public key.
|
|
40
40
|
*/
|
|
41
41
|
static getPublicKey(privateKey: Uint8Array, keyType?: KeyType, withZeroByte?: boolean): Uint8Array;
|
package/dist/types/otp/totp.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class Totp {
|
|
|
19
19
|
* @param window The allowable margin for the counter.
|
|
20
20
|
* @param interval The time step of the counter.
|
|
21
21
|
* @param timestamp The timestamp now.
|
|
22
|
-
* @returns
|
|
22
|
+
* @returns The counter delta on success, or undefined if no matching code is found within the window.
|
|
23
23
|
*/
|
|
24
24
|
static verify(token: string, key: Uint8Array, window?: number, interval?: number, timestamp?: number): number | undefined;
|
|
25
25
|
/**
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,219 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.4-next.11](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.10...crypto-v0.0.4-next.11) (2026-06-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **crypto:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
16
|
+
* @twin.org/nameof bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
20
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.10 to 0.0.4-next.11
|
|
21
|
+
|
|
22
|
+
## [0.0.4-next.10](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.9...crypto-v0.0.4-next.10) (2026-06-15)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* add context id features ([#206](https://github.com/iotaledger/twin-framework/issues/206)) ([ef0d4ee](https://github.com/iotaledger/twin-framework/commit/ef0d4ee11a4f5fc6cc6f52a4958ce905c04ee13b))
|
|
28
|
+
* add crypto argon2id ([#255](https://github.com/iotaledger/twin-framework/issues/255)) ([27fe3a7](https://github.com/iotaledger/twin-framework/commit/27fe3a72eeb0f398a278ebb3f1cb9c4dd459743c))
|
|
29
|
+
* add guards arrayEndsWith and arrayStartsWith ([95d875e](https://github.com/iotaledger/twin-framework/commit/95d875ec8ccb4713c145fdde941d4cfedcec2ed3))
|
|
30
|
+
* add mnemonic validation ([4b43491](https://github.com/iotaledger/twin-framework/commit/4b43491cf04bb626c27faea66e5c74b3971b111d))
|
|
31
|
+
* add rsa cipher support ([7af6cc6](https://github.com/iotaledger/twin-framework/commit/7af6cc67512d3363bd4a2f2e87bd7733c2800147))
|
|
32
|
+
* add RSA support for public key components ([7126259](https://github.com/iotaledger/twin-framework/commit/7126259103b758c291e52a8a03818eb822d1aad1))
|
|
33
|
+
* additional RSA methods and async ([1fceee2](https://github.com/iotaledger/twin-framework/commit/1fceee2d1248a24a7620846025fcf906495c07f4))
|
|
34
|
+
* change method accessibility ([c1b77fc](https://github.com/iotaledger/twin-framework/commit/c1b77fcfb61c092a01c97aebb2fe2dc2bbaa221b))
|
|
35
|
+
* eslint migration to flat config ([74427d7](https://github.com/iotaledger/twin-framework/commit/74427d78d342167f7850e49ab87269326355befe))
|
|
36
|
+
* factory create and integrity ([#235](https://github.com/iotaledger/twin-framework/issues/235)) ([9f98b99](https://github.com/iotaledger/twin-framework/commit/9f98b99daf46eb365346fae49cc4ffba63e74cb3))
|
|
37
|
+
* improve signatures ([cdd24be](https://github.com/iotaledger/twin-framework/commit/cdd24be6fb898d33955b6f2f93c3ddbd73582269))
|
|
38
|
+
* improved password generation and validation ([#232](https://github.com/iotaledger/twin-framework/issues/232)) ([ca4e18f](https://github.com/iotaledger/twin-framework/commit/ca4e18f388b1882cdfb774fc0d0921b8530fac33))
|
|
39
|
+
* locales validation ([#197](https://github.com/iotaledger/twin-framework/issues/197)) ([55fdadb](https://github.com/iotaledger/twin-framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
|
|
40
|
+
* relocate core packages from tools ([bcab8f3](https://github.com/iotaledger/twin-framework/commit/bcab8f3160442ea4fcaf442947462504f3d6a17d))
|
|
41
|
+
* typescript 6 update ([1d10f31](https://github.com/iotaledger/twin-framework/commit/1d10f31e6516ec622773f45e88af82fe749b384a))
|
|
42
|
+
* update dependencies ([4da77ab](https://github.com/iotaledger/twin-framework/commit/4da77ab30f499e52825ac5a76f51436ceb59c26e))
|
|
43
|
+
* update dependencies ([f3bd015](https://github.com/iotaledger/twin-framework/commit/f3bd015efd169196b7e0335f5cab876ba6ca1d75))
|
|
44
|
+
* use cause instead of inner for errors ([1f4acc4](https://github.com/iotaledger/twin-framework/commit/1f4acc4d7a6b71a134d9547da9bf40de1e1e49da))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
* docs ([9df46e0](https://github.com/iotaledger/twin-framework/commit/9df46e0a3940a4d1f479373f58830519262f9590))
|
|
50
|
+
* docs ([67c8887](https://github.com/iotaledger/twin-framework/commit/67c888739448e753106ea067a8703d058e0ddf12))
|
|
51
|
+
* ensure __decorate is defined for decorators ([103a563](https://github.com/iotaledger/twin-framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Dependencies
|
|
55
|
+
|
|
56
|
+
* The following workspace dependencies were updated
|
|
57
|
+
* dependencies
|
|
58
|
+
* @twin.org/core bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
59
|
+
* @twin.org/nameof bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
60
|
+
* devDependencies
|
|
61
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
62
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
63
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.9 to 0.0.4-next.10
|
|
64
|
+
|
|
65
|
+
## [0.0.4-next.9](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.8...crypto-v0.0.4-next.9) (2026-06-15)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
### Miscellaneous Chores
|
|
69
|
+
|
|
70
|
+
* **crypto:** Synchronize repo versions
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Dependencies
|
|
74
|
+
|
|
75
|
+
* The following workspace dependencies were updated
|
|
76
|
+
* dependencies
|
|
77
|
+
* @twin.org/core bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
78
|
+
* @twin.org/nameof bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
79
|
+
* devDependencies
|
|
80
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
81
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
82
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.8 to 0.0.4-next.9
|
|
83
|
+
|
|
84
|
+
## [0.0.4-next.8](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.7...crypto-v0.0.4-next.8) (2026-06-10)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Miscellaneous Chores
|
|
88
|
+
|
|
89
|
+
* **crypto:** Synchronize repo versions
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
### Dependencies
|
|
93
|
+
|
|
94
|
+
* The following workspace dependencies were updated
|
|
95
|
+
* dependencies
|
|
96
|
+
* @twin.org/core bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
97
|
+
* @twin.org/nameof bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
98
|
+
* devDependencies
|
|
99
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
100
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
101
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.7 to 0.0.4-next.8
|
|
102
|
+
|
|
103
|
+
## [0.0.4-next.7](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.6...crypto-v0.0.4-next.7) (2026-06-10)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Miscellaneous Chores
|
|
107
|
+
|
|
108
|
+
* **crypto:** Synchronize repo versions
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Dependencies
|
|
112
|
+
|
|
113
|
+
* The following workspace dependencies were updated
|
|
114
|
+
* dependencies
|
|
115
|
+
* @twin.org/core bumped from 0.0.4-next.6 to 0.0.4-next.7
|
|
116
|
+
* @twin.org/nameof bumped from 0.0.4-next.6 to 0.0.4-next.7
|
|
117
|
+
* devDependencies
|
|
118
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.6 to 0.0.4-next.7
|
|
119
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.6 to 0.0.4-next.7
|
|
120
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.6 to 0.0.4-next.7
|
|
121
|
+
|
|
122
|
+
## [0.0.4-next.6](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.5...crypto-v0.0.4-next.6) (2026-06-05)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
### Miscellaneous Chores
|
|
126
|
+
|
|
127
|
+
* **crypto:** Synchronize repo versions
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### Dependencies
|
|
131
|
+
|
|
132
|
+
* The following workspace dependencies were updated
|
|
133
|
+
* dependencies
|
|
134
|
+
* @twin.org/core bumped from 0.0.4-next.5 to 0.0.4-next.6
|
|
135
|
+
* @twin.org/nameof bumped from 0.0.4-next.5 to 0.0.4-next.6
|
|
136
|
+
* devDependencies
|
|
137
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.5 to 0.0.4-next.6
|
|
138
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.5 to 0.0.4-next.6
|
|
139
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.5 to 0.0.4-next.6
|
|
140
|
+
|
|
141
|
+
## [0.0.4-next.5](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.4...crypto-v0.0.4-next.5) (2026-06-04)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### Miscellaneous Chores
|
|
145
|
+
|
|
146
|
+
* **crypto:** Synchronize repo versions
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### Dependencies
|
|
150
|
+
|
|
151
|
+
* The following workspace dependencies were updated
|
|
152
|
+
* dependencies
|
|
153
|
+
* @twin.org/core bumped from 0.0.4-next.4 to 0.0.4-next.5
|
|
154
|
+
* @twin.org/nameof bumped from 0.0.4-next.4 to 0.0.4-next.5
|
|
155
|
+
* devDependencies
|
|
156
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.4 to 0.0.4-next.5
|
|
157
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.4 to 0.0.4-next.5
|
|
158
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.4 to 0.0.4-next.5
|
|
159
|
+
|
|
160
|
+
## [0.0.4-next.4](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.3...crypto-v0.0.4-next.4) (2026-06-02)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
### Miscellaneous Chores
|
|
164
|
+
|
|
165
|
+
* **crypto:** Synchronize repo versions
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
### Dependencies
|
|
169
|
+
|
|
170
|
+
* The following workspace dependencies were updated
|
|
171
|
+
* dependencies
|
|
172
|
+
* @twin.org/core bumped from 0.0.4-next.3 to 0.0.4-next.4
|
|
173
|
+
* @twin.org/nameof bumped from 0.0.4-next.3 to 0.0.4-next.4
|
|
174
|
+
* devDependencies
|
|
175
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.3 to 0.0.4-next.4
|
|
176
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.3 to 0.0.4-next.4
|
|
177
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.3 to 0.0.4-next.4
|
|
178
|
+
|
|
179
|
+
## [0.0.4-next.3](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.2...crypto-v0.0.4-next.3) (2026-05-28)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
### Miscellaneous Chores
|
|
183
|
+
|
|
184
|
+
* **crypto:** Synchronize repo versions
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
### Dependencies
|
|
188
|
+
|
|
189
|
+
* The following workspace dependencies were updated
|
|
190
|
+
* dependencies
|
|
191
|
+
* @twin.org/core bumped from 0.0.4-next.2 to 0.0.4-next.3
|
|
192
|
+
* @twin.org/nameof bumped from 0.0.4-next.2 to 0.0.4-next.3
|
|
193
|
+
* devDependencies
|
|
194
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.2 to 0.0.4-next.3
|
|
195
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.2 to 0.0.4-next.3
|
|
196
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.2 to 0.0.4-next.3
|
|
197
|
+
|
|
198
|
+
## [0.0.4-next.2](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.1...crypto-v0.0.4-next.2) (2026-05-28)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
### Miscellaneous Chores
|
|
202
|
+
|
|
203
|
+
* **crypto:** Synchronize repo versions
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
### Dependencies
|
|
207
|
+
|
|
208
|
+
* The following workspace dependencies were updated
|
|
209
|
+
* dependencies
|
|
210
|
+
* @twin.org/core bumped from 0.0.4-next.1 to 0.0.4-next.2
|
|
211
|
+
* @twin.org/nameof bumped from 0.0.4-next.1 to 0.0.4-next.2
|
|
212
|
+
* devDependencies
|
|
213
|
+
* @twin.org/nameof-transformer bumped from 0.0.4-next.1 to 0.0.4-next.2
|
|
214
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.4-next.1 to 0.0.4-next.2
|
|
215
|
+
* @twin.org/validate-locales bumped from 0.0.4-next.1 to 0.0.4-next.2
|
|
216
|
+
|
|
3
217
|
## [0.0.4-next.1](https://github.com/iotaledger/twin-framework/compare/crypto-v0.0.4-next.0...crypto-v0.0.4-next.1) (2026-05-27)
|
|
4
218
|
|
|
5
219
|
|
|
@@ -68,7 +68,7 @@ Error if the private key is not the correct length.
|
|
|
68
68
|
|
|
69
69
|
> `static` **sign**(`privateKey`, `block`): `Uint8Array`
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Signs the block with the private key and returns a signature.
|
|
72
72
|
|
|
73
73
|
#### Parameters
|
|
74
74
|
|
|
@@ -68,7 +68,7 @@ Error if the private key is not the correct length.
|
|
|
68
68
|
|
|
69
69
|
> `static` **sign**(`privateKey`, `block`): `Uint8Array`
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
Signs the block with the private key and returns a signature.
|
|
72
72
|
|
|
73
73
|
#### Parameters
|
|
74
74
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto",
|
|
3
|
-
"version": "0.0.4-next.
|
|
3
|
+
"version": "0.0.4-next.11",
|
|
4
4
|
"description": "Helper methods and classes which implement cryptographic functions",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/iotaledger/framework.git",
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-framework.git",
|
|
8
8
|
"directory": "packages/crypto"
|
|
9
9
|
},
|
|
10
10
|
"author": "martyn.janes@iota.org",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@scure/base": "2.2.0",
|
|
21
21
|
"@scure/bip32": "2.2.0",
|
|
22
22
|
"@scure/bip39": "2.2.0",
|
|
23
|
-
"@twin.org/core": "0.0.4-next.
|
|
24
|
-
"@twin.org/nameof": "0.0.4-next.
|
|
23
|
+
"@twin.org/core": "0.0.4-next.11",
|
|
24
|
+
"@twin.org/nameof": "0.0.4-next.11",
|
|
25
25
|
"micro-key-producer": "0.8.6"
|
|
26
26
|
},
|
|
27
27
|
"main": "./dist/es/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"security"
|
|
53
53
|
],
|
|
54
54
|
"bugs": {
|
|
55
|
-
"url": "git+https://github.com/iotaledger/framework/issues"
|
|
55
|
+
"url": "git+https://github.com/iotaledger/twin-framework/issues"
|
|
56
56
|
},
|
|
57
57
|
"homepage": "https://twindev.org"
|
|
58
58
|
}
|