Skip to content

[DO NOT MERGE] Vitest blockchain test runner for coverage reports, BLS coverage attempt by including implementation code as well #3997

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
30 changes: 30 additions & 0 deletions packages/evm/src/precompiles/bls12_381/nbl/src/_shortw_utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Utilities for short weierstrass curves, combined with noble-hashes.
* @module
*/
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
import { hmac } from '@noble/hashes/hmac'
import { concatBytes, randomBytes } from '@noble/hashes/utils'
import type { CHash } from './abstract/utils.ts'
import { type CurveFn, type CurveType, weierstrass } from './abstract/weierstrass.ts'

/** connects noble-curves to noble-hashes */
export function getHash(hash: CHash): {
hash: CHash
hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => Uint8Array
randomBytes: typeof randomBytes
} {
return {
hash,
hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => hmac(hash, key, concatBytes(...msgs)),
randomBytes,
}
}
/** Same API as @noble/hashes, with ability to create curve with custom hash */
export type CurveDef = Readonly<Omit<CurveType, 'hash' | 'hmac' | 'randomBytes'>>
export type CurveFnWithCreate = CurveFn & { create: (hash: CHash) => CurveFn }

export function createCurve(curveDef: CurveDef, defHash: CHash): CurveFnWithCreate {
const create = (hash: CHash): CurveFn => weierstrass({ ...curveDef, ...getHash(hash) })
return { ...create(defHash), create }
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy