Skip to content

Commit

Permalink
bumped noble for fix to point marshalling (#78)
Browse files Browse the repository at this point in the history
* bumped noble for fix to point marshalling
* changed an error message
* changed github node version to a specific one
  • Loading branch information
CluEleSsUK committed Mar 18, 2024
1 parent 4efb441 commit 0ed3bff
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/beacon-verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Expand Down Expand Up @@ -108,7 +108,7 @@ function roundBuffer(round: number) {
}

async function randomnessIsValid(beacon: RandomnessBeacon): Promise<boolean> {
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
}

Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
13 changes: 6 additions & 7 deletions test/beacon-verification.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
2 changes: 1 addition & 1 deletion test/http-caching-chain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 () => {
Expand Down

0 comments on commit 0ed3bff

Please sign in to comment.