From bd17160713c9fdf9e5192c3bc6c4c31884658a17 Mon Sep 17 00:00:00 2001 From: dapplion Date: Sat, 28 Nov 2020 19:11:21 +0000 Subject: [PATCH] Use 'message' arg name consistently --- src/functional.ts | 34 +++++++++++++++++----------------- src/herumi/publicKey.ts | 4 ++-- src/interface.ts | 8 ++++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/functional.ts b/src/functional.ts index 7c7be12..c11ea00 100644 --- a/src/functional.ts +++ b/src/functional.ts @@ -11,13 +11,13 @@ export function functionalInterfaceFactory({ /** * Signs given message using secret key. * @param secretKey - * @param messageHash + * @param message */ - function sign(secretKey: Uint8Array, messageHash: Uint8Array): Uint8Array { + function sign(secretKey: Uint8Array, message: Uint8Array): Uint8Array { assert(secretKey, "secretKey is null or undefined"); - assert(messageHash, "messageHash is null or undefined"); + assert(message, "message is null or undefined"); const privateKey = PrivateKey.fromBytes(secretKey); - return privateKey.sign(messageHash).toBytes(); + return privateKey.sign(message).toBytes(); } /** @@ -41,15 +41,15 @@ export function functionalInterfaceFactory({ /** * Verifies if signature is message signed with given public key. * @param publicKey - * @param messageHash + * @param message * @param signature */ - function verify(publicKey: Uint8Array, messageHash: Uint8Array, signature: Uint8Array): boolean { + function verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean { assert(publicKey, "publicKey is null or undefined"); - assert(messageHash, "messageHash is null or undefined"); + assert(message, "message is null or undefined"); assert(signature, "signature is null or undefined"); try { - return Signature.fromBytes(signature).verify(PublicKey.fromBytes(publicKey), messageHash); + return Signature.fromBytes(signature).verify(PublicKey.fromBytes(publicKey), message); } catch (e) { return false; } @@ -58,17 +58,17 @@ export function functionalInterfaceFactory({ /** * Verifies if aggregated signature is same message signed with given public keys. * @param publicKeys - * @param messageHash + * @param message * @param signature */ - function verifyAggregate(publicKeys: Uint8Array[], messageHash: Uint8Array, signature: Uint8Array): boolean { + function verifyAggregate(publicKeys: Uint8Array[], message: Uint8Array, signature: Uint8Array): boolean { assert(publicKeys, "publicKey is null or undefined"); - assert(messageHash, "messageHash is null or undefined"); + assert(message, "message is null or undefined"); assert(signature, "signature is null or undefined"); try { return Signature.fromBytes(signature).verifyAggregate( publicKeys.map((pubkey) => PublicKey.fromBytes(pubkey)), - messageHash + message ); } catch (e) { return false; @@ -78,22 +78,22 @@ export function functionalInterfaceFactory({ /** * Verifies if signature is list of message signed with corresponding public key. * @param publicKeys - * @param messageHashes + * @param messages * @param signature * @param fast Check if all messages are different */ - function verifyMultiple(publicKeys: Uint8Array[], messageHashes: Uint8Array[], signature: Uint8Array): boolean { + function verifyMultiple(publicKeys: Uint8Array[], messages: Uint8Array[], signature: Uint8Array): boolean { assert(publicKeys, "publicKey is null or undefined"); - assert(messageHashes, "messageHash is null or undefined"); + assert(messages, "message is null or undefined"); assert(signature, "signature is null or undefined"); - if (publicKeys.length === 0 || publicKeys.length != messageHashes.length) { + if (publicKeys.length === 0 || publicKeys.length != messages.length) { return false; } try { return Signature.fromBytes(signature).verifyMultiple( publicKeys.map((publicKey) => PublicKey.fromBytes(publicKey)), - messageHashes.map((msg) => msg) + messages.map((msg) => msg) ); } catch (e) { return false; diff --git a/src/herumi/publicKey.ts b/src/herumi/publicKey.ts index 79532c3..3d102a3 100644 --- a/src/herumi/publicKey.ts +++ b/src/herumi/publicKey.ts @@ -43,8 +43,8 @@ export class PublicKey implements IPublicKey { return agg; } - verifyMessage(signature: Signature, messageHash: Uint8Array): boolean { - return this.value.verify(signature.value, messageHash); + verifyMessage(signature: Signature, message: Uint8Array): boolean { + return this.value.verify(signature.value, message); } toBytes(): Uint8Array { diff --git a/src/interface.ts b/src/interface.ts index ee34ad2..62c9a53 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -15,12 +15,12 @@ export interface IBls { aggregate(signatures: ISignature[]): ISignature; }; - sign(secretKey: Uint8Array, messageHash: Uint8Array): Uint8Array; + sign(secretKey: Uint8Array, message: Uint8Array): Uint8Array; aggregatePubkeys(publicKeys: Uint8Array[]): Uint8Array; aggregateSignatures(signatures: Uint8Array[]): Uint8Array; - verify(publicKey: Uint8Array, messageHash: Uint8Array, signature: Uint8Array): boolean; - verifyAggregate(publicKeys: Uint8Array[], messageHash: Uint8Array, signature: Uint8Array): boolean; - verifyMultiple(publicKeys: Uint8Array[], messageHashes: Uint8Array[], signature: Uint8Array): boolean; + verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean; + verifyAggregate(publicKeys: Uint8Array[], message: Uint8Array, signature: Uint8Array): boolean; + verifyMultiple(publicKeys: Uint8Array[], messages: Uint8Array[], signature: Uint8Array): boolean; init(): Promise; destroy(): void;