From c94dfc99cc4f0ecab3591213a31550399ce90275 Mon Sep 17 00:00:00 2001 From: Dimasik Kolezhniuk Date: Tue, 23 Apr 2024 13:55:46 +0200 Subject: [PATCH 1/2] Remove hashing from ed25519 --- src/kms/key-providers/ed25519-provider.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/kms/key-providers/ed25519-provider.ts b/src/kms/key-providers/ed25519-provider.ts index 4d6ade44..28c03a6c 100644 --- a/src/kms/key-providers/ed25519-provider.ts +++ b/src/kms/key-providers/ed25519-provider.ts @@ -3,7 +3,6 @@ import { AbstractPrivateKeyStore, KmsKeyId, KmsKeyType } from '../store'; import * as providerHelpers from '../provider-helpers'; import { ed25519 } from '@noble/curves/ed25519'; import { bytesToHex } from '../../utils'; -import { sha256 } from '@iden3/js-crypto'; /** * Provider for Ed25519 keys @@ -61,24 +60,24 @@ export class Ed25519Provider implements IKeyProvider { * signs prepared payload of size, * with a key id * @param {KmsKeyId} keyId - key identifier - * @param {Uint8Array} data - data to sign (32 bytes) + * @param {Uint8Array} digest - data to sign (32 bytes) * @returns {Promise} signature */ - async sign(keyId: KmsKeyId, data: Uint8Array): Promise { + async sign(keyId: KmsKeyId, digest: Uint8Array): Promise { const privateKeyHex = await this.privateKey(keyId); - return ed25519.sign(sha256(data), privateKeyHex); + return ed25519.sign(digest, privateKeyHex); } /** * Verifies a signature for the given message and key identifier. - * @param message - The message to verify the signature against. + * @param digest - The message to verify the signature against. * @param signatureHex - The signature to verify, as a hexadecimal string. * @param keyId - The key identifier to use for verification. * @returns A Promise that resolves to a boolean indicating whether the signature is valid. */ - async verify(message: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise { + async verify(digest: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise { const publicKeyHex = await this.publicKey(keyId); - return ed25519.verify(signatureHex, sha256(message), publicKeyHex); + return ed25519.verify(signatureHex, digest, publicKeyHex); } /** From 33988bf84a8b12e11ee04bf480d188e6aba87df8 Mon Sep 17 00:00:00 2001 From: Dimasik Kolezhniuk Date: Tue, 23 Apr 2024 13:55:53 +0200 Subject: [PATCH 2/2] 1.11.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 023ed5de..c5046a55 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.11.0", + "version": "1.11.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@0xpolygonid/js-sdk", - "version": "1.11.0", + "version": "1.11.1", "license": "AGPL-3.0", "dependencies": { "@noble/curves": "^1.4.0", diff --git a/package.json b/package.json index 77ec481d..1dcd5981 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@0xpolygonid/js-sdk", - "version": "1.11.0", + "version": "1.11.1", "description": "SDK to work with Polygon ID", "main": "dist/node/cjs/index.js", "module": "dist/node/esm/index.js",