@semaphore-protocol/group 0.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -7
- package/dist/index.mjs +6 -12
- package/dist/index.node.js +6 -12
- package/dist/types/group.d.ts +0 -6
- package/package.json +2 -2
- package/src/group.test.ts +0 -12
- package/src/group.ts +5 -10
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<h1 align="center">
|
|
3
3
|
Semaphore group
|
|
4
4
|
</h1>
|
|
5
|
-
<p align="center">A library
|
|
5
|
+
<p align="center">A library to create and manage Semaphore groups.</p>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
@@ -117,9 +117,3 @@ group.indexOf(commitment) // 0
|
|
|
117
117
|
```typescript
|
|
118
118
|
const proof = group.generateProofOfMembership(0)
|
|
119
119
|
```
|
|
120
|
-
|
|
121
|
-
\# **verifyProofOfMembership**(proof: _MerkleProof_): _boolean_
|
|
122
|
-
|
|
123
|
-
```typescript
|
|
124
|
-
group.verifyProofOfMembership(proof) // true
|
|
125
|
-
```
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/group
|
|
3
|
-
* @version 0.
|
|
4
|
-
* @file A library
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @file A library to create and manage Semaphore groups.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore.js/tree/main/packages/group}
|
|
@@ -80,7 +80,7 @@ var Group = /** @class */ (function () {
|
|
|
80
80
|
* @param identityCommitment New member.
|
|
81
81
|
*/
|
|
82
82
|
Group.prototype.addMember = function (identityCommitment) {
|
|
83
|
-
this._merkleTree.insert(identityCommitment);
|
|
83
|
+
this._merkleTree.insert(BigInt(identityCommitment));
|
|
84
84
|
};
|
|
85
85
|
/**
|
|
86
86
|
* Adds new members to the group.
|
|
@@ -105,15 +105,9 @@ var Group = /** @class */ (function () {
|
|
|
105
105
|
* @returns Proof object.
|
|
106
106
|
*/
|
|
107
107
|
Group.prototype.generateProofOfMembership = function (index) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
* Verifies a proof of membership and return true or false.
|
|
112
|
-
* @param proof Proof to be verified.
|
|
113
|
-
* @returns True or false.
|
|
114
|
-
*/
|
|
115
|
-
Group.prototype.verifyProofOfMembership = function (proof) {
|
|
116
|
-
return this._merkleTree.verifyProof(proof);
|
|
108
|
+
var merkleProof = this._merkleTree.createProof(index);
|
|
109
|
+
merkleProof.siblings = merkleProof.siblings.map(function (s) { return s[0]; });
|
|
110
|
+
return merkleProof;
|
|
117
111
|
};
|
|
118
112
|
return Group;
|
|
119
113
|
}());
|
package/dist/index.node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/group
|
|
3
|
-
* @version 0.
|
|
4
|
-
* @file A library
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @file A library to create and manage Semaphore groups.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore.js/tree/main/packages/group}
|
|
@@ -84,7 +84,7 @@ var Group = /** @class */ (function () {
|
|
|
84
84
|
* @param identityCommitment New member.
|
|
85
85
|
*/
|
|
86
86
|
Group.prototype.addMember = function (identityCommitment) {
|
|
87
|
-
this._merkleTree.insert(identityCommitment);
|
|
87
|
+
this._merkleTree.insert(BigInt(identityCommitment));
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
90
|
* Adds new members to the group.
|
|
@@ -109,15 +109,9 @@ var Group = /** @class */ (function () {
|
|
|
109
109
|
* @returns Proof object.
|
|
110
110
|
*/
|
|
111
111
|
Group.prototype.generateProofOfMembership = function (index) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
* Verifies a proof of membership and return true or false.
|
|
116
|
-
* @param proof Proof to be verified.
|
|
117
|
-
* @returns True or false.
|
|
118
|
-
*/
|
|
119
|
-
Group.prototype.verifyProofOfMembership = function (proof) {
|
|
120
|
-
return this._merkleTree.verifyProof(proof);
|
|
112
|
+
var merkleProof = this._merkleTree.createProof(index);
|
|
113
|
+
merkleProof.siblings = merkleProof.siblings.map(function (s) { return s[0]; });
|
|
114
|
+
return merkleProof;
|
|
121
115
|
};
|
|
122
116
|
return Group;
|
|
123
117
|
}());
|
package/dist/types/group.d.ts
CHANGED
|
@@ -55,10 +55,4 @@ export default class Group {
|
|
|
55
55
|
* @returns Proof object.
|
|
56
56
|
*/
|
|
57
57
|
generateProofOfMembership(index: number): MerkleProof;
|
|
58
|
-
/**
|
|
59
|
-
* Verifies a proof of membership and return true or false.
|
|
60
|
-
* @param proof Proof to be verified.
|
|
61
|
-
* @returns True or false.
|
|
62
|
-
*/
|
|
63
|
-
verifyProofOfMembership(proof: MerkleProof): boolean;
|
|
64
58
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semaphore-protocol/group",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A library
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "A library to create and manage Semaphore groups.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.node.js",
|
|
7
7
|
"exports": {
|
package/src/group.test.ts
CHANGED
|
@@ -80,16 +80,4 @@ describe("Group", () => {
|
|
|
80
80
|
expect(proof.leaf).toBe(BigInt(1))
|
|
81
81
|
})
|
|
82
82
|
})
|
|
83
|
-
|
|
84
|
-
describe("# verifyProofOfMembership", () => {
|
|
85
|
-
it("Should verify a proof of membership", () => {
|
|
86
|
-
const group = new Group()
|
|
87
|
-
group.addMembers([BigInt(1), BigInt(3)])
|
|
88
|
-
const proof = group.generateProofOfMembership(0)
|
|
89
|
-
|
|
90
|
-
const response = group.verifyProofOfMembership(proof)
|
|
91
|
-
|
|
92
|
-
expect(response).toBeTruthy()
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
83
|
})
|
package/src/group.ts
CHANGED
|
@@ -64,7 +64,7 @@ export default class Group {
|
|
|
64
64
|
* @param identityCommitment New member.
|
|
65
65
|
*/
|
|
66
66
|
addMember(identityCommitment: Member) {
|
|
67
|
-
this._merkleTree.insert(identityCommitment)
|
|
67
|
+
this._merkleTree.insert(BigInt(identityCommitment))
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -91,15 +91,10 @@ export default class Group {
|
|
|
91
91
|
* @returns Proof object.
|
|
92
92
|
*/
|
|
93
93
|
generateProofOfMembership(index: number): MerkleProof {
|
|
94
|
-
|
|
95
|
-
}
|
|
94
|
+
const merkleProof = this._merkleTree.createProof(index)
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* @returns True or false.
|
|
101
|
-
*/
|
|
102
|
-
verifyProofOfMembership(proof: MerkleProof): boolean {
|
|
103
|
-
return this._merkleTree.verifyProof(proof)
|
|
96
|
+
merkleProof.siblings = merkleProof.siblings.map((s) => s[0])
|
|
97
|
+
|
|
98
|
+
return merkleProof
|
|
104
99
|
}
|
|
105
100
|
}
|