Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ed25519-remove-hash #225

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 6 additions & 7 deletions src/kms/key-providers/ed25519-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Uint8Array>} signature
*/
async sign(keyId: KmsKeyId, data: Uint8Array): Promise<Uint8Array> {
async sign(keyId: KmsKeyId, digest: Uint8Array): Promise<Uint8Array> {
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<boolean> {
async verify(digest: Uint8Array, signatureHex: string, keyId: KmsKeyId): Promise<boolean> {
const publicKeyHex = await this.publicKey(keyId);
return ed25519.verify(signatureHex, sha256(message), publicKeyHex);
return ed25519.verify(signatureHex, digest, publicKeyHex);
}

/**
Expand Down