Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BLS secret key validation is missing #96

Open
dnkolegov opened this issue Jun 2, 2021 · 3 comments
Open

BLS secret key validation is missing #96

dnkolegov opened this issue Jun 2, 2021 · 3 comments

Comments

@dnkolegov
Copy link

Describe the bug
The BLS spec requires that the secret key (SK) must be a uniformly random integer such that 1 <= SK < r.
Where r is the order curve.

The last check is missing:

Expected behavior

Check that the provided SK < r.

@dapplion
Copy link
Contributor

dapplion commented Jun 3, 2021

Thanks for looking into this! I think BLST takes care of that, but it would be good to add a test. Transfering to bls repo.

@dapplion dapplion transferred this issue from ChainSafe/lodestar Jun 3, 2021
@dnkolegov
Copy link
Author

The following test for SK = q+1 will pass and will not raise an exception.

describe("q+1 secret key", () => {
    const qHex = fromHex("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000002");
    const sk = bls.SecretKey.fromBytes(qHex);
    const msg = Buffer.from("sample-msg");
    const sig = sk.sign(msg);
    const pk = sk.toPublicKey();
    console.log(pk.toBytes())
    it("verify", () => {
      const valid = bls.verify(msg, pk, sig);
      expect(valid).to.equal(true);
    });
    
 });

@dapplion
Copy link
Contributor

dapplion commented Jun 3, 2021

Feel free to do a PR with the test and a fix if you want! I can do the latter if you need help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants