This repository has been archived on 2023-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
chainsafe-bls/test/spec/sign_message.test.ts

21 lines
658 B
TypeScript
Raw Normal View History

2019-08-05 15:48:26 +00:00
import {join} from "path";
import {describeSpecTest} from "@chainsafe/eth2.0-spec-test-util";
import bls from "../../src";
import {padLeft} from "../../src/helpers/utils";
describeSpecTest(
join(__dirname, "./spec-tests/tests/bls/sign_msg/sign_msg.yaml"),
bls.sign,
({input}) => {
const domain = padLeft(Buffer.from(input.domain.replace('0x', ''), 'hex'), 8);
return [
Buffer.from(input.privkey.replace('0x', ''), 'hex'),
Buffer.from(input.message.replace('0x', ''), 'hex'),
domain
];
},
({output}) => output,
(result) => `0x${result.toString('hex')}`,
() => false,
);