Use 'message' arg name consistently

This commit is contained in:
dapplion 2020-11-28 19:11:21 +00:00
parent b0ed0e8cb5
commit bd17160713
3 changed files with 23 additions and 23 deletions

View File

@ -11,13 +11,13 @@ export function functionalInterfaceFactory({
/** /**
* Signs given message using secret key. * Signs given message using secret key.
* @param secretKey * @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(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); 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. * Verifies if signature is message signed with given public key.
* @param publicKey * @param publicKey
* @param messageHash * @param message
* @param signature * @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(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"); assert(signature, "signature is null or undefined");
try { try {
return Signature.fromBytes(signature).verify(PublicKey.fromBytes(publicKey), messageHash); return Signature.fromBytes(signature).verify(PublicKey.fromBytes(publicKey), message);
} catch (e) { } catch (e) {
return false; return false;
} }
@ -58,17 +58,17 @@ export function functionalInterfaceFactory({
/** /**
* Verifies if aggregated signature is same message signed with given public keys. * Verifies if aggregated signature is same message signed with given public keys.
* @param publicKeys * @param publicKeys
* @param messageHash * @param message
* @param signature * @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(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"); assert(signature, "signature is null or undefined");
try { try {
return Signature.fromBytes(signature).verifyAggregate( return Signature.fromBytes(signature).verifyAggregate(
publicKeys.map((pubkey) => PublicKey.fromBytes(pubkey)), publicKeys.map((pubkey) => PublicKey.fromBytes(pubkey)),
messageHash message
); );
} catch (e) { } catch (e) {
return false; return false;
@ -78,22 +78,22 @@ export function functionalInterfaceFactory({
/** /**
* Verifies if signature is list of message signed with corresponding public key. * Verifies if signature is list of message signed with corresponding public key.
* @param publicKeys * @param publicKeys
* @param messageHashes * @param messages
* @param signature * @param signature
* @param fast Check if all messages are different * @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(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"); 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; return false;
} }
try { try {
return Signature.fromBytes(signature).verifyMultiple( return Signature.fromBytes(signature).verifyMultiple(
publicKeys.map((publicKey) => PublicKey.fromBytes(publicKey)), publicKeys.map((publicKey) => PublicKey.fromBytes(publicKey)),
messageHashes.map((msg) => msg) messages.map((msg) => msg)
); );
} catch (e) { } catch (e) {
return false; return false;

View File

@ -43,8 +43,8 @@ export class PublicKey implements IPublicKey {
return agg; return agg;
} }
verifyMessage(signature: Signature, messageHash: Uint8Array): boolean { verifyMessage(signature: Signature, message: Uint8Array): boolean {
return this.value.verify(signature.value, messageHash); return this.value.verify(signature.value, message);
} }
toBytes(): Uint8Array { toBytes(): Uint8Array {

View File

@ -15,12 +15,12 @@ export interface IBls {
aggregate(signatures: ISignature[]): ISignature; aggregate(signatures: ISignature[]): ISignature;
}; };
sign(secretKey: Uint8Array, messageHash: Uint8Array): Uint8Array; sign(secretKey: Uint8Array, message: Uint8Array): Uint8Array;
aggregatePubkeys(publicKeys: Uint8Array[]): Uint8Array; aggregatePubkeys(publicKeys: Uint8Array[]): Uint8Array;
aggregateSignatures(signatures: Uint8Array[]): Uint8Array; aggregateSignatures(signatures: Uint8Array[]): Uint8Array;
verify(publicKey: Uint8Array, messageHash: Uint8Array, signature: Uint8Array): boolean; verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
verifyAggregate(publicKeys: Uint8Array[], messageHash: Uint8Array, signature: Uint8Array): boolean; verifyAggregate(publicKeys: Uint8Array[], message: Uint8Array, signature: Uint8Array): boolean;
verifyMultiple(publicKeys: Uint8Array[], messageHashes: Uint8Array[], signature: Uint8Array): boolean; verifyMultiple(publicKeys: Uint8Array[], messages: Uint8Array[], signature: Uint8Array): boolean;
init(): Promise<void>; init(): Promise<void>;
destroy(): void; destroy(): void;