Compare commits

..

14 Commits

Author SHA1 Message Date
cedoor
b93acc884b chore: v3.5.0
Former-commit-id: 64a2e010f1
2023-03-31 13:14:48 +01:00
Cedoor
c9e565a445 Merge pull request #295 from semaphore-protocol/feat/identity-getter
New identity secret attribute and getter

Former-commit-id: 2af0af9a22
2023-03-31 12:53:30 +01:00
cedoor
6cea8c5dcc feat(identity): add new identity secret attribute and getter
re #294


Former-commit-id: 99ea3a15bc
2023-03-31 12:20:49 +01:00
Cedoor
5bd7cd93f7 Merge pull request #293 from semaphore-protocol/fix/semaphore-ethers
Correct nullifier hash parameter

Former-commit-id: 1118452cd4
2023-03-28 14:00:04 +01:00
cedoor
da1b4f6d8f fix(data): set correct nullifier hash parameter
Former-commit-id: d36a79e7ab
2023-03-28 12:52:46 +01:00
Cedoor
124f627d39 Merge pull request #292 from mmqxyz/patch-1
docs: fix small typos in Pairing.sol
Former-commit-id: 53963f7cd4
2023-03-28 11:01:50 +01:00
mmqxyz
199dca2a3b fix small typos in Pairing.sol
Former-commit-id: 9aa18b2fff
2023-03-28 11:32:29 +02:00
Cedoor
51accfc939 Merge pull request #291 from semaphore-protocol/docs/heyauthn-readme
Add new author

Former-commit-id: c77451857c
2023-03-24 10:16:47 +00:00
vplasencia
1696294881 style(heyauthn): format code with prettier
Former-commit-id: 220b34dade
2023-03-24 09:39:29 +01:00
vplasencia
c85b758120 docs(heyauthn): add new author
Former-commit-id: a31259011d
2023-03-24 09:28:38 +01:00
cedoor
12fd0f7a80 chore: v3.4.0
Former-commit-id: 254218b1e5
2023-03-21 19:41:10 +00:00
cedoor
78da99055d feat(cli): add support for arbitrum goerli
Former-commit-id: 7c4a2a1022
2023-03-21 19:40:40 +00:00
cedoor
77e4770b53 docs: add heyauthn docs link
Former-commit-id: ff692f1507
2023-03-21 19:35:50 +00:00
cedoor
799afc82f4 docs: add heyauthn package to readme
Former-commit-id: 79103bbbb0
2023-03-21 19:31:49 +00:00
18 changed files with 91 additions and 47 deletions

View File

@@ -217,6 +217,28 @@ The core of the Semaphore protocol is in the [circuit logic](/packages/circuits/
</a>
</td>
</tr>
<tr>
<td>
<a href="/packages/heyauthn">
@semaphore-protocol/heyauthn
</a>
<a href="https://semaphore-protocol.github.io/semaphore/heyauthn">
(docs)
</a>
</td>
<td>
<!-- NPM version -->
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
<img src="https://img.shields.io/npm/v/@semaphore-protocol/heyauthn.svg?style=flat-square" alt="NPM version" />
</a>
</td>
<td>
<!-- Downloads -->
<a href="https://npmjs.org/package/@semaphore-protocol/heyauthn">
<img src="https://img.shields.io/npm/dm/@semaphore-protocol/heyauthn.svg?style=flat-square" alt="Downloads" />
</a>
</td>
</tr>
<tbody>
</table>

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/cli-template-hardhat",
"version": "3.3.0",
"version": "3.5.0",
"description": "Semaphore Hardhat template.",
"license": "Unlicense",
"files": [
@@ -36,10 +36,10 @@
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.0.0",
"@nomiclabs/hardhat-etherscan": "^3.0.0",
"@semaphore-protocol/group": "3.3.0",
"@semaphore-protocol/hardhat": "3.3.0",
"@semaphore-protocol/identity": "3.3.0",
"@semaphore-protocol/proof": "3.3.0",
"@semaphore-protocol/group": "3.5.0",
"@semaphore-protocol/hardhat": "3.5.0",
"@semaphore-protocol/identity": "3.5.0",
"@semaphore-protocol/proof": "3.5.0",
"@typechain/ethers-v5": "^10.1.0",
"@typechain/hardhat": "^6.1.2",
"@types/chai": "^4.2.0",
@@ -58,7 +58,7 @@
"typescript": ">=4.5.0"
},
"dependencies": {
"@semaphore-protocol/contracts": "3.3.0"
"@semaphore-protocol/contracts": "3.5.0"
},
"config": {
"solidity": {

View File

@@ -1,7 +1,7 @@
{
"name": "@semaphore-protocol/cli",
"type": "module",
"version": "3.3.0",
"version": "3.5.0",
"description": "A command line tool to set up your Semaphore project and get group data.",
"license": "MIT",
"bin": {
@@ -41,7 +41,7 @@
"typedoc": "^0.22.11"
},
"dependencies": {
"@semaphore-protocol/data": "3.3.0",
"@semaphore-protocol/data": "3.5.0",
"axios": "^1.3.2",
"boxen": "^7.0.1",
"chalk": "^5.1.2",

View File

@@ -14,7 +14,7 @@ import Spinner from "./spinner.js"
const packagePath = `${dirname(fileURLToPath(import.meta.url))}/..`
const { description, version } = JSON.parse(readFileSync(`${packagePath}/package.json`, "utf8"))
const supportedNetworks = ["sepolia", "goerli", "mumbai", "optimism-goerli", "arbitrum"]
const supportedNetworks = ["sepolia", "goerli", "mumbai", "optimism-goerli", "arbitrum", "arbitrum-goerli"]
program
.name("semaphore")

View File

@@ -89,8 +89,8 @@ library Pairing {
/// @return r the product of a point on G1 and a scalar, i.e.
/// p == p.scalar_mul(1) and p.addition(p) == p.scalar_mul(2) for all points p.
function scalar_mul(G1Point memory p, uint256 s) public view returns (G1Point memory r) {
// By EIP-196 the values p.X and p.Y are verified to less than the BASE_MODULUS and
// form a valid point on the curve. But the scalar is not verified, so we do that explicitelly.
// By EIP-196 the values p.X and p.Y are verified to be less than the BASE_MODULUS and
// form a valid point on the curve. But the scalar is not verified, so we do that explicitly.
if (s >= SCALAR_MODULUS) {
revert InvalidProof();
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/contracts",
"version": "3.3.0",
"version": "3.5.0",
"description": "Semaphore contracts to manage groups and broadcast anonymous signals.",
"license": "MIT",
"files": [

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/data",
"version": "3.3.0",
"version": "3.5.0",
"description": "A library to query Semaphore contracts.",
"license": "MIT",
"main": "dist/index.node.js",

View File

@@ -275,7 +275,7 @@ export default class SemaphoreEthers {
signal: event.signal.toString(),
merkleTreeRoot: event.merkleTreeRoot.toString(),
externalNullifier: event.externalNullifier.toString(),
nullifierHash: event.externalNullifier.toString()
nullifierHash: event.nullifierHash.toString()
}))
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/group",
"version": "3.3.0",
"version": "3.5.0",
"description": "A library to create and manage Semaphore groups.",
"license": "MIT",
"main": "dist/index.node.js",

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/hardhat",
"version": "3.3.0",
"version": "3.5.0",
"description": "A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.",
"license": "MIT",
"main": "dist/index.node.js",
@@ -38,7 +38,7 @@
},
"dependencies": {
"@nomiclabs/hardhat-ethers": "^2.1.1",
"@semaphore-protocol/contracts": "3.3.0",
"@semaphore-protocol/contracts": "3.5.0",
"circomlibjs": "^0.0.8",
"ethers": "^5.7.1",
"hardhat-dependency-compiler": "^1.1.3"

View File

@@ -112,7 +112,8 @@ generateProof(identity, group, group.id, "42", {
## Authors
- @vb7401
- @rrrliu
- @emmaguo13
- @sehyunc
- [Vivek Bhupatiraju](https://github.com/vb7401)
- [Richard Liu](https://github.com/rrrliu)
- [emma](https://github.com/emmaguo13)
- [Sehyun Chung](https://github.com/sehyunc)
- [Enrico Bottazzi](https://github.com/enricobottazzi)

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/heyauthn",
"version": "3.3.0",
"version": "3.5.0",
"description": "A library to allow developers to create and manage Semaphore identities using WebAuthn",
"license": "MIT",
"main": "dist/index.node.js",
@@ -35,7 +35,7 @@
"typedoc": "^0.22.11"
},
"dependencies": {
"@semaphore-protocol/identity": "3.3.0",
"@semaphore-protocol/identity": "3.5.0",
"@simplewebauthn/browser": "7.2.0",
"@simplewebauthn/server": "7.2.0"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/identity",
"version": "3.3.0",
"version": "3.5.0",
"description": "A library to create Semaphore identities.",
"license": "MIT",
"main": "dist/index.node.js",

View File

@@ -19,6 +19,7 @@ describe("Identity", () => {
expect(identity1.trapdoor).not.toBe(identity2.getTrapdoor())
expect(identity1.nullifier).not.toBe(identity2.getNullifier())
expect(identity1.secret).not.toBe(identity2.getSecret())
expect(identity1.commitment).not.toBe(identity2.getCommitment())
})
@@ -82,8 +83,18 @@ describe("Identity", () => {
})
})
describe("# generateCommitment", () => {
it("Should generate an identity commitment", () => {
describe("# getSecret", () => {
it("Should return an identity secret", () => {
const { secret } = new Identity("message")
expect(secret.toString()).toBe(
"17452394798940441025978193762953691632066258438336130543532009665042636950194"
)
})
})
describe("# getCommitment", () => {
it("Should return an identity commitment", () => {
const { commitment } = new Identity("message")
expect(commitment.toString()).toBe(

View File

@@ -1,11 +1,14 @@
import { BigNumber } from "@ethersproject/bignumber"
import hash from "js-sha512"
import { poseidon1 } from "poseidon-lite/poseidon1"
import { poseidon2 } from "poseidon-lite/poseidon2"
import checkParameter from "./checkParameter"
import { generateCommitment, genRandomNumber, isJsonArray } from "./utils"
import { genRandomNumber, isJsonArray } from "./utils"
export default class Identity {
private _trapdoor: bigint
private _nullifier: bigint
private _secret: bigint
private _commitment: bigint
/**
@@ -16,7 +19,8 @@ export default class Identity {
if (identityOrMessage === undefined) {
this._trapdoor = genRandomNumber()
this._nullifier = genRandomNumber()
this._commitment = generateCommitment(this._nullifier, this._trapdoor)
this._secret = poseidon2([this._nullifier, this._trapdoor])
this._commitment = poseidon1([this._secret])
return
}
@@ -25,10 +29,11 @@ export default class Identity {
if (!isJsonArray(identityOrMessage)) {
const h = hash.sha512(identityOrMessage).padStart(128, "0")
// alt_bn128 is 253.6 bits, so we can safely use 253 bits
// alt_bn128 is 253.6 bits, so we can safely use 253 bits.
this._trapdoor = BigInt(`0x${h.slice(64)}`) >> BigInt(3)
this._nullifier = BigInt(`0x${h.slice(0, 64)}`) >> BigInt(3)
this._commitment = generateCommitment(this._nullifier, this._trapdoor)
this._secret = poseidon2([this._nullifier, this._trapdoor])
this._commitment = poseidon1([this._secret])
return
}
@@ -37,7 +42,8 @@ export default class Identity {
this._trapdoor = BigNumber.from(trapdoor).toBigInt()
this._nullifier = BigNumber.from(nullifier).toBigInt()
this._commitment = generateCommitment(this._nullifier, this._trapdoor)
this._secret = poseidon2([this._nullifier, this._trapdoor])
this._commitment = poseidon1([this._secret])
}
/**
@@ -72,6 +78,22 @@ export default class Identity {
return this._nullifier
}
/**
* Returns the identity secret.
* @returns The identity secret.
*/
public get secret(): bigint {
return this._secret
}
/**
* Returns the identity secret.
* @returns The identity secret.
*/
public getSecret(): bigint {
return this._secret
}
/**
* Returns the identity commitment.
* @returns The identity commitment.

View File

@@ -1,7 +1,5 @@
import { BigNumber } from "@ethersproject/bignumber"
import { randomBytes } from "@ethersproject/random"
import { poseidon1 } from "poseidon-lite/poseidon1"
import { poseidon2 } from "poseidon-lite/poseidon2"
/**
* Generates a random big number.
@@ -12,16 +10,6 @@ export function genRandomNumber(numberOfBytes = 31): bigint {
return BigNumber.from(randomBytes(numberOfBytes)).toBigInt()
}
/**
* Generates the identity commitment from trapdoor and nullifier.
* @param nullifier The identity nullifier.
* @param trapdoor The identity trapdoor.
* @returns identity commitment
*/
export function generateCommitment(nullifier: bigint, trapdoor: bigint): bigint {
return poseidon1([poseidon2([nullifier, trapdoor])])
}
/**
* Checks if a string is a JSON.
* @param jsonString The JSON string.

View File

@@ -1,6 +1,6 @@
{
"name": "@semaphore-protocol/proof",
"version": "3.3.0",
"version": "3.5.0",
"description": "A library to generate and verify Semaphore proofs.",
"license": "MIT",
"main": "dist/index.node.js",
@@ -37,8 +37,8 @@
"typedoc": "^0.22.11"
},
"peerDependencies": {
"@semaphore-protocol/group": "3.3.0",
"@semaphore-protocol/identity": "3.3.0"
"@semaphore-protocol/group": "3.5.0",
"@semaphore-protocol/identity": "3.5.0"
},
"dependencies": {
"@ethersproject/bignumber": "^5.5.0",

View File

@@ -1 +1 @@
db9ac44677af043f133407f3ec845b045c7ad6fa
23fe56d2949cd7a272f84fdb2bad9bde366662d7