Merge pull request #48 from ChainSafe/cayman/secretKeyToPublicKey

Add secretKeyToPublicKey function
This commit is contained in:
Cayman 2020-11-30 13:13:56 -07:00 committed by GitHub
commit 380487e410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 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

@ -44,6 +44,7 @@ export declare let aggregatePublicKeys: IBls["aggregatePublicKeys"];
export declare let verify: IBls["verify"]; export declare let verify: IBls["verify"];
export declare let verifyAggregate: IBls["verifyAggregate"]; export declare let verifyAggregate: IBls["verifyAggregate"];
export declare let verifyMultiple: IBls["verifyMultiple"]; export declare let verifyMultiple: IBls["verifyMultiple"];
export declare let secretKeyToPublicKey: IBls["secretKeyToPublicKey"];
export declare class SecretKey implements ISecretKey { export declare class SecretKey implements ISecretKey {
static fromBytes(bytes: Uint8Array): SecretKey; static fromBytes(bytes: Uint8Array): SecretKey;

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;