Make bls types more strict

This commit is contained in:
Cayman 2020-02-10 22:25:23 -06:00
parent 31d74562df
commit fa1f393e79
1 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@ export function generateKeyPair(): Keypair {
* Generates public key from given secret. * Generates public key from given secret.
* @param {BLSSecretKey} secretKey * @param {BLSSecretKey} secretKey
*/ */
export function generatePublicKey(secretKey: BLSSecretKey): BLSPubkey { export function generatePublicKey(secretKey: BLSSecretKey): Buffer {
assert(secretKey, "secretKey is null or undefined"); assert(secretKey, "secretKey is null or undefined");
const keypair = new Keypair(PrivateKey.fromBytes(Buffer.from(secretKey as Uint8Array))); const keypair = new Keypair(PrivateKey.fromBytes(Buffer.from(secretKey as Uint8Array)));
return keypair.publicKey.toBytesCompressed(); return keypair.publicKey.toBytesCompressed();
@ -33,7 +33,7 @@ export function generatePublicKey(secretKey: BLSSecretKey): BLSPubkey {
* @param messageHash * @param messageHash
* @param domain * @param domain
*/ */
export function sign(secretKey: BLSSecretKey, messageHash: Bytes32, domain: Domain): BLSSignature { export function sign(secretKey: BLSSecretKey, messageHash: Bytes32, domain: Domain): Buffer {
assert(secretKey, "secretKey is null or undefined"); assert(secretKey, "secretKey is null or undefined");
assert(messageHash, "messageHash is null or undefined"); assert(messageHash, "messageHash is null or undefined");
assert(domain, "domain is null or undefined"); assert(domain, "domain is null or undefined");
@ -48,7 +48,7 @@ export function sign(secretKey: BLSSecretKey, messageHash: Bytes32, domain: Doma
* Compines all given signature into one. * Compines all given signature into one.
* @param signatures * @param signatures
*/ */
export function aggregateSignatures(signatures: BLSSignature[]): BLSSignature { export function aggregateSignatures(signatures: BLSSignature[]): Buffer {
assert(signatures, "signatures is null or undefined"); assert(signatures, "signatures is null or undefined");
return signatures.map((signature): Signature => { return signatures.map((signature): Signature => {
return Signature.fromCompressedBytes(Buffer.from(signature as Uint8Array)); return Signature.fromCompressedBytes(Buffer.from(signature as Uint8Array));
@ -61,7 +61,7 @@ export function aggregateSignatures(signatures: BLSSignature[]): BLSSignature {
* Combines all given public keys into single one * Combines all given public keys into single one
* @param publicKeys * @param publicKeys
*/ */
export function aggregatePubkeys(publicKeys: BLSPubkey[]): BLSPubkey { export function aggregatePubkeys(publicKeys: BLSPubkey[]): Buffer {
assert(publicKeys, "publicKeys is null or undefined"); assert(publicKeys, "publicKeys is null or undefined");
if(publicKeys.length === 0) { if(publicKeys.length === 0) {
return Buffer.alloc(PUBLIC_KEY_LENGTH); return Buffer.alloc(PUBLIC_KEY_LENGTH);