Skip to content

Commit

Permalink
Merge pull request #604 from semaphore-protocol/docs/v4-alpha
Browse files Browse the repository at this point in the history
V4-alpha documentation
  • Loading branch information
cedoor authored Feb 7, 2024
2 parents 64e2f6a + c0aaa39 commit b33b64f
Show file tree
Hide file tree
Showing 27 changed files with 1,492 additions and 245 deletions.
41 changes: 26 additions & 15 deletions apps/docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type * as Preset from "@docusaurus/preset-classic"
import type { Config } from "@docusaurus/types"
import { themes } from "prism-react-renderer"

const lightCodeTheme = themes.github
const darkCodeTheme = themes.dracula
const lightCodeTheme = themes.oneLight
const darkCodeTheme = themes.oneDark

const config: Config = {
title: "Semaphore",
tagline: "Documentation and Guides",
tagline: "Semaphore documentation and guides.",
url: "https://docs.semaphore.pse.dev/",
baseUrl: "/",
favicon: "/img/favicon.ico",
Expand All @@ -28,8 +28,9 @@ const config: Config = {
docs: {
routeBasePath: "/",
sidebarPath: require.resolve("./sidebars.js"),
editUrl: "https://github.com/semaphore-protocol/website/edit/main/",
includeCurrentVersion: false
editUrl: "https://github.com/semaphore-protocol/semaphore/edit/main/apps/docs",
includeCurrentVersion: false,
lastVersion: "V3"
},
theme: {
customCss: [require.resolve("./src/css/custom.scss")]
Expand All @@ -38,38 +39,48 @@ const config: Config = {
]
],
themeConfig: {
// announcementBar: {
// id: "semaphore-v4-alpha",
// content:
// '<b>We are pleased to announce the release of Semaphore V4-alpha 🎉</b>',
// backgroundColor: "#DAE0FF",
// textColor: "#000000"
// },
announcementBar: {
id: "semaphore-v4-alpha",
content:
'<b>Semaphore V4-alpha is out 🎉 <a href="/V4-alpha/getting-started">Try it out</a> and let us know for any feedback on <a href="https://semaphore.pse.dev/discord" target="_blank">Discord</a> or <a href="https://github.com/orgs/semaphore-protocol/discussions" target="_blank">Github</a>!</b>',
backgroundColor: "#dde6fc",
textColor: "#000000"
},
navbar: {
logo: {
alt: "Semaphore Logo",
src: "img/semaphore-logo.svg"
},
items: [
{
type: "docsVersionDropdown",
position: "left",
dropdownActiveClassDisabled: true
},
{
label: "Whitepaper",
to: "https://docs.semaphore.pse.dev/whitepaper-v1.pdf",
position: "right",
className: "V1"
position: "left",
className: "whitepaper-v1"
},
{
label: "Github",
href: "https://github.com/semaphore-protocol",
position: "right"
},
{
label: "Website",
href: "https://semaphore.pse.dev",
position: "right"
},
{
type: "localeDropdown",
position: "right"
}
]
},
colorMode: {
defaultMode: "dark",
defaultMode: "light",
// Should we use the prefers-color-scheme media-query,
// using user system preferences, instead of the hardcoded defaultMode
respectPrefersColorScheme: true
Expand Down
10 changes: 5 additions & 5 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "3.1.0",
"@docusaurus/preset-classic": "3.1.0",
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@mdx-js/react": "^3.0.0",
"@svgr/webpack": "^5.5.0",
"clsx": "^1.2.1",
"docusaurus-plugin-sass": "^0.2.2",
"docusaurus-plugin-sass": "^0.2.5",
"file-loader": "^6.2.0",
"prism-react-renderer": "^2.1.0",
"react": "^18.2.0",
Expand All @@ -27,8 +27,8 @@
"url-loader": "^4.1.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.0",
"@docusaurus/tsconfig": "3.1.0",
"@docusaurus/module-type-aliases": "3.1.1",
"@docusaurus/tsconfig": "3.1.1",
"@types/react": "^18.2.29",
"typescript": "~5.2.2"
},
Expand Down
25 changes: 25 additions & 0 deletions apps/docs/src/components/Articles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useEffect, useState } from "react"

export default function Articles() {
const [articles, setArticles] = useState<any[]>([])

useEffect(() => {
fetch("https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/website/src/data/articles.json")
.then((response) => response.json())
.catch(() => [])
.then(setArticles)
}, [])

return (
<ul>
{articles.map((article) => (
<li key={article.url + article.title}>
<a href={article.url} target="_blank" rel="noreferrer">
{article.title}
</a>{" "}
- {article.authors.join(", ")} (<i>{article.date}</i>)
</li>
))}
</ul>
)
}
56 changes: 56 additions & 0 deletions apps/docs/src/components/DeployedContracts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import Heading from "@theme/Heading"
import { useEffect, useState } from "react"

function capitalizeFirstLetter(s: string): string {
return s.charAt(0).toUpperCase() + s.slice(1)
}

function getEtherscanLink(network: string): string {
switch (network) {
case "sepolia":
return "https://sepolia.etherscan.io/address/"
case "mumbai":
return "https://mumbai.polygonscan.com/address/"
case "arbitrum":
return "https://arbiscan.io/address/"
case "arbitrum-sepolia":
return "https://sepolia.arbiscan.io/address/"
case "optimism-sepolia":
return "https://sepolia-optimism.etherscan.io/address/"
default:
return ""
}
}

export default function DeployedContracts() {
const [deployedContracts, setDeployedContracts] = useState<any[]>([])

useEffect(() => {
fetch(
"https://raw.githubusercontent.com/semaphore-protocol/semaphore/feat/semaphore-v4/packages/contracts/deployed-contracts.json"
)
.then((response) => response.json())
.catch(() => [])
.then(setDeployedContracts)
}, [])

return (
<div>
{deployedContracts.map(({ network, contracts }) => (
<div key={network}>
<Heading as="h2">{capitalizeFirstLetter(network)}</Heading>
<ul>
{contracts.map(({ name, address }) => (
<li key={address}>
{name}:{" "}
<a href={getEtherscanLink(network) + address} target="_blank" rel="noreferrer">
{address}
</a>
</li>
))}
</ul>
</div>
))}
</div>
)
}
21 changes: 21 additions & 0 deletions apps/docs/src/components/RemoteCode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useEffect, useState } from "react"
import CodeBlock from "@theme/CodeBlock"

export default function RemoteCode({ url, language, title }: { url: string; language: string; title: string }) {
const [code, setCode] = useState<string>("")

useEffect(() => {
fetch(url)
.then((response) => response.text())
.catch(() => "")
.then((text) => setCode(text))
}, [url])

return (
<div>
<CodeBlock language={language} title={title} showLineNumbers>
{code}
</CodeBlock>
</div>
)
}
25 changes: 25 additions & 0 deletions apps/docs/src/components/Videos.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { useEffect, useState } from "react"

export default function Videos() {
const [videos, setVideos] = useState<any[]>([])

useEffect(() => {
fetch("https://raw.githubusercontent.com/semaphore-protocol/semaphore/main/apps/website/src/data/videos.json")
.then((response) => response.json())
.catch(() => [])
.then(setVideos)
}, [])

return (
<ul>
{videos.map((video) => (
<li key={video.url + video.title}>
<a href={video.url} target="_blank" rel="noreferrer">
{video.title}
</a>{" "}
- {video.speakers.join(", ")} at <u>{video.eventName}</u> (<i>{video.date}</i>)
</li>
))}
</ul>
)
}
13 changes: 12 additions & 1 deletion apps/docs/src/css/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ h5 {
}

.navbar {
height: 95px;
align-items: center;
box-shadow: none;
font-size: 18px;
Expand Down Expand Up @@ -234,6 +233,18 @@ html[data-theme="light"] {
}
}

/* Navbar items visibility */

a.whitepaper-v1 {
display: none;
}

html.docs-version-V1 {
a.whitepaper-v1 {
display: inline-block;
}
}

.container {
padding: 0px;
/* margin: 4rem auto 0px; */
Expand Down
30 changes: 0 additions & 30 deletions apps/docs/src/theme/NavbarItem/index.tsx

This file was deleted.

19 changes: 19 additions & 0 deletions apps/docs/versioned_docs/version-V4-alpha/credits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
sidebar_position: 11
---

# Credits

Semaphore is the work of several people, for a complete list of contributors you can visit the Semaphore [Github insights](https://github.com/semaphore-protocol/semaphore/graphs/contributors).

- [Barry WhiteHat](https://github.com/barryWhiteHat)
- [Kobi Gurkan](https://github.com/kobigurk)
- [Koh Wei Jie](https://github.com/weijiekoh)
- [Andrija Novakovic](https://github.com/akinovak)
- [Cedoor](https://github.com/cedoor)
- [Rachel Aux](https://github.com/rachelaux)
- [Andy Guzman](https://github.com/aguzmant103)
- [Vivian Plasencia](https://github.com/vplasencia)
- [LauNaMu](https://github.com/0xyNaMu)
- [0xjei](https://github.com/0xjei)
- [Mari Poveda](https://github.com/maripoveda)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebar_position: 5
---

import DeployedContracts from '@site/src/components/DeployedContracts';

# Deployed contracts

<DeployedContracts />
37 changes: 37 additions & 0 deletions apps/docs/versioned_docs/version-V4-alpha/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_position: 10
---

# FAQ

## Where can I ask questions about Semaphore?

You can ask questions about Semaphore on [Discord](https://semaphore.pse.dev/discord) or by opening a [Semaphore Discussion](https://github.com/semaphore-protocol/semaphore/discussions). The most frequent questions will be listed below.

## Why should I prevent proofs from being verified twice?

Since zero-knowledge proofs are completely anonymous, it is important to prevent those generated by eligible identities from being reused by a malicious party.

For example, in an anonymous voting application a valid proof could be reused to vote again.

## What is the difference between the "nullifier" and "scope"?

The [scope](/V4-alpha/glossary#scope) is used like a topic on which users can generate a valid proof only once. The scope is a public value and every one can see what the scope of a proof is.

The [nullifier](/V4-alpha/glossary#nullifier) is the hash of the private key of the identity and the scope, and it is used to check if the same proof with that specific scope has already been generated by the same user. The nullifier is also a public value and it is what is actually stored to prevent, for example, double-voting.

In the case of a voting application, if you have a group and you want all members of this group to vote only once, you can use the id of the group as the scope. When a user votes the first time, you can store the hash of voter's private key and the group id (i.e., the nullifier) and prevent double-voting by checking if that hash already exists.

See the [Semaphore circuits](/V4-alpha/technical-reference/circuits) for more technical information, or the [Semaphore boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4) for a real use-case.

## Where can I find examples of applications using Semaphore?

You can find a complete list of applications that are using Semaphore on the [Semaphore website](https://semaphore.pse.dev/projects).

## How can I start a project using Semaphore?

There are three ways you can start using Semaphore in your project: using the [CLI](https://github.com/semaphore-protocol/semaphore/tree/feat/semaphore-v4/packages/cli), using the [boilerplate](https://github.com/semaphore-protocol/boilerplate/tree/version/4) as a template or forking it, or installing the Semaphore [packages](/V4-alpha/guides/identities) manually.

## How can I contribute to the protocol?

There are several ways you could contribute to the protocol, you can find more information about on [Github](https://github.com/semaphore-protocol#ways-to-contribute).
Loading

0 comments on commit b33b64f

Please sign in to comment.