-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtype.js
83 lines (74 loc) · 1.62 KB
/
type.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'use strict'
const crypto = require('crypto')
const tf = require('typeforce')
/**
* @typedef {Object} BigInt
*/
function BigInt(x) {
return typeof x === 'bigint'
}
BigInt.toJSON = () => 'bigint'
/**
* @typedef {Object} Curve
*/
const Curve = tf.object({
ProjectivePoint: tf.Function,
CURVE: {n: BigInt},
})
const Data = tf.oneOf(tf.String, tf.Buffer)
const Hash = tf.oneOf(tf.String, tf.Function)
/**
* @typedef {Object} Point
*/
const Point = tf.quacksLike('Point')
/**
* @typedef {Object} Update
* @property {(String|Buffer)} d The element.
* @property {Point} z The current accumulation.
* @property {Point} Q The public component.
* @property {Number} i The index.
*/
const Update = tf.object({
d: Data,
z: Point,
Q: Point,
i: tf.oneOf(tf.Null, tf.Number),
})
/**
* @typedef {Object} Witness
* @property {(String|Buffer)} d The element.
* @property {Point} v The previous accumulation.
* @property {Point} w The previous accumulation raised to the secret value.
*/
const Witness = tf.object({
d: Data,
v: Point,
w: Point,
})
/**
* @typedef {Object} WitnessUpdate
* @property {(String|Buffer)} d The element.
* @property {Point} z The current accumulation.
* @property {Point} v The previous accumulation.
* @property {Point} w The previous accumulation raised to the secret value.
* @property {Point} Q The public component.
* @property {Number} i The index.
*/
const WitnessUpdate = tf.object({
d: Data,
z: Point,
v: Point,
w: Point,
Q: Point,
i: tf.oneOf(tf.Null, tf.Number),
})
module.exports = {
BigInt,
Curve,
Data,
Hash,
Point,
Update,
Witness,
WitnessUpdate,
}