From 0ed3bffbc31979576270e6b41b01697e431eb3bf Mon Sep 17 00:00:00 2001 From: PM <3749956+CluEleSsUK@users.noreply.github.com> Date: Mon, 18 Mar 2024 15:19:41 +0100 Subject: [PATCH] bumped noble for fix to point marshalling (#78) * bumped noble for fix to point marshalling * changed an error message * changed github node version to a specific one --- .github/workflows/build.yml | 2 +- lib/beacon-verification.ts | 4 ++-- package-lock.json | 20 ++++++++++---------- package.json | 4 ++-- test/beacon-verification.test.ts | 13 ++++++------- test/http-caching-chain.test.ts | 2 +- test/integration.test.ts | 4 ++-- 7 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60815b6..dfb1a1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: latest + node-version: 19.4.0 - name: Bump version and push tag id: tag_version diff --git a/lib/beacon-verification.ts b/lib/beacon-verification.ts index d846f53..d4222a5 100644 --- a/lib/beacon-verification.ts +++ b/lib/beacon-verification.ts @@ -46,7 +46,7 @@ async function verifyBeacon(chainInfo: ChainInfo, beacon: RandomnessBeacon, expe return verifySigOnG1(beacon.signature, await unchainedBeaconMessage(beacon), publicKey, 'BLS_SIG_BLS12381G1_XMD:SHA-256_SSWU_RO_NUL_') } - console.error(`Beacon type ${chainInfo.schemeID} was not supported`) + console.error(`Beacon type ${chainInfo.schemeID} was not supported or the beacon was not of the purported type`) return false } @@ -108,7 +108,7 @@ function roundBuffer(round: number) { } async function randomnessIsValid(beacon: RandomnessBeacon): Promise { - const expectedRandomness = await sha256(Buffer.from(beacon.signature, 'hex')) + const expectedRandomness = sha256(Buffer.from(beacon.signature, 'hex')) return Buffer.from(beacon.randomness, 'hex').compare(expectedRandomness) == 0 } diff --git a/package-lock.json b/package-lock.json index 2d36ea3..7256df7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "drand-client", - "version": "1.2.2", + "version": "1.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "drand-client", - "version": "1.2.2", + "version": "1.2.3", "license": "(Apache-2.0 OR MIT)", "dependencies": { "@babel/traverse": "^7.23.2", - "@noble/curves": "^1.1.0", + "@noble/curves": "^1.4.0", "buffer": "^6.0.3" }, "devDependencies": { @@ -1229,20 +1229,20 @@ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==" }, "node_modules/@noble/curves": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.1.0.tgz", - "integrity": "sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.0.tgz", + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", "dependencies": { - "@noble/hashes": "1.3.1" + "@noble/hashes": "1.4.0" }, "funding": { "url": "https://paulmillr.com/funding/" } }, "node_modules/@noble/hashes": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.1.tgz", - "integrity": "sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", "engines": { "node": ">= 16" }, diff --git a/package.json b/package.json index c87eaf6..ca57aef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "drand-client", - "version": "1.2.3", + "version": "1.2.4", "description": "A client to the drand randomness beacon network.", "main": "index.js", "types": "index.d.ts", @@ -31,7 +31,7 @@ }, "dependencies": { "@babel/traverse": "^7.23.2", - "@noble/curves": "^1.1.0", + "@noble/curves": "^1.4.0", "buffer": "^6.0.3" }, "repository": { diff --git a/test/beacon-verification.test.ts b/test/beacon-verification.test.ts index bf162b5..be26fce 100644 --- a/test/beacon-verification.test.ts +++ b/test/beacon-verification.test.ts @@ -30,17 +30,16 @@ describe('verifyBeacon', () => { } }) it('should validate unchained beacons from the go codebase', async () => { + const beacon = { + round: 19369534, + randomness: '778180564f4fb9b77580af69a559ce941eb23d8d3180c48c4d290484b516c6aa', + signature: 'a33833d2098f5e0c4df334fb6c5b1c2de3ab293c77825f55d816254dabf7f4f3d429b6207e1cd2a808876e06058a1f8102bb6f6927b654b391259ea99c3566a4eb55feb9665dbaf9d33af08a10b1d8d8b35d91fd3536eb4c197be0041beb5dc2' + } const chainInfo = createChainInfo( - '8d91ae0f4e3cd277cfc46aba26680232b0d5bb4444602cdb23442d62e17f43cdffb1104909e535430c10a6a1ce680a65', + '8200fc249deb0148eb918d6e213980c5d01acd7fc251900d9260136da3b54836ce125172399ddc69c4e3e11429b62c11', 'pedersen-bls-unchained' ) - const beacon = { - round: 397092, - randomness: '7731783ab8118d7484d0e8e237f3023a4c7ef4532f35016f2e56e89a7570c796', - signature: '94da96b5b985a22a3d99fa3051a42feb4da9218763f6c836fca3770292dbf4b01f5d378859a113960548d167eaa144250a2c8e34c51c5270152ac2bc7a52632236f746545e0fae52f69068c017745204240d19dae2b4d038cef3c6047fcd6539' - } - expect(await verifyBeacon(chainInfo, beacon, beacon.round)).toBeTruthy() }) diff --git a/test/http-caching-chain.test.ts b/test/http-caching-chain.test.ts index 88c7a60..3911724 100644 --- a/test/http-caching-chain.test.ts +++ b/test/http-caching-chain.test.ts @@ -25,7 +25,7 @@ describe('caching chain', () => { } it('should only call the network for the first request', async () => { // create a client with some verification options matching the expected chainInfo - const chain = new HttpCachingChain('https:///example.com/wow', { + const chain = new HttpCachingChain('https://example.com/wow', { ...defaultChainOptions, chainVerificationParams: { chainHash: chainInfo.hash, diff --git a/test/integration.test.ts b/test/integration.test.ts index 5462a7b..c05511d 100644 --- a/test/integration.test.ts +++ b/test/integration.test.ts @@ -3,7 +3,7 @@ import 'jest-fetch-mock' describe('randomness client', () => { - describe('testnet default network', () => { + describe('testnet unchained 3s network', () => { const testnetUnchainedUrl = 'https://pl-eu.testnet.drand.sh/7672797f548f3f4748ac4bf3352fc6c6b6468c9ad40ad456a397545c6e2df5bf'; const chain = new HttpCachingChain(testnetUnchainedUrl) const client = new HttpChainClient(chain) @@ -13,7 +13,7 @@ describe('randomness client', () => { expect(beacon.round).toBeGreaterThan(0) }) it('can consume some round', async () => { - const beacon = await fetchBeacon(client, 7456110) + const beacon = await fetchBeacon(client, 19369060) expect(beacon.round).toBeGreaterThan(0) }) it('watch returns successive rounds', async () => {