forked from tornado-packages/noble-curves
Fix tests
This commit is contained in:
parent
31d92cce11
commit
d424c661fb
@ -174,7 +174,7 @@ There are following zero-dependency algorithms:
|
|||||||
- [abstract/weierstrass: Short Weierstrass curve](#abstractweierstrass-short-weierstrass-curve)
|
- [abstract/weierstrass: Short Weierstrass curve](#abstractweierstrass-short-weierstrass-curve)
|
||||||
- [abstract/edwards: Twisted Edwards curve](#abstractedwards-twisted-edwards-curve)
|
- [abstract/edwards: Twisted Edwards curve](#abstractedwards-twisted-edwards-curve)
|
||||||
- [abstract/montgomery: Montgomery curve](#abstractmontgomery-montgomery-curve)
|
- [abstract/montgomery: Montgomery curve](#abstractmontgomery-montgomery-curve)
|
||||||
- [abstract/bls: BLS curves](#abstractbls-bls-curves)
|
- [abstract/bls: Barreto-Lynn-Scott curves](#abstractbls-barreto-lynn-scott-curves)
|
||||||
- [abstract/hash-to-curve: Hashing strings to curve points](#abstracthash-to-curve-hashing-strings-to-curve-points)
|
- [abstract/hash-to-curve: Hashing strings to curve points](#abstracthash-to-curve-hashing-strings-to-curve-points)
|
||||||
- [abstract/poseidon: Poseidon hash](#abstractposeidon-poseidon-hash)
|
- [abstract/poseidon: Poseidon hash](#abstractposeidon-poseidon-hash)
|
||||||
- [abstract/modular: Modular arithmetics utilities](#abstractmodular-modular-arithmetics-utilities)
|
- [abstract/modular: Modular arithmetics utilities](#abstractmodular-modular-arithmetics-utilities)
|
||||||
@ -452,7 +452,7 @@ Proper Elliptic Curve Points are not implemented yet.
|
|||||||
|
|
||||||
You must specify curve params `Fp`, `a`, `Gu` coordinate of u, `montgomeryBits` and `nByteLength`.
|
You must specify curve params `Fp`, `a`, `Gu` coordinate of u, `montgomeryBits` and `nByteLength`.
|
||||||
|
|
||||||
### abstract/bls: BLS curves
|
### abstract/bls: Barreto-Lynn-Scott curves
|
||||||
|
|
||||||
The module abstracts BLS (Barreto-Lynn-Scott) pairing-friendly elliptic curve construction.
|
The module abstracts BLS (Barreto-Lynn-Scott) pairing-friendly elliptic curve construction.
|
||||||
They allow to construct [zk-SNARKs](https://z.cash/technology/zksnarks/) and
|
They allow to construct [zk-SNARKs](https://z.cash/technology/zksnarks/) and
|
||||||
|
@ -566,6 +566,7 @@ describe('ed448', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
should('not verify when sig.s >= CURVE.n', () => {
|
should('not verify when sig.s >= CURVE.n', () => {
|
||||||
|
function get56bSig() {
|
||||||
const privateKey = ed448.utils.randomPrivateKey();
|
const privateKey = ed448.utils.randomPrivateKey();
|
||||||
const message = Uint8Array.from([0xab, 0xbc, 0xcd, 0xde]);
|
const message = Uint8Array.from([0xab, 0xbc, 0xcd, 0xde]);
|
||||||
const publicKey = ed448.getPublicKey(privateKey);
|
const publicKey = ed448.getPublicKey(privateKey);
|
||||||
@ -580,8 +581,19 @@ describe('ed448', () => {
|
|||||||
s = numberToBytesLE(s, 56);
|
s = numberToBytesLE(s, 56);
|
||||||
|
|
||||||
const sig_invalid = concatBytes(R, s);
|
const sig_invalid = concatBytes(R, s);
|
||||||
|
return { sig_invalid, message, publicKey };
|
||||||
|
}
|
||||||
|
let sig;
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
sig = get56bSig();
|
||||||
|
break;
|
||||||
|
} catch (error) {
|
||||||
|
// non-56b sig was generated, try again
|
||||||
|
}
|
||||||
|
}
|
||||||
throws(() => {
|
throws(() => {
|
||||||
ed448.verify(sig_invalid, message, publicKey);
|
ed448.verify(sig.sig_invalid, sig.message, sig.publicKey);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user