Add secretKeyToPublicKey function

This commit is contained in:
Cayman 2020-11-30 13:40:07 -06:00
parent f3e9392847
commit e0076d0f27
No known key found for this signature in database
GPG Key ID: 54B21AEC3C53E1F5
2 changed files with 10 additions and 0 deletions

View File

@ -106,6 +106,14 @@ export function functionalInterfaceFactory({
} }
} }
/**
* Computes a public key from a secret key
*/
function secretKeyToPublicKey(secretKey: Uint8Array): Uint8Array {
validateBytes(secretKey, "secretKey");
return SecretKey.fromBytes(secretKey).toPublicKey().toBytes();
}
return { return {
sign, sign,
aggregateSignatures, aggregateSignatures,
@ -113,5 +121,6 @@ export function functionalInterfaceFactory({
verify, verify,
verifyAggregate, verifyAggregate,
verifyMultiple, verifyMultiple,
secretKeyToPublicKey,
}; };
} }

View File

@ -21,6 +21,7 @@ export interface IBls {
verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean; verify(publicKey: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
verifyAggregate(publicKeys: Uint8Array[], message: Uint8Array, signature: Uint8Array): boolean; verifyAggregate(publicKeys: Uint8Array[], message: Uint8Array, signature: Uint8Array): boolean;
verifyMultiple(publicKeys: Uint8Array[], messages: Uint8Array[], signature: Uint8Array): boolean; verifyMultiple(publicKeys: Uint8Array[], messages: Uint8Array[], signature: Uint8Array): boolean;
secretKeyToPublicKey(secretKey: Uint8Array): Uint8Array;
init(): Promise<void>; init(): Promise<void>;
destroy(): void; destroy(): void;