aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ts/schemas/ec_signature_schema.ts16
-rw-r--r--src/ts/utils/schema_validator.ts3
2 files changed, 15 insertions, 4 deletions
diff --git a/src/ts/schemas/ec_signature_schema.ts b/src/ts/schemas/ec_signature_schema.ts
index e4249afc2..94e58e53c 100644
--- a/src/ts/schemas/ec_signature_schema.ts
+++ b/src/ts/schemas/ec_signature_schema.ts
@@ -1,9 +1,19 @@
+export const ECSignatureParameter = {
+ id: '/ECSignatureParameter',
+ type: 'string',
+ pattern: '^0[xX][0-9A-Fa-f]{64}$',
+};
+
export const ECSignatureSchema = {
id: '/ECSignature',
properties: {
- v: {type: 'number'},
- r: {type: 'string'},
- s: {type: 'string'},
+ v: {
+ type: 'number',
+ minimum: 27,
+ maximum: 28,
+ },
+ r: {$ref: '/ECSignatureParameter'},
+ s: {$ref: '/ECSignatureParameter'},
},
required: ['v', 'r', 's'],
type: 'object',
diff --git a/src/ts/utils/schema_validator.ts b/src/ts/utils/schema_validator.ts
index a0d6f1bee..1cbffee58 100644
--- a/src/ts/utils/schema_validator.ts
+++ b/src/ts/utils/schema_validator.ts
@@ -1,10 +1,11 @@
import {Validator as V, ValidatorResult} from 'jsonschema';
-import {ECSignatureSchema} from '../schemas/ec_signature_schema';
+import {ECSignatureSchema, ECSignatureParameter} from '../schemas/ec_signature_schema';
export class SchemaValidator {
private v: V;
constructor() {
this.v = new V();
+ this.v.addSchema(ECSignatureParameter, ECSignatureParameter.id);
this.v.addSchema(ECSignatureSchema, ECSignatureSchema.id);
}
public validate(instance: object, schema: Schema): ValidatorResult {