forked from tornado-packages/noble-curves
Merge pull request #58 from sublimator/nd-validate-dst-as-stringoruint8array-closes-57-2023-06-22
fix: validate hash_to_field DST as stringOrUint8Array (closes #57)
This commit is contained in:
commit
c2edc97868
@ -127,7 +127,7 @@ export function expand_message_xof(
|
|||||||
*/
|
*/
|
||||||
export function hash_to_field(msg: Uint8Array, count: number, options: Opts): bigint[][] {
|
export function hash_to_field(msg: Uint8Array, count: number, options: Opts): bigint[][] {
|
||||||
validateObject(options, {
|
validateObject(options, {
|
||||||
DST: 'string',
|
DST: 'stringOrUint8Array',
|
||||||
p: 'bigint',
|
p: 'bigint',
|
||||||
m: 'isSafeInteger',
|
m: 'isSafeInteger',
|
||||||
k: 'isSafeInteger',
|
k: 'isSafeInteger',
|
||||||
|
@ -246,6 +246,7 @@ const validatorFns = {
|
|||||||
function: (val: any) => typeof val === 'function',
|
function: (val: any) => typeof val === 'function',
|
||||||
boolean: (val: any) => typeof val === 'boolean',
|
boolean: (val: any) => typeof val === 'boolean',
|
||||||
string: (val: any) => typeof val === 'string',
|
string: (val: any) => typeof val === 'string',
|
||||||
|
stringOrUint8Array: (val: any) => typeof val === 'string' || val instanceof Uint8Array,
|
||||||
isSafeInteger: (val: any) => Number.isSafeInteger(val),
|
isSafeInteger: (val: any) => Number.isSafeInteger(val),
|
||||||
array: (val: any) => Array.isArray(val),
|
array: (val: any) => Array.isArray(val),
|
||||||
field: (val: any, object: any) => (object as any).Fp.isValid(val),
|
field: (val: any, object: any) => (object as any).Fp.isValid(val),
|
||||||
|
Loading…
Reference in New Issue
Block a user